akhauriyash/Code-Regression huggingface dataset:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
 


def main():
    s = input()
    if s[-1] == "s":
        print(s + "es")
    else:
        print(s + "s")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9480
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let s =
        read string
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    s
    |> fun x -> x.Substring(8)
    |> Seq.rev
    |> Seq.map string
    |> String.concat ""
    |> printfn "%s"

    0 // return an integer exit code


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

    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("-O3")
    #pragma GCC optimize("no-stack-protector")
    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld  double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = INT_MAX, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=1e5;
signed main(){
    fast_io;
    int k;
    cin>>k;
    ll ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int t=1;t<=k;t++){
                ans+=__gcd(t,__gcd(i,j));
            }
        }
    }
    cout<<ans;
    return 0;
}

/*



    /////

*/


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> count(n + 1, 0);

  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    count[from]++;
    count[to]++;
  }

  for (int i = 1; i <= n; i++) {
    cout << count[i] << endl;
  }
}


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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n, m, p,k;
    cin>>n>>m>>p;
    cin>>k;
    priority_queue<int> q;
    q.push(n);
    q.push(m);
    q.push(p);

    while(k--){
        auto x=q.top()*2;
        q.pop();
        q.push(x);
    }
    int ans=0;
    while(!q.empty()){
        ans+=q.top();
        q.pop();
    }

    cout<<ans;
    cout<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

