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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

//! n?????§?\???°???o???????????¨??????p?????§?????????
int win[1010][1010][2];
int solve(int n, int o, int p){
  int& res = win[n][o][p];
  if(res) return res;

  if(n == 2){
	if(p)
	  res = (o==2? 1: -1);
	else
	  res = (o==0? 1: -1);
	return res;
  }

  // e, o
  if(n > o && o >= 1){
	if(solve(n-1, o, p^1) < 0)
	  return res = 1;
  }
  // o, o
  if(o >= 2){
	if(solve(n-1, o-2, p^1) < 0)
	  return res = 1;
  }
  // e, e
  if(n-o >= 2){
	if(solve(n-1, o, p^1) < 0)
	  return res = 1;
  }

  return res = -1;
}

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

  int V;
  cin >> V;
  int E = 0;
  VVI G(V);
  REP(i,V){
	string s;
	cin >> s;
	REP(j,V){
	  if(s[j] == 'Y'){
		++E;
		G[i].PB(j);
	  }
	}
  }
  E /= 2;

  if(V%2 == 1){
	cout << ((V*(V-1)/2 - E)%2==0? "Hanako": "Taro") << endl;
  }
  else{
	vector<bool> vis(V);
	function<int(int)> dfs = [&](int u){
	  int res = 1;
	  vis[u] = true;
	  for(int to: G[u]){
		if(vis[to]) continue;
		res += dfs(to);
	  }
	  return res;
	};

	int n = 0, o = 0;
	REP(i,V)
	  if(!vis[i]){
		++n;
		if(dfs(i)%2)
		  ++o;
	  }

	int p = (V * (V-1) / 2 - E) % 2;
	//cout << n << ","<<o<<","<<p<<endl;
	cout << (solve(n, o, 1^p)>0? "Taro": "Hanako") << endl;
  }

  return 0;
}

Measured memory_bytes: 7444
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        long[] nk = longa();
        long n = nk[0], k = nk[1];
        long d = n / k;
        long ans = n - d * k;
        if (ans > k - ans) ans = k - ans;
        Write(ans);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27504
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char A[230];
char B[230];
int main(){
	scanf("%s%s",A,B);
	if(strlen(A)!=strlen(B)){
		if(strlen(A)>strlen(B))printf("GREATER\n");
		else printf("LESS\n");
		return 0;
	}
	for(int i=0;A[i];i++){
		if(A[i]!=B[i]){
			if(A[i]>B[i])printf("GREATER\n");
			else printf("LESS\n");return 0;
		}
	}
	printf("EQUAL\n");
}

Measured memory_bytes: 128
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (k+1) #残りの石iで回ってきたときの勝敗
for i in range(k+1):
    dp[i] = 0
    for j in a:
        if j > i:
            break
        if 1 - dp[i-j]:
            dp[i] = 1
            break
print(['Second', 'First'][dp[k]])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<int,int>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














const int N=105;
int n,k;
int a[N];
int main()
{
     cin>>n>>k;
     for(int i=0;i<n;i++)cin>>a[i];
     bool dp[k+1];memset(dp,0,sizeof(dp));
     dp[0]=0;
     for(int i=1;i<=k;i++)
     {
          for(int j=0;j<n;j++)
          {
               if(i>=a[j]&&!dp[i])
               {
                    dp[i]=!dp[i-a[j]];
               }
               else if(i<a[j]&&!dp[i])dp[i]=0;
          }
     }
     if(dp[k])cout<<"First";
     else cout<<"Second";
}























 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, a, b; cin >> n >> a >> b;
  int m = __builtin_popcount(a ^ b);
  if (m & 1) cout << "YES" << '\n';
  else return cout << "NO" << '\n', 0;
  auto f = [](int m) -> V<> {
    V<> a;
    for (int bit = 0; bit < 1 << m; ++bit) {
      a.push_back(bit ^ bit >> 1);
    }
    for (int bit = 0; bit < 1 << m; ++bit) {
      for (int i = 2; i < m; i += 2) if (bit + (1 << i) >= 1 << m) {
        int x = a[bit] & 1 << i - 2;
        int y = a[bit] & 1 << i - 1;
        a[bit] -= x + y;
        a[bit] += x << 1;
        a[bit] += y >> 1;
        a[bit] ^= (1 << i) - (1 << i - 2);
      }
    }
    return a;
  };
  V<> res;
  bool tg = true;
  if (n - m) for (int e : f(m)) {
    if (tg) {
      for (int bit = 0; bit < 1 << n - m; ++bit) {
        int x = bit ^ bit >> 1;
        res.push_back(e | x << m);
      }
    } else {
      for (int bit = (1 << n - m) - 1; bit >= 0; --bit) {
        int x = bit ^ bit >> 1;
        res.push_back(e | x << m);
      }
    }
    tg ^= true;
  } else res = f(m);
  V<> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return ((a ^ b) & 1 << i) > ((a ^ b) & 1 << j); });
  for (int i = 0; i < 1 << n; ++i) {
    int x = res[i];
    res[i] = 0;
    for (int j = 0; j < n; ++j) if (x & 1 << j) {
      res[i] |= 1 << idx[j];
    }
    if (i) assert(__builtin_popcount(res[i] ^ res[i - 1]) == 1);
    // cout << bitset<5>(res[i]) << '\n';
    cout << (a ^ res[i]) << " \n"[i == (1 << n) - 1];
  }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

