akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

typedef long long lli;

const int DIGITS = 1000;
const int BASE = 100000;
const int BD = 5;

class BigNum{
  lli val[DIGITS], tmp[DIGITS];
  int dig;
public:
  BigNum(){
    dig = 1;
    memset(val, 0, sizeof(val));
  }
  BigNum(lli x){
    dig = 0;
    for(int i=0;i<DIGITS;++i){
      if(x == 0) val[i] = 0;
      else{
        ++dig;
        val[i] = x % BASE;
        x /= BASE;
      }
    }
  }

  void operator + (const lli x){
    val[0] += x;
    for(int i=0;i<DIGITS;++i){
      val[i+1] += val[i] / BASE;
      val[i] %= BASE;
      if(val[i]) dig = i + 1;
    }
  }

  void operator * (const lli x){
    for(int i=0;i<DIGITS;++i) val[i] *= x;
    for(int i=0;i<DIGITS;++i){
      val[i+1] += val[i] / BASE;
      val[i] %= BASE;
      if(val[i]) dig = i + 1;
    }
  }

  string toString(){
    string res;
    for(int i=0;i<dig;++i){
      for(int j=0;j<BD;++j){
        res.push_back(val[i]%10 + '0');
        val[i] /= 10;
      }
    }
    int size;
    for(size=res.size();size>1&&res[size-1]=='0';--size);
    res = res.substr(0, size);
    reverse(res.begin(), res.end());
    return res;
  }
};

main(){
  int n;
  cin >> n;
  BigNum x = BigNum(1);
  for(int i=2;i<=n+1;++i) x * i;
  x + 2;
  cout << x.toString() << endl;
  for(int i=0;i<n;i++) cout << i+2 << endl;
}

Measured memory_bytes: 1244
n,k=[int(x) for x in input().split()]
p=[int(x)-1 for x in input().split()]
c=[int(x) for x in input().split()]

ans=max(c)
if ans<0:
    print(ans)
    exit()

for i in range(n):
    #最後に自分という順番
    nxt=i
    lp=[]
    while 1:
        nxt=p[nxt]
        lp.append(nxt)
        if nxt==i:
            break
    lpc=max(0,sum(c[x] for x in lp))
    nxt=i
    lpl=len(lp)
    wks=0
    #ループ内の最大値を見る
    for j in range(lpl):
        nxt=p[nxt]
        wks+=c[nxt]
        #ループ内の距離をkから引いた数でループ長を割ることによって
        #剰余部分を加算するパータンと、剰余に突入する1つ前のループの途中でやめた
        #パターンの両方を確認できる
        #ループが負になる場合も考えて,この部分のみ加算するパターンも考える
        #このループはkを超えないので安全
        ans=max(ans,(k-j-1)//lpl*lpc+wks,wks)
        #ループの長さがkを超える場合打ち切る
        if j==k-1:
            break
print(ans)


Measured memory_bytes: 81860
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll X;cin>>X;
    
	// 解法
	ll money = 100;
	ll ans = 0;
	while (money<X){
		ans++;
		money += money/100;
	}
	
	//出力
	printf("%lld\n", ans);
}


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