int main() {
	std::string S;
	std::cin >> S;

	const int a = std::stoi(S.substr(0, 2));
	const int b = std::stoi(S.substr(2, 2));

	const auto month = [](int n) -> bool {
		return 1 <= n && n <= 12;
	};

	std::string result;
	if(month(a) && month(b)) {
		result = "AMBIGUOUS";
	} else if(month(a) && !month(b)) {
		result = "MMYY";
	} else if(!month(a) && month(b)) {
		result = "YYMM";
	} else {
		result = "NA";
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<vector>
int main()
{
    int sum=0;
   std::vector<int>c(6);
    
    for(int i=0;i<6;i++){
    std::cin>>c[i];
    }
    c[1]*=5;
    c[2]*=10;
    c[3]*=50;
    c[4]*=100;
    c[5]*=500;	
     for(int i=0;i<6;i++){
    sum+=c[i];
    }
    if(sum>=1000)std::cout<<"1"<<std::endl;
    else std::cout<<"0"<<std::endl;
    return 0;        
}	

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

vector<int>prime(int N){
    vector<int>factor(N+1);//factor[i]:iの最小の素因数 iが素数の場合は0
    factor[0]=-1,factor[1]=-1;
    for(int i=2;i*i<=N;i++){
        if(factor[i]!=0)continue;
        for(int j=i*2;j<=N;j+=i)if(factor[j]==0)factor[j]=i;
    }
    return factor;
}
vector<int>S(1000001);

map<int,int>osa_k(int N){
    //vector<int>factor=prime(N);
    map<int,int>prime_factor;
    if(N==0||N==1)return prime_factor;
    for(;S[N]!=0;N/=S[N])prime_factor[S[N]]++;
    prime_factor[N]++;
    return prime_factor;
}

int N;
bool pairwise=true,setwise=true;
int main(){
    cin>>N;
    vector<long long>A(N); 
    for(int i=0;i<N;i++)cin>>A[i];
    map<long long,bool>factor;
    map<long long,long long>f_cnt;

    S=prime(1000001);
    for(int k=0;k<N;k++){
        long long Num=A[k];
        auto p=osa_k(Num);
        for(auto x:p){
            if(factor[x.first])pairwise=false;
            factor[x.first]=true;
            f_cnt[x.first]++;
        }
    }
    for(auto x:f_cnt)if(x.second==N)setwise=false;
    if(pairwise){cout<<"pairwise coprime"<<endl;return 0;}
    if(setwise){cout<<"setwise coprime"<<endl;return 0;}
    cout<<"not coprime"<<endl;
    return 0;
}

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

int main(){
  int n,m;
  vector<int> v;

  cin >> n >> m;
  for(int i = 0 ; i < 2*n ; i++){
    v.push_back(i+1);
  } 

  int k;
  while(m--){
    cin >> k;

    if(k == 0){
      vector<int> tmp;
      int t = n;
      for(int i = 0 ; i < n ; i++){
	tmp.push_back(v[i]);
	tmp.push_back(v[i+t]);
      }
      v = tmp;
    }
    else{
      vector<int> tmp;
      for(int i = 0 ; i < k ; i++){
	tmp.push_back(v[0]);
	v.erase(v.begin());
      }
      for(int i = 0 ; i < (int)tmp.size() ; i++){
	v.push_back(tmp[i]);
      }
    }
  }

  for(int i = 0 ; i < (int)v.size() ; i++){
    cout << v[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		Node T = null;
		for(int i = 0; i < n; ++i) {
			String[] str = br.readLine().split(" ");
			if(str[0].equals("insert")){
				T = Node.insert(T, new Node(Integer.parseInt(str[1])));
			}else{
				System.out.print(' ');
				Node.inOrder(T);
				System.out.println();

				System.out.print(' ');
				Node.preOrder(T);
				System.out.println();
			}
		}
	
	}
}

class Node{
	public int key;
	public Node left;
	public Node right;
	public Node p;
	public Node(int key){
		this.key = key;
	}
	public static Node insert(Node T, Node z){
		Node y = null;
		Node x = T;
		while(x != null){
			y = x;
			if(z.key < x.key){
				x = x.left;
			}else{
				x = x.right;
			}
		}
		z.p = y;
		
		if(y == null){
			T = z;
		}else if(z.key < y.key){
			y.left = z;
		}else{
			y.right = z;
		}
		return T;
	}
	public static void inOrder(Node z){
		if(z == null){
			return;
		}

		if(z.left != null){
			inOrder(z.left);
			System.out.print(' ');
		}
		System.out.print(z.key);
		if(z.right != null){
			System.out.print(' ');
			inOrder(z.right);
		}
		
	}
	public static void preOrder(Node z){
		if(z == null){
			return;
		}
		System.out.print(z.key);
		if(z.left != null){
			System.out.print(' ');
			preOrder(z.left);
		}
		if(z.right != null){
			System.out.print(' ');
			preOrder(z.right);
		}
	}
}

Measured memory_bytes: 189832
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int  a, b, c, d, n, ans=0 ; 
    cin >> a >> b >> c >> d >> n ; 
    a *= 8, b *= 4, c*=2 ; 
    if (a<=b and a<=c and a<=d) ans = (a*n)/2 ; 
    else if (b<=a and b<=c and b<=d) ans = (b*n)/2;
    else if (c<=b and c<=a and c<=d) ans = (c*n)/2;
    else {
        if (n&1){
            n--; ans = (d*n)/2 ; 
            if (a<=b and a<=c) ans += a/2;
            if (b<=a and b<=c) ans += b/2;
            if (c<=b and c<=a) ans += c/2;
        }
        else ans = (d*n)/2;
    }
    cout << ans << endl;
} 

signed main() 
{ 
    int n=1; // cin>>n; 
    while (n--) solve(); 
    return 0; 
} 


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  vector<ll> x(m); rep(i, m) cin >> x[i];
  sort(x);

  if (n >= m) {
    outl(0);
    return;
  }

  vector<ll> diffs(m - 1);
  for (int i = 1; i < m; i++)
    diffs[i - 1] = x[i] - x[i - 1];
  sort(diffs);

  ll ans = x.back() - x[0];
  for (int i = 0; i < n - 1; i++) ans -= diffs[m - i - 2];
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n; cin >> n;
    vector<char> vc;
    ll div = 26;
    while(n>0)
    {
        char temp;
        if (n % 26==0)
        {
            temp = 'z';
            vc.push_back(temp);
            n /= 26;
            n--;
        }else
        {
            temp = (int)('a' + n % 26-1);
            vc.push_back(temp);
            n /= 26;
        }
       
    }
    reverse(vc.begin(), vc.end());
    for (auto &&i : vc)
    {
        cout << i;
    }
    cout  << endl;
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ll long long
#define mp make_pair
#define MAXN 1e6
const int mod=1e9+7;

void solve()
{
  int n,x;
  cin>>n;
  vector<int> dp(3);
  for(int i=0;i<n;i++)
  {
    vector<int> new_dp(3,0);
    vector<int> c(3);
    for(int j=0;j<3;j++)
    cin>>c[j];

    for(int j=0;j<3;j++)
    {
      for(int k=0;k<3;k++)
      {
        if(j!=k)
        {
          new_dp[k]=max(new_dp[k],dp[j]+c[k]);
        }
      }
    }
    dp=new_dp;
  }
  cout<<max({dp[0],dp[1],dp[2]});
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 384
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

void solve() {
    int n, y;
    cin >> n >> y;
    REP(i, 0, n + 1) REP(j, 0, n + 1 - i) {
        int sum = i * 10000 + j * 5000 + (n - i - j) * 1000;
        if (sum == y) {
            cout << i << " " << j << " " << n - i - j << endl;
            return;
        }
    }
    cout << "-1 -1 -1" << endl;
}

signed main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


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

    ll ans = 0;

    vector<ll> vec;

    ll tmp = 1;
    vec.pb(1);
    while(true){
        if(tmp * 6 <= 100000){
            tmp *= 6;
            vec.pb(tmp);
        }else{
            break;
        }
    }
    tmp = 1;
    while(true){
        if(tmp * 9 <= 100000){
            tmp *= 9;
            vec.pb(tmp);
        }else{
            break;
        }
    }

    sort(all(vec),greater<ll>());

    vector<ll> dp(n+1, INF);
    dp.at(0) = 0;
    rep(i,n+1){
        rep(j,vec.size()){
            if(i - vec.at(j) >= 0){
                chmin(dp.at(i), dp.at(i-vec.at(j)) + 1);
            }
        }
    }

    cout << dp.at(n) << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
// #define mod 1000000007
#define ll long long
#define V vector<vector<ll>>
using namespace std;
const int mod = 1e9+7;
ll mul(ll A,ll B){
	return  (A*B)%mod;
}
V matrix_multiplication(V A,V B){
	int n=A.size();
	V temp(n,vector<ll>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll sum=0;
			for(int k=0;k<n;k++){
				sum+=mul(A[i][k],B[k][j]);
				sum%=mod;
			}
			temp[i][j]=sum;
		}
	}
	return temp;
}
V matrix_expo(V A,ll K){
	if(K==1)
		return A;
	V B=matrix_expo(A,K/2);
	B=matrix_multiplication(B,B);
	if(K%2==1)
		B=matrix_multiplication(B,A);
	// cout<<"k:"<<K<<"\n";
	// int n=A.size();
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<n;j++){
	// 		cout<<B[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	return B;
}
int main(){
	int n;
	ll k;
	cin>>n>>k;
	V arr(n,vector<ll>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cin>>arr[i][j];
	}
	V result=matrix_expo(arr,k);
	ll res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			res+=result[i][j];
			res%=mod;
			// cout<<result[i][j]<<" ";
		}
		// cout<<endl;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;


int main() {
	cin >> N;
	ans = 180 * (N - 2);
	cout << ans << endl;
}


Measured memory_bytes: 256
L, R = map(int, input().split())

if R-L >= 2019:
    print(0)
else:
    L, R = L%2019, R%2019
    if L > R:
        R += 2019
    ans = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, i*j%2019)
    print(ans)


Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod

class Union_find
{
public:
    vector<int> par;
    vector<int> sz;

    Union_find(int N){
        par = vector<int>(N);
        REP(i, N) par[i] = i;
        sz = vector<int>(N, 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(sz[x] < sz[y]) swap(x, y);

        par[y] = x;
        sz[x] += sz[y];
    }

    bool is_union(int x, int y){
        x = find(x);
        y = find(y);
        return x == y;
    }

    int union_size(int x){
        return sz[find(x)];
    }

};

signed main(){

    int N, M; cin >> N >> M;
    vec A(M), B(M);
    REP(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    vec ans(M);
    int tmp = N * (N - 1) / 2;
    Union_find UF(N);
    IREP(i, M){
        ans[i] = tmp;
        if(!UF.is_union(A[i], B[i])){
            int s1 = UF.union_size(A[i]);
            int s2 = UF.union_size(B[i]);
            tmp -= s1 * s2;
            UF.unite(A[i], B[i]);
        }
    }
    REP(i, M) cout << ans[i] << endl;

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  // まず行ごとにとりこむ
  vector<string> a(H);
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }

  // 判定用変数
  vector<int> row(H);
  vector<int> columnn(W);
  char c;
  
  // 行と列の判定　i行目が全部白なら row.at(i)=0　j列目が全部白なら　columnn.at(j)=0
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        row.at(i) = 1;
        columnn.at(j) = 1;
      }
    }
  }
  
  // 出力
  for (int i = 0; i < H; i++) {
    if (row.at(i) == 0) {
      continue;
    }
    for (int j = 0; j < W; j++) {
      if (columnn.at(j) == 0) {
        continue;
      }
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007

// for using in pairs
#define F first
#define S second

// Macros
#define all(x) begin(x), end(x)

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

#define int long long

///////////////////////////////////////////////////////////////////////

#define SIZE 1000

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

int n, m;

queue<pair<int, int>> todo;

void dfs(vector<vector<char>>& a, vector<vector<int>>& ans, int i, int j, int count)
{
	if (a[i][j] == '#' || ans[i][j])
		return;

	ans[i][j] = count;

	for (int k = 0; k < 4; k++)
	{
		int i2 = i + dy[k];
		int j2 = j + dx[k];

		if (i2 < 0 || i2 >= n || j2 < 0 || j2 >= m)
			continue;

		if (!ans[i2][j2] && a[i2][j2] != '#')
		{
			dfs(a, ans, i2, j2, count);
		}

		if (a[i2][j2] == '#')
		{
			int y = i - 2, x = j - 2;
			for (y = max(0LL, i - 2); y <= min(n - 1, i + 2); y++)
			{
				for (x = max(j - 2, 0LL); x <= min(m - 1, j + 2); x++)
				{
					if (a[y][x] == '.' && !ans[y][x])
					{
						// dfs(a, ans, y, x, count + 1);
						todo.push({y, x});
					}
				}
			}
		}
	}
			
}

void solve(int tc)
{
	cin >> n >> m;
	int y, x, ty, tx;
	cin >> y >> x;
	cin >> ty >> tx;

	y--;
	x--;
	ty--;
	tx--;

	// char a[n][m];
	// int ans[n][m];

	vector<vector<char>> a(n, vector<char>(m));
	vector<vector<int>> ans(n, vector<int>(m, 0));


	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			ans[i][j] = 0;
			cin >> a[i][j];
		}
	}
	
	dfs(a, ans, ty, tx, 1);

	int count = 2;
	while (!todo.empty())
	{
		int size = todo.size();
		while (size--)
		{
			auto [i, j] = todo.front();
			todo.pop();

			dfs(a, ans, i, j, count);
		}
		count++;
	}

	// for (int i = 0; i < n; i++)
	// {
	// 	for (int j = 0; j < m; j++)
	// 	{
	// 		cout << ans[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }

	ans[y][x]--;
	cout << ans[y][x] << "\n";

}

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

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 13588
#include <stdio.h>
#include <string.h>

