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

template <typename t>
void mi(t& a, const t& b) { a = min(a, b); }

template <typename t>
void ma(t& a, const t& b) { a = max(a, b); }

constexpr int g1 = 1000 * 1000 * 1000, si = 1024 * 1024, si_log = 10 + 10, mod = static_cast<int>(1e9) + 7;
constexpr long double eps = 1.0e-9;
int n, m, ar[si], br[si], cost[16][16], bc[16][16];
char car[si];
vector<int> gr[si];

int64_t sol()
{
  auto r = 0 * numeric_limits<int64_t>::max();

  memcpy(bc, cost, sizeof bc);
  ar[1 + 1] = 0;

  for (int i = 0; i <= 9; ++i)
  {
    bc[i][i] = 0;
  }

  for (int le = 0; le <= 9; ++le)
  {
    for (int row = 0; row <= 9; ++row)
    {
      for (int col = 0; col <= 9; ++col)
      {
        mi(bc[row][col], bc[row][le] + bc[le][col]);
      }
    }
  }

  for (int i = 0; i <= 9; ++i)
    r += ar[i + 1] * static_cast<int64_t>(bc[i][1]);

  return r;
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  while (2 == scanf("%d%d", &n, &m))
  {
    for (int row = 0; row <= 9; ++row)
    {
      for (int col = 0; col <= 9; ++col)
      {
        scanf("%d", cost[row] + col);
      }
    }

    for (int row = 0; row < n; ++row)
    {
      for (int col = 0; col < m; ++col)
      {
        int di;
        scanf("%d", &di);
        ar[di + 1]++;
      }
    }

    auto s = sol();
    //puts(s ? "Yes" : "No");
    cout << s << '\n';
#ifndef _DEBUG
    break;
#else
    for (int i = 0; i <= n + 2; i++)
    {
      gr[i].clear();
    }
    memset(car, 0, sizeof car);
    memset(ar, 0, sizeof ar);
    memset(br, 0, sizeof br);
    memset(cost, 0, sizeof cost);
#endif
  }
  return 0;
}


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