int main () {
  string s,t,u;
  cin >> s >> t >> u;
  char dif='A'-'a';

  char xs,xt,xu;
  xs=s[0]+dif;
  xt=t[0]+dif;
  xu=u[0]+dif;

  cout << xs << xt << xu << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    map<int, int> m;
    string ans = "YES";
    rep(i,n) {
        int a; cin >> a;
        m[a]++;
        if (m[a] > 1) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for(int r=0; r<=N/R; r++){
        for(int g=0; g<=N/G; g++){
            int cnt = N - (R*r + G*g);
            if(cnt>=0 && cnt%B==0) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (i * (M - j) + j * (N - i) == K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val result = Array.fill(4,3,10)(0)
  
  val n = StdIn.readLine().toInt
  (0 until n).foreach{ i =>
    val Array(b, f, r, v) = StdIn.readLine().split(' ').map(_.toInt)
    result(b-1)(f-1)(r-1) += v
  }

  private final val border = "#"*20
  
  print(
    result.map { b =>
      b.map { r =>
        " " + r.mkString(" ") + f"%n"
      }.mkString("")
    }.mkString(border + f"%n")
  )
}


Measured memory_bytes: 44604
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  long long int a,b,c;
  cin >> a >> b >> c;
  
  long long int ans = 0;
  
  if(c <= b + a){
    ans += b+c;
    cout << ans << endl;
    return 0;
  } else {
    ans += 2*b + a + 1;
        cout << ans << endl;
    return 0;
  }

  return 0;
}

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

void solve_A(){
	int a,b;
	cin >> a >> b;
	if(a>=10||b>=10) cout << "-1" << endl;
	else cout << a*b << endl;
}

void solve_B(){
	bool s[105]={0};
	int n,i,j;
	cin >> n;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			s[i*j]=true;
		}
	}
	if(s[n]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void solve_C(){
	long long n,i,m=0;
	cin >> n;
	for(i=1;i*i<=n;i++){
		if(n%i==0) m=i;
	}
	cout << m+n/m-2 << endl;
}

void solve_D(){
	double a,b,x,ans;
	cin >> a >> b >> x;
	x /= a;
	if(x>=a*b/2){
		x -= a*b/2.0;
		x = 2.0*x/a;
		x = b-x;
		ans =atan(x/a);
	} else {
		x = 2.0*x/b;
		ans = atan(b/x);
	}
	ans = ans*180.0/3.1415926535897;
	printf("%.13lf\n",ans);
}


int main() {
	// your code goes here
	//solve_A();
	//solve_B();
	//solve_C();
	solve_D();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N;

void solve() {
	cin >> N;
	ll a = 0, n = 1;
	while(n * 2 <= N + 1) {
		a++; n *= 2;
	}
	vector<int> ans;
	ll cn = N + 1 - n;
	rep(i, 0, a) {
		if(cn & (1LL << i)) {
			cn -= (1LL << i);
			ans.pb(99 - i);
		}
		ans.pb(i);
	}
	rep(i, 0, 100) ans.pb(i);
	cout << sz(ans) << "\n";
	rep(i, 0, sz(ans)) {
		cout << ans[i] + 1 << " ";
	}
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

using namespace std;

int main(){
  int n, tp = 0, hp = 0;
  cin >> n;
  while (n) {
    n--;
    string ts, hs;
    cin >> ts >> hs;
    if (ts == hs) tp++, hp++;
    else if (ts > hs) tp += 3;
    else hp += 3;
  }
  cout << tp << " " << hp << endl;
  return 0;
}

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

ll solve() {
  int N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  int cnt = 0;
  bool z = false;
  rep(i, 0, N) {
    if(A[i] == 0) z = true;
    if(A[i] < 0) {
      cnt++;
      A[i] = -A[i];
    }
  }
  ll tot = accumulate(A.begin(), A.end(), 0LL);
  ll mn = *min_element(A.begin(), A.end());
  if(z || cnt % 2 == 0) return tot;
  else return tot - 2 * mn;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <list>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)

int color[100000];
//vector<edge> G[100000];

struct edge
{
public:
    int to, cost;
};
vector<edge> G[100000];

bool dfs(int v, int prev, int c)
{
    color[v] = c;

    for (int i = 0; i < G[v].size(); i++)
    {
        if (G[v][i].to == prev)
            continue;
        dfs(G[v][i].to, v, (c + G[v][i].cost) % 2);
    }
    return true;
}

int main(void)
{
    int n;
    cin >> n;
    REP(i, n - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        edge e;
        e.cost = w;
        e.to = v;
        G[u].push_back(e);
        edge e2;
        e2.cost = w;
        e2.to = u;
        G[v].push_back(e2);
    }

    REP(i, n)
    {
        color[i] = -1;
    }

    for (int i = 0; i < n; i++)
    {
        if (color[i] == -1)
        {
            dfs(i, -1, 0);
        }
    }
    REP(i, n)
    {
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 9088
#include <cstdio>
#include <algorithm>

int main()
{
  long long n, k;
  scanf("%lld %lld", &n, &k);
  long long ans = 0;
  if (k == 0)
  {
    printf("%lld\n", n * n);
    return 0;
  }
  for (long long b = k + 1; b <= n; ++b)
  {
    ans += (b - k) * (n / b) + std::max(0LL, (n % b) - k + 1);
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

string temp = "ULDR";
const int vy[] = {-1, 0, 1, 0}, vx[] = {0, -1, 0, 1};

int H, W;
string S[10];

bool isin(int x, int y)
{
  return (0 <= x && x < W && 0 <= y && y < H);
}

string rec(int bit, int x, int y, int curr)
{
  string ret = "";
  for(int i = -1; i <= 1; i++) {
    int dd = (curr + i + 4) % 4;
    int ny = y + vy[dd], nx = x + vx[dd];
    while(isin(nx, ny) && (S[ny][nx] > 30 || (bit >> S[ny][nx]) & 1)) ny += vy[dd], nx += vx[dd];
    if(!isin(nx, ny)) continue;
    string res = string(1, temp[dd]) + rec(bit | (1 << S[ny][nx]), nx, ny, dd);
    if(res.size() > ret.size()) ret = res;
  }
  return (ret);
}

int main()
{


  vector< int > g[30];
  int sx, sy, idx = 0;

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
    for(int j = 0; j < W; j++) {
      if(S[i][j] == 'o') S[i][j] = idx++;
      else if(S[i][j] != '.') sx = j, sy = i;
    }
  }
  cout << rec(0, sx, sy, temp.find(S[sy][sx])) << endl;
}

Measured memory_bytes: 3152
int main(void){
	int w[9<<14]={};
	int k;
	int max=0;
    int i=0;
	scanf("%d",&k);
	for(;~scanf("%d",&k);)w[k]++;
	for(;++i<1e5;){
		if(w[i-1]+w[i]+w[i+1]>max){
			max=w[i-1]+w[i]+w[i+1];
		}
	}
	printf("%d",max);
}

Measured memory_bytes: 2256
#include <iostream>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int m=0;
  int ans=0;
  for( int i=0;i<N;i++ )
    {
      int h;
      cin >> h;
      if( h>=m )
	{
	  ans++;
	  m = h;
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;

void input() {
  cin >> N >> M;
  ;
}
void solve() {
  //(N+X)/2 = M
  cout << -N + 2 * M << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
//Twitter@KonoLv1 2020年春卒で現在就職活動中！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count1,count2,count;   //  カウント用に使用
    int box[256] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    int a,b,c;
    a = b = c = i = 0;
    int mode = 0;
    count = count1 = count2 = 0;
 
    //  入力処理
    
    scanf("%d",&a);
    scanf("%s",s);

 
    //  計算処理
    
    if (a >= 3200){
        printf("%s",s);
    }else{
        printf("red");
    }
  
    //  出力処理
 

 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int s=0;
	int arr[101];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n,greater<int>());
	for(int i=0;i<n;i++){
		if(i%2==0)s+=arr[i];
		if(i%2==1)s-=arr[i];
	}
	cout<<s<<endl;
	return 0
	;
}


Measured memory_bytes: 256
open System
open System.Collections.Generic
open System.Linq
open System

// Following contents are my library. The Main processes are on the bottom of this code.

let puts = Console.WriteLine : 'a -> unit
let put = Console.Write : 'a -> unit
let Read() = Console.ReadLine()
let Reads () = Console.ReadLine().Split()
let ReadInt () = Read() |> int
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])
let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ReadIntQuadruple () = ReadQuadruple() |> FuncQuadruple int int int int
let ReadIntTriple () = ReadTriple () |> FuncTriple int int int
let ReadIntDouble () = ReadDouble () |> FuncDouble int int
let ensmallen l = l % 1000000007L
let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)
let sayYESNO b = if b then puts "YES" else puts "NO"


// The main contents of this submission are below this line.

let n, k = (ReadInt(), ReadInt())
Reads() |> Seq.map int
    |> Seq.sumBy (fun i -> min i (k - i))
    |> ((*)2)
    |> puts


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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int N;
vector<int> v;
string str;
bool flag=true;

void check(){
	for(int i=2; i<N; i++){
		if(str[i-1]=='o' && v[i-1]==0) v[i]=v[i-2];
		else if(str[i-1]=='o' && v[i-1]==1) v[i]=1-v[i-2];
		else if(str[i-1]=='x' && v[i-1]==0) v[i]=1-v[i-2];
		else if(str[i-1]=='x' && v[i-1]==1) v[i]=v[i-2];
	}
	if(str[0]=='o' && v[0]==0){
		if(!(v[1]==v[N-1])){
			flag=false;
		}
	}
	if(str[0]=='o' && v[0]==1){
		if(!(v[1]!=v[N-1])){
			flag=false;
		}
	}
	if(str[0]=='x' && v[0]==0){
		if(!(v[1]!=v[N-1])){
			flag=false;
		}
	}
	if(str[0]=='x' && v[0]==1){
		if(!(v[1]==v[N-1])){
			flag=false;
		}
	}

	if(str[N-1]=='o' && v[N-1]==0){
		if(!(v[0]==v[N-2])){
			flag=false;
		}
	}
	if(str[N-1]=='o' && v[N-1]==1){
		if(!(v[0]!=v[N-2])){
			flag=false;
		}
	}
	if(str[N-1]=='x' && v[N-1]==0){
		if(!(v[0]!=v[N-2])){
			flag=false;
		}
	}
	if(str[N-1]=='x' && v[N-1]==1){
		if(!(v[0]==v[N-2])){
			flag=false;
		}
	}
	if(flag){
		for(int i=0; i<N; i++){
			if(v[i]==0){
				cout<<'S';
			}else{
				cout<<'W';
			}
		}
		cout<<endl;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	cin>>N;
	v.resize(N);
	cin>>str;

	v[0]=0;
	v[1]=0;
	flag=true;
	check();
	if(flag){
		return 0;
	}
	
	v[0]=0;
	v[1]=1;
	flag=true;
	check();
	if(flag){
		return 0;
	}

	v[0]=1;
	v[1]=0;
	flag=true;
	check();
	if(flag){
		return 0;
	}

	v[0]=1;
	v[1]=1;
	flag=true;
	check();

	if(!flag){
		cout<<-1<<endl;
	}

	return 0;
}


Measured memory_bytes: 976
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << endl;
	return 0;
}


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

std::queue<long long int> co;
std::queue<long long int> co2;

bool flag = false;
int main(void){
    int k;
    int cnt = 9;
    std::cin >> k;
    for(int i = 1; i < 10; i++){
        //std::cout << i << std::endl;
        co.push(i);
    }
    
    int keta = 10;
    long long int ans;
    if(k < 10){
        for(int i = 0; i < k-1; i++){
            co.pop();
        }
        ans = co.front();
    }else{
        while(true){
            while(!co.empty()){
                long long int tmp = co.front();
                co.pop();
                for(int i = 0; i < 10; i++){

                    if((tmp % 10) - i <= 1 && (tmp % 10) - i >= -1){
                        ans = tmp * 10 + i;
                        co2.push(ans);
                        cnt++;
                        if(cnt == k){
                            flag = true;
                            break;
                        }
                    }
                }
                if(flag){
                    break;
                }  
            }
            if(flag){
                    break;
            }
            co = co2;

            while (!co2.empty()){
                co2.pop();
            }
            

            //std::queue<long long int> empty;
            //std::swap(co2, empty);
            keta = keta * 10;
        }
        
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1024
n, c, k = gets.split.map(&:to_i)
t = n.times.map{gets.to_i}.sort
r = 0
until t.empty?
  a = t.first
  i = t.bsearch_index{|b| b > a + k}
  i = t.size if i == nil
  j = [c, i].min
  r += 1
  t.shift(j)
end
p r

Measured memory_bytes: 4656
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

n, m = map(int, readline().split())
a = np.array(read().split(), np.int64)
a.sort()


def check(mid):
    mid = np.searchsorted(a, mid - a)
    return n * n - mid.sum() >= m


left = 0
right = 10 ** 6
while left + 1 < right:
    mid = (left + right) // 2
    if check(mid):
        left = mid
    else:
        right = mid

mid = np.searchsorted(a, right - a)
cumsum = np.zeros(n + 1, np.int64)
cumsum[1:] = np.cumsum(a)
ans = (cumsum[-1] - cumsum[mid]).sum() + (a * (n - mid)).sum() + (m - n * n + mid.sum()) * left
print(ans)


Measured memory_bytes: 18224
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------
vector<int> arr(1000007,1);
void Eratosthenes(){
  arr[0] = 0;
  arr[1] = 0;
  for(int i=2; i*i<=10000007; i++){
    if(arr[i]){
      for(int j=2; i*j<=1000007; j++){
        arr[i*j] = 0;
      }
    }
  }
}


int main(){
  int X;
  cin >> X;
  Eratosthenes();
  while(1){
    if(arr[X]){
      cout << X << endl;
      return 0;
    }
    X++;
  }
  return 0;
}


Measured memory_bytes: 4096
n = int(input())
a = list(map(int, input().split()))
if sum(a) % (n * (n + 1) // 2) != 0:
	print("NO")
else:
	k = sum(a) // (n * (n + 1) // 2)
	ok = True
	for i in range(n - 1):
		if (a[i] + k) % n != a[i + 1] % n or a[i] + k < a[i + 1]:
			ok = False
			break
	if (a[-1] + k) % n != a[0] % n or a[-1] + k < a[0]:
		ok = False

	if ok:
		print("YES")
	else:
		print("NO")

Measured memory_bytes: 14588
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> ruisekiwa(N+1);
    ruisekiwa[0] = 0;
    int ans = 0;
    ll mini = 303030303030;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        ruisekiwa[i + 1] = ruisekiwa[i] + A[i];
    }
    for (int i = 0; i < N;i++)
    {
        mini = min(mini,abs(ruisekiwa[N] - ruisekiwa[i] * 2));
    }
    cout << mini << endl;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<char> ans(0);
    int i = 0;
    while(i < N){
        char tmp = S[i];
        int t = 1;
        while (i + t < N && tmp == S[i + t])
            t++;
        ans.push_back(S[i]);
        i += t;
    }
    int A = ans.size();
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MAXN = 2005

dp0 = [[-1] * MAXN for _ in range(MAXN)]
dp1 = [[-1] * MAXN for _ in range(MAXN)]

def dfs(i,j,p,z,w,a,n):
    if p == 0:
        if dp0[i][j] != -1:
            return dp0[i][j]
        if i == n:
            if j == 0:
                return abs(w - a[-1])
            return abs(a[j -1] - a[-1])
        ans = 0
        for k in range(i,n):
            ans = max(ans,dfs(k + 1,k,1,z,w,a,n))
        if i == 1:
            ans = max(ans,abs(a[-1] - w))
        else:
            ans = max(ans,abs(a[-1]- a[i - 1]))
        dp0[i][j] = ans
        return ans
    elif p == 1:
        if dp1[i][j] != -1:
            return dp1[i][j]
        if i == n:
            if j == 0:
                return abs(z - a[-1])
            return abs(a[j - 1] - a[-1])
        ans = INF
        for k in range(i,n):
            ans = min(ans,dfs(k + 1,k,0,z,w,a,n))
        if i == 1:
            ans = min(ans,abs(a[-1] - z))
        else:
            ans = min(ans,abs(a[-1] - a[i - 1]))
        dp1[i][j] = ans
        return ans

def main():
    n,z,w = map(int,input().split())
    a = list(map(int,input().split()))

    ans = dfs(1,0,0,z,w,a,n)
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 110556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  set<int> st;
  rep(i,K){
    int x;cin >> x;
    st.insert(x);
  }
  repp(x,N,10*N){
    int x_ = x;
    bool issat = true;
    while(x_!=0 && issat){
      if(st.count(x_%10)) issat = false;
      x_/=10;
    }
    if(issat){
      cout << x << endl;
      break;
    }
  }
  return 0;
}


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

int main(){
  string s;
  cin>>s;
  string ans(s.size(),'x');
  cout<<ans<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
struct testimony{
  int x,y;
  testimony(int x,int y):x(x),y(y){};
};

vector<vector<testimony>> TA;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;
  TA.assign(N,vector<testimony>());
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A.push_back(a);
    for (int j = 0; j < a; j++)
    {
      int x,y;
      cin >> x >> y;
      x--;
      TA[i].emplace_back(x,y);
    }
  }
}

int solve(){
  int ans = 0;
  for (ll bit = 0; bit < (1<<N); bit++)
  {
    bool isOK=true;
    for (int i = 0; i < N; i++)
    {
      if(bit>>i&1) {
        for(auto t:TA[i]){
          if(((bit>>t.x)&1)!=t.y) {isOK=false; continue;}
        }
      }
    }
    if(isOK) ans = max(ans,__builtin_popcount(bit));
  }
  cout << ans << endl;
  
  return 0;
}

int main()
{
  input();
  solve();
  // test();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){

  char *S;
  int A[30];
  int i;

  for(i = 0; i < 26; i++){
    A[i] = 0;
  }

  int len = 0;

  S = (char*)malloc(10000);

  scanf("%[^\t]", S);

  while(S[len]){
    len++;
  }

  for(i = 0; i < len; i++){
    if('A' <= S[i] && S[i] <= 'Z'){
      S[i] += 'a' - 'A';
    }
  }

  for(i = 0; i < len; i++){
    A[S[i] - 'a']++;
  }

  printf("a : %d\n", A[0]);
  printf("b : %d\n", A[1]);
  printf("c : %d\n", A[2]);
  printf("d : %d\n", A[3]);
  printf("e : %d\n", A[4]);
  printf("f : %d\n", A[5]);
  printf("g : %d\n", A[6]);
  printf("h : %d\n", A[7]);
  printf("i : %d\n", A[8]);
  printf("j : %d\n", A[9]);
  printf("k : %d\n", A[10]);
  printf("l : %d\n", A[11]);
  printf("m : %d\n", A[12]);
  printf("n : %d\n", A[13]);
  printf("o : %d\n", A[14]);
  printf("p : %d\n", A[15]);
  printf("q : %d\n", A[16]);
  printf("r : %d\n", A[17]);
  printf("s : %d\n", A[18]);
  printf("t : %d\n", A[19]);
  printf("u : %d\n", A[20]);
  printf("v : %d\n", A[21]);
  printf("w : %d\n", A[22]);
  printf("x : %d\n", A[23]);
  printf("y : %d\n", A[24]);
  printf("z : %d\n", A[25]);

  free(S);
  
  return 0;
}


Measured memory_bytes: 2140
/*

author: @PearlYadav        

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

#define ibs ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb pushback
#define f(i,k,n) for(int i=k;i<n;i++)
#define fe(i,k,n) for(int i=k;i<=n;i++)
#define ll unsigned long long int

int main(){
    ibs
    int ans=0;
    char s[6];
    for (int i = 0; i < 6; ++i)
        cin>>s[i];
    if (s[0]==s[3])
        ans++;
    if (s[1]==s[4])
        ans++;
    if (s[2]==s[5])
        ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int a,x=1,n;
int main(void)
{
    int i;
	scanf("%d",&n);
	for(i=1;i<n;i++){
	    a=i*i;
		if(n>=a) x=a;
		else if(n<a) break;
	}
	printf("%d\n",x);
	return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch( int key ) {
	Node *cur = nil->next;
	while( cur != nil && cur->key != key ) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node*)malloc( sizeof( Node ) );
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while( 1 ) {
		if( cur == nil ) break;
		if( isf++ > 0 ) printf( " " );
		printf( "%d", cur->key );
		cur = cur->next;
	}
	puts( "" );
}

void deleteNode( Node *t ) {
	if( t == nil ) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free( t );
}

void deleteFirst() {
	deleteNode( nil->next );
}

void deleteLast() {
	deleteNode( nil->prev );
}

void deleteKey( int key ) {
	deleteNode( listSearch( key ) );
}

void insert( int key ) {
	Node *x = (Node*)malloc( sizeof( Node ) );
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main( void ) {
	int key, n;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf( "%d", &n );
	init();
	REP( i, n ) {
		scanf( "%s%d", com, &key );
		if( com[0] == 'i' ) { insert( key ); np++; size++; } else if( com[0] == 'd' ) {
			if( strlen( com ) > 6 ) {
				if( com[6] == 'F' ) deleteFirst();
				else if( com[6] == 'L' ) deleteLast();
			} else {
				deleteKey( key ); nd++;
			}
			size--;
		}
	}

	printList();
}


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

int main()
{
    ll  t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;

    ll y1 = (a1-b1)*t1;
    ll y2 = (a2-b2)*t2;

    if (y1 > 0)
    {
        y1 *= -1LL;
        y2 *= -1LL;
    }

    if (y1 +y2 < 0) 
    {
        cout << 0 << endl;
        return 0;
    }
    // cout << "**" << endl;
    if (y1 + y2 == 0)
    {
        cout << "infinity" << endl;
        return 0;
    }
    ll d = y1+y2;
    ll cnt = llabs(y1/d)*2LL + 1LL;
    // cout << "******" << endl;
    // cout << y1 << " " << d << endl;
    if (y1%d == 0) --cnt;
    cout << cnt << endl;


    return 0;
}

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

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	int count = 0;
	for (int i = 0;i < S.length();i++) {
		if (S[i] != T[i]) {
			count++;
		}
	}
	if(count == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

#define pi 3.1415926535898
long long arr[200000+10] = {0};

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

    for(int i = 1; i < n; i++)
    {
        cin >> m;
        arr[m]++;
    }

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

    return 0;
}


Measured memory_bytes: 5096
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var count = n
    for (i in 0..n) {
        var cc = 0
        var t = i
        while (t > 0) {
            cc += t % 6
            t /= 6
        }
        t = n - i
        while (t > 0) {
            cc += t % 9
            t /= 9
        }
        if (count > cc) count = cc
    }
    println(count)
}



Measured memory_bytes: 31692
#include <bits/stdc++.h>
using namespace std;
long fun(long n,long x){
  return (n==-1? 0:n/x+1);
} 

int main() {
  long a,b,x;cin>>a>>b>>x;
  cout<<fun(b,x)-fun(a-1,x)<<endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines().foreach(rec)
  }

  def rec(s: String): Unit = {
    if (!s.matches(""".*(the|that|this).*""")) {
      rec(s.map({
        case c if 'a' to 'z' contains c => (((c - 'a' + 1) % 26) + 'a').toChar
        case c => c
      }))
    } else println(s)
  }
}

Measured memory_bytes: 47032
let n = stdin.ReadLine() |> int64

// 素因数分解した後の各要素を1+2+..となるようにmapしてやれば答え

/// xの素因数分解
let pf (x:int64) :int64[]=

    if x = 1L then Array.empty
    else
    let unfolder (dived, div) =
        if div > dived then
            None
        elif div * div > dived then
            Some(Some(dived), (dived, dived + 1L))
        elif dived % div = 0L then
            Some(Some(div), (dived / div, div))
        else 
            Some(None, (dived, div + 1L))
    Array.unfold unfolder (x,2L)
    |> Array.choose id

/// param x return m when x>=1+2+..+m
let stepCount x =
    let mutable i = 1
    let mutable acc = 0
    while x >= acc do 
        acc <- acc + i
        i <- i + 1
    i - 2 


pf n |> Array.countBy id |> Array.map snd |> Array.map stepCount|> Array.sum |> stdout.WriteLine

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

int main() {
    int n;cin>>n;
    int L[n],a,b,c,ans=0;
    
    for(int i=0;i<n;++i){
        cin>>L[i];
    }
//    sort(L,L+n,greater<int>());
      sort(L,L+n);
    
    for(int i=0;i<n;++i){
            a = L[i];

        for(int j=i+1;j<n;++j){
            b = L[j];

            for(int k=j+1;k<n;++k){
            c = L[k];
            if(a+b>c && b+c>a && c+a>b)ans+=1;
            else break;
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int a,b,c;
    cin >> a >> b >> c;
    int d = a+b+c;
    if(d%2 != 0) {
        Yes(0);
        return 0;
    }
    d /= 2;
    Yes(d == a || d == b || d == c);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> data;

    UnionFind(int n) {
        data.resize(n);
        rep(i, n) data[i] = -1;
    }

    int root(int x) {
        if (data[x] < 0) return x;
        return data[x] = root(data[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -data[root(x)];
    }
};

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

    UnionFind uf(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    rep(i, n) {
        if (uf.root(i) != i) continue;
        chmax(ans, uf.size(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3960
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  return A <= 8 && B <= 8 ? "Yay!" : ":(";
};

console.log(main(read()));


Measured memory_bytes: 29604
n,k=map(int,input().split())
a = list(map(int,input().split()))
visit = []
visit = [0]*n
pos=0
move=[]
roop=[]
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos]+=1
    pos = a[pos]-1
if len(move)>k:
    print(move[k]+1)
else:
    mod = (k-(len(move)-len(roop)))%len(roop)
    print(roop[mod]+1)

Measured memory_bytes: 32744
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    char suit;
    while(cin >> suit, suit != '#'){
        vector<vector<pair<int ,char>>> v(4);
        char inp[2];
        rep(i,4){
            rep(j,13){
                cin >> inp;
                if(inp[0] == 'K') v[i].emplace_back(make_pair(13, inp[1]));
                else if(inp[0] == 'Q') v[i].emplace_back(make_pair(12, inp[1]));
                else if(inp[0] == 'J') v[i].emplace_back(make_pair(11, inp[1]));
                else if(inp[0] == 'T') v[i].emplace_back(make_pair(10, inp[1]));
                else v[i].emplace_back(make_pair(inp[0] - '0', inp[1]));
            }
        }

        char base = v[0][0].second;
        int score[2] = {0};
        rep(i,13){
            int maxi = -1;
            int player;
            rep(j,4){
                if(v[j][i].second == suit && v[j][i].first > maxi){
                    maxi = v[j][i].first;
                    player = j;
                }
            }
            if(maxi == -1){
                rep(j,4){
                    if(v[j][i].second == base && v[j][i].first > maxi){
                        maxi = v[j][i].first;
                        player = j;
                    }
                }
            }
            score[player % 2]++;
            base = v[player][i + 1].second;
        }
        if(score[0] > score[1]){
            cout << "NS " << score[0] - 6 << endl;
        }else{
            cout << "EW " << score[1] - 6 << endl;
        }
    }
}

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

int main() {
  int a, b;	cin >> a >> b;
  rep(i,100*100)
    if (a==i*8/100 && b==i/10) {
      cout << i << endl;
      return 0;
    }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    while(true) {
        bool ex = false;
        rep(i,n) {
            if(h[i] > 0) {
                ex = true;
                h[i]--;
            } else {
                if(ex) break;
            }
        }
        if(!ex) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
  	int ANS = 0;
  	int[] A = new int[N];
    int[] B = new int[N-1];
	for (int k=0;k<N-1;k++){
      B[k] = sc.nextInt();
    }
  	
  	A[0] = B[0];
  	A[N-1] = B[N-2];
  	for(int i=1;i<N-1;i++){
      	if(B[i]<B[i-1]){
          	A[i] = B[i];
        }else{
          	A[i] = B[i-1];
        }
    }
  	//System.out.println("A = " + Arrays.toString(A));     
  
  	for(int j=0;j<N;j++){
      ANS += A[j];
    }
  		System.out.println(ANS);

	}
}

Measured memory_bytes: 23764
import math
A, B, H, M = map(int, input().split())
m = 60 * H + M
h_rad = m / 360
m_rad = M / 30
dif = 1 - abs(abs(h_rad - m_rad) - 1)
C = math.sqrt(A * A + B * B - 2 * A * B * math.cos(dif * math.pi))
print(C)

Measured memory_bytes: 9560