const unsigned long long B = 100000007;

int main()
{
  int i, al, bl;
  unsigned long long t, ah, bh;
  char b[1000003], a[10003];
  fgets(b, 1000002, stdin);
  fgets(a, 10002, stdin);

  al = strlen(a);
  bl = strlen(b);
  if (a[al-1]=='\n') a[--al]='\0';
  if (b[bl-1]=='\n') b[--bl]='\0';

  t = 1;
  for (i=0; i<al; i++) t *= B;
  ah = 0;
  bh = 0;
  for (i=0; i<al; i++) {
    ah = ah * B + a[i];
    bh = bh * B + b[i];
  }
  for (i=0; i+al <= bl; i++) {
    if (ah == bh) printf("%d\n", i);
    if (i+al<bl) bh = bh * B + b[i+al]-b[i] * t;
  }
  return 0;
}


Measured memory_bytes: 2768
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5, mod = 1000000007;
int n;
string s1, s2;

struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>s1>>s2;
    
    
    modular ans = 1;
    
    int pre_v = 0;
    for (int i = 0; i < n;){
        if(s1[i]==s2[i]){
            if(i==0)ans*=3;
            else{
                if(pre_v)ans *= 2;
            }
            pre_v = 1;
            i++;
        }else{
            if(i==0)ans *= 6;
            else{
                if(pre_v){
                    ans *= 2;
                }else{
                    ans *= 3;
                }
            }
            pre_v = 0;
            i+=2;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i = 0; i < 3*n; i++) cin >> a[i];
    std::sort(a.begin(), a.end(),greater<int>());
    long long max = 0;
    for(int i = 0; i < n; i++){
        max += a[2*i+1];
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  cout << s.substr(0, s.size() - 8) << endl;

  return 0;
}


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

template <int MOD_>
struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 3010;
int N;
int M;
string s;

int rightMost[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M >> s;
	for (int i = 0; i < N; i++) {
		rightMost[i] = i+1;
	}
	for (int i = 0; i < M; i++) {
		int l, r; cin >> l >> r; l--;
		rightMost[l] = max(rightMost[l], r);
	}
	for (int i = 1; i < N; i++) {
		rightMost[i] = max(rightMost[i], rightMost[i-1]);
	}

	vector<num> dp(N+1);
	dp[0] = 1;
	for (int i = 0, cur = 0; i < N; i++) {
		int incr = 0;
		while (cur < rightMost[i]) {
			incr += int(s[cur] - '0');
			cur++;
		}

		vector<num> ndp(N+1);
		for (int c = 0; c <= N; c++) {
			if (!int(dp[c])) continue;
			int d = c + incr;
			if (d) {
				ndp[d-1] += dp[c];
			}
			if (d != cur-i) {
				ndp[d] += dp[c];
			}
		}
		dp = std::move(ndp);
	}
	cout << dp[0] << '\n';

	return 0;
}

Measured memory_bytes: 256
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
    
    
    ll a,b,c;
    cin>>a>>b>>c;
    
    ll z=a+b;
    ll s=(z*c)/2;
    
    o(s)

    
    
    
    
    
        
        
        
	re
}

