akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;


typedef long long ll;
typedef long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s[s.size()-1]=='s')
        {
            cout<<s<<"es";
        }
        else
        {
            cout<<s<<"s";
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    string s;
    cin>>s;
    n=sz(s);
    /**int dp[n][2];
    for (int i=0;i<n;++i)
        for (int j=0;j<2;++j)
            dp[i][j]=-1e9;
    if (s[0]=='D')
        dp[0][0]=1;
    else if (s[0]=='P')
        dp[0][1]=0;
    else
    {
        dp[0][0]=1;
        dp[0][1]=0;
    }
    for (int i=1;i<n;++i)
    {
        if (s[i]=='D')
            dp[i][0]=max(dp[i-1][0]+1,dp[i-1][1]+2);
        else if (s[i]=='P')
            dp[i][1]=max(dp[i-1][0],dp[i-1][1]);
        else
        {
            dp[i][0]=max(dp[i-1][0]+1,dp[i-1][1]+2);
            dp[i][1]=max(dp[i-1][0],dp[i-1][1]);
        }
    }
    cout<<max(dp[n-1][0],dp[n-1][1]);**/
    for (int i=0;i<n;++i)
    {
        if (s[i]=='?')
            cout<<"D";
        else
            cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

int main(void){
    int data[4][3][10] = {0};
    int n,b,f,r,v,i,j,k;
    scanf("%d",&n);
    for(i = 0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        data[b-1][f-1][r-1] += v;
    }
    for(i = 0;i<4;i++){
        for(j = 0;j<3;j++){
            for(k = 0;k<10;k++){
                printf(" %d",data[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3){
            printf("####################\n");
        }
    }
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    cout << !n << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int h = num / 3600, m, s;

        num %= 3600;
        m = num/60;
        num %= 60;
        s = num;

        System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 25988
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = pow(10, 9) + 7
neg = 0
zero = 0
for i in range(n):
    if a[i] >= 0:
        if a[i] == 0:
            zero += 1
        a[i] = [a[i], 1]
    else:
        a[i] = [-a[i], 0]
        neg += 1
a.sort(reverse = True)
ans = 1
if n == k:
    for i in range(n):
        ans *= a[i][0]
        ans %= mod
        if not a[i][1]:
            ans *= -1
            ans %= mod
elif k % 2 == 1 and (neg == n or neg + zero == n):
    for i in range(1, k + 1):
        ans *= -a[-i][0]
        ans %= mod
else:
    pos, neg = 0, 0
    lastpos, lastneg = mod, mod
    for i in range(k):
        ans *= a[i][0]
        ans %= mod
        if a[i][1]:
            pos += 1
            lastpos = a[i][0]
        else:
            neg += 1
            lastneg = a[i][0]
    if neg % 2 == 1:
        firstpos, firstneg = mod, mod
        for i in range(k, n):
            if not firstpos == mod and not firstneg == mod:
                break
            if firstpos == mod and a[i][1]:
                firstpos = a[i][0]
            elif firstneg == mod and not a[i][1]:
                firstneg = a[i][0]
        if not mod in [lastpos, lastneg, firstpos, firstneg]:
            if firstpos * lastpos >= firstneg * lastneg:
                ans = ans * pow(lastneg, mod - 2, mod) * firstpos % mod
            else:
                ans = ans * pow(lastpos, mod - 2, mod) * firstneg % mod
        elif not mod in [lastpos, firstneg]:
            ans = ans * pow(lastpos, mod - 2, mod) * firstneg % mod
        elif not mod in [lastneg, firstpos]:
            ans = ans * pow(lastneg, mod - 2, mod) * firstpos % mod
print(ans)

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<int> t(n),a(n);
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  LL ans=1;
  if(t[n-1]!=a[0]){
    cout << 0 << endl;
    return 0;
  }
  if(a[0]>a[1]){
    if(t[0]!=a[0]){
      cout << 0 << endl;
      return 0;
    }
  }
  if(t[n-1]>t[n-2]){
    if(t[n-1]!=a[n-1]){
      cout << 0 << endl;
      return 0;
    }
  }
  int h;
  for(int i=1;i<n-1;i++){
    h=0;
    if(t[i]>t[i-1]){
      h=t[i];
      if(t[i]>a[i]){
        cout << 0 << endl;
        return 0;
      }
    }
    if(a[i]>a[i+1]){
      if(h&&a[i]!=h){
        cout << 0 << endl;
        return 0;
      }
      if(a[i]>t[i]){
        cout << 0 << endl;
        return 0;
      }
      h=a[i];
    }
    if(!h){
      ans=ans*min(t[i],a[i])%1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N; cin >> N; 
	long long ans = 0LL; 
	for(long long i = 1; i <= N; i++){
		if(i % 3 == 0) continue;
		if(i % 5 == 0) continue; 
		else ans += i;  
	}
	cout << ans << endl; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read()
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x > 0 (x != 0) ***
{
	if(!x)
		return ;
	write(x / 10);
	putchar(x % 10 + '0');
}
#define maxn 100100
int n;
int a[1010][1010];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	int k = 0;
	for( ; ; k ++)
	{
		if(k * (k + 1) > n * 2)
			return cout << "No\n", 0;
		else if(k * (k + 1) == n * 2)
			break;
	}
	int cur = 0;
	for(int i = 1; i <= k + 1; i ++)
	{
		for(int j = 1; j < i; j ++)
			a[i][j] = a[j][i - 1];
		int rem = k - i + 1;
		for(int j = 1; j <= rem; j ++)
			a[i][i + j - 1] = cur + j;
		cur += rem;
	}
	cout << "Yes\n";
	cout << k + 1 << endl;
	for(int i = 1; i <= k + 1; i ++)
	{
		cout << k << ' ';
		for(int j = 1; j <= k; j ++)
			cout << a[i][j] << ' ';
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
using System;
using System.Text;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            var count = 0;
            while((count = int.Parse(Console.ReadLine())) != 0) {
                var value = Console.ReadLine();
                var temp = new StringBuilder(44800);
                int length;
                char last;
                while(--count >= 0) {
                    length = 1;
                    last = value[0];
                    for(int i = 1; i < value.Length; i++) {
                        if(last == value[i]) {
                            ++length;
                        }
                        else {
                            temp.Append(length);
                            temp.Append(last);
                            last = value[i];
                            length = 1;
                        }
                    }
                    temp.Append(length);
                    temp.Append(last);
                    value = temp.ToString();
                    temp.Length = 0;
                }
                Console.WriteLine(value);
            }
        }
    }
}

Measured memory_bytes: 6336
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 5;
ll a[maxn];

void solve()
{
    int n;
    cin >> n;
    ll total = 0;
    a[0] = a[n + 1] = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        total += abs(a[i] - a[i - 1]);
    }
    total += abs(a[n]);
    
    for(int i = 1; i <= n; i++)
    {
        cout << total + abs(a[i - 1] - a[i + 1]) - abs(a[i] - a[i + 1]) - abs(a[i - 1] - a[i]) << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 2048
n = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
lenth = 0
dif = 0
for N in range(n + 1):
    lenth += abs(A[N] - A[N + 1])
for i in range(n):
    dif = abs(A[i] - A[i + 2]) - abs(A[i + 1] - A[i]) - abs(A[i + 2] - A[i + 1])
    print(lenth + dif)

Measured memory_bytes: 14176
n,q=map(int,input().split())
s=input()
td=[list(input().split()) for _ in range(q)]


def bichk(x,flg):
  if not 0<=x<n:return False
  now=[x,s[x]]
  for t,d in td:
    if t==now[1]:
      if d=='L':
        x-=1
        if x<0 and flg:return False
        if x<0 and not flg:return True
        now=[x,s[x]]
      else:
        x+=1
        if x>n-1 and not flg:return False
        if x>n-1 and flg:return True
        now=[x,s[x]]
  return True
l,r=0,n
# 左から落ちないゴーレムの最小座標
while r-l>1:
  x=(l+r)//2
  if bichk(x,True):
    l,r=l,x
  else:
    l,r=x,r
l0=l if bichk(l,True) else r

l,r=0,n
# 右から落ちないゴーレムの最大座標
while r-l>1:
  x=(l+r)//2
  if bichk(x,False):
    l,r=x,r
  else:
    l,r=l,x
r0=r if bichk(r,False) else l
if l0==n-1:print(0)
elif r0==0:print(0)
else:
  print(max(0,r0-l0+1))


Measured memory_bytes: 116352
n,m=map(int,input().split())
mList=set([int(input()) for _ in range(m)])

dp=[0]*(n+1)
#dp=[-1]*(n+1)
dp[0]=1
if 1 not in mList:
  dp[1]=1

for i in range(2,n+1):
  if i in mList: continue
  dp[i]+=dp[i-1]
  dp[i]+=dp[i-2]
  dp[i]%=1000000007

#def calc(i):
#  if dp[i]!=-1: return dp[i]
#  if i in mList:
#    dp[i]=0
#    return dp[i]
#  dp[i]=calc(i-1)+calc(i-2)
#  dp[i]%=1000000007
#  return dp[i]

#print(calc(n))
print(dp[n])


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


int main(){
	long long n;
	long long ans = 1;
	cin >> n;

	vector<int>  fact(10000); //factor container
	
    for(int j = 2; j<=n;j++){
    
    long long num = j;

	for (int i = 2; i <= num; i++) {
		    while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			     fact.at(i)++; //割った個数を配列に足す
			    num /= i;
		    }
	}

    }

    for(int i = 0; i < 1003; i++){
            ans *= (fact.at(i) + 1);
            ans %= 1000000007;
    }




    cout << ans << endl;

}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
int main(){
	int n,k;
	std::cin >> n >> k;
	int i;
	int tmp;
	int cnt[n+1];
	for(i=1;i<=n;i++){
		tmp = i;
		cnt[i] = 1;
		while(tmp < k){
			tmp *= 2;
			cnt[i] *= 2;
		}
	}
	double ans = 0;
	for(i=1;i<=n;i++){
		ans += (double) 1/cnt[i];
	}
	ans /= (double)n;
	printf("%.10lf",ans);
}

  

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

#define ll long long

using namespace std;

int main(){
	string s,w;
	ll k=0,n,i;
	
	cin>>s;
	
	n=s.size();
	for(i=0;i<n;i++){
		if(s[i]<'a') s[i]+='a'-'A';
	}
	
	while(1){
		cin>>w;
		if(w=="END_OF_TEXT") break;
		n=w.size();
		for(i=0;i<n;i++){
			if(w[i]<'a') w[i]+='a'-'A';
		}
		if(w==s) k++;
	}
	
	cout<<k<<endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;
const ll P = 998244353;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	ll Ans = 1;
	ll n, mx, d[N], cnt[N], fac[N], inv[N];
	
	inline ll power(ll a, ll b, ll res = 1) {
		for (; b; b >>= 1, a = a * a % P) 
			res = (b & 1)? res * a % P: res;
		return res;
	}
	
	inline ll C(ll n, ll m) {
		if (n < m) return 0;
		return fac[n] * inv[m] % P * inv[n - m] % P;
	}
	
	inline ll A(ll n, ll m) {
		if (n < m) return 0;
		return fac[n] * inv[n - m] % P;
	}
	
	int main() {
		n = read();
		For ( i, 1, n ) ++cnt[d[i] = read()], mx = max(mx, d[i]);
		For ( i, 1, n ) if (d[i] >= n) return puts("0"), 0;
		
		if (d[1] > 0 || cnt[0] > 1) return puts("0"), 0;
		
		fac[0] = 1;
		For ( i, 1, n ) fac[i] = fac[i - 1] * i % P;
		inv[n] = power(fac[n], P - 2);
		Rep ( i, n - 1, 0 ) inv[i] = inv[i + 1] * (i + 1) % P;
		For ( i, 0, mx ) if (!cnt[i]) return puts("0"), 0;
		For ( i, 1, mx ) Ans = (Ans * power(cnt[i - 1], cnt[i])) % P;
		return wln(Ans), 0;
	}
	// 把 cnt[i] 分给 cnt[i - 1] 允许为空 
}

int main()
{
	return Cesare :: main();
}

/*

*/



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#ifdef EVAH
    #define _WIN32_WINNT 0x0500
    #include<windows.h>
#endif
#define openFile(n) ShellExecute(nullptr,"open",n,nullptr,nullptr,SW_SHOWNORMAL);
#define closeP(n) system((string("taskkill /im ")+n+" /f").c_str());
#define closeConsole PostMessage(GetConsoleWindow(), WM_CLOSE, 0, 0);
#define opf "output.txt"
#define ipf "input.txt"
#define mem(n,x) memset(n,x,sizeof(n));
#define sf scanf
#define pf printf
#define ff first
#define ss second
#define pb push_back
#define PII pair<int,int>
#define For(x,n) for(int i=x; i<n; i++)
#define stv v+2*(mid-tl+1)
#define LL long long int
#define PI acos(-1.0)
#define N 500001

const int blockSize = 800;

struct query {
    int l,r,idx;
    bool operator<(query other) const {
        if(l/blockSize != other.l/blockSize) return l<other.l;
        return (l/blockSize&1) ? (r<other.r) : (r>other.r);
    }
};

vector<int> clr(N),appeared(N);
int tempAns = 0;

void rmv(int idx) {
    appeared[clr[idx]]--;
    if(!appeared[clr[idx]]) tempAns--;
}
void add(int idx) {
    if(!appeared[clr[idx]]) tempAns++;
    appeared[clr[idx]]++;
}
int get_ans() {
    return tempAns;
}

vector<int> mosAlgo(vector<query> queries) {
    vector<int> ans(queries.size());
    sort(queries.begin(),queries.end());
    int curL = 0;
    int curR = -1;
    for(query q : queries) {
        while(curL > q.l) {
            curL--;
            add(curL);
        }
        while(curR < q.r) {
            curR++;
            add(curR);
        }
        while(curL < q.l) {
            rmv(curL);
            curL++;
        }
        while(curR > q.r) {
            rmv(curR);
            curR--;
        }
        ans[q.idx] = get_ans();
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    #ifdef EVAH
        //freopen(ipf,"r",stdin);
        //openFile(ipf);
        //closeConsole;
        //freopen(opf,"w",stdout);
    #endif

    int n,q,l,r;
    cin >> n >> q;
    //blockSize = sqrt(n);
    vector<query> queries(q);
    For(0,n) {
        cin >> clr[i];
    }
    For(0,q) {
        queries[i].idx = i;
        cin >> queries[i].l >> queries[i].r;
        queries[i].l--;
        queries[i].r--;
    }
    vector<int> ans = mosAlgo(queries);
    For(0,ans.size()) {
        cout << ans[i] << "\n";
    }

    #ifdef EVAH
        //openFile(opf);
        //Sleep(3000);
        //closeP("notepad.exe");
        //closeConsole;
    #endif
}


Measured memory_bytes: 20740
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int color(int rate) {
    if (rate >= 3200) return -1;
    for (int i = 0; i < 8; ++i) {
        if (rate < 400 * (i + 1))
            return i;
    }
}

int main() {
    int N, r, cnt = 0;
    bool D[8] = {};

    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> r;

        int c = color(r);
        if (c == -1)
            ++cnt;
        else
            D[c] = true;
    }

    int ans = 0;
    for (int i = 0; i < 8; ++i)
        ans += D[i];

    if (cnt == 0)
        cout << ans << ' ' << ans << endl;
    else if (ans == 0)
        cout << 1 << ' ' << cnt << endl;
    else
        cout << ans << ' ' << ans + cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  ll n, k; cin >> n >> k;
  ll ans = 0;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  for(int i=k+1; i<=n; i++){
    ans += n/i*(i-k);
    ans += max(n%i-k+1, 0ll);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>a(m);
	rep(i, m)cin >> a.at(i);
	ll sum=0;
	rep(i, m)sum += a.at(i);
	if (sum > n)cout << "-1" << endl;
	else cout << n - sum << endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}

class ModCom {
    public:
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            fac.assign(n,0);
            finv.assign(n,0);
            inv.assign(n,0);
            init();
        }
        vector<long long> inv;
        vector<long long> fac;
        vector<long long> finv;

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return fac.at(_n) * (finv.at(k) * finv.at(_n - k) % mod) % mod;
        }

    private:
        int n;
        long long mod;

        void init(void){
            fac.at(0) = fac.at(1) = 1;
            finv.at(0) = finv.at(1) = 1;
            inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                fac.at(i) = fac.at(i - 1) * i % mod;
                inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
                finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
            }
            return;
        }
};

ModCom com(int(1e+6) + 200,MOD);

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector<ll> primes(ll n) {
    if (n<2) {
        return vector<ll>();
    }
    vector<ll> ret;
    vector<bool> chk(n+100,false);
    ll cur = 2;
    while(cur<n) {
        if (!chk[cur]) {
            for(ll i=cur;i<=n;i+=cur) {
                chk[i] = true;
            }
            ret.push_back(cur);
        }
        cur++;
    }
    return ret;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);
    vector<ll> ps = primes(1000000+10);
    vector<ll> mp(1000000+10,0);
    rep(i,n) cin>>a[i];
    rep(i,n) {
        ll target = a[i];
        for(auto x:ps) {
            ll cnt = 0;
            if (x*x>a[i])break;
            while(target%x==0) {
                cnt++;
                target /= x;
            }
            chmax(mp[x], cnt);
        }
        if (target!=1) {
            chmax(mp[target], 1LL);
        }
    }
    ll lcm = 1;
    rep(i,1000000+10){
        if (mp[i]==0)continue;
        lcm *= modpow(i,mp[i],MOD);
        lcm %= MOD;
    }
    ll res = 0;
    rep(i,n) {
        res += lcm * com.inv[a[i]];
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int x=0;
    for(int i=a; i<=b; i++)
    {
        if(c%i==0)
        {
            x++;
        }
    }
    cout<<x<<endl;
    return 0;
    }

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

using namespace std;

int main()
{
  char ch[4];
  cin >> ch;
  int n[4];
  for(int i = 0; i < 4; i++){
    n[i] = ch[i] - '0';
  }
  //sort(n, n + 4);
  if((n[0] == n[1] && n[1] == n[2]) || (n[2] == n[1] && n[3] == n[2])) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[5][100007];

ll cme;

ll compME(ll b, ll e, ll m){  // bのe乗のmod m を返す
  if (e == 0) return 1;
  cme = compME(b, e / 2, m);
  cme = (cme * cme) % m;
  if (e % 2 == 1) cme = (cme * b) % m;
  return cme;
}

int main(){
  ll N,A,B,sum=0;
  cin >> N >> A >> B;
  ll X[100007];
  rep(i,N){
    cin >> X[i];
  }
  rep(i,N-1){
    sum+=min(A*(X[i+1]-X[i]),B);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
bool seen[505][505];

//dpTable
//bool dp[100050];

int main(){
    string S;
    cin >> S;
    bool YYMM = false,MMYY = false;
    //YYMM
    if (S.at(2) == '0' && S.at(3) != '0') YYMM = true;
    else if (S.at(2) == '1') {
        if (S.at(3) == '0' ||S.at(3) == '1' || S.at(3) == '2') YYMM = true;
    }
    //MMYY
    if (S.at(0) == '0' && S.at(1) != '0') MMYY = true;
    else if (S.at(0) == '1') {
        if (S.at(1) == '0' ||S.at(1) == '1' || S.at(1) == '2') MMYY = true;
    }
    if (YYMM && MMYY) cout << "AMBIGUOUS" << endl;
    else if (YYMM) cout << "YYMM" << endl;
    else if (MMYY) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}

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

using ll = long long;

const int MAXN = 3e5;
int N;

int A[MAXN];

pair<ll, ll> sums[2][MAXN];

void go(int z) {
	ll totsum = 0;
	ll jsum = 0;
	for (int i = 0, j = 0; i < N; i++) {
		totsum += A[i];
		for (; jsum < totsum - jsum; j++) {
			jsum += A[j];
		}
		assert(j > 0);
		if (abs(jsum - (totsum - jsum)) < abs(jsum - A[j-1] - (totsum - (jsum - A[j-1])))) {
			sums[z][i+1] = {jsum, totsum - jsum};
		} else {
			sums[z][i+1] = {jsum - A[j-1], totsum - (jsum - A[j-1])};
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int z = 0; z < 2; z++) {
		go(z);
		reverse(A, A + N);
	}

	reverse(sums[1], sums[1] + N + 1);
	ll ans = 1e18;
	for (int i = 2; i+1 < N; i++) {
		vector<ll> buf;
		for (int z = 0; z < 2; z++) {
			buf.push_back(sums[z][i].first);
			buf.push_back(sums[z][i].second);
		}
		ans = min(ans, *max_element(buf.begin(), buf.end()) - *min_element(buf.begin(), buf.end()));
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 10496
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	string s;
	cin >> s;
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (s[i] != s[i - 1])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int[][][] dp;

	static boolean solve() {
		int N = in.nextInt();
		int K = in.nextInt();
		int S = in.nextInt();
		if (N + K + S == 0) return false;

		dp = new int[11][30][200];
		dp[0][0][0] = 1;

		for (int i=0; i<10; i++) {
			for (int j=0; j<30; j++) {
				for (int k=0; k<200; k++) {
					for (int l=j+1; l<=N; l++) {
						if (k+l < 200)
							dp[i+1][l][k+l] += dp[i][j][k];
					}
				}
			}
		}

		int ans = 0;
		for (int j=1; j<=N; j++) {
			ans += dp[K][j][S];
		}
		out.println(ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

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

Measured memory_bytes: 54268
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
    int x,y,cx,cy;
    cin>>x>>y>>cx>>cy;
    string s="";
    for(int i=0;i<cy-y;i++){
        s+='U';
    }
    for(int i=0;i<cx-x;i++){
        s+='R';
    }
    for(int i=0;i<cy-y;i++){
        s+='D';
    }
    for(int i=0;i<cx-x;i++){
        s+='L';
    }
    s+='L';
    for(int i=0;i<cy-y+1;i++){
        s+='U';
    }
    for(int i=0;i<cx-x+1;i++){
        s+='R';
    }
    s+='D';
    s+='R';
    for(int i=0;i<cy-y+1;i++){
        s+='D';
    }
    for(int i=0;i<cx-x+1;i++){
        s+='L';
    }
    s+='U';
    cout<<s<<endl;
    //cout<<s.size()<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 100000 + 10;
int nums[MAXN];

int gcd(int a, int b) {
    if (b > a) return gcd(b, a);
    if (a % b == 0) return b;
    return gcd(a%b, b);
}

bool solve (int n, int k) {
    scanf("%d", &nums[0]);
    if (n == 1) {
        if (nums[0] == k) return true;
        else return false;
    }
    int big = nums[0];
    for (int i = 1; i < n; i++) {
        scanf("%d", &nums[i]);
        if (nums[i] == k) return true;
        big = max(big, nums[i]);
    }
    if (k > big) return false;
    for (int i = 0; i < n; i++) {
        big = gcd(big, nums[i]);
        if (k % big == 0) return true;
    }
    return false;
}
int main() {
//    freopen("test.txt", "r", stdin);
    int n, k;
    scanf("%d%d", &n, &k);
    if (solve(n, k)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;


}

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

int main(){

    // 1. 入力情報.
    int M1, D1, M2, D2;
    scanf("%d %d %d %d", &M1, &D1, &M2, &D2);
    
    // 2. 出力.
    printf("%d\n", (D2 == 1) ? 1 : 0);
    return 0;
    
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-21 16:17:12
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

inline unsigned long long fast_gcd(unsigned long long x, unsigned long long y) {
  int shift;
  if (x == 0) return y;
  if (y == 0) return x;
  shift = __builtin_ctzll(x | y);
  x >>= __builtin_ctzll(x);
  do {
    y >>= __builtin_ctzll(y);
    if (x > y) {
      /*
      unsigned long long t = y;
      y = x;
      x = t;
      */
      std::swap(x, y);
    }
    y -= x;
  } while (y);
  return x << shift;
}

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

  int k; cin >> k;

  int64 ans = 0;
 
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      int d = fast_gcd(a, b);
      for (int c = 1; c <= k; ++c) {
        ans += fast_gcd(c, d);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n)cin>>a[i];
    if(a[0]!=0)Cout(-1);
    else{
        rep(i,n-1){
            if(a[i+1]-a[i]>1){
                Cout(-1);
                return 0;
            }
        }
        rep(i,n-1){
            if(a[i]<a[i+1])ans++;
            else ans+=a[i+1];
        }
        Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  rep(i,N) cin >> V[i];
  rep(i,N) cin >> C[i];
  int ans = 0;
  rep(i,N){
    ans += max(0,V[i]-C[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
 
struct UnionFind {
    vector<int> rank, parent, size;
 
    // +1 for 1-indexed nodes
    UnionFind(int n) : rank(n + 1, 0), parent(n + 1), size(n + 1, 1) {
        iota(parent.begin(), parent.end(), 0); // parent is itself
    }
    int root(int x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) { return link(root(x), root(y)); }
    bool link(int x, int y) {
        if (x == y)
            return false;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        } else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }
    int getSize(int x) { return size[root(x)]; }
};
 
int main() {
    int n;
    cin >> n;
    vi x(n), y(n);
    vector<tuple<int, int, int>> xy;
    vector<tuple<int, int, int>> yx;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        xy.emplace_back(x[i], y[i], i);
        yx.emplace_back(y[i], x[i], i);
    }
    sort(xy.begin(), xy.end());
    UnionFind uf(n);
    for (int i = 1; i < n; ++i) {
        if (get<0>(xy[i]) == get<0>(xy[i - 1]))
            uf.unite(get<2>(xy[i]), get<2>(xy[i - 1]));
    }
    sort(yx.begin(), yx.end());
    for (int i = 1; i < n; ++i) {
        if (get<0>(yx[i]) == get<0>(yx[i - 1]))
            uf.unite(get<2>(yx[i]), get<2>(yx[i - 1]));
    }
    vector<set<int>> xs(100000);
    vector<set<int>> ys(100000);
    for (int i = 0; i < n; ++i) {
        int root = uf.root(i);
        xs[root].insert(x[i]);
        ys[root].insert(y[i]);
    }
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        ret += xs[i].size() * ys[i].size();
    }
    ret -= n;
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 18604
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int gcd(int x, int y) {
  if (y == 0)return x;
  return gcd(y, x%y);
}

int main() {
  INIT;
  
  int n,count=0;
  std::vector<ll> a;
  cin >> n;
  REP(i,n){
    ll f;
    cin >>f;
    if(f < 0){
      count++;
      f = -f;
    }
    a.push_back(f);
  }
  
  sort(a.begin(), a.end());
  
  if(count % 2 == 0){
    cout << accumulate(a.begin(), a.end(), 0LL) << endl;
  }else{
    cout << accumulate(a.begin()+1, a.end(), 0LL) - a[0] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    lens = len(S)
    ans = YES
    for i in range(lens):
        s, t = S[i], T[i]
        if s != t:
            ans = NO
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    int n,l;
    cin >> n >> l;
    vector<string> ls;
    rep(i,n){
        string s;
        cin >> s;
        ls.push_back(s);
    }
    sort(ls.begin(),ls.end());

    std::string str;
    rep(i,n){
        str += ls[i];
    }
    cout << str;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or a[i] == c[i] or b[i] == c[i]:
        count += 1
    else:
        count += 2

print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll a,b,c,d;
    // ll ans=0;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    // ll [n];
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    // while(1)
    ll tt,ta;
    tt = c%b==0 ? c/b : c/b+1;
    ta = a%d==0 ? a/d : a/d+1;
    if(tt<=ta){
        YES;
    }else{
        NO;
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
vector<int> nex[214514];
ll adeg[214514],bdeg[214514],alive[214514];
signed main(){
	int n,m;
	cin>>n>>m;
	string str;
	cin>>str;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x==y){
			nex[x].pb(x);
			if(str[x-1]=='A'){
				adeg[x]++;
			}
			else{
				bdeg[x]++;
			}
		}
		else{
			nex[x].pb(y);
			if(str[y-1]=='A'){
				adeg[x]++;
			}
			else{
				bdeg[x]++;
			}
			nex[y].pb(x);
			if(str[x-1]=='A'){
				adeg[y]++;
			}
			else{
				bdeg[y]++;
			}
		}
	}
	queue<int> que;
	for(int i=1;i<=n;i++){
		if(adeg[i] == 0 || bdeg[i]==0){
			que.push(i);
			alive[i] = -1;
		}
	}
	while(!que.empty()){
		int cur = que.front();que.pop();
		int aa = 0, bb = 0;
		if(str[cur-1]=='A')aa++; else bb++;
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			if( adeg[nx] > 0 && bdeg[nx] > 0){
				adeg[nx] -= aa;
				bdeg[nx] -= bb;
				if( adeg[nx] == 0 || bdeg[nx] == 0){
					alive[nx] = -1;
					que.push(nx);
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(alive[i]==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 17924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout<<'\n'
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%2==0)
    {printf("%.10f",0.5000000000);return 0;}
    else
    printf("%.10f",float(n/2+1)/n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int myctoi(char C)
{
  if (C == '0') return 0; if (C == '1') return 1;
  if (C == '2') return 2; if (C == '3') return 3;
  if (C == '4') return 4; if (C == '5') return 5;
  if (C == '6') return 6; if (C == '7') return 7;
  if (C == '8') return 8; if (C == '9') return 9;
}

int main()
{
  string n;
  cin >> n;
  int N = stoi(n);
  
  int S = 0;
  for (int i = 0; i < n.size(); i++)
  {
    S += myctoi(n.at(i));
  }
  
  string ans = "No";
  if (N % S == 0) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll a, b, c, i, j, k,  m, t, arr[200005], ar[200005];
int main() {
    string s;
    double n;
    cin >> n;
    printf("%.6lf",(n / 3) * (n / 3) * (n / 3));
}


Measured memory_bytes: 256