akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i < N; i++)
#define p(s) cout << (s) << endl
#define p2(a, b) cout << (a) << ' ' << (b) << endl
using namespace std;
typedef long long ll;

bool isPrime[1000010];
void hurui(int n){
    isPrime[0] = isPrime[1] = false;
    for(int i=2;i<n+1;i++) isPrime[i] =true;
    for (int i = 2; i*i <= n; i++) {
        for(int j=i*2;j<n+1;j+=i){
            isPrime[j]=false;
        }
    }
}

int main() {
    hurui(1000000);
    int n;
    while(cin >> n && n){
        int cnt=0;
        REP(i,n+1,2*n+1) if(isPrime[i]) cnt++;
        p(cnt);
    }
    return 0;
}


Measured memory_bytes: 4064
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
  long long n,m;
  cin>>n>>m;
  long long ans = 0;
  ans += min(n,m/2);
  m -= (ans*2);
  ans += m/4;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]

if c[1][0] - c[0][0] == c[1][1] - c[0][1] \
    and c[1][0] - c[0][0] == c[1][2] - c[0][2] \
        and c[1][1] - c[0][1] == c[1][2] - c[0][2] \
            and c[2][0] - c[0][0] == c[2][1] - c[0][1] \
                and c[2][0] - c[0][0] == c[2][2] - c[0][2] \
                    and c[2][1] - c[0][1] == c[2][2] - c[0][2]:
                        print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N,M=map(int,input().split())
A=map(int,input().split())
L=[(1,a) for a in A]
for _ in range(M):
  b,c=map(int,input().split())
  L.append((b,c))
L=sorted(L,key=lambda x: x[1],reverse=True)
ans,k=0,0
for n,a in L:
  if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n
print(ans)