Measured memory_bytes: 256
import math

N, K = map(int, input().split())

p = 0.0
if N < K:
    for i in range(1, N+1):
        p += math.pow(0.5, math.ceil(math.log2(K/i)))/N
else:
    for i in range(1, K+1):
        p += math.pow(0.5, math.ceil(math.log2(K/i)))/N
    p += (N-K)/N    

print(p)

Measured memory_bytes: 3060
#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];

  int ans = 0;
  for (int i = 1; i < N - 1; i++) {
    int minimum = min(v[i - 1], min(v[i], v[i + 1]));
    int maximum = max(v[i - 1], max(v[i], v[i + 1]));
    if (v[i] != minimum && v[i] != maximum) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    ll a; int b, c;
    scanf("%lld %d.%d", &a, &b, &c);

    ll d = b*100 + c;
    cout << a * d / 100 << endl;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  int a[m];
  int all =0;
  for(int i=0;i<m;++i){
    cin >> a[i];
    all += a[i];
  }
  int pl = -1;
  if(n >= all) pl = n-all;
  cout << pl << endl;
  
}


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

int main() {
  int N;
  cin >> N;
  
  string S;
  for(int i = 0; i < N; i++){
    cin >> S;
    
    if(S == "Y")
      break;
  }
  
  if(S == "Y")
    cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;
  vector<int> xs(n);
  vector<int> x_to_count(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    x_to_count[xs[i]]++;
  }

  vector<int> count_to_sum(n + 1);
  for (int x = 1; x <= n; x++) {
    for (int c = 1; c <= x_to_count[x]; c++) {
      count_to_sum[c]++;
    }
  }

  if (DEBUG) cout << "count_to_sum: " << count_to_sum << endl;

  vector<int> k_to_count(n + 1, 0);
  int current_sum = 0;
  for (int c = 1; c <= n; c++) {
    current_sum += count_to_sum[c];
    // cout << current_sum / c << endl;
    k_to_count[current_sum / c] = c;
  }

  for (int k = n - 1; k >= 1; k--) {
    UpdateMax(k_to_count[k], k_to_count[k + 1]);
  }

  int current_output = n;
  for (int k = 1; k <= n; k++) {
    cout << k_to_count[k] << "\n";
  }
}

