akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
  {
    cout << "Yes"
         << "\n";
  }
  else
  {
    cout << "No"
         << "\n";
  }
  return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

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

int main()
{
    string S;
    cin >> S;
    int n = S.size();
    ll sum = 0;
    rep(bit,1<<(n-1))
    {
        ll tmp = S[0] - '0';
        rep(i,n-1)
        {   
            if(bit & (1<<i))
            {  
                sum += tmp;
                tmp = S[i+1] - '0';
            }
            else
            {
                tmp *= 10;
                tmp += S[i+1] - '0';
            }
        }
        sum += tmp;
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <climits>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <cstring>
#include <cassert>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif

//#define int ll
#pragma GCC optimize("Ofast")


using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
#define sz(x) int((x).size())

#ifdef ONLINE_JUDGE
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
mt19937 rng(1000 - 7);
#endif

const int N = 2e3 + 10;
const int inf = INT_MAX / 2;
const ll INF = LLONG_MAX / 3;
//const int MOD = 998244353;
const int MOD = 1e9 + 7;
const ld eps = 1e-6;
const pii dir[] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };



signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(9);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;

    vector <int> a(n);
    for (int& x : a) {
        cin >> x;
    }

    sort(a.rbegin(), a.rend());
    ll ans = 0;

    ans += a.front();
    if (n > 2) {
        ans += a[1];
    }
    
    vector <int> b = { a[0], a[1], a[2] }, c;
    int j = 0;
    for (int i = 3; i < n; i++) {
        if (j == sz(b)) {
            vector <int> v;
            for (int k = 0; k < sz(b); k++) {
                v.push_back(b[k]);
                v.push_back(c[k]);
            }
            b = v;
            c.clear();
            j = 0;
        }
        ans += min(b[j], b[(j + 1) % sz(b)]);
        debug(j, b, min(b[j], b[(j + 1) % sz(b)]));
        j++;
        c.push_back(a[i]);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 7388
#include <stdio.h>

int isPrime( int );

int main( void ) {
	int a, d, n, fig;

	for ( ; scanf( "%d %d %d", &a, &d, &n ), a; printf( "%d\n", fig - d ) )
		for ( fig = a; n; fig += d )
			if ( isPrime( fig ) )
				n--;

	return 0;
}

int isPrime( int n ) {
	int i;

	if ( n == 1 )
		return 0;

	for ( i = 2; i * i <= n; i++ )
		if ( n % i == 0 )
			break;
	if ( i * i > n )
		return 1;

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    int x=a[n-1],cur=-1;
    rep(i,n-1)if(a[i]<=x){
        ++cur;
        swap(a[cur],a[i]);
    }
    ++cur;
    swap(a[cur],a[n-1]);
    rep(i,n){
        if(cur==i) cout<<"["<<a[i]<<"]"<<(i==n-1?"":" ");
        else cout<<a[i]<<(i==n-1?"":" ");
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3388
def gcd(x, y): 
    while(y): 
        x, y = y, x % y 
  
    return x
n = int(input())
sums = 0
for i in range(1,n+1):
    for k in range(1,n+1):
        for j in range(1,n+1):
            num = gcd(i,j)
            nums = gcd(num,k)
            sums += nums
print(sums)

Measured memory_bytes: 68824
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::cin >> N;
	if (N < 1000) {
		std::cout << "ABC\n";
	} else {
		std::cout << "ABD\n";
	}
}


Measured memory_bytes: 512
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int H , W , h , w ;
    cin >> H >> W >> h >> w ;
    cout << (H-h) * (W-w) ;




























return 0 ;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  if(n%2){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; n/2 > i; i++){
    if(s[i] != s[i+n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;

int main() {
  std::string o, e, ans = "";
  cin >> o >> e;

  for (int i = 0; i < e.length(); i++) {
     ans = ans + o[i] + e[i];
  }

  if (o.length() != e.length()) {
     ans = ans + o[(o.length() - 1)];
  }

  cout << ans << endl;
  

/*
  const std::vector<int> v = {1, 2, 3};
  for (const int x : v) {
    std::cout << x << std::endl;
  }
  */

}

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

int main() {
  double a,b,x;
  cin >> a >> b >> x;
  double theta;
  
  if(a*a*b/2.0 <=x){
    theta = atan(((2*a*a*b-2*x))/(a*a*a));
  }else{
    theta = M_PI/2 - atan(2*x/(a*b*b));
  }
  cout << fixed<< setprecision(10) << theta*180/M_PI << endl;
}

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

//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll a[200001];
int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	vector<ll> v;
	rep(i, n) {
		cin >> a[i];
		a[i] -= (i + 1);
		v.push_back(a[i]);
	}
	sort(v.begin(), v.end());

	ll ans = 0;
	rep(i, n) {
		ans += abs(a[i] - v[v.size() / 2]);
	}
	cout << ans << '\n';




}

Measured memory_bytes: 3568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main
{
    public static void main(String[] args) throws IOException {
        int t = 0;
        int s = 0;
        int m = 0;
        int h = 0;
  
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
         t = Integer.parseInt(br.readLine());//数値
        //String buf = br.readLine();
  
        if (t >= 0 && t < 86400)
        {
            h = t / 3600;
            m = t % 3600 / 60;
            s = t - (3600 * h + m * 60);
            System.out.println(h+":"+m+":"+s);
        }
    }
}


Measured memory_bytes: 24316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <utility>
#include <algorithm>
#include <vector>
#define MAXN 200005
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
inline pi read()
{
	ll x=0;
	pi ans;
	int f=0;
	char c=getchar();
	while (!isdigit(c)&&c!='.')	c=getchar();
	while (isdigit(c)||c=='.')
	{
		if (c=='.')
		{
			f=1;c=getchar();
			continue;
		}
		if (f) --ans.first,--ans.second;
		x=(x<<3)+(x<<1)+(c^48),c=getchar();
	}
	while (x%2==0) x/=2,++ans.first;
	while (x%5==0) x/=5,++ans.second;
	return ans;
}
pi a[MAXN];
int s[205][205];
const int N=100;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++) ++s[a[i].first+N][a[i].second+N];
	for (int i=0;i<=2*N;i++)
		for (int j=0;j<=2*N;j++)
		{
			if (i==0&&j==0) continue;
			if (i==0) s[i][j]+=s[i][j-1];
			else if (j==0) s[i][j]+=s[i-1][j];
			else s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
		}
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		int x=N-a[i].first,y=N-a[i].second;
		ans+=s[2*N][2*N]-s[2*N][y-1]-s[x-1][2*N]+s[x-1][y-1];
	}
	for (int i=1;i<=n;i++) if (a[i].first>=0&&a[i].second>=0) --ans;	
	ans>>=1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a == b && a != c) {
			System.out.println("Yes");
		} else if (b == c && b != a) {
			System.out.println("Yes");
		} else if (c == a && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    int n,T; cin >> n >> T;
    vector<int> c(n), t(n);
    vector<pair<int, int> > ct(n);
    rep(i, n) cin >> c[i] >> t[i], ct[i] = make_pair(c[i], t[i]);
    sort(ct.begin(), ct.end());
    bool hit = false;
    rep(i,n){
        if (ct[i].second <= T){
            cout << ct[i].first << endl;
            hit = true;
            break;
        }
    }
    if (!hit){
        cout << "TLE" << endl;
    }
    
}

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

using namespace std;

int main(void){

    int n;
    cin >> n;
    vector<int> d(n);
    int ans = 1;
    int current = 0;
    for(int i = 0;i < n;i++) cin >> d[i];

    sort(d.begin(), d.end(), greater<int>());

    current = d[0];

    for(int i = 0;i < n;i++){
        if(current > d[i]) ans++;
        current = d[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    int num[N] = {};

    bool isPoss = 1;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (num[a-1] != 0 && num[a-1] != b || a == 1 && b == 0 && N > 1) isPoss = 0;
        else num[a-1] = b;
    }

    if (isPoss) {
        if (N == 1) cout << max(num[0], 0);
        else {
            cout << max(num[0], 1);
            for(int i = 1; i < N; i++) {
                cout << num[i];
            }
        }
    }
    else cout << "-1";
    return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


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

    vector<int>a(n+2);
    rep2(i,1,n)cin>>a[i];

    vector<int>l(n+2),r(n+2);
    l[1]=a[1];
    r[n]=a[n];

    rep2(i,2,n+1){l[i]=__gcd(l[i-1],a[i]);}
    repr(i,n-1,1){r[i]=__gcd(r[i+1],a[i]);}

    int ans=0;

    rep2(i,1,n+1){ans=max(ans,__gcd(l[i-1],r[i+1]));}

    cout<<ans<<endl;

}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll rounds = n / (a + b);
  ll lft = n % (a + b);
  cout << rounds * a + min(lft, a) << 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 repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

vector<int> vx={-1,-1,0,1};
vector<int> vy={0,1,1,1};
vector<vector<bool>> cha,chb;
int ap=0,bp=0;

void ren(int x, int y, vector<vector<bool>> &v, vector<vector<bool>> &ch, int &p){
  rep(i,4){
    int tmp=-1;
    int nx = x, ny = y;
    while(0<=nx&&nx<v.size()&&0<=ny&&ny<v.size()){
      if(!v[nx][ny]) break;
      tmp++;
      nx+=vx[i];
      ny+=vy[i];
    }
    nx = x, ny = y;
    while(0<=nx&&nx<v.size()&&0<=ny&&ny<v.size()){
      if(!v[nx][ny]) break;
      tmp++;
      nx-=vx[i];
      ny-=vy[i];
    }
    if(tmp==v.size()){
      if(i==0){
        if(!ch[i][y]) ch[i][y]=true,p++;
      }else if(i==1){
        if(!ch[i][0]) ch[i][0]=true,p++;
      }else if(i==2){
        if(!ch[i][x]) ch[i][x]=true,p++;
      }else{
        if(!ch[i][0]) ch[i][0]=true,p++;
      }
    }
  }
  return;
}

struct check{
  int x;
  int y;
  int p;
  check(int xx, int yy, int pp) : x(xx),y(yy),p(pp){}
};

int main(){
  int n,u,v,m;
  cin >> n >> u >> v >> m;
  if(n==1){
    int x,y;
    cin >> x >> y;
    int a=0,b=0;
    bool usa=false,neko=false;
    int c;
    rep(i,m){
      cin >> c;
      if(x==c){
        if(a==0) a++;
        if(a>=u) usa=true;
      }
      if(y==c){
        if(b==0) b++;
        if(b>=v) neko=true;
      }
      if(usa||neko) break;
    }
    if(usa){
      if(neko){
        cout << "DRAW" << endl;
      }else{
        cout << "USAGI" << endl;
      }
    }else{
      if(neko){
        cout << "NEKO" << endl;
      }else{
        cout << "DRAW" << endl;
      }
    }
    return 0;
  }
  vector<vector<bool>> a(n,vector<bool>(n,false)),b(n,vector<bool>(n,false));
  map<int,vector<check>> mp;
  int x;
  rep(i,n){
    rep(j,n){
      cin >> x;
      mp[x].push_back(check(i,j,0));
    }
  }
  rep(i,n){
    rep(j,n){
      cin >> x;
      mp[x].push_back(check(i,j,1));
    }
  }
  bool usa=false,neko=false;
  cha=vector<vector<bool>>(4,vector<bool>(n));
  chb=vector<vector<bool>>(4,vector<bool>(n));
  rep(t,m){
    cin >> x;
    for(auto &c:mp[x]){
      if(c.p==0){
        a[c.x][c.y]=true;
        ren(c.x,c.y,a,cha,ap);
        if(ap>=u){
          usa=true;
        }
      }else{
        b[c.x][c.y]=true;
        ren(c.x,c.y,b,chb,bp);
        if(bp>=v){
          neko=true;
        }
      }
    }
    if(usa){
      if(neko){
        cout << "DRAW" << endl;
        return 0;
      }else{
        cout << "USAGI" << endl;
        return 0;
      }
    }else{
      if(neko){
        cout << "NEKO" << endl;
        return 0;
      }
    }
  }
  cout << "DRAW" << endl;
  return 0;
}



Measured memory_bytes: 33048
var
 n,i,m,j,t,s:longint;
 a:array[0..100001] of longint;
begin
 readln(n,m);
 for i:=1 to n do
  read(a[i]);
 for i:=1 to m do
  for j:=i+1 to n do
   if a[i]<a[j] then
    begin
     t:=a[i]; a[i]:=a[j]; a[j]:=t;
    end;
 for i:=1 to m do
  s:=s+a[i];
 writeln(s);
end.

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

typedef long long ll;
static const int MAX = 510000;
static const ll MOD = 1000000007;

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin>>A[i];
    vector<ll> color(3,0);

    ll ans = 1;

    for(int i=0; i<N; i++){
        ll kake = 0;
        for(int j=0; j<3; j++){
            if(color[j] == A[i]) kake++;
        }

        ans *= kake;
        ans %= MOD;

        for(int j=0; j<3; j++){
            if(color[j] == A[i]){
                color[j]++;
                break;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4040
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 

 
int main()
{
    long long int l ;
    cin>>l;
   long double val = (double)(l*l*l)/(double)(27);
    cout<<setprecision(10)<<val<<endl;
}




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

int main(){
    int a,b;
    cin>>a>>b;
    int required = 1,extended = a;
    while(extended < b){
        required++;
        extended += a-1;
    }
    if(b == 1){
        cout<<0;
    }else{
        cout<<required;
    }
    return 0;
}

Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

bool operator<(P x, P y) {
    return x.first < y.first;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi check(10);
    vector<P> card(n);
    vector<string> vv(10);
    rep(i, n) {
        string s;
        cin >> s;
        int num = stoi(s.substr(1));
        check[num]++;
        card[i] = P(num, check[num]-1);
        vv[num] += s[0];
    }

    vector<P> cc = card;

    rep(i, n) {
        for(int j = n-1; j >= i+1; --j) {
            if(card[j] < card[j-1]) {
                swap(card[j], card[j-1]);
            }
        }
    }

    rep(i, n) {
        int minj = i;
        for(int j = i; j < n; ++j) {
            if(cc[j] < cc[minj]) {
                minj = j;
            }
        }
        swap(cc[i], cc[minj]);
    }

    rep(i, n) {
        cout << vv[card[i].first][card[i].second] << card[i].first << (i == n-1?'\n':' ');
    }
    bool x = true;
    rep(i, n-1) {
        if(card[i].second > card[i+1].second and card[i].first == card[i+1].first) x = false;
    }
    if(x) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    rep(i, n) {
        cout << vv[cc[i].first][cc[i].second] << cc[i].first << (i == n-1?'\n':' ');
    }
    x = true;
    rep(i, n-1) {
        if(cc[i].second > cc[i+1].second and cc[i].first == cc[i+1].first) x = false;
    }
    if(x) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}


Measured memory_bytes: 3204
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 1e5 + 10;
ll d[maxN];
int sz[maxN];
vector < int > g[maxN];
void dfs(int v, int p, int he, ll& ans) {
    ans += he;
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v, he + 1, ans);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    vector < pair < ll, int > > f;
    for (int i = 1; i <= n; i++) {
        cin >> d[i];
        f.emplace_back(d[i], i);
        sz[i] = 1;
    }
    sort(f.begin(), f.end());
    vector < pair < int, int > > ed;
    for (int i = n - 1; i >= 1; i--) {
        if (sz[f[i].second] > n / 2) {
            cout << -1;
            return 0;
        }
        ll need = f[i].first - n + 2 * sz[f[i].second];
        int r = lower_bound(f.begin(), f.end(), make_pair(need, -1)) - f.begin();
        if (f[r].first != need) {
            cout << -1;
            return 0;
        }
        ed.emplace_back(f[r].second, f[i].second);
        sz[f[r].second] += sz[f[i].second];
        g[f[r].second].emplace_back(f[i].second);
        g[f[i].second].emplace_back(f[r].second);
    }
    int who = f[0].second;
    ll ans = 0;
    dfs(who, -1, 0, ans);
    if (ans != d[who]) {
        cout << -1;
        return 0;
    }
    for (auto it : ed) {
        cout << it.first << " " << it.second << '\n';
    }



    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

bool dfs(const vector<vector<int64_t>>& adjs, vector<int64_t>& colors,
         int64_t v, int64_t c) {
    colors[v] = c;

    for (auto u : adjs[v]) {
        if (colors[u] >= 0) {
            if (colors[u] + c != 1) {
                return false;
            }

            continue;
        }

        if (!dfs(adjs, colors, u, (c + 1) % 2)) {
            return false;
        }
    }

    return true;
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<vector<int64_t>> adjs(n);
    for (auto _ : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<int64_t> colors(n, -1L);
    if (dfs(adjs, colors, 0L, 0L)) {
        // two-party
        array<int64_t, 2> nn{};
        nn[0] = count(colors.begin(), colors.end(), 0L);
        nn[1] = n - nn[0];

        // cerr << nn[0] << " " << nn[1] << endl;

        int64_t ans = 0;
        for (auto i : irange(0L, n)) {
            ans += nn[(colors[i] + 1) % 2] - adjs[i].size();
        }
        ans /= 2;

        cout << ans << endl;
    } else {
        cout << n * (n - 1) / 2 - m << endl;
    }
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n,m;
	cin >> n >> m;
	vector<ll> a(n);
	ll sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum += a[i];
	}

	sort(a.begin(), a.end(), greater<ll>());

	for (int i = 0; i < m; i++)
	{
		if (4*m * a[i] >= sum)
			continue;
		else
		{
			cout << "No" << endl;
			ret;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 cnt = 0;
	SINT32 hou = 0;

	cin >> N;

	vector<SINT32> DATA(N);
	
	cin >> DATA[0];
	rep(i,1,N) {
		cin >> DATA[i];
		if (hou == 0) {
			if (DATA[i] > DATA[i-1]) {
				hou = 1;
			}
			if (DATA[i] < DATA[i-1]) {
				hou = -1;
			}

		} else if (hou == 1) {
			if (DATA[i] < DATA[i-1]) {
				hou = 0;
				cnt++;
			}

		} else {
			if (DATA[i] > DATA[i-1]) {
				hou = 0;
				cnt++;
			}
		}

	}


	cout << cnt+1 << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

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

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve()
{
    int n, m;
    cin >> n >> m;

    vector<bool> vis(n + 1);
    for (int i = 0; i < m; i++)
    {
        int tp;
        cin >> tp;
        vis[tp] = true;
    }
    vector<int> dp(n + 1);
    dp[0] = 1;
    for (int i = 0; i <= n; i++)
    {
        if (vis[i])
            continue;
        if (i + 1 <= n)
            dp[i + 1] += dp[i];
        if (i + 2 <= n)
            dp[i + 2] += dp[i];
        if (i + 1 <= n)

            dp[i + 1] %= MOD;
        if (i + 2 <= n)

            dp[i + 2] %= MOD;
    }
    cout << dp[n];
}

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

    int t = 1;
    //    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
#include<math.h>
#include<algorithm>

using namespace std;

int main() {
	int N, d[100000],p,med;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	/*for (int i = 0; i < N; i++) {
		for (int m = i; m < N - 1 ; m++) {
			if (d[i] > d[m + 1]) {
				p = d[i];
				d[i] = d[m + 1];
				d[m + 1] = p;
			}
		}
	}*/
	sort(d, d + N);
	med = (N / 2) - 1;
	if (d[med] == d[med+1]) {
		cout << 0 << endl;
	}
	else {
		if (d[med] == d[med-1]) {
			cout << d[med+1] - d[med] << endl;
		}
		else cout << d[med+1] - d[med]  << endl;
	}
		return 0;
}


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

int main() {
  long N,H,W;
  cin>>N>>H>>W;
  vector<long> a(N);
  vector<long> b(N);
  for(int i=0;i<N;i++) cin>>a[i]>>b[i];
  long ans=0;
  for(int i=0;i<N;i++){
    if(a[i]>=H&&b[i]>=W) ans++;
  }
cout<<ans<<endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        String s = std.next();
        String t = std.next();
        int a = std.nextInt();
        int b = std.nextInt();
        String u = std.next();

        if (s.equals(u)) {
            a--;
        } else {
            b--;
        }

        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

template<typename T>
struct Segtree {
    int n;
    T e; // default value
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input) {
        initialize(n_input, f_input, e_input);
    }

    void initialize(int n_input, Func f_input, T e_input) {
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) { n<<=1; }
        dat.resize(2*n-1, e);
    }

    void update(int k, T a) {
        k += n-1;
        dat[k] = a;
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k) {
        return dat[k+n-1];
    }
    // [a, b)
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // [a, b)
    T _query(int a, int b, int k, int l, int r) {
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = _query(a, b, 2*k+1, l, (l+r)/2);
        T vr = _query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};
/** Usage:
Segtree<int> seg(n, [](int a, int b) {return max(a,b);}, 0); // init
REP(i, n+1) st.update(i, i)
st.query(a, b)
*/

const int N = 2e5+5;
Segtree<LL> seg(N, [](LL a, LL b) { return max(a,b); }, 0);
LL H[N], A[N];

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

    int n;
    cin >> n;
    REP(i, n) cin >> H[i];
    REP(i, n) cin >> A[i];

    LL ans = 0;
    REP(i, n) {
        LL mx = seg.query(0, H[i]) + A[i];
        chmax(ans, mx);
        seg.update(H[i], mx);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7552
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     static int dx[]={1,-1,0,0};
      static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), m=sc.nextInt();  
  int n=sc.nextInt();  
  int m=sc.nextInt();  
  long d[]=new long[n], ans=0;
  int ed[] = new int[n];
  int from[] = new int[m];
  int to[] = new int[m];
  long c[] = new long[m],inf=(1L<<55);
  for( int i=0; i<n; i++ ){d[i] = inf;}
    for( int i=0; i<m; i++ ){
    int x=sc.nextInt()-1;
    int y=sc.nextInt()-1;
        from[i] = x;
        to[i] = y;
        c[i] = -sc.nextLong();
    }

    d[0]=0;
    int lp=0;
    long q=-1,p=q;
    while(true){
        boolean b=false;
        lp++;
        for( int i=0; i<m; i++ ){
            int fr = from[i];
            int t = to[i];
            if( d[fr] != inf && d[t] > d[fr] + c[i]){
                d[t] = d[fr] + c[i];
                b=true;
            }
        }
        q=d[n-1];
        if(!b){ans=-d[n-1]; break;}
        if(lp > 2010 ){
    if(q<p)out.println("inf");
    else out.println(-d[n-1]);
    out.flush();

    return;
}
p=q;
        // db(d);
    }
    // if(ans==0)
    out.println(ans);
    out.flush();
}

static void rep(int x, long d){

}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

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

int main(void){
   long long A,B,C;
   cin>>A>>B>>C;
   long long cnt=0;
   bool flag=false;
   if(A%2!=0||B%2!=0||C%2!=0){
      cout<<cnt<<endl;
      return 0;
   }
   while(!flag){
      int temp1=A;
      int temp2=B;
      int temp3=C;
      A=(temp2+temp3)/2;
      B=(temp1+temp3)/2;
      C=(temp1+temp2)/2;
      if(temp1==A&&temp2==B&&temp3==C){
         cout<<-1<<endl;
         return 0;
      }
      cnt++;
      if(A%2!=0||B%2!=0||C%2!=0){
         flag=true;
      }
   }
   cout<<cnt<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{
	int S, h, m, s, amari;
	cin >> S;
	h = S / 3600;
	amari = S % 3600;
	m = amari / 60;
	s = amari % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp = {{"SUN", 7}, {"MON", 6}, {"TUE", 5}, {"WED", 4}, {"THU", 3}, {"FRI", 2}, {"SAT", 1}};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  cout << mp[s] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;





int main()
{
	string r, a;
	int hit, blow;
	
	while (cin >> r >> a)
	{
		if (r=="0" && a=="0") break;
		hit = blow = 0;
		for (int i=0; i<4; i++)
		{
			if (r[i] == a[i]) hit++;
		}
		for (int i=0; i<4; i++)
		{
			for (int j=0; j<4; j++)
			{
				if (i == j) continue;
				if (r[i] == a[j])
				{
					blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1184
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	if (k == 0)
	{
		cout << (ll)n * (ll)n << endl;
		return 0;
	}

	ll ans = 0;

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

	cout << ans << endl;

	return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  string s;
  cin>>s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

dr = [0, 0, 1, -1]
dc = [1, -1, 0, 0]

H, W = map(int, input().split())
a = [[None for _ in range(W)] for _ in range(H)]  # black == True
reached = [[False for _ in range(W)] for _ in range(H)]
for r in range(H):
    s = input()
    for c in range(W):
        a[r][c] = (s[c] == '#')

ans = 0
for r in range(H):
    for c in range(W):
        if reached[r][c]: continue
        reached[r][c] = True

        b = 0
        w = 0

        dq = deque()
        dq.append((r, c))

        while dq:
            rr, cc = dq.popleft()
            if a[rr][cc]:
                b += 1
            else:
                w += 1
            for di in range(4):
                nr = rr + dr[di]
                if not (0 <= nr < H): continue

                nc = cc + dc[di]
                if not (0 <= nc < W): continue

                if a[rr][cc] == a[nr][nc]: continue

                if reached[nr][nc]: continue
                reached[nr][nc] = True

                dq.append((nr, nc))
        ans += b * w

print(ans)


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

int main() {
  int a, b, c, d, L, R;

  cin >> a >> b >> c >> d;

  L = a + b;
  R = c + d;

  if (L > R) {
    cout << "Left" << endl;
  } else if (L < R) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    vint a(3);
    REP(i,3) cin>>a[i];
    sort(ALL(a));
    int K; cin>>K;
    cout<<a[0]+a[1]+(a[2]<<K)<<endl;
}


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

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

    string S;
    cin >> S;

    int K;
    cin >> K;

    char c = S[K-1];

    replace_if(begin(S), end(S), [&](const auto& x){return x != c;}, '*');

    cout << S << endl;
}

Measured memory_bytes: 256
a = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().strip().split())
    a[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print(''.join(' {}'.format(a[b][f][r])for r in range(10)))
    if b < 3:
        print("#" * 20)

Measured memory_bytes: 7736
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn dfs(g: &Vec<Vec<(usize, isize)>>, ans: &mut Vec<isize>, e: usize, c: isize) -> bool {
    if ans[e] != 999999999 && ans[e] != c {
        return false;
    }
    if ans[e] != 999999999 {
        return true;
    }
    ans[e] = c;
    for a in &g[e] {
        if dfs(g, ans, a.0, c + a.1)==false{
            return false;
        }
    }
    return true;
}

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    let mut graph: Vec<Vec<(usize, isize)>> = vec![Vec::new(); n];
    let mut flag = true;

    let mut ans: Vec<isize> = vec![999999999; n];
    for _ in 0..m {
        let (l, r, d): (usize, usize, isize);
        input!(l, r, d);
        graph[l - 1].push((r - 1, d));
        graph[r - 1].push((l - 1, -1 * d));
    }

    for z in 0..n {
        if !flag {
            break;
        }
        if ans[z] == 999999999 {
            if !dfs(&graph, &mut ans, z, 0) {
                flag = false;
            }
        }
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 21372
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            double a = int.Parse(Console.ReadLine());
            double b = int.Parse(Console.ReadLine());
            if (a == b && a == 0) { break; }
            double g = Math.Sqrt(b * b + (a / 2 * a / 2));
            Console.WriteLine((a * a) + (2 * a * g));
        }
    }
}

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

namespace Program
{
	class Program
	{
		static void Main(string[] args)
		{
			var arg = Console.ReadLine().Split(' ');

			var n = int.Parse(arg[0]);
			var a = int.Parse(arg[1]);
			var b = int.Parse(arg[2]);

			var trainSumValue = n * a;
			var taxiSumvalue = b;

			Console.WriteLine(Math.Min(trainSumValue, taxiSumvalue));
		}
	}
}


Measured memory_bytes: 11092