Measured memory_bytes: 104324
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())

	if N < 10 {
		fmt.Println(N)
	} else if N < 100 {
		fmt.Println(9)
	} else if N < 1000 {
		fmt.Println(9 + N - 100 + 1)
	} else if N < 10000 {
		fmt.Println(9 + 900)
	} else if N < 100000 {
		fmt.Println(9 + 900 + N - 10000 + 1)
	} else {
		fmt.Println(9 + 900 + 90000)
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int main(){
 
  int x,y;
 
  scanf("%d %d", &x, &y);
 
  int i,j;
  int f = 0;
  for(i = 0;i <= x;i++){
    for(j = 0;j <= x;j++){
      if(i + j > x) continue;
      if((i + j) == x && i*4 + j*2 == y){
        f = 1;
        break;
      }
    }
  }
 
  if(f) printf("Yes\n");
  else printf("No\n");
 
  return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(q);
    vector<int> point(n+1);
    for(int i=0;i<n+1;i++){
        point[i]=k;
    }
    for(int i=0;i<q;i++){
        cin>>a[i];
        point[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        if(point[i]>q){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <functional>
#include <queue>
#include <utility>

constexpr int INF = 1000000000;
using Pair = std::pair<int, int>;

int n, k;

int v[101][101];
int c[101];
int dijkstra(int st, int en) {
    for(int i = 0; i < n; ++i) {
        c[i] = INF;
    }
    c[st] = 0;

    std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair>> que;
    que.push({0, st});

    while(!que.empty()) {
        auto p = que.top(); que.pop();

        if(c[p.second] < p.first) {
            continue;
        }

        for(int i = 0; i < n; ++i) {
            if(v[p.second][i] && c[p.second] + v[p.second][i] < c[i]) {
                c[i] = c[p.second] + v[p.second][i];
                que.push({c[i], i});
            }
        }
    }
    
    return c[en];
}

int main() {
    while(std::cin >> n >> k, n + k) {
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            v[i][j] = 0;
        }
    }

    int c, p, q, r;
    for(int i = 0; i < k; ++i) {
        std::cin >> c >> p >> q;
        --p, --q;
        if(c) {
            std::cin >> r;

            if(v[p][q]) {
                v[p][q] = v[q][p] = std::min(v[p][q], r);
            }else {
                v[p][q] = v[q][p] = r;
            }
        }else {
            r = dijkstra(p, q);

            std::cout << (r == INF ? -1 : r) << std::endl;
        }
    }
    }
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n,a,b;
  cin >> n;
  cin >> b;
  rep(i,n){
  cin>>a;
  b=__gcd(b,a);
  }
  cout<<b;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long int
using namespace std;
void solveA(){
    string s;
    cin>>s;
    int r=0;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<"3";
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))cout<<"2";
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout<<"1";
    else cout<<0;

}
int main()
{
    solveA();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <bitset>

using namespace std;
using ll = long long;

int main() {
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    50005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define mid  (l + r + 1)/2
#define s3   1.73205080757
const int inf = (int)1e18+10 ;
const int MAX= 1010;
set<int> v[205];
queue<pii> q;
int a[205][205] , dp[205][205];
int vis[205] = {0};
signed main(){
  fast;
  int n  , y;
  cin >> n;
  string s;
  for(int i = 1 ; i <=n ; i++){
  	    cin >> s;
  	    for(int j = 0 ; j < n ; j++){
  	    	  if(s[j] == '1') a[i][j+1] = 1 , dp[i][j+1] = 1;
  	    	  else  a[i][j+1] = 0 , dp[i][j+1] = inf;
              dp[j+1][j+1] = 0;
  	    }

  }
  int maxd = 0, x = 0;
  for(int k = 1 ; k <= n ; k++){
  	   for(int i = 1 ; i <=n ; i++){
  	   	    for(int j = 1 ; j<= n ; j++){
  	   	    	   dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k][j]);
  	   	    }
  	   }
  }
  for(int i = 1 ; i <=n ; i++){
   	    for(int j = 1 ; j<= n ; j++){
   	    	   if(dp[i][j] > maxd)
   	    	   	maxd = dp[i][j] , x = i;
   	    }
   }

  // cout << maxd << endl;
  q.push({x , 1});
  vis[x] = 1;
  v[1].insert(x);
  int ymax = 1;
  while(q.size() > 0){
          pii p = q.front();
          q.pop();
          x = p.ff;
          y = p.ss;
          // cout << x <<"  " << y << endl;
          ymax = max(ymax , y);
          for(int i = 1 ; i <=n ; i++){
          	    if(a[x][i] == 1 && !vis[i]){
          	    	vis[i] = 1;
          	    	v[y + 1].insert(i);
          	    	q.push({i , y + 1});
          	    }
          }
  }

  for(int i = 1 ; i <= ymax ; i++){
  	     for(auto j : v[i]){
                for(int k = 1 ; k <= n ; k++){
                	   if(a[j][k]){
                	   	    if(v[i].find(k) != v[i].end()){
                	   	    	cout << "-1" << endl;
                	   	    	return 0;
                	   	    }
                	   }
                }
  	     }
  }
  cout << maxd + 1 << endl;


 // check for n=1 edge case 
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n;
    cin>>n;
    Vi a(n);
    REP(i,0,n){
        cin>>a[i];
        a[i]--;
    }
    
    int t=0;
    Vi ans;
    REP(i,0,n){
        if(a[i]==i) t++;
        else if(t!=0){
            ans.pb(t);
            t=0;
        }
    }
    if(t!=0) ans.pb(t);
    
    int Ans=0;
    REP(i,0,ans.size()) Ans+=RUP(ans[i],2);
    cout<<Ans<<endl;
    return 0;
}


Measured memory_bytes: 1660
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

s =getN()


app = math.floor(math.sqrt(s - 1)) + 1
if app > 10**9:
    app = 10 ** 9
mx = app**2

sabun = mx - s
# print(app, s)
h = app
w = app
if sabun >= w:
    h -= sabun // w
    sabun -= (sabun // w) * w

print(0, 0, w, 1, sabun, h)

# print(557776632 * 557776631 - 83445295)

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
      cin >> a[i];
    }
    int c = 0;
    for (int i = 0; i < N; i++) {
      while (a[i] != 0) {
        for (int j = i; j < N; j++) {
          if (a[j] == 0) {
            break;
          }
          a[j]--;
        }
        c++;
      }
    }
    cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i,j in list(combinations(L,2)):
  if j < 2*i:
    ans += max(0, bisect.bisect_left(L, i+j) - bisect.bisect_right(L, j-i)-2)
  else:
    ans += max(0, bisect.bisect_left(L, i+j) - bisect.bisect_right(L, j-i)-1)
print(ans//3)

Measured memory_bytes: 131912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll M=1e9+7;
const ll mxx=1e5+7;


int main()
{
	
    int x;
    cin>>x;
    cout<<1-x<<endl;
}

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

using namespace std;

int main(){

    int N, H;
    cin >> N >> H;

    vector<int> a(N), b(N), strong;
    int amax=0;
    int ans=0;

    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i];
        amax = max(amax,a[i]);
    }

    for(int i=0; i<N; i++)
        if(amax < b[i])
            strong.push_back(b[i]);

    sort(strong.begin(),strong.end());
    reverse(strong.begin(),strong.end());

    for(int i=0;i<strong.size();i++){
        ans++;
        H -= strong[i];
        if(H <= 0){
            cout << ans << endl;
            return 0;
        }
    }

    if(H % amax == 0 || amax == 1)
        ans += H / amax;
    else
        ans += H / amax +1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/
#define MAX_N 100000
int N;
struct edge{int to; ll cost;};
vector<edge> G[MAX_N];
ll d[MAX_N];
bool used[MAX_N];
/*****************************functions********************************/
void dfs(int x){
    used[x] = true;
    for(int i = 0;i < G[x].size();i++){
        if(!used[G[x][i].to]){
            d[G[x][i].to] = d[x] + G[x][i].cost;
            dfs(G[x][i].to);
        }
    }
}
/****************************main function*****************************/
int main(void){
    cin >> N;
    for(int i = 0;i < N - 1;i++){
        int a,b; ll c;
        cin >> a >> b >> c;
        a--,b--;
        G[a].push_back({b,c}),G[b].push_back({a,c});
    }
    for(int i = 0;i < N;i++){
        used[i] = false;
    }
    int Q,K; cin >> Q >> K;
    d[--K] = 0;
    dfs(K);

    for(int i = 0;i < Q;i++){
        int x,y; cin >> x >> y;
        x--,y--;
        cout << d[x] + d[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 14336
import math

while 1:
    n = input()
    if n == -1:
        break
    x, y = 0.0, 0.0
    radian = math.radians(-90)
    for i in xrange(n):
        radian += math.pi / 2
        x += math.cos(radian)
        y += math.sin(radian)
        radian = math.atan2(y, x)
    print "%.2f\n%.2f" % (x, y)

Measured memory_bytes: 4496
function Main(input) {
	input = input.split(' ')
	const [A, B, C, K] = input.map(i => parseInt(i))

    if (A >= K) {
        console.log(K)
    } else if (A + B >= K) {
        console.log(A)
    } else {
        const pos = A
        const neg = K - (A + B)

        console.log(pos - neg)
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 29664
<?php

while (true) {
  $input = trim(fgets(STDIN));
  if ($input === "-") {
    break;
  }

  $s = $input;
  $num_shuffle = trim(fgets(STDIN));
  do {
    $num_cards = trim(fgets(STDIN));
    $a = substr($s, 0, $num_cards);
    $b = substr($s, $num_cards);
    $s = $b . $a;
    $num_shuffle--;
  } while ($num_shuffle > 0);
  echo $s . PHP_EOL;
}

Measured memory_bytes: 15188
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define A 1
#define G 2
#define C 3
#define T 4
using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int dp[102][5][5][5][5],n;
int solve(int pos,int a,int b,int c,int d)
{
    if(b==A && c==G && d==C)return 0;
    if(b==A && c==C && d==G)return 0;
    if(b==G && c==A && d==C)return 0;
    if(a==A && b==G && d==C)return 0;
    if(a==A && c==G && d==C)return 0;
    if(pos>n)return 1;
    int &ret=dp[pos][a][b][c][d];
    if(ret!=(-1))return ret;
    ret=0;
    ret=ad(ret,solve(pos+1,b,c,d,A));
     ret=ad(ret,solve(pos+1,b,c,d,G));
      ret=ad(ret,solve(pos+1,b,c,d,C));
       ret=ad(ret,solve(pos+1,b,c,d,T));
       return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>n;
    int ses=solve(1,0,0,0,0);
    cout<<ses<<endl;
    return 0;

}





































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

template<class T> inline bool chmax(T& a, T b){
	if(a<b){a=b;return true;} return false;
}
const long long INF = 1LL<<60;

string s,t;

int dp[3100][3100]={0};
int main(){
	cin>>s>>t;
	for (int i=0;i<s.size();++i){
		for (int j=0;j<t.size();++j){
			if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
			chmax(dp[i+1][j+1],dp[i+1][j]);
			chmax(dp[i+1][j+1],dp[i][j+1]);

		}
	}

	string res="";

	int i = (int)s.size(),j=(int)t.size();
	while(i>0&&j>0){
		if(dp[i][j]==dp[i-1][j]) {--i;} 
		else if(dp[i][j]==dp[i][j-1]) {--j;}
		else {res=s[i-1]+res;--i;--j;}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <iomanip>

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

cout << fixed << setprecision(15);
double n, m, d; cin >> n >> m >> d;

if (d)
    cout << 2 * (m - 1) * (n - d) / n / n << endl;
else 
    cout << (m - 1) / n << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <cstdio>
#define f(x)((x)*(x))
int main() {
	int d;
	while(scanf("%d",&d)!=EOF) {
		int sum=0;
		for(int i=1;i*d<=600-d;i++) {
			sum+=f(i*d)*d;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1024
/*

            ░   ▒▓█  𝕿𝖆𝖑𝖐 𝖎𝖘 𝖈𝖍𝖊𝖆𝖕. 𝕾𝖍𝖔𝖜 𝖒𝖊 𝖙𝖍𝖊 𝖈𝖔𝖉𝖊 █▓▒░
   */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ld long double
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
#define pr_vec(v) for(ll _=0;_<v.size();_++) cout << v[_] << " " ;
const int N = 1e6 + 7;
ll m = 998244353;



void solve()
{
    ll n, s, x, ans = 0;
    cin >> n >> s;

    std::vector<ll> dp(s + 1);
    rep(_, n)
    {
        dp[0] += 1;
        cin >> x;
        for(ll j = s - x; j >= 0; j--)
            (dp[j + x] += dp[j]) %= m;

        (ans += dp[s]) %= m;

    }
    cout << ans;



}





int main()
{



    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;


    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        // cout << endl;
    }


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0013
    {
        public static void Main(string[] args)
        {
            int[] stack = new int[10]{0,0,0,0,0,0,0,0,0,0};
            int i = 0;

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                int line = int.Parse(input);

                if (line == 0)
                {
                    i--;
                    Console.WriteLine(stack[i]);
                }
                else
                {
                    stack[i] = line;
                    i++;
                }
            }
        }
    }
}

Measured memory_bytes: 5548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// ABC141-D, 826, 
	int n, m, tmp;
	cin >> n >> m;
	multiset<ll> st;
	ll ans = 0;
	rep(i, n) {
		cin >> tmp;
		st.insert(tmp);
		ans += tmp;
	}
	rep(i, m) {
		ll val = *st.rbegin();
		st.erase(st.find(val));
		ans -= val - val / ll(2);
		st.insert(val / ll(2));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8308
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, read().split())

    if abs(N - M) > 1:
        print(0)
        return

    COM_MAX = max(N, M)

    fac = [0] * (COM_MAX + 1)
    fac[0] = fac[1] = 1
    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD

    if N == M:
        ans = 2 * fac[N] * fac[M] % MOD
    else:
        ans = fac[N] * fac[M] % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 63308
N, A = input().split(" ")
N, A = int(N), int(A)
x = input().split(" ")
x = [int(i) for i in x]
y = [0]+[int(i)-A for i in x]
X = max(x+[A])

dp = [[0 for t in range(2*N*X+1)] for j in range(N+1)]

for j in range(N+1):
    for t in range(2*N*X+1):
        if j == 0 and t == N*X:  # 0枚の時は0しか達成できない
            dp[j][t] = 1
        elif j >= 1 and (t - y[j-1] < 0 or t-y[j] > 2*N*X):  # xの値が平均Aを超えてしまう場合は、前回の結果から場合の総数に変化なし
            dp[j][t] = dp[j-1][t]
        elif j >= 1 and 0 <= t-y[j-1] <= 2*N*X:  # 前回の場合の総数に、今回の数を足して0になる場合の総数を足す
            dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j]]
        else:
            dp[j][t] = 0
print(dp[N][N*X] - 1)

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

#define ll long long
#define pb push_back

const int maxn = 3e2 + 20;

int dp[maxn][maxn][maxn];

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

	string s;
	cin >> s;

	int k;
	cin >> k;

	int n = s.size();

	for(int l = n - 1; l >= 0; l--)
		for(int r = l; r < n; r++)
			for(int i = 0; i <= k; i++)
			{
				if(l == r)
				{
					dp[l][r][i] = 1;
					continue;
				}

				if(r - l + 1 == 2)
				{
					dp[l][r][i] = 1;
					if(s[l] == s[r] || i)
						dp[l][r][i] = 2;
					continue;
				}

				if(i)
					dp[l][r][i] = max(dp[l][r][i] , dp[l + 1][r - 1][i - 1] + 2);
				if(s[l] == s[r])
					dp[l][r][i] = max(dp[l][r][i] , dp[l + 1][r - 1][i] + 2);

				dp[l][r][i] = max(dp[l][r][i] , max(dp[l + 1][r][i] , dp[l][r - 1][i]));
			}

	cout << dp[0][n - 1][k] << endl;
}






















Measured memory_bytes: 120960
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n;
int a[N];

bool inc(int k, vector<pair<int, int> > &v)
{
	vector<pair<int, int> > temp;
	int cur=0;
	while(v.size() && v.back().first==k)
	{
		temp.push_back(v.back());
		v.pop_back();
	}
	if(!v.size())
		return 0;
	if(v.back().second>=2)
	{
		v[v.size()-1].second-=1;
		int cur=v.back().first;
		v.push_back({cur+1, 1});
	}
	else
		v[v.size()-1].first+=1;
	while(temp.size())
	{
		v.push_back({1, temp.back().second});
		temp.pop_back();
	}
	return 1;
}

int check(int k)
{
	vector<pair<int, int> > v;
	v.push_back({1, a[1]});
	int len=a[1];
	for(int i=2;i<=n;i++)
	{
		int sz=v.size();
		if(a[i]>a[i-1])
			v.push_back({1, a[i]-a[i-1]});
		else if(a[i]==a[i-1])
		{
			if(!inc(k, v))
				return 0;
		}
		else
		{
			while(v.size())
			{
				if(len-v.back().second>=a[i])
				{
					len-=v.back().second;
					v.pop_back();
				}
				else
					break;
			}
			v[v.size()-1].second-=(len-a[i]);
			if(!inc(k, v))
				return 0;
		}
		len=a[i];
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(check(mid))
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=binsearch(1, n);
	cout<<ans;	
	return 0;
}

Measured memory_bytes: 9624
# ABC058C - 怪文書 / Dubious Document (ARC071C)
def main():
    N = int(input())
    S = tuple(input() for _ in range(N))
    ans = ""
    for i in "abcdefghijklmnopqrstuvwxyz":
        if all(i in s for s in S):
            ans += i * min(s.count(i) for s in S)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ll long long
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> P;
//////////////////////////////////////////////////////
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp


const long long INF = 9223372036854775000;
const int VMAX = 1002;
const int EMAX = 3000;

struct Edge{
	int from;
	int to;
	int cost;
};


int main() {
	int N,M; SCD2(N,M);
	struct Edge e[EMAX];
	long long d[VMAX];
	bool negcycle[VMAX] = {};
	
	REP(i,M){
		int a,b,c;
		SCD3(a,b,c);
		e[i].from = a;
		e[i].to = b;
		e[i].cost = -c; // -1
	}
	
	REP(i,VMAX){
		d[i] = INF;
	}

	d[1] = 0;
	
	REP(i,N-1){ // loop V times --> NEGCYCLE

			bool update = false;
			REP(j,M){
				int u = e[j].from;
				int v = e[j].to;
				int c = e[j].cost;
				
				if ((d[u] + c < d[v]) and (d[u] != INF)) { //s-->uへ現状行けないときを弾く
					d[v] = d[u] + c;
					update = true;
				}
			}
	}
	
	ll ans = -d[N];
	
	REP(i,N){
		REP(j,M){
			int u = e[j].from;
			int v = e[j].to;
			int c = e[j].cost;
			
			if (d[u] == INF) continue;
			
			if (d[v] > d[u] + c){
				d[v] = d[u] + c;
				negcycle[v] = true;
			}
			
			if (negcycle[u] == true){
				negcycle[v] = true;
			}
		}
	}
	
	
	if (negcycle[N]) {
		printf("inf\n");
		return 0;
	}
	
	PRINTLLD(ans);
	
	
	return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, cnt = 0, temp;
    cin >> n;
    rep(i, n) {
        cin >> temp;
        if(temp % 2) cnt++;
    }
    if(cnt % 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

int main(){
    while(true){
        int x, y;
        cin >> x >> y;
        if(x==0 && y==0){
            break;
        }
        if(x<=y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
}



Measured memory_bytes: 3084
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
    int n,k,h,ans=0;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> h;
        if(h>=k){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
ctr = 0

# 赤ボール
for r in range(N + 1):
    for g in range(N + 1 - r):
        b = N - r - g
        if r % R == 0 and g % G == 0 and b % B == 0:
            ctr += 1

print(ctr)

Measured memory_bytes: 41308
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

vector<P> v1;

int main(){
	int h,w,n;
	int i,j,k;
	int a,b,c,s;
	int dis=0;
	cin>>h>>w>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		v1.push_back(make_pair(a,b));
	}
	sort(v1.begin(),v1.end());
	s=h;
	for(i=0;i<n;i++){
		a=v1[i].first-v1[i].second;
		if(a<dis)continue;
		if(a==dis)dis++;
		else s=min(s,v1[i].first-1);
	}
	cout<<s<<endl;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 500005
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, a[maxn], sum;
il bool cmp(int a, int v) {
	return a > v;
}
signed main() {
	n = read(), m = read();
	rep(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1, cmp);
	rep(i, m + 1, n) sum += a[i];
	cout << sum;
	return 0;
}

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


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

	vector<int> h(N);
	for(int i=0;i<N;i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	int min_diff = 1000000002;
	for(int i=0;i+K-1<N;i++) {
		min_diff = min(min_diff, abs(h[i] - h[i + K - 1]));
	}
	cout << min_diff << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h> 

using namespace std;
int main(){
	char a, b;
	cin>>a>>b;
	if(a=='H' && b=='H'){
		cout<<'H';
	}else if(a=='D' && b=='H'){
		cout<<'D';
	}else if(a=='H' && b=='D'){
		cout<<'D';
	}else if(a=='D' && b=='D'){
		cout<<'H';
	}
		return 0;
	

}

Measured memory_bytes: 256
def solve():
    A, B = map(int, input().split())

    print(100, 100)

    rem = B - 1
    for i in range(50):  # black
        if i%2 == 1: # not put
            line = "." * 100
            print(line)
            continue
        line = ""
        for j in range(50):  # put black
            if rem > 0:
                line += "#."
                rem -= 1
            else:
                line += ".."
        print(line)

    rem = A - 1
    for i in range(50):  # black
        if i%2 == 0: # not put
            line = "#" * 100
            print(line)
            continue
        line = ""
        for j in range(50):  # put black
            if rem > 0:
                line += ".#"
                rem -= 1
            else:
                line += "##"
        print(line)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int h[100005], dp[100005];

int main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> h[i];
	for(int i=2;i<=n;i++) {
		int mn = INF;
		for(int j=i-1;j>=1&&j>=i-k;j--)
			mn = min(mn, dp[j]+abs(h[i]-h[j]));
		dp[i] = mn;
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

bool is_ok(ll n, vll &a, vll &sum, ll x) {
	ll sz = a[x];
	for (ll i = 0; i < n; i++) {
		if (i == x) continue;
		if (2 * sz < a[i]) return false;
		else sz += a[i];
	}
	return true;
}

ll bs(ll l, ll r, ll n, vll &a, vll &sum) {
	if (l + 1 == r) return l;
	ll mid = (l + r) / 2;
	if (is_ok(n, a, sum, mid)) return bs(l, mid, n, a, sum);
	else return bs(mid, r, n, a, sum);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(all(a));

	vll sum(n + 1, 0);
	for (ll i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];

	ll ans = 0;
	if (is_ok(n, a, sum, 0)) ans = n;
	else if (!is_ok(n, a, sum, n - 1)) ans = 0;
	else ans = n - bs(0, n - 1, n, a, sum) - 1;
	cout << ans << endl;
}


Measured memory_bytes: 1792
def get_count(li,c):
    if(li==[]):
        return ((0,0))
    m=(li[0][c],1)
    h={}
    h[li[0][c]]=1
    for i in li[1:]:
        if(i[c] in h):
            h[i[c]]+=1
        else:
            h[i[c]]=1
        if(m[1]<h[i[c]]):
            m=(i[c],h[i[c]])
    return m


h,w,n=list(map(int,input().split()))

if(h==1 or w==1 or n<=1):
    li = []
    for i in range(n):
        li.append(tuple(map(int, input().split())))
    print(n)
else:
    li=[]
    for i in range(n):
        li.append(tuple(map(int,input().split())))
    li=list(set(li))
    r=get_count(li,0)
    c=get_count(li,1)
    # print(r,c)
    s=0
    if(r[1]>c[1]):
        temp=[]
        for i in li:
            if(i[0]!=r[0]):
                temp.append(i)
        s+=r[1]+get_count(temp,1)[1]
    else:
        temp=[]
        for i in li:
            if(i[1]!=c[0]):
                temp.append(i)
        s+=c[1]+get_count(temp,0)[1]

    print(s)


Measured memory_bytes: 198520
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            if (i % 2 == 0) {
                if (a % 2 == 1) a--;
                b += a / 2;
                a /= 2;
            }
            else {
                if (b % 2 == 1) b--;
                a += b / 2;
                b /= 2;
            }
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    int n, l; cin >> n >> l;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    string ans = "";
    rep(i,n) ans += s[i];
    cout << ans << endl;
}


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

namespace MergeSortApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var array = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();
            var count = 0;
            var sorted = MergeSort(array, 0, array.Length, ref count);
            Console.WriteLine(string.Join(" ", sorted));
            Console.WriteLine(count);
        }

        private static int[] MergeSort(int[] array, int leftIndex, int rightIndex, ref int count)
        {
            var mid = leftIndex + (rightIndex - leftIndex) / 2;
            if (leftIndex == mid)
            {
                return new[] { array[leftIndex] };
            }

            var leftArray = MergeSort(array, leftIndex, mid, ref count);
            var rightArray = MergeSort(array, mid, rightIndex, ref count);
            return Merge(leftArray, rightArray, ref count);
        }

        private static int [] Merge(int[] leftArray, int[] rightArray, ref int count)
        {
            var result = new int[leftArray.Length + rightArray.Length];
            var leftIndex = 0;
            var rightIndex = 0;
            var resultIndex = 0;

            while(leftIndex < leftArray.Length || rightIndex < rightArray.Length)
            {
                count++;
                if (leftIndex == leftArray.Length)
                {
                    result[resultIndex++] = rightArray[rightIndex++];
                    continue;
                }

                if (rightIndex == rightArray.Length)
                {
                    result[resultIndex++] = leftArray[leftIndex++];
                    continue;
                }

                var leftValue = leftArray[leftIndex];
                var rightValue = rightArray[rightIndex];
                if (leftValue < rightValue)
                {
                    result[resultIndex++] = leftArray[leftIndex++];
                }
                else
                {
                    result[resultIndex++] = rightArray[rightIndex++];
                }
            }

            return result;
        }
    }
}



Measured memory_bytes: 84772
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s,t; cin >> s >> t;

    cout << t+s << ln;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);
  char s[n+10];
  scanf("%s",s);

  if(n%2==1)
    printf("No\n");
  else{
    int i,j=n/2;
    int flag=0;
    for(i=0;i<j;i++){
      if(s[i]!=s[n/2+i]){
        flag=1;
        break;
      }
    }

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

  }

  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int count = scanner.nextInt();
			scanner.nextLine();

			Map<String, Integer> map = new HashMap<>();
			for (int i = 0; i < count; i++) {
				String key = scanner.nextLine();
				Integer val = map.get(key);
				if (val == null) {
					val = 1;
				} else {
					val++;
				}
				map.put(key, val);
			}

			count = scanner.nextInt();
			scanner.nextLine();
			for (int i = 0; i < count; i++) {
				String key = scanner.nextLine();
				Integer val = map.get(key);
				if (val == null) {
					val = -1;
				} else {
					val--;
				}
				map.put(key, val);
			}

			List<Integer> list = new ArrayList<>(map.values());
			Collections.sort(list);
			int max = list.get(list.size() - 1);
			if (max > 0) {
				System.out.println(max);
			} else {
				System.out.println(0);
			}
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

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

signed main() {
  double n, k;
  cin >> n >> k;
  double kt = 0;
  int sk = 1;
  int kn = n;
  dep(i, kn, 1) {
    while(k > i * sk) n *= 2, sk *= 2;
    kt += 1 / n;
  }

  cout << fixed << setprecision(10) << kt << endl;
}


Measured memory_bytes: 256
# 人も言語もグラフの頂点と見なす
# ある人がある言語を話せる場合連結となる
# 頂点のキーは[言語 or 人][番号(人番号 or 言語番号)]
# 0:言語 1:人

N,M = map(int,input().split())
from collections import defaultdict
E = [[],[]]
E[0] = [[] for i in range(M)]
E[1] = [[] for i in range(N)]

for i in range(N):
  langs = list(map(int,input().split()))[1:]
  for lang in langs:
    E[1][i].append((0,lang-1))
    E[0][lang-1].append((1,i))
    
# 任意の頂点からBFSして、全ての人の頂点が往訪済みになればOK
from collections import deque
q = deque([])
# 人で、0番目からスタート
q.append((1,0))
seen = [[],[]]
seen[0] = [False for i in range(M)]
seen[1] = [False for i in range(N)]

while q:
  kind,v = q.popleft()
  if seen[kind][v]:
    continue
  seen[kind][v] = True
  children = E[kind][v]
  for child in children:
    q.append([child[0],child[1]])
    
for s in seen[1]:
  if not s:
    print("NO")
    break
else:
  print("YES")
  

Measured memory_bytes: 57056
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	var A, B, M int
	A = nextInt()
	B = nextInt()
	M = nextInt()
	priceA := make([]int, A)
	priceB := make([]int, B)
	minA := 100001
	minB := 100001

	for i := 0; i < A; i++ {
		tempA := nextInt()
		priceA[i] = tempA
		if minA > tempA {
			minA = tempA
		}
	}

	for i := 0; i < B; i++ {
		tempB := nextInt()
		priceB[i] = tempB
		if minB > tempB {
			minB = tempB
		}
	}

	min := 200001
	for i := 0; i < M; i++ {
		x := nextInt()
		y := nextInt()
		c := nextInt()

		if tempTotal := priceA[x-1] + priceB[y-1] - c; min > tempTotal {
			min = tempTotal
		}
	}

	if min > minA+minB {
		min = minA + minB
	}

	fmt.Println(min)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  int p = 0, m = 0;
  rep(i, N) {
    int a;
    cin >> a;
    if (a < 0) m++;
    else p++;
    A[i] = abs(a);
  }
  sort(A.begin(), A.end());
  if (m%2 == 1) A[0] = -A[0];
  ll ans = 0;
  rep(i, N) ans += A[i];
  cout << ans << endl;
}

Measured memory_bytes: 3988
# include <iostream>
# include <vector>


using namespace std;


int main() {
    int n, m; cin >> n >> m;
    vector<double> a(n);

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

    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (a[i] >= (s / (4*m))) cnt++;
    }

    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<map>
using namespace std;
const int mod=998244353;
string s;
map<string,int> mp;
void merge(string &s,string t){
	for(int i=0;i<s.size();++i)
		if(s[i]=='1'&&t[i]=='1') s[i]='1';
		else s[i]='0';
}
int work(string s){
	if(s.size()==1) return s[0]-'0'+1;
	if(mp.count(s)) return mp[s];
	int ans=work(s.substr(1,s.size()-1))*(s[0]-'0'+1)%mod;
	for(int i=1;i<s.size();++i){
		string now=s.substr(0,i);
		for(int j=i*2;j<=s.size();j+=i){
			merge(now,s.substr(j-i,i)); int v=j==s.size()?1:work(s.substr(j,s.size()-j));
			ans=(ans+1ll*work(now)*v%mod)%mod;
		}
	}
	return mp[s]=ans;
}
int main(){
	cin>>s;
	cout<<work(s);
}

Measured memory_bytes: 5632
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
var sub_fn = (ary)=>{
  
}
reader.on('close', () => {
  var a = 1*lines[0]
  var b = 1*lines[1]  
  var c = 1*lines[2]
  var x = 1*lines[3]
  
  var cnt = 0;
  
  for(var i = 0; i <= a; i++){
    for(var j = 0; j <= b; j++){
     // console.log(j)
      for(var k = 0; k <= c; k++)
        if((i*500 + j*100 + k*50) == x){
        ++cnt}
    }  
  }
  
  console.log(cnt)
});

Measured memory_bytes: 7628