Measured memory_bytes: 5632
h, w = map(int, input().split())
s = list(input() for _ in range(h))

for i in range(h):
    ans = ""
    for j in range(w):
        if s[i][j] == "#":
            ans += "#"
        else:
            ans += str(sum(k[max(0, j-1):min(w, j+2)].count('#') for k in s[max(0, i-1):min(h, i+2)]))
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
		int S, T;
		cin >> S >> T;
		cout << 2*T -S;
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a;
string s;
int main(){ 
    cin>>a;
    cin>>s;
int SUMw=0;
int SUMe=0;
int b=999999;
    for (int i=0;i<a;i++)
        {
           if (s[i]=='W') SUMw++;
        }
    for (int i=a-1;i>=0;i--)
        {
           if (s[i]=='E') SUMe++;
           else {SUMe--;b=min(SUMe,b);}
        }
    int ANS=0;
    if (SUMe<=0 && SUMe<=b) ANS=SUMe+SUMw;
    else if (b<=0) ANS=SUMw+b;
         else ANS=SUMw;
    cout<<ANS<<endl;
    return 0;
}

Measured memory_bytes: 900
def main():
    r1, c1, r2, c2 = (int(i) for i in input().split())
    m = r2 + c2 + 3
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m
    MOD = 10**9 + 7

    def COMBinitialize(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COMB(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMBinitialize(m)
    ans = COMB(r2+c2+2, r2+1)
    ans -= COMB(r1+c2+1, r1) + COMB(r2+c1+1, c1)
    ans %= MOD
    ans += COMB(r1+c1, r1)
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 85488
n, k = map(int, input().split())
A = []
A_dup = []
cnt = 0

for i in range(k):
    input()
    # A.append(list(map(int, input().split())))
    A_dup += list(map(int, input().split()))
A_eldup = list(set(A_dup))

for i in range(1, n+1):
    if i not in A_eldup:
        cnt += 1
print(cnt)


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}
int main() 
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int i,j;
  int a,b,c,d;
  int ab,bc,ca;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a-b>0){
    ab=a-b;
  }else{
    ab=b-a;
  }
  if(b-c>0){
    bc=b-c;
  }else{
    bc=c-b;
  }
  if(c-a>0){
    ca=c-a;
  }else{
    ca=a-c;
  }
  if(ca<=d){
    printf("Yes\n");
    return 0;
  }else if(ab<=d && bc<=d){
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Name
    {
        static void Main(string[] args)
        {
            var rand = new Random();
            var str = Console.ReadLine();
            var len = str.Length;
            var i = rand.Next(0, len - 3);

            var NickName = str.Substring(i, 3);

            Console.WriteLine(NickName);
        } 
    }
}


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