const lint M = 1000000007;

vector<lint> fac(300001); //n!(mod M)
vector<lint> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

lint mpow(lint x, lint n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    lint ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

lint comb(lint a, lint b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    lint tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

bool is_overK(int *a, int c, int k){
  rep(i, c+1){
    if (a[i] > k){
      return true;
    }
  }
  return false;
}
int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<vector<char>> chocolate(h, vector<char>(w));
  rep(i, h){
    rep(j, w){
      cin >> chocolate[i][j];
    }
  }

  int ans = 1000000000;
  rep(i, 1 << (h-1)){

    int cnt = 0;
    map<int, int> group;
    rep(j, h){
      group[j] = cnt;
      if (i & (1 << j)) cnt++;
    }
    int d[cnt+1][w];
    rep(j, cnt+1){
      rep(l, w){
        d[j][l] = 0;
      }
    }
    rep(j, h){
      rep(l, w){
        d[group[j]][l] += (int)(chocolate[j][l] - '0');
      }
    }

    int check[cnt+1];
    rep(j, cnt+1) check[j] = 0;
    bool flg = false;
    int b = 0;

    rep(j, w){
      if (is_overK(check, cnt, k)){
        flg = true;
        break;
      }
      rep(l, cnt+1){
        check[l] += d[l][j];
      }
      if (is_overK(check, cnt, k)){
        b++;
        rep(l, cnt+1){
          check[l] = d[l][j];
        }
      }
    }
    if (flg) continue;
    ans = min(ans, b + cnt);
  }
  cout << ans << endl;
}




Measured memory_bytes: 4992
def main():
    n, x = map(int, input().split())
    inlis = list(map(int, input().split()))
    ans = 1
    tmp = 0

    for i in range(n):
        tmp += inlis[i]
        if tmp <= x:
            ans += 1
        else:
            break
    print(ans)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll,ll>pl;


int main(){
	ios_base::sync_with_stdio(0),cin.tie(NULL);
	string s;
	ll ans=0;
	cin>>s;
	for(auto &x:s)if(x=='?')x='D';
/*	for(int i=0;i<s.length();i++){
		if(s[i]=='P'){
			if(i!=s.length()-1&&s[i+1]!='P')ans++;
		}
		else ans++;
	}*/
	cout<<s;
	return 0;
}

Measured memory_bytes: 3768
N = int(input())
A = list(map(int, input().split()))
A.sort()                  #エラトステネスの篩にかけるためソート
Amax = A[-1]
dp = [1]*(Amax+1)         #Aの最大値までのエラトステネスの篩を作る。
ans = 0
for i in range(len(A)-1):
  p = A[i]
  if dp[p] == 1:          #A[i]がA[j]の倍数でないかをエラトステネスの篩でチェック
    for q in range(Amax//p+1):
      dp[p*q] = 0         #A[i]の倍数をすべて0にする
    if A[i] != A[i+1]: 
      ans += 1            #A[i]が重複していなければカウント
if dp[Amax] == 1:         #重複チェック時にレンジオーバーするためAmaxだけ別で判定 
  ans += 1
print(ans)

Measured memory_bytes: 32240
#include <algorithm>
#include <array>
#include <bitset>
#include <functional>
#include <iostream>
#include <memory>
#include <string>

using namespace std;

pair<int, unique_ptr<int[]>> ReadInts() {
	int n;
	cin >> n;
	unique_ptr<int[]> a(new int[n]);
	for (int i = 0; i < n; i++) {
		cin >> a.get()[i];
	}
	return make_pair(n, move(a));
}

int main() {
	int n;
	unique_ptr<int[]> a;
	tie(n, a) = ReadInts();

	sort(a.get(), a.get() + n, greater<int>());
	int alice = 0;
	int bob = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a.get()[i];
		}
		else {
			bob += a.get()[i];
		}
	}
	cout << (alice - bob) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
vector<int> adj[mxn];
bool vis[mxn];
int n, m;
void dfs(int i){
    vis[i]=true;
    for(auto x: adj[i]){
        if(!vis[x])dfs(x);
    }
}
int main(){
    rishabh();
    cin>>n>>m;
    while(m--){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(!vis[i])
        {
            dfs(i);
            cnt++;
        }
    }
    cout<<cnt-1;
}

Measured memory_bytes: 19084
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		long num = c - a - b;
		//c < a + bならば絶対にNo
		if (num < 0)  { 
			System.out.print("No");
		} else {

			if(num * num > 4 * a * b) {
				System.out.print("Yes");
			} else {
				System.out.print("No");
			}
		}
	}
}