int main(){
    int D, N;  cin >> D >> N;
    if(D == 0){
        if(N == 100){
            cout << 101 << endl;
        }else{
            cout << N << endl;
        }
    }else{
        int base = pow(100, D);
        int cnt = 0;
        for(int i=1; i<200; i++){
            int n= base * i;
            int tmp = 0;
            while(n % 100 == 0){
                n /= 100;
                tmp++;
            }
            // cout << i << " " << base*i << " " << tmp << endl;
            if(tmp == D){
                cnt++;
            }
            if(cnt == N){
                cout << base * i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int count=0;
		for(int i=0;i!=a;i++) {
			int b=scan.nextInt();
			int c=scan.nextInt();
			count+=c-b+1;
		}
		System.out.println(count);
		}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  int pos = 0, result = 0;
  bool isp;
  while (pos<N) {
    int tmpp = pos+1, now = pos+1;
    while (A[tmpp-1]==A[tmpp]&&tmpp!=N) tmpp++;
    if (tmpp==N) { result++; break; }
    else {
      isp = (A[tmpp]-A[tmpp-1]>0);
      while ((A[now]-A[now-1]==0||(A[now]-A[now-1]>0==isp))&&now!=N) now++;
      pos = now;
      result++;
    }
    // cout << pos << " " << isp << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CManyRequirements {
public:
    int N, M, Q;
    vector<int> a, b, c, d;
    int res = 0;
    void dfs(vector<int>& cur) {
        if (cur.size() == N) {
            int tmp = 0;
            REP(i, Q) {
                if (cur[b[i]] - cur[a[i]] == c[i]) {
                    tmp += d[i];
                }
            }
            res = max(res, tmp);
            return;
        }
        int start = 1;
        if (!cur.empty()) {
            start = cur.back();
        }
        FOR(i, start, M) {
            cur.push_back(i);
            dfs(cur);
            cur.pop_back();
        }
    }
    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M >> Q;
        a.resize(Q);
        b.resize(Q);
        c.resize(Q);
        d.resize(Q);
        REP(i, Q) {
            cin >> a[i] >> b[i] >> c[i] >> d[i];
            a[i]--, b[i]--;
        }
        vector<int> v;
        dfs(v);

        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CManyRequirements solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3660
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;wahile(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
string binary(int n){bitset<32>b(n) ;string p =b.to_string();return p;}
int decimal(string s){int res = 0; for(int i = 0; i < s.size() ; i++ ){if(s[i] == '1')res = res + pow(2,s.size() - i -1);}    return res;}
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    int ta,tb;
    int sa,sb;
    cin>>ta>>tb>>sa>>sb;
    int i = 0;
    while(ta>0&&sa>0){
        
        i++;
        if(i%2){
            sa = sa - tb;
        }else{
            ta = ta-sb;
        }
    }
    if(ta>0){
        cout<<"Yes\n";
    }else
    cout<<"No\n";
    
   
}

Measured memory_bytes: 3676
S,T=input(),input()
l,m=len(S),len(T)
 
for i in range(l-m+1):
  if all(c in"?"+d for c,d in zip(S[-i-m:],T)):
    S=S.replace("?","a")
    print(S[:-i-m]+T+S[l-i:])
    quit()
 
print("UNRESTORABLE")

Measured memory_bytes: 3064
using System;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x=1,y;

            while (true)
            {
                string s = Console.ReadLine();
                y = int.Parse(s);

                if (y==0) break;

                

                if (y > 0)
                {
                    Console.WriteLine("Case " + x + ": " + y);

                }
                x++;
            }
        }
    }
}

Measured memory_bytes: 9388
# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)
ans = -1 * min(par)

print(ans)


Measured memory_bytes: 74728
package main

import "fmt"

func main() {
	// Code for C - Strange Bank
	var N int
	fmt.Scan(&N)

	var ans int
	var min int = 1000000
	var temp int
	var count int
	for i := 0; i <= N; i++ {
		if 6*i > N {
			break
		}
		for j := 0; j <= N; j++ {
			ans = 0
			if 6*i+9*j > N {
				break
			} else {
				ans += N - 6*i - 9*j

				temp = i
				for {
					count = temp / 6
					ans += temp % 6
					if count != 0 {
						temp = count
					} else {
						break
					}
				}

				temp = j
				for {
					count = temp / 9
					ans += temp % 9
					if count != 0 {
						temp = count
					} else {
						break
					}
				}

				if min > ans {
					min = ans
				}
			}
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		bubbleSort(A, N);
		sc.close();
	}

	public static void bubbleSort(int[] A, int N) {
		int count = 0;
		boolean flag = true;
		for (int i = 0; flag; i++) {
			flag = false;
			for (int j = N - 1; j >= i + 1; j--) {
				if (A[j] < A[j - 1]) {
					int tmp = A[j];
					A[j] = A[j - 1];
					A[j - 1] = tmp;
					flag = true;
					count++;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (i > 0) {
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.printf("\n");
		System.out.println(count);
	}
}



Measured memory_bytes: 26388
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
vector<lli> prefix_function(string &s)
{
	lli n=s.size();
	vector<lli>pi(n);
	for(lli i=1;i<n;i++)
	{
		lli j=pi[i-1];
		while(j>0 && s[i]!=s[j])
			j=pi[j-1];
		if(s[i]==s[j])
			j++;
		pi[i]=j;

	}
	return pi;
}
int main()
{
		#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS
	
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	
	string s,t;
	cin>>s>>t;
	
	lli n=sz(s);
	lli m=sz(t);
	// string sub=t.substr(m-1,1);
	// string str=sub+'#'+s;
	// vector<lli>pre=prefix_function(str);
	// lli mx=0;
	// for(lli i=sz(sub)+1;i<=sz(sub)+sz(s);i++)
	// 	mx=max(mx,pre[i]);
	// //cout<<mx<<endl;
	// for(lli i=m-2;i>=0;i--)
	// {
	// 	sub=t[i]+sub;
	// 	str=sub+'#'+s;
	// 	vector<lli>pr=prefix_function(str);
	// for(lli j=sz(sub)+1;j<=sz(sub)+sz(s);j++)
	// {
	// 	if(j-m-1>=m-i)
	// 	mx=max(mx,pr[j]);
	// }



	// }
	
	// // lli mx=0;
	// // lli j=0;
	// // for(auto i:pre)
	// 	//cout<<i<<" "<<j++<<endl;
	
	// cout<<sz(t)-mx<<endl;
	// for(lli len=m;len<=n;len++)
	// {
	lli len=m;
	lli cnt=0,mx=0;
		for(lli i=0;i<=n-m;i++)
		{
			lli r=m+i-1;
			lli cnt=0;
			for(lli j=i;j<=r;j++)
			{
				if(s[j]==t[j-i])
					cnt++;
			}
			mx=max(mx,cnt);

		}
		cout<<m-mx<<endl;

	}

	
	
	



Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  ld a, b, c;
  cin >> a >> b >> c;

  if(a+b+2*sqrt(a*b) < c+1e-14) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
text=input()
n=int(input())
for i in range(n):
    order=input().split()
    a,b=map(int,order[1:3])
    if order[0]=="print":
        print(text[a:b+1])
    elif order[0]=="reverse":
        re_text=text[a:b+1]
        text=text[:a]+re_text[::-1]+text[b+1:]
    else :
        text=text[:a]+order[3]+text[b+1:]


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

void trace(int a[], int n) {
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      cout << ' ';
    }
    cout << a[i];
  }
  cout << endl;
}

void insertion_sort(int a[], int n) {
  int j, v;
  for (int i = 1; i < n; ++i) {
    v = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      --j;
    }
    a[j + 1] = v;
    trace(a, n);
  }
}

int main() {
  int n;
  int a[100];

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

  trace(a, n);
  insertion_sort(a, n);

  return 0;
}



Measured memory_bytes: 3080
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>



typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;


using namespace std;
void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}


class Main{
public:
    int N,P;
    int A[2];
    Main(){
        cin>>N>>P;
        A[0] = 0; A[1] = 0;
        FOR(i,0,N){
            int k; cin>>k;
            A[k%2]++;
        }
    }
    
    ll fact(int i){
        if(i == 0 ) return 1;
        return i * fact(i-1);
    }
    
    ll comb(int x, int i){
        if(x < i) return 0;
        if(x == i) return 1;
        return  comb(x-1,i) * x / (x-i);
    }
    
    ll a(int x){
        ll ans = 0;
        for(int i = 0 ; i<=x;i+=2){
            ans += comb(x,i);
        }
        return ans;
    }
    ll b(int x){
        ll ans = 0;
        for(int i = 1 ; i<=x;i+=2){
            ans += comb(x,i);
        }
        return ans;
    }
    ll getans(){
        if(P == 0) return pow(2,A[0]) * a(A[1]);
        return pow(2,A[0]) * b(A[1]);
    }
    
    
    void run(){
        const ll ans = getans();
        cout<<ans<<endl;
    }
};

int main(){
    omajinai();
    Main().run();
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int n;cin>>n;
    if(n < 10){
        cout << n << endl;
    }else if(n < 100){
        cout << 9 << endl;
    }else if(n < 1000){
        cout << 9 +(n - 99) << endl;
    }else if (n < 10000){
        cout << 909 << endl;
    }else if (n < 100000){
        cout << 909 + (n - 9999) << endl;
    }else{
        cout << 90909<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();



int main(){

  int n,y; cin>>n>>y;
  bool flag = false;

  int a, b, c;
  REP(i, n+1)
  {
    REP(j,n-i+1){
      
        int num = 10000 * i + 5000 * j + 1000 * (n-i-j);

        if (num==y){
          flag = true;
          a = i; b=j; c = n-i-j;
        }
      
    }
  }

if(flag)
  cout << a <<" "<< b << " "<< c << endl;
  else
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int N;
long long ans=0;
cin>>N;
rep(i,N){
long long a;
cin>>a;
ans+=a-1;
}
cout<<ans<<endl;
 return 0;
}
/*
3
3 4 6

10

5
7 46 11 20 11

90

7
994 518 941 851 647 2 581

4527
*/

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        long n = in.nextInt();
        
        out.println(n * (n-1) / 2);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

}


Measured memory_bytes: 23124
// https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  vi a(n);
  rep(i, 0, n)
  {
    cin >> a[i];
  }
  rep(i, 0, n)
  {
    if ((a[i] - 1) % 2 == 1)
    {
      count++;
    }
    if (a[i] % 2 == 1)
    {
      count++;
      ans++;
    }
    if ((a[i] + 1) % 2 == 1)
    {
      count++;
    }
  }
  int even = n - ans;
  int odd = ans;
  cout << pow(3, n) - pow(2, even) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef long long int ll;

vector<int> primes;
bool isPrime(int n){
  if(n<=1)return false;
  for(int p:primes){
    if(n%p==0) return false;
  }
  return true;
}
ll adder(map<int,int>& divisors, map<int,int>::iterator iter){
  if(iter==divisors.end())return 1;
  ll sum=0;
  for(int i=0;i<=(*iter).second;i++)
    sum+=pow((*iter).first,i);
  ++iter;
  return sum*adder(divisors,iter);
}

int n;
void solve(){
  map<int,int> divisors;
  int n_=n;
  for(int p:primes){
    if(p>n_)break;
    while(n_%p==0){
      divisors[p]++;
      n_/=p;
    }
  }
  if(n_!=1) divisors[n_]=1;
  //  for(auto d:divisors)cout<<d.first<<"-"<<d.second<<" ";
  //  cout<<endl;
  int s=adder(divisors,divisors.begin())-n;
  //  cout<<adder(divisors,divisors.begin())-n<<endl;
  if(n==s)cout<<"perfect number"<<endl;
  else if(n>s)cout<<"deficient number"<<endl;
  else cout<<"abundant number"<<endl;
}
int main(){ _;
  primes.push_back(2);
  primes.push_back(3);
  for(int i=5;i<10000;i+=2){
    if(isPrime(i))
      primes.push_back(i);
  }
  while(cin>>n,n!=0)
    solve();
}

Measured memory_bytes: 1276
import java.util.Scanner;


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

		while(sc.hasNext()){
			int d = Integer.parseInt(sc.nextLine());
			int value = 0,s = 0;

			while(value != 600-d){
				value += d;
				int line = value*value;
				s += line*d;
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 17256
import collections
N = int(input())
A = [int(_) for _ in input().split()]


def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a


d = collections.defaultdict(int)
for a in A:
    for x in prime_factorize(a):
        d[x] += 1
if len(d):
    e = max(d.values())
if len(d) == 0 or e == 1:
    ans = 'pairwise coprime'
elif e == N:
    ans = 'not coprime'
else:
    ans = 'setwise coprime'
print(ans)


Measured memory_bytes: 184484
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define N 111111
using namespace std;

    int n, a[2*N], u[N*2];
    ll sm = 0;

    vector<int> v;

    inline ll smm(ll a){
        return ( a * a - a ) / 2;
    }

int main(){

    cin >> n;

    for(int i=1; i<=n; i++){
        cin >> a[i];
        u[a[i]]++;
        if( u[a[i]] == 1 ){
            v.pb( a[i] );
        }
    }

    for(auto x : v){
        sm += smm( u[x] );
    }

    for(int i=1; i<=n; i++){
        cout << sm - smm(u[a[i]]) + smm(u[a[i]] - 1) << endl;;
    }

    return 0;
}


Measured memory_bytes: 3832
nu = gets.to_i
shop = Array.new(nu).map{Array.new(10, 0)}
pr = Array.new(nu).map{Array.new(11, 0)}
for i in 0..nu - 1
  shop[i] = gets.chomp.split(" ").map(&:to_i)
end
for i in 0..nu - 1
  pr[i] = gets.chomp.split(" ").map(&:to_i)
end
my_s = Array.new(10, 0)
ans = -10**10
inst = 0
count = 0
check = 0
for i in 1..1023
  count = i
  for j in 0..9
    my_s[j] = count % 2
    count /= 2
  end
  for j in 0..nu - 1
    for k in 0..9
      if my_s[k] == 1 && shop[j][k] == 1
        check += 1
      end
    end
    inst += pr[j][check]
    check = 0
  end
  if ans < inst
    ans = inst
  end
  inst = 0
end

puts ans


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int N;
ll bit[1000010];

void add(int a,ll w) {
    while(a <= N) {
        bit[a] += w;
        a += a & -a;
    }
}

ll sum(int a) {
    ll ret = 0;
    while(a > 0) {
        ret += bit[a];
        a -= a & -a;
    }
    return ret;
}

int main() {
    cin >> N;
    ll D,A;
    cin >> D >> A;
    vector<P> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i).first >> vec.at(i).second;
    }
    sort(vec.begin(),vec.end());
    vector<ll> C(N);
    for(int i = 0;i < N;i++) {
        C.at(i) = vec.at(i).first;
    }
    for(int i = 0;i < 1000010;i++) {
        bit[i] = 0;
    }
    ll ret = 0;
    for(int i = 0;i < N;i++) {
        if(vec.at(i).second - sum(i + 1) * A <= 0) {
            continue;
        }
        else {
            ll cnt = (vec.at(i).second - sum(i + 1) * A + A - 1) / A;
            ret += cnt;
            auto itr = upper_bound(C.begin(),C.end(),C.at(i) + 2 * D);
            int itr2 = itr - C.begin();
            itr2++;
            add(i + 1,cnt);
            add(itr2,-cnt);
        }
    }
    cout << ret << endl;
}

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

int main() {

        int n, t;
        std::cin >> n >> t;

        int min = std::numeric_limits<int>::max();

        for (int i = 0; i < n; ++i) {
                int rn, rt;
                std::cin >> rn >> rt;

                if (rt <= t && rn < min) {
                        min = rn;
                }
        }

        if (min == std::numeric_limits<int>::max()) {
                std::cout << "TLE" << std::endl;
        }
        else {
                std::cout << min << std::endl;
        }

        return 0;
}

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

// a^n 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;
}

int main() {
	int n;
	cin >> n;
	vector<ll> cnt(n);
	int a;
	cin >> a;
	ll end = 0;
	if (a != 0) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, n - 1) {
		ll k;
		cin >> k;
		cnt[k]++;
		end = max(end, k);
	}
	ll ans = 1;
	for(int i=1;i<=end;i++) {
		if (cnt[i] == 0 && cnt[i + 1] != 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (cnt[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	cnt[0] = 1;
	for (int i = 1; i <= end; i++) {
		ans *= modpow(cnt[i-1], cnt[i], mod);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
N, T = input().split(' ')
N = int(N)
T = int(T)
x = [i for i in range(N+1)]
t = input()
cnt = 0
for ti in t.split(' '):
    x[cnt] = int(ti)
    cnt += 1
x[cnt] = -1
ans = 0
prev = -1

for ti in x:
    if ti == -1:
        ans += T
    elif prev == -1:
        prev = ti
    else:
        if ti-prev > T:
            ans += T
        else:
            ans += ti-prev

    prev = ti

print (ans)


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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin >> s;
    int counter = 1;
    bool b = true;
    for (char c : s) {
        if (counter % 2 == 0 && c == 'R' 
            || counter % 2 != 0 && c == 'L') {
            b = false;
            break;
        }
        ++counter;
    }
    if (b) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

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



void solve() {
    string s, t;
    cin >> s >> t;
    
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) ans += (s[i] != t[i]);
    
    cout << ans << endl;
}







    
    
    
    
    
    
    
    
int main() {
    solve();
}

Measured memory_bytes: 3868
use std::io::*;

mod enumeration {
    pub struct Enumeration {
        fact: Vec<u64>,
        finv: Vec<u64>,
        modulo: u64,
    }
    impl Enumeration {
        pub fn new(n: usize, modulo: u64) -> Enumeration {
            let mut fact: Vec<u64> = vec![1; n];
            let mut inv: Vec<u64> = vec![1; n];
            let mut finv: Vec<u64> = vec![1; n];
            for i in 2..n {
                fact[i] = fact[i - 1] * (i as u64) % modulo;
                inv[i] = modulo - (modulo / (i as u64)) * inv[(modulo as usize % i)] % modulo;
                finv[i] = inv[i] * finv[i - 1] % modulo;
            }
            Enumeration {
                fact: fact,
                finv: finv,
                modulo: modulo,
            }
        }
        pub fn c(&self, n: usize, k: usize) -> u64 {
            if n < k {
                return 0;
            }
            self.fact[n] * self.finv[n - k] % self.modulo * self.finv[k] % self.modulo
        }
    }
}

fn mod_pow(mut x: u64, mut e: u64, m: u64) -> u64 {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % m;
        }
        x = x * x % m;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: u64 = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    const MOD: u64 = 998244353;
    let en = enumeration::Enumeration::new(n, MOD);
    let mut ans = 0;
    for i in 0..=k {
        ans += m * en.c(n - 1, i) % MOD * mod_pow(m - 1, (n - 1 - i) as u64, MOD) % MOD;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6684
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,K = mint()
p = lint()

ans = sum(p[:K])
tmp = ans
for i in range(K,N):
    tmp = tmp-p[i-K]+p[i]
    ans = max(ans,tmp)
print((ans+K)/2)

Measured memory_bytes: 102100
def main():
    S = input().rstrip()
    for idx, s in enumerate(S, start=1):
        if idx % 2 == 1 and s not in ["R", "U", "D"]:
            print("No")
            exit()
        elif idx % 2 == 0 and s not in ["L", "U", "D"]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61940
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstring>
#include <ctime>
#include <map>
#include <algorithm>
#include <cmath>
#define MAXN 200005
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ba 823
#define mo 974711
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;

int N,A[100005];
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; ++i) scanf("%d",&A[i]);
	sort(A + 1,A + N + 1);
	printf("%d ",A[N]);
	double T = A[N] / 2.0;
	int t = 1;
	for(int i = 2 ; i <= N ; ++i) {
		if(fabs(A[i] - T) < fabs(A[t] - T)) t = i;
	}
	printf("%d\n",A[t]);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main() {
	double h, upper, lower;

	scanf(" %lf ", &upper);
	lower = upper;
	while (scanf(" %lf ", &h) != EOF) {
		if (h > upper) {
			upper = h;
		}
		else if (h < lower) {
			lower = h;
		}
	}
	printf("%lf\n", upper - lower);
	return 0;
}

Measured memory_bytes: 648
#include<stdio.h>

 int main(void)
 {
 int W,H,x,y,r,f;

 printf("");
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

 f=0;
 if(x+r>W)f=1;
 if(y+r>H)f=1;
 if(r>x)f=1;
 if(r>y)f=1;

 if(f==0)printf("Yes\n");
 else printf("No\n");

 return 0;
 }


Measured memory_bytes: 2108
import bisect
n,h = map(int, input().split( ))
a = []
b = []
for i in range(n):
    ai,bi = map(int, input().split( ))
    a.append(ai)
    b.append(bi)


a_max = max(a)
b.sort()
j = bisect.bisect_left(b,a_max)

b_sum = sum(b[j:])
#print(b_sum)
ans = n-j
h -= b_sum
#print(h)
if h>=0:
    ans += h//a_max
#print(ans)
    if h%a_max:
        ans += 1

    print(ans)
else:#bで終わってしまう場合
    while h<0:
        h+=b[j]
        j+=1
        ans -=1
    if h>0:
        ans +=1
    print(ans)

Measured memory_bytes: 62424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll n,d;
    cin >> n >> d;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i,n) cin >> x[i] >> y[i];
    int ans = 0;
    rep(i,n){
        if(d*d >= x[i]*x[i]+y[i]*y[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const int N = 1e5 + 7;

pair <long long, long long> a[N];

int n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i].first >> a[i].second;
	sort (a + 1, a + n + 1, [](pair <int, int> x, pair <int, int> y) {
		return x.first + x.second > y.first + y.second;		
	});
	long long res = 0;
	for (int i = 1; i <= n; i++)
		if (i % 2) 
			res += a[i].first;
		else
			res -= a[i].second;
	cout << res;
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef unsigned long long ULL;
typedef long long ll;
const ULL base = 233;
const int N = 100005;

int n;
int f[201000];
ll val1[200100],val2[201000];
int find(int x){return f[x]==x?x:(f[x]=find(f[x]));}

int main(){
    cin>>n;
    FOR(i,1,2*N)f[i]=i;
    FOR(i,1,n){
        int x,y;
        scanf("%d%d",&x,&y);
        f[find(x)]= find(y+N);
    }
    FOR(i,1,N)val1[find(i)]++;
    FOR(i,N+1,2*N)val2[find(i)]++;
    ll ans=0;
    FOR(i,1,2*N){
        ans+=val1[i]*val2[i];
        //if(val1[i]*val2[i])cout<<ans<<" "<<i<<" "<<i-N<<endl;
    }
    printf("%lld\n",ans-n);
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

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

    for(int i=sqrt(n);i>0;i--){
        if(n%i==0){
            cout<<i+(n/i)-2<<endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int INF = 1e9 + 239;

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	auto can = [&](int x) {
		int c = 0;
		for (auto t : a) {
			c += (t + x - 1) / x - 1;
		}
		return c <= k;
	};
	int l = 0;
	int r = INF;
	while (r - l > 1) {
		int m = (r + l) >> 1;
		if (can(m)) {
			r = m;
		} else {
			l = m;
		}
	}
	cout << r << '\n';
}


Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    if (a > b)
    {
        cout << a-1 << endl;
    } else {
        cout << a << endl;
    }
    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  vector<char> c(n);
  for(int i=0;i<n;i++){
    c[i]=s.at(i);
  }
  if(c[k-1]=='A'){c[k-1]='a';}
  else if(c[k-1]=='B'){c[k-1]='b';}
  else if(c[k-1]=='C'){c[k-1]='c';}
  for(int j=0;j<n;j++){
    cout<<c[j];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair < int , int >
#define vi vector < int >
#define pb push_back
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define vll vector < long long int >
#define sll set < long long int >
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main()
{
	fastIO;
	double n,m,d,ans;
	cin>>n>>m>>d;
	if(d>0)ans = 2.0*(m-1)*(n-d)/(n*n);
	else ans = (m-1)*(n-d)/(n*n);
	printf("%.12lf",ans);
	return(0);
}

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

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int a=0;
  for(int i=0;i<n-1;i++)
  {
    if(s[i]==s[i+1])
      ++a;
       
  }
  cout<<min(n-1,a+2*k)<<endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];

	int max1, max2;
	max1 = v[0];
	max2 = v[1];
	int x = 0;
	for (int i = 1; i < n; i++) {
		if (max1 < v[i]) {
			max2 = max1;
			max1 = v[i];
			x = i;
		}
		else if (max2 < v[i]) {
			max2 = v[i];
		}
	}

	for (int i = 0; i < n; i++) {
		if (x == i)	cout << max2 << endl;
		else	cout << max1 << endl;
	}

	return 0;
}

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

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

    int N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];

    int res = 1;
    ll tmp = A[0];
    int step = 1;
    bool is_up;

    for(int i = 1; i < N; ++i){

        if(step == 0){
            step = 1;
        }

        if(A[i] > A[i - 1] and step == 1){
            is_up = true;
            step = 2;
        }
        if(A[i] < A[i - 1] and step == 1){
            is_up = false;
            step = 2;
        }
        if(A[i] > A[i - 1] and not is_up and step == 2){
            res++;
            step = 0;
        }
        if(A[i] < A[i - 1] and is_up and step == 2){
            res++;
            step = 0;
        }
        
        ll tmp = A[i];

    }
    cout << res << endl;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {


    int n;
    cin >> n;
    int a[n];
    
    for(int i=0; i<n; i++)
        cin >> a[i];
        
    reverse(a,a+n);
    
    for(int i=0; i<n-1; i++)
        cout << a[i] << " ";
    cout << a[n-1] << endl;
    
    return 0;
    
}



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

int main(){
  int n;
  cin >> n;
  vector<int> np(n);
  rep(i,n){
    np[i]=i+1;
  }
  vector<pair<int,int>> v(n);
  rep(i,n){
    int x,y;
    cin >> x >> y;
    pair<int,int> p=make_pair(x,y);
    v[i]=p;
  }
  double ans=0.0;
  int cnt=0;
  do{
    rep(i,n-1){
      ans+=sqrt((v[np[i]-1].first-v[np[i+1]-1].first)*
                 (v[np[i]-1].first-v[np[i+1]-1].first)
                 +(v[np[i]-1].second-v[np[i+1]-1].second)*
                  (v[np[i]-1].second-v[np[i+1]-1].second)
                );
    }
    cnt++;
  }while(next_permutation(np.begin(),np.end()));
  printf("%.8f\n",ans/(double)cnt);

  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n;
vector<pair<int,int>> g[110000];
vector<int> color;

bool dfs(int v, int dis){
  color[v] = dis%2;
  rep(i,g[v].size()){
    if(color[g[v][i].first] == -1)dfs(g[v][i].first, dis + g[v][i].second);
  }
}

signed main(){
  cin>>n;
  color.resize(110000);rep(i,110000)color[i] = -1;
  rep(i,n-1){
    int u,v,w;cin>>u>>v>>w;u--;v--;w %= 2;
    g[u].push_back(make_pair(v,w));
    g[v].push_back(make_pair(u,w));
  }
  dfs(0, 0);
  rep(i,n)cout << color[i] << endl;
}


Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define int long long
#define pii pair<int,int>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define pb push_back

signed main(){
    vector<char> front;
    vector<char> back;

    string s;
    cin>>s;

    f(i,s.length()){
        front.pb(s[i]);
    }

    int numQ;
    cin>>numQ;
    pair<pair<int,int>,char> q[numQ];

    f(i,numQ){
        cin>>q[i].F.F;
        if(q[i].F.F==2){
            cin>>q[i].F.S>>q[i].S;
        }
    }

    bool reversed = false;

    f(i,numQ){
        if(q[i].F.F==1){
            reversed = !reversed;
        }else{
            if(q[i].F.S==1){
                //beginning
                if(!reversed)
                    back.pb(q[i].S);
                else
                    front.pb(q[i].S);

            }else{
                //end
                if(reversed)
                    back.pb(q[i].S);
                else
                    front.pb(q[i].S);

            }
        }
    }

    if(!reversed){
        for(int i=back.size()-1;i>=0;i--){
            cout<<back[i];
        }
        for(int i=0;i<front.size();i++){
            cout<<front[i];
        }
        cout<<endl;
        
    }else{
        for(int i=front.size()-1;i>=0;i--){
            cout<<front[i];
        }
        for(int i=0;i<back.size();i++){
            cout<<back[i];
        }
        cout<<endl;
    }

}

Measured memory_bytes: 5756