int main(){
	long long n,k;
	cin>>n>>k;
	long long a,b,res=0,p=0,r;
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	for(long long i=1;i<=n;i++){
		b=i;
		r=n%b;
		p=n/b;
		res+=p*max(b-k,0LL);
		//res+=r;
		res+=max(r-k+1,0LL);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())
graph = [deque([]) for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

# 幅優先探索
def bfs(u):
    ans = [None] * (N+1)
    queue = deque([u])
    d = [None] * (N+1) # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in graph[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                ans[i] = v
                queue.append(i)
    return ans
d = bfs(1)
print("Yes")
for i in range(2,N+1):
    print(d[i])

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

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    sort(vec.begin(),vec.end());

    ll ans = 0;
    for(int i=0;i<k;i++){
        ans += vec[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Step(i, a, b, x) for (i = a; i <= b; i += x)
using namespace std;
inline int read() {
    int res = 0; bool bo = 0; char c;
    while (((c = getchar()) < '0' || c > '9') && c != '-');
    if (c == '-') bo = 1; else res = c - 48;
    while ((c = getchar()) >= '0' && c <= '9')
        res = (res << 3) + (res << 1) + (c - 48);
    return bo ? ~res + 1 : res;
}
const int PYZ = 998244353;
map<string, int> f, g;
int F(string); int G(string);
int G(string s) {
    if (g[s]) return g[s]; int i, n = s.size(); if (n == 1) return g[s] = s[0] - '0' + 1;
    int j, k, res = 0; For (i, 1, n - 1) if (n % i == 0) {
        string t = ""; For (j, 1, i) {
            int r = 1; Step (k, j - 1, n - 1, i) r &= s[k] - '0';
            t += (char) (r + '0');
        }
        res = (res + F(t)) % PYZ;
    }
    return g[s] = res;
}
int F(string s) {
    if (f[s]) return f[s]; int i, n = s.size(); if (!n) return f[s] = 1;
    int res = 0; For (i, 1, n)
        res = (res + 1ll * G(s.substr(0, i)) * F(s.substr(i, n)) % PYZ) % PYZ;
    return f[s] = res;
}
int main() {
    string s; cin>>s; cout << F(s) << endl;
    return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    int a[n];
    rep(i, n) { cin >> a[i]; }

    int temp, j;
    rep(i, n) {
        temp = a[i];
        j    = i - 1;
        while (j >= 0 && a[j] > temp) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = temp;
        rep(i, n) {
            if (i != 0) cout << " ";
            cout << a[i];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int n;
int main()
{
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        ans+=(long long)(n-i+1)*i;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a>b)swap(a,b);
        ans-=(long long)a*(n-b+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
# 1
# https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_b
N,A,B=map(int,input().split())
S=input()
X=0
Y=0
for s in S:
    if s=='a':
        if X+Y<A+B:
            print('Yes')
            X+=1
        else:
            print('No')
    elif s=='b':
        if X+Y<A+B and Y+1<=B:
            print('Yes')
            Y+=1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


@njit('(i8,i8,i4[:],i4[:],i8,i8)', cache=True)
def judge1(tn, K, Ap, Am, Nm, Np):

    count = 0
    for i in range(Nm):
        search = -(-tn // -Am[i])
        j = np.searchsorted(Ap, search, side='left')
        count += Np - j

    return count >= K


@njit('(i8,i8,i4[:],i4[:],i8,i8,i8,i8)', cache=True)
def judge2(tn, K, Ap, Am, Nm, Np, m_count, z_count):

    count = 0
    for i in range(Np):
        search = tn // Ap[i]
        j = np.searchsorted(Ap, search, side='right')
        count += max(0, j - i - 1)

    for i in range(Nm):
        search = tn // Am[i]
        j = np.searchsorted(Am, search, side='right')
        count += max(0, j - i - 1)

    return count >= (K - m_count - z_count)


@njit('(i8,i8,i4[:],i4[:],i8,)', cache=True)
def solve(N, K, Ap, Am, Nz):

    INF = 10**18
    Np = Ap.size
    Nm = Am.size

    m_count = Np * Nm
    z_count = Nz * (Np + Nm) + Nz * (Nz - 1) // 2

    if K <= m_count:

        min_n, max_n = -INF, -1
        while max_n - min_n != 1:
            tn = (min_n + max_n) // 2
            if judge1(tn, K, Ap, Am, Nm, Np):
                max_n = tn
            else:
                min_n = tn

        ans = max_n

    elif K <= m_count + z_count:
        ans = 0

    else:

        min_n, max_n = 1, INF
        while max_n - min_n != 1:
            tn = (min_n + max_n) // 2
            if judge2(tn, K, Ap, Am, Nm, Np, m_count, z_count):
                max_n = tn
            else:
                min_n = tn

        ans = max_n

    return ans


def main():
    N, K = in_nn()
    A = in_nl()
    Ap, Am = [], []
    Nz = 0

    for i in range(N):
        if A[i] > 0:
            Ap.append(A[i])
        elif A[i] == 0:
            Nz += 1
        else:
            Am.append(A[i])

    Ap = np.array(sorted(Ap), np.int32)
    Am = np.array(sorted([-a for a in Am]), np.int32)

    print(solve(N, K, Ap, Am, Nz))


if __name__ == '__main__':
    main()


Measured memory_bytes: 124184
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    res = pow(n // k, 3)
    if k % 2 != 0:
        print(res)
    else:
        res += pow((n + k // 2) // k, 3)
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9156