Measured memory_bytes: 23892
n = int(input())
arr = list(map(int, input().split()))
c = []
count = 0
maxi = arr[0]
for i in range(1,n):
	if arr[i]<=maxi:
		count+=1
		maxi = arr[i]
	else:
		maxi = arr[i]
		c.append(count)
		count = 0
		
c.append(count)
print(max(c))

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
ll n;
vector<char>vc;
pair<char,ll>pci[11]={};
bool head[30]={};
ll ans=0;
void dfs(int depth,int bit,ll sum){
  //cout<<depth<<endl;
  if(depth==vc.size()){
    if(sum==0){
      ans++;
      //cout<<ans<<endl;
    }
    return;
  }
  if(head[vc[depth]-'A']){
    for(int i=1;i<10;i++){
      if(!(bit&(1<<i))){
	dfs(depth+1,bit+(1<<i),sum+(pci[depth].S*i));
      }
    }
  }else{
    for(int i=0;i<10;i++){
      if(!(bit&(1<<i))){
	dfs(depth+1,bit+(1<<i),sum+(pci[depth].S*i));
      }
    }
  }
}
int main(){
  while(cin>>n,n){
    ans=0;
    vc.clear();
    for(int i=0;i<11;i++)
      pci[i]=mp(0,0);
    for(int i=0;i<30;i++)
      head[i]=false;
    ll alfa1[30][15]={};
    ll alfa2[30][15]={};
    bool syu[30]={};
    for(int i=0;i<n-1;i++){
      string s;cin>>s;
      if(s.size()!=1)
      head[s[0]-'A']=true;
      for(int j=s.size()-1;j>=0;j--){
	syu[s[j]-'A']=true;
	alfa1[s[j]-'A'][s.size()-j-1]++;
      }
    }
    string s;cin>>s;
    head[s[0]-'A']=true;
    for(int i=s.size()-1;i>=0;i--){
      alfa2[s[i]-'A'][s.size()-i-1]++;
      syu[s[i]-'A']=true;
    }
    ll cnt=0;
    for(int i=0;i<26;i++){
      if(syu[i]){
	//	cout<<(char)(i+'A')<<endl;
	vc.pb((char)(i+'A'));
	pci[cnt]=mp((char)(i+'A'),0);
	ll kake=1;
	for(int j=0;j<10;j++){
	  pci[cnt].S+=alfa1[i][j]*kake;
	  pci[cnt].S-=alfa2[i][j]*kake;
	  kake*=10;
	}
	cnt++;
      }
    }
    //cout<<vc.size()<<endl;
    dfs(0,0,0);
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3012
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node
{
    int key;
    Node *right,*left,*parent;
};

Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL)
    {
        y = x;
        if(z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }

    z->parent = y;
    if(y == NIL)
    {
        root = z;
    }
    else
    {
        if(z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node*u)
{
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);

}

int main()
{
    int n,x,i;
    string com;
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        cin >> com;
        if(com == "insert")
        {
            scanf("%d",&x);
            insert(x);
        }
        else if(com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
    
}


Measured memory_bytes: 26620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll N, M, Q;
vector<vector<ll>> LR(501, vector<ll>(501, 0));
vector<vector<ll>> v(501, vector<ll>(501, 0));

int main(void){
    
    cin >> N >> M >> Q;
    for(int i = 0; i < M; ++i){
        ll a, b; scanf("%d %d", &a, &b);
        ++LR[a][b];
    }
    
    for(int x = 1; x <= N; ++x){
        ll sum = 0;
        for(int y = 1; y <= N; ++y){
            sum += LR[x][y], v[x][y] = sum;
        }
    }
    
    for(int i = 0; i < Q; ++i){
        ll a, b; scanf("%d %d", &a, &b);
        ll sum = 0;
        for(int i = a; i <= b; ++i){
            sum += v[i][b] - v[i][a - 1];
        }
        printf("%d\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,n_1,n_2,n_3,n_4;
  cin >> N;
  n_1 = N / 1000;
  n_2 = (N-n_1*1000) / 100;
  n_3 = (N-n_1*1000-n_2*100) / 10;
  n_4 = N-n_1*1000-n_2*100-n_3*10;
  if( (n_1 == n_2 && n_2 == n_3) || (n_2 == n_3 && n_3 == n_4) ){
  	cout << "Yes" << endl;
  }else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define A 200000
int main(void){
    int n, i, j, k;
    int R[A];
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &R[i]);
    }
    for(i=0;i<n-1;i++){
        if(i==0 || j>R[i]){
           j=R[i];
        }
        if(i==0 || k<R[i+1]-j){
           k=R[i+1]-j;
         }
    }
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 2640
import scala.math._

// longでrangeの作り方

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
//  val a, b, c = sc.next
  val list = List.fill(3)(sc.next)

  val ans = list.foldLeft("")((acc, p) => acc + p.head.toUpper)

  println(ans)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

int N;
int A[100000];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A, A+N);

    long long unsigned int max1, max2;
    int idx;
    max1 = max2 = 0;
    idx = -1;
    for(int i = N-1; i > 0; i--){
        if(A[i] == A[i-1]){
            max1 = A[i];
            idx = i-2;
            break;
        }
    }
    for(int i = idx; i > 0; i--){
        if(A[i] == A[i-1]){
            max2 = A[i];
            break;
        }
    }
    cout << max1*max2;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long c=sc.nextLong();
    long d =(c - a - b) * (c - a - b) - 4*a*b;
    if((a + b < c)&&(d>0)){System.out.println("Yes");}
    else{System.out.println("No");}
  }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>
int main()
{
  int n,a,b;
  scanf("%d",&n);
  switch(n){
    case 1: printf("Hello World"); break;
    case 2: scanf("%d %d",&a,&b); printf("%d",a+b); break;
  }
  return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
p = [INT() for _ in range(N)]

print(sum(p) - max(p)//2)

Measured memory_bytes: 5396
use std::io::*;
use std::str::FromStr;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn is_prime(number: i64) -> bool {
	let upper_n = (number as f64).sqrt().floor() as i64;
	for i in 2..upper_n {
		if number % i == 0 {
			return false
		}
	}
	return true
}
     
fn main() {
    let number: i64 = read();
	let mut i = number;
	while !is_prime(i) {
		i += 1;
	}
	println!("{}", i)
}

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

int main() {
    string S;
    string T;
    int cnt = 0;
    cin >> S >> T;
    for (int i = 0; i < S.size(); ++i) {
        if(S[i] != T[i]){
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  vector<int> vec;
  string ans;
  long long N;
  cin>>N;
  while(true){
    N--;
    vec.push_back(N%26);
    N=N/26;
    if (N==0) break;
  }
  reverse(vec.begin(),vec.end());
  REP(i,vec.size()){
    char moji='a';
    REP(j,26){
      if (vec.at(i)==j) ans.push_back(moji);
      moji++;
    }
  }
 cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	string s;
	cin >> s;

	bool ok = true;
	for (int i = 0; i < s.size(); ++i) {
		if (i % 2 == 0 && s[i] == 'L') { ok = false; }
		if (i % 2 == 1 && s[i] == 'R') { ok = false; }
	}

	if (ok) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = next()
    let ans = (BigInt(n) - 1n) * BigInt(n) / 2n
    console.log(ans.toString())
}
Main()



Measured memory_bytes: 29520
#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);
( my $s = <STDIN> ) =~ s/[\x00-\x20]+$//io;

my @w_ct = ();
$#w_ct = ($n - 1);
my @e_ct = ();
$#e_ct = ($n - 1);
my $w = 0;
my $e = 0;
for(my $i=0;$i<$n;$i++){
  $w += ( substr($s,$i,1) eq 'W' ? 1 : 0 );
  $w_ct[$i] = $w;
  $e += ( substr($s,$n-1-$i,1) eq 'E' ? 1 : 0 );
  $e_ct[$n-1-$i] += $e;
}

my $mn = $n-1;
for(my $i=0;$i<$n;$i++){
  my $ct = 0;
  $ct += $w_ct[$i-1] if $i>0;
  $ct += $e_ct[$i+1] if $i<$n-1;
  $mn = $ct if $ct < $mn;
}
print "$mn\n";




Measured memory_bytes: 19660
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


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

    string S[N];
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S, S + N);

    string sum = "";
    for (int i = 0; i < N; i++) {
        sum += S[i];
    }
    cout << sum << endl;
    
    return 0;
}

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

int main() {
string s;
cin>>s;
char c='A';
int a=-1;
for(int i=0;i<s.length();i++){
    if(s[i]!=c){
        c=s[i];
        a++;
    }
}
cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
 
const int inf = 1e9;
const ll INF = 1e18;

const int mn = 1e5 + 10;
const ll mod = 1e9 + 7;

ll a[mn], b[mn], c[2 * mn];
ll pre[2 * mn];
int main()
{
	int n;	scanf("%d", &n);
	ll tans1 = 0, tans2 = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld %lld", &a[i], &b[i]);
		tans1 += a[i], tans2 += b[i];
		c[i] = a[i], c[i + n] = b[i];
	}
	
	ll ans = min(tans1, tans2);
	
	sort(c + 1, c + 2 * n + 1);
	for (int i = 1; i <= n; i++)
		pre[i] = pre[i - 1] + c[i];
	for (int i = 1; i <= n; i++)
	{
		ll x = a[i], y = b[i];
		if (x > y)	swap(x, y);
		
		int p1 = lower_bound(c + 1, c + 2 * n + 1, x) - c;
		int p2 = lower_bound(c + 1, c + 2 * n + 1, y) - c;
		
		if (p1 > n - 2 && p2 > n - 2)
			ans = min(ans, x + y + pre[n - 2]);
		else if (p1 <= n - 1 && p2 > n - 1)
			ans = min(ans, pre[n - 1] + y);
		else if (p1 <= n && p2 <= n)
			ans = min(ans, pre[n]);
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    string s, t;
    cin >> s >> t;

    bool f = false;
    lint N = s.size();

    rep(i, N) {
        if(s == t) {
            f = true;
        }
        char b = s.back();
        s = b + s;
        s.pop_back();
    }

    if(f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;
 
long func_f(long a) {
	if (a % 2 == 0) {
		return (a / 2);
	}
	else {
		return (3 * a + 1);
	}
}
 
 
int main() {
 
	long s;
	cin >> s;
 
	vector<long> a;
	a.push_back(s);
 
	long cnt = 1;
 
	while (cnt == 1) {
		a.push_back(func_f(a.back()));
		cnt = count(a.begin(), a.end(), a.back());
	}
 
	cout << a.size() << endl;
 
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int s;

int Fizz(int n) {
  return n/3;
}
int Buzz(int n) {
  return n/5;
}
int FizzBuzz(int n) {
  return n/15;
}

int pw[22];
int len[22];
int getNdig(int n) {
  int d = 1, x = 1, t = 0;
  //pw[0] = 1;
  for(; t < n; (t < n ? d++, x *= 10 : 0)) {
    int y = x*10-1;
    int f = Fizz(x*10-1)-Fizz(x-1), b = Buzz(x*10-1)-Buzz(x-1), fb = FizzBuzz(x*10-1)-FizzBuzz(x-1);
    //cout<<y<<" "<<x<<" "<<f<<" "<<b<<" "<<fb<<endl;
    t += (y-(x-1)-f-b+fb)*d+f*4+b*4;//-fb*4;
    pw[d] = x-1;
    len[d] = t;
  }
  return d;
}

signed main()
{
  cin >> s;
  int d = getNdig(s);
  //cout << d << endl;
  int lb = 1;
  for(int i = 1; i < d; i++) lb *= 10;
  int ub = lb*10;
  lb--, ub++;
  //cout<<len[d]<<endl;
  //cout<<pw[d]<<endl;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    int f = Fizz(mb)-Fizz(pw[d]), b = Buzz(mb)-Buzz(pw[d]), fb = FizzBuzz(mb)-FizzBuzz(pw[d]);
    int t = len[d-1]+(mb-pw[d]-f-b+fb)*d+f*4+b*4;//-fb*4;
    //cout<<mb<<" "<<t<<" "<<pw[d]<<" "<<f<<" "<<b<<endl;
    if(t < s) lb = mb;
    else ub = mb;
  }
  //cout << ub << endl;
  int f = Fizz(ub)-Fizz(pw[d]), b = Buzz(ub)-Buzz(pw[d]), fb = FizzBuzz(ub)-FizzBuzz(pw[d]);
  int l = len[d-1]+(ub-pw[d]-f-b+fb)*d+f*4+b*4;
  //cout<<l<<endl;
  int out = 20;
  if(l >= s) {
    string o;
    if(ub%15 == 0) {
      o = "FizzBuzz";
    } else if(ub%3 == 0) {
      o = "Fizz";
    } else if(ub%5 == 0) {
      o = "Buzz";
    } else {
      o = to_string(ub);
    }
    out -= ((l-s)+1);
    cout << o.substr(o.size()-((l-s)+1));
  }
  for(int i = ub+1; out > 0; i++) {
    string o;
    if(i%15 == 0) {
      o = "FizzBuzz";
    } else if(i%3 == 0) {
      o = "Fizz";
    } else if(i%5 == 0) {
      o = "Buzz";
    } else {
      o = to_string(i);
    }
    cout << ((int)o.size() <= out ? o : o.substr(0, out));
    out -= o.size();
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3236
"use strict"

function Main(input) {
  let lines = input.split('\n');
  const [a, b, c, d] = lines[0].split(' ').map(BigInt);

  let product_matrix = [];
  product_matrix.push(a * c);
  product_matrix.push(a * d);
  product_matrix.push(b * c);
  product_matrix.push(b * d);
  const max = product_matrix.reduce((a,b)=>a>b?a:b)

  console.log(max.toString());
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29464
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	
	std::map<std::string, int64_t> item;
	for (int64_t i = 0; i < N; i++)
	{
		std::string name;
		std::cin >> name;
		item[name]++;
	}

	std::cout << item.size() << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 19244
n,s = map(int,input().split())
f = 0
m = 1001
for _ in [0]*n:
  c,t = map(int,input().split())
  if t<=s:
    f = 1
    m = min(m,c)
if f == 0:
  print("TLE")
else:
  print(m)

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

const int N = 3e5 + 9;

int ans[N];
int32_t main()
{
    int n, x, y; cin >> n >> x >> y;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(i <= x && j <= x || i>= y && j >= y) ans[j - i]++;
            else{
                int d = 0, u = i, v = j;
                if(u <= x) d += x - u, u = x;
                if(v >= y) d += v - y, v = y;
                d += min(v - u, u - x + y - v + 1);
                ans[d]++;
            }
        }
    }
    for(int i = 1; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline int fastpow(int bas, int ex){
	register int res = 1;
	for(; ex; ex >>= 1, bas = bas * (ll)bas % MOD) if(ex & 1) res = res * (ll)bas % MOD;
	return res;
}

inline int kazu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}
inline int hiku(int a, const int &b) {return (a -= b) < 0 ? a + MOD : a;}

int N, A = 0, a[500005], sum0[500005], ans = 0;
int nxt[1 << 20], head[1 << 20], id[500005], top, cnt0[1000005], f[1000005][2];

inline int calc_even(const int &x){
	if(head[x] > N) return 0; id[top = 1] = head[x];
	while(nxt[id[top]] <= N) id[top + 1] = nxt[id[top]], top++;
	register int M = 0;
	for(register int i = 1; i <= top; i++){
		cnt0[++M] = -1;
		if(i < top) cnt0[++M] = sum0[id[i + 1]] - sum0[id[i]];
	}
	f[0][0] = 1, f[0][1] = 0;
	for(register int i = 1; i <= M; i++){
		if(cnt0[i] == -1) f[i][0] = f[i - 1][0], f[i][1] = kazu(f[i - 1][1], f[i - 1][0]);
		else f[i][1] = f[i - 1][1], f[i][0] = kazu(f[i - 1][0], f[i - 1][1] * (ll)cnt0[i] % MOD);
	}
	return f[M][1];
}

inline int calc_odd(const int &x){
	if(head[x] > N) return 0; id[top = 1] = head[x];
	while(nxt[id[top]] <= N) id[top + 1] = nxt[id[top]], top++;
	register int M = 0;
	for(register int i = 1; i < top; i++){
		cnt0[++M] = -1;
		cnt0[++M] = sum0[id[i + 1]] - sum0[id[i]];
	}
	f[0][0] = 1, f[0][1] = 0;
	for(register int i = 1; i <= M; i++){
		if(cnt0[i] == -1) f[i][0] = f[i - 1][0], f[i][1] = kazu(f[i - 1][1], f[i - 1][0]);
		else f[i][1] = f[i - 1][1], f[i][0] = kazu(f[i - 1][0], f[i - 1][1] * (ll)cnt0[i] % MOD);
	}
	return f[M][0];
}

int main(){
	getint(N);
	for(register int i = 1; i <= N; i++) getint(a[i]), A = max(A, a[i] ^= a[i - 1]);
	for(register int i = 1; i <= N; i++) sum0[i] = sum0[i - 1] + (a[i] == 0);
	for(register int i = 0; i <= A; i++) head[i] = N + 1;
	for(register int i = N; i; i--) nxt[i] = head[a[i]], head[a[i]] = i;
	if(a[N]) ans = calc_odd(a[N]);
	else{
		ans = fastpow(2, sum0[N] - 1);
		for(register int i = 1; i <= A; i++) ans = kazu(ans, calc_even(i));
	}
	return printf("%d\n", ans), 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

class UnionFind
{
    std::vector<int> data;

public:
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

constexpr int MAX_N = 300010;

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

    int n, r;
    cin >> n >> r;
    vector<int> p(n), used(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        p[i]--;
        if (i == p[i])
            used[i] = 1;
    }
    vector<int> sz;
    int sum = 0;
    UnionFind uf(n);
    for (int i = 0; i < n; i++)
    {
        if (used[i])
            continue;
        int pos = i;
        used[pos] = 1;
        while (used[p[pos]] == 0)
        {
            uf.unite(pos, p[pos]);
            pos = p[pos];
            used[pos] = 1;
        }
        sum += uf.size(i);
        sz.push_back(uf.size(i));
    }
    bitset<MAX_N> bs;
    bs[0] = 1;
    for (auto v : sz)
    {
        bs |= (bs << v);
    }
    for (int i = 0; i <= n; i++)
    {
        if (bs[i] == 0)
            continue;
        int j = sum - i;
        if(i<=r && j<=n-r)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(i<=n-r && j<=r)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 7304
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();      
        int N = r.i();
        int[] B = r.ii();
        int sum = B[0] + B[N-2];
        for(int i = 0; i < N-2; i++){
            sum += Math.min(B[i], B[i+1]);
        }
        println(sum);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
int c=0;
long A[500001];
void merge(long A[],int left,int mid,int right)
{
	int i,j,k;
	long INFTY = 2147483647;
	int n1 = mid - left;
	int n2 = right - mid;
	long L[250001],R[250001];
	for (i = 0; i < n1; i++){
		L[i] = A[left + i];}
	for (i = 0; i < n2; i++){
		R[i] = A[mid + i];}
	L[n1] = INFTY;
	R[n2] = INFTY;
	i = j = 0;
	for (k = left; k < right; k++){
		if (L[i] <= R[j]){
			A[k] = L[i++];
			c++;}
		else {
			A[k] = R[j++];
			c++;}}
}
void mergeSort(long A[],int left,int right)
{
	int mid;
	if (left + 1 < right){
		mid = (left + right)/2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);}
}
int main(void)
{
	int i,n;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%ld",&A[i]);}
	mergeSort(A,0,n);
	for(i=0; i<n; i++){
		printf("%ld",A[i]);
		printf(!(i-n+1)?"\n":" ");}
		printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 8408
import sys
import math
import copy
from typing import Tuple, List, Union
input = sys.stdin.readline

sin60 = math.sqrt(3) / 2
cos60 = 1/ 2

class Position:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __repr__(self):
        return "{:.8f} {:.8f}".format(self.x, self.y)


def koch(n: int, p1, p2):
    if n == 0:
        return
    s = Position((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3)
    t = Position((p1.x + 2 * p2.x) / 3, (p1.y +  2 * p2.y) / 3)
    u = Position((t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x,
                 (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y)
    koch(n - 1, p1, s)
    print(s)
    koch(n-1, s, u)
    print(u)
    koch(n-1, u, t)
    print(t)
    koch(n-1, t, p2)



def main():
    n = int(input())
    p1 = Position(0.0, 0.0)
    p2 = Position(100.0, 0.0)
    print(p1)
    koch(n, p1, p2)
    print(p2)

if __name__ == '__main__':
    main()



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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  if (s[k-1] == 'A') s[k-1] = 'a';
  if (s[k-1] == 'B') s[k-1] = 'b';
  if (s[k-1] == 'C') s[k-1] = 'c';
  
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,N,A[2][36],minj,atmp;
  char C[2][36],ctmp;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&C[0][i],&A[0][i]);
    A[1][i]=A[0][i];
    C[1][i]=C[0][i];
  }

  for(i=0;i<=N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[1][j]<A[1][j-1]){
	atmp=A[1][j];
	A[1][j]=A[1][j-1];
	A[1][j-1]=atmp;

	ctmp=C[1][j];
	C[1][j]=C[1][j-1];
	C[1][j-1]=ctmp;
      }
    } 
  }

  for(i=0;i<N;i++){
    printf("%c%d",C[1][i],A[1][i]);
    if(i!=N-1)printf(" ");
  }
  printf("\nStable\n");

  for(i=0;i<N;i++){
    A[1][i]=A[0][i];
    C[1][i]=C[0][i];
  }

  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[1][j]<A[1][minj])minj=j;
    }
    atmp=A[1][i];
    A[1][i]=A[1][minj];
    A[1][minj]=atmp;

    ctmp=C[1][i];
    C[1][i]=C[1][minj];
    C[1][minj]=ctmp;
  }

  for(i=0;i<N;i++){
    printf("%c%d",C[1][i],A[1][i]);
    if(i!=N-1)printf(" ");
  }
  minj=0;
  for(i=0;i<=N-1;i++){
    for(j=i+1;j<=N-1;j++){
      for(atmp=0;atmp<=N-1;atmp++){
	for(ctmp=atmp+1;ctmp<=N-1;ctmp++){
	  if(A[1][i]==A[1][j] && C[1][i]==C[0][ctmp] && C[1][j]==C[0][atmp]){
	    minj=1;
	    break;
	  }
	}
      }
    }
  }
  if(minj==0)printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    string x,y,z;
    cin>>x>>y;

    x+=x;
    if(x.find(y)==-1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int N;
	cin >> N;
	int ans = 0;
	if(N >= 105) ans++;
	if(N >= 135) ans++;
	if(N >= 165) ans++;
	if(N >= 189) ans++;
	if(N >= 195) ans++;
	cout <<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

namespace io {
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  const int SIZE = (1 << 21) + 1;
  char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
  inline char getc () {return (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++);}
  inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
  inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
  template<class T>
  inline void read(T &x) {
    char ch; int f = 1;
    x = 0;
    while(isspace(ch = getc()));
    if(ch == '-') ch = getc(), f = -1;
    do x = x * 10 + ch - '0'; while(isdigit(ch = getc()));
    x *= f;
  }
  template<class T, class ...Args>
  inline void read(T &x, Args&... args) {read(x); read(args...);}
  template<class T>
  inline void write(T x) {
    static char stk[128];
    int top = 0;
    if(x == 0) {putc('0'); return;}
    if(x < 0) putc('-'), x = -x;
    while(x) stk[top++] = x % 10, x /= 10;
    while(top) putc(stk[--top] + '0');
  }
  template<class T, class ...Args>
  inline void write(T x, Args... args) {write(x); putc(' '); write(args...);}
  inline void space() {putc(' ');}
  inline void endl() {putc('\n');}
  struct _flush {~_flush() {flush();}} __flush;
};
using io::read; using io::write; using io::flush; using io::space; using io::endl; using io::getc; using io::putc;

const int N = 505, P = 10005;
int p[P], pc = 0;
bool np[P];
void prime_sieve(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!np[i]) p[pc++] = i;
    for (int j = 0; j < pc && i * p[j] <= n; ++j) {
      np[i * p[j]] = true;
      if (i % p[j] == 0) break;
    }
  }
}

ll a[N][N];

ll gcd(ll x, ll y) {
  ll t;
  while (y) t = x, x = y, y = t % y;
  return x;
}
ll lcm(ll x, ll y) {
  if (!x || !y) return x | y;
  return x / gcd(x, y) * y;
}

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int n;
int border(int x, int y) {
  return x >= 0 && x < n && y >= 0 && y < n;
}

int main() {
  prime_sieve(10000);
  read(n);
  if (n == 2) {
    write(4, 7), endl();
    write(23, 10), endl();
    return 0;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (((i ^ j) & 1) == 0) {
        int l1 = (i + j) / 2;
        int l2 = n + ((i - j) / 2) + (n - 1) / 2;
        a[i][j] = p[l1] * p[l2];
      }
    }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!a[i][j]) {
        a[i][j] = 1;
        for (int d = 0; d < 4; ++d)
          if (border(i + dx[d], j + dy[d]))
            a[i][j] = lcm(a[i][j], a[i + dx[d]][j + dy[d]]);
        ++a[i][j];
      }
      write(a[i][j]), space();
    }
    endl();
  }
  return 0;
}

Measured memory_bytes: 7468