akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

l,r,d=mii()
ans=0
for i in range(l,r+1):
    if i%d==0:
        ans+=1
print(ans)

Measured memory_bytes: 10404
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<map<char, int> > vec_s(n, map<char, int>());
	REP(i, n)
	{
		string s;
		cin >> s;
		REP(j, SIZE(s))
		{
			vec_s[i][s[j]]++;
		}
	}

	string ans = "";
	for (char c = 'a'; c <= 'z'; ++c)
	{
		int num = 9999;
		REP(j, n)
		{
			if (vec_s[j].count(c) < 1)
			{
				num = 9999;
				break;
			}
			chmin(num, vec_s[j][c]);
		}
		if (num < 9999)
		{
			REP(k, num)
			{
				ans += c;
			}
		}
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 384
#include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <complex>

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

using namespace std;
typedef complex<double> vec;

double const pi = acos(-1);
double const eps = 1e-6;

int main(){
    int n;
    while (cin >> n && n){
        vector<vec> v(n);
        rep(i, n){
            double x, y; cin >> x >> y;
            vec p(x, y);
            v[i] = p;
        }

        if (n == 1) {
            puts("1");
            continue;
        }
        int ans = 1;
        rep(i, n)rep(j, n)if (i != j){
            double d = abs(v[i] - v[j]);
            if (d > 2) continue;
            ans = max(ans, 2);
            double h = sqrt(1 - d*d / 4);
            vec c1 = polar(h, arg(v[i] - v[j]) + pi / 2) + (v[i] + v[j]) / 2.;
            vec c2 = polar(h, arg(v[i] - v[j]) - pi / 2) + (v[i] + v[j]) / 2.;
            int a1 = 0, a2 = 0;
            rep(k, n){
                if (abs(c1 - v[k]) <= 1) a1++;
                if (abs(c2 - v[k]) <= 1) a2++;
            }
            ans = max(ans, a1);
            ans = max(ans, a2);
        }
        cout << ans << endl;
    }
}

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

int main() {
    int n, x, y; cin >> n >> x >> y;

    vector<int> answer(n, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dist = abs(i - j);
            dist = min(dist, abs(i - x) + 1 + abs(y - j));
            dist = min(dist, abs(i - y) + 1 + abs(x - j));
            answer[dist]++;
        }
    }

    for (int i = 1; i <= n - 1; i++) {
        cout << answer[i] << endl;
    }
    return 0;
}


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

class A
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(Enumerable.Range(1, a[0]).SelectMany(i => Enumerable.Range(1, a[1]).Select(j => new { i, d1 = j % 10, d2 = j / 10 })).Count(_ => _.d1 >= 2 && _.d2 >= 2 && _.i == _.d1 * _.d2));
	}
}


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

int main(){

    int N;
    cin >> N;
    vector<int> vec(N,0);
    for(int i = 0; i < N;i++)cin >> vec[i];
    
    int cont = 0;
    for(int i = 0; i < N - 1;i++){
        if(vec[i] == i+1){
            cont++;
            swap(vec[i],vec[i+1]);
        }
    }
    
    if(vec[N - 1]==N)cont++;
    
    cout << cont << endl;
    
}


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

int main() {
  int d;

  cin >> d;

  vector<int> c(26,0);
  vector<vector<int> > s(d, vector<int>(26,0));
  vector<int> last(26,0);

  vector<int> ans(d,0);

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

  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }

  int max;
  int k;
  for(int i=0;i<d;i++) {
    max=s[i][0] + c[0]*(i+1-last[0]);
    k=0;
    for(int j=1;j<26;j++) {
      int p= s[i][j] + c[j]*(i+1-last[j]);
      if(max<p) {
        max=p;
        k=j;
      } else if(max==p) {
        if(c[k]<c[j]) {
          max=p;
          k=j;
        }
      }
    }
    ans[i] = k;
    last[k]++;
  }

  for(int i=0;i<d;i++) {
    cout << ans[i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3680
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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 long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

static const double pi = 3.141592653589793;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0){
        cout<<1<<endl;
    }
    else if(b==0){
        cout<<2<<endl;
    }
        else if(c==0){
            cout<<3<<endl;
        }
            else if(d==0){
                cout<<4<<endl;
            }
                else{
                    cout<<5<<endl;
                }
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 505;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
ll arr[MAXN];
ll pre[MAXN];
ll d[MAXN][MAXN];
bool s[MAXN][MAXN];

ll dp(int l, int r){
    if(s[l][r]) return d[l][r];
    s[l][r] = 1;
    if(l == r) return 0;
    else{
        d[l][r] = INF; 
        for(int k = l; k < r; k++){
            d[l][r] = min(d[l][r], pre[k] - pre[l - 1] + pre[r] - pre[k] + dp(l, k) + dp(k + 1, r));
        }

        return d[l][r];
    }
}


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;

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

    cout<<dp(1, n)<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    double n=sc.nextDouble();
    double k=sc.nextDouble();
    double total=0;
    for(int i=1;i<=n;i++){
      int an=0;
      for(int s=0;;s++){
        if(i*Math.pow(2,s)>=k){
          an=s;
          break;
        }
      }
      total+=1/(Math.pow(2,an)*n);
    }

    System.out.println(total);

    sc.close();
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long H, long long W){
  if(H==1||W==1){
    cout<<1<<endl;
    return;
  }
  if(H*W%2==0){
    cout<<H*W/2<<endl;
  }else{
    cout<<H*W/2+1<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 

ll int power(ll int a,int b)
{
	ll int ans=1,f=a;
	while(b)
	{
		 if(b&1)
		 ans=(ans*f)%mod;
		 b=b>>1;
		 f=(f*f)%mod;
	}
	return ans%mod;
}
int main()
{
    int k;
    cin>>k;
  string s;
  cin>>s;
  if(sz(s)<=k) cout<<s;
  else
  {
      fo(i,0,k)
      cout<<s[i];
      cout<<"...";
  }
 
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -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; }

int main()
{
    int n, k;
    cin >> n >> k;
    vector <double> p(n), x(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    vector <double> s(1001, 0);
    s[1] = 1.0;
    for (double i = 2; i <= 1000; i++) {
        s[i] = s[i-1] + i;
        //cout << i << " " << s[i] << endl;
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        x[i] = s[p[i]] / p[i];
    }
    double tmp = 0;
    for (int i = 0; i < k; i++) {
        ans += x[i];
    }
    tmp = ans;
    for (int i = 0; i < n-k; i++) {
        tmp += x[i+k] - x[i];
        chmax(ans, tmp);
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long H,t=0,i=0,j=0,a;
  int long long ans=0;
  
  cin >> H;

  while (H!=1)
  {
    H/=2;
    i++;
  }
  ans=pow(2,i+1)-1;
  

  printf ("%lld\n",ans);
  return 0;
}

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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToList();
        var ans = 0;
        while (0<a.Count())
        {
            for (int i = 0; i < a.Count(); ++i)
            {
                if (a[i] % 2 == 0)
                {
                    ans++;
                    a[i] /= 2;
                }
                else a.RemoveAt(i);
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 14304
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long s,c,cnt=0;
    cin >> s >> c;
    // c が 2つ と S １つで cnt+1 なので、c/2で(cが2つ分の数)と S の数の小さい方に Scc が作れる数が依存するのでmin()をとる。
    cnt += min(s,c/2);
    //今のcntは言い換えれば、cの2つ組み合わせの数とも言える。なので元のcから使った2つ分のc (cnt*2) を引く。
    c -= cnt * 2;
    // 最後に cが4つで cnt+1 なので、c/4で4つ組み合わさる数を足す。
    cnt += c/4;
    cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_N 100000

int main(void) {
  int N, M;
  std::cin >> N >> M;

  std::vector<std::vector<int>> jobs(M);
  rep(i, N) {
    int a, b;
    std::cin >> a >> b;
    if(a > M) continue;
    jobs[M-a].push_back(b);
  }

  std::priority_queue<int> que;
  std::int64_t ANS = 0;
  for(int i = M-1; i >= 0; i--) {
    for(int b : jobs[i]) {
      que.push(b);
    }
    if(que.empty()) continue;

    ANS += que.top();
    que.pop();
  }
  std::cout << ANS << std::endl;
  return 0;
}


Measured memory_bytes: 5504
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  vector<string> ans;
  string res;
  rep(i, n) res += 'a';
  vector<int> used(n, 0);
  used[0] = n;
  while (1) {
    ans.push_back(res);
    int idx = n - 1;
    while (idx > 0 && used[res[idx] - 'a'] == 1) {
      idx--;
    }
    if (idx == 0) break;
    used[res[idx] - 'a']--;
    used[res[idx] - 'a' + 1]++;
    res[idx]++;
    FOR(i, idx + 1, n) {
      used[res[i] - 'a']--;
      used[0]++;
      res[i] = 'a';
    }
  }
  rep(i, ans.size()) cout << ans[i] << endl;



  
  return 0;
}

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
int main(void){
	const int N = (int)1e6;
	vector<bool> isP(N, true);
    isP[0] = isP[1] = false;
	for(int i = 2; i * i < N; i++) if(isP[i]) for(int j = i; i * j < N; j++) isP[i * j] = false;

	for(int n; cin >> n, n;){
		int res = 0;
		range(i, n + 1, 2 * n + 1){
			if(isP[i]) res++;
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1316
#include<stdio.h>
#define N 20000

int main(void){
	int r,c,i,j,susu=0;
	int su[200][200]={{0}};
	int sumg[N],suml[N]={0};
	
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&su[i][j]);
		}
	}
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			printf("%d ",su[i][j]);
			sumg[i]=sumg[i]+su[i][j];
		}
		printf("%d\n",sumg[i]);
	}
	for(i=0;i<c;i++){
		for(j=0;j<r;j++){
			suml[i]=suml[i]+su[j][i];
		}
		printf("%d ",suml[i]);
		susu=susu+suml[i];
	}
	printf("%d\n",susu);
	
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int N,M,C;
cin >> N >> M >> C;
int a[N][M],b[M];
for(int i=0;i<M;i++){
  cin >> b[i];
}
for(int i=0;i<N;i++){
  for(int j=0;j<M;j++){
    cin >> a[i][j];
  }
}
int sum = 0,count = 0;
for(int i=0;i<N;i++){
  for(int j=0;j<M;j++){
    sum += a[i][j]*b[j];
    }
    if(sum+C > 0)
    count++;
    sum = 0;
  }
cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		String res = "";

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != 'B') {
				res += s.charAt(i);
			}
			else {
				res = res.substring(0, Math.max(res.length() - 1, 0));


			}
		}

		System.out.println(res);



		/*

		int[] skip = new int[s.length()];
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'B') {
				if (i > 0)
					skip[i - 1] = 1;
			}
		}

		for (int i = 0; i < s.length(); i++) {
			if (skip[i] == 0 && s.charAt(i) != 'B') {
				res += s.charAt(i);
			}
		}
		System.out.println(res);
		*/
	}
}

Measured memory_bytes: 23892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = long long;

template <int MAX_N>
class UnionFind {
public:
    int parent[MAX_N];
    int rank[MAX_N];

    UnionFind(int n) {
        for (int j = 0; j < n; ++j) {
            parent[j] = j; rank[j] = 0;
        }
    }

    int find(int x) {
        if (parent[x] == x) { return x; }
        return parent[x] = find(parent[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) { return false; }

        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
        }

        return true;
    }

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


struct edge {
    int from, to, cost;
    edge() {}
    edge(int a, int b, int c): from(a), to(b), cost(c) {}

    bool operator < (const edge& o) const {
        return cost > o.cost;
    }
};

int N;
i64 A[300][300];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
            cin >> A[j][k];
        }
    }

    i64 B[300][300];
    for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
            B[j][k] = A[j][k];
        }
    }
    
    for (int l = 0; l < N; ++l) {
        for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                B[j][k] = min(B[j][k], B[j][l] + B[l][k]);
            }
        }
    }

    for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
            if (A[j][k] != B[j][k]) {
                cout << "-1" << endl;
                return 0;
            }
        }
    }

    UnionFind<300> uf(N);
    priority_queue<edge> edges;
    for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
            edges.emplace(j, k, B[j][k]);
        }
    }

    i64 C[300][300];
    for (int j = 0; j < N; ++j) {
        fill(C[j], C[j]+N, 1LL<<60);
        C[j][j] = 0;
    }

    i64 cost = 0;
    while (!edges.empty()) {
        edge e = edges.top(); edges.pop();

        if (e.cost == C[e.from][e.to]) {
            continue;
        }

        cost += e.cost;
        C[e.from][e.to] = C[e.from][e.to] = e.cost;
        for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                C[j][k] = min(C[j][k], C[j][e.from] + C[e.to][k] + e.cost);
                C[j][k] = min(C[j][k], C[j][e.to] + C[e.from][k] + e.cost);
            }
        }
    }
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 3572
def main():
    N, *X = map(int, open(0).read().split())
    A = X[:N]
    Q = X[N]
    s = sum(A)
    B = {}
    for a in A:
        if a not in B:
            B[a] = 0
        B[a] += 1

    ans = []
    for i in range(Q):
        b, c = X[N + 1 + 2*i], X[N + 1 + 2*i + 1]
        if b in B:
            num = B[b]
            s += (c - b)*num
            if c not in B:
                B[c] = 0
            B[c] += num
            B[b] = 0
        ans.append(str(s))
    print('\n'.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 43868
import java.io.*;

class Main
{
	public static void main (String args[]) throws IOException
{
	BufferedReader br =
	new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	int x = Integer.parseInt(str);

 
		System.out.println((int)Math.pow(x,3));
	 }
	
}

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

using namespace std;

int main()
{
    string N;
	cin >> N;
    auto pos = N.find("7");
    if(pos == std::string::npos)
    {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

	return 0;
}

Measured memory_bytes: 3624
n,k=map(int,input().split())
R,S,P=map(int,input().split())
t=list(input())
ans=0
cmds=[""]*n
for i,j in enumerate(t):

    if j=="r":
        cmd="p"
        point=P

    elif j=="s":
        cmd="r"
        point=R

    elif j=="p":
        cmd="s"
        point=S

    if i-k>=0 and cmds[i-k]==cmd:
        cmd=""
        point=0
    ans+=point
    cmds[i]=cmd

print(ans)

Measured memory_bytes: 4792
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

/*signed*/int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3544
fn main() {
    let (a, b) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        let a: Vec<i64> = line.split_whitespace().map(|a|(a).parse().unwrap()).collect();
        (a[0], a[1])
    };

    println!("{}", if b == 1 {0} else {std::cmp::max(0, b - 2) / (a - 1) + 1})
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        //for (int tt = 1; tt <= t; tt++) {
        string s;
        cin >> s;
        int n = s.size();
        int cnt = 0;
        int maxi = -1;
        bool ji = 1;
        if (s == "SSR") {
            cout << 1;
            continue;
        }
        if (n == 1 and s[0] == 'R')
            maxi = 1;
        for (int i = 0; i < n - 1; i++) {
            if (s[i] == 'R' and ji) {
                cnt++;
                ji = 0;
            }
            if (s[i] == 'R' and s[i + 1] == 'R')
                cnt++;
            maxi = max(cnt, maxi);
            if (s[i] != 'R')
                cnt = 0;
        }
        cout << maxi;
    }
    return 0;

}




Measured memory_bytes: 3576
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    int now = nn;
    int ans = now;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7828
N = int(input())
A = [int(input()) for i in range(0, N)]
ans1 = max(A)
s = A.index(ans1)

if A.count(ans1) >= 2:
    for i in range(N):
        print(ans1)
else:
    for i in range(N):
        if i == s:
            A.remove(ans1)
            print(max(A))
        else:
            print(ans1)

Measured memory_bytes: 12532
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
//pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const ll mod = 1e9 + 7;
const ll N = 3e5 + 7;

int add(int a, int b) {
	return (a + (b % mod) + mod) % mod;
}

int mult(int a, int b) {
	return (1LL * a * b) % mod;
}

int p1 = 31, p2 = 53;
int p1powers[N], p2powers[N];

void pre() {
	p1powers[0] = p2powers[0] = 1;
	for (int i = 1; i < N; i++) {
		p1powers[i] = mult(p1, p1powers[i - 1]);
		p2powers[i] = mult(p2, p2powers[i - 1]);
	}
}

struct hash_pair
{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

int fp(int b, int e) {
	if (!e)
		return 1;
	int ans = fp(b, e / 2);
	ans = mult(ans, ans);
	if (e & 1)
		ans = mult(ans, b);
	return ans;
}



int main() {
	fastIO;
	pre();
	int n;
	//srand(time(0));
	int invP1 = fp(p1, mod - 2), invP2 = fp(p2, mod - 2);
	cin >> n;
	//n = 5e3;
	string s;
	cin >> s;
	//s = string(n, 'a');
	/*for (int i = 0; i < n; i++) {
		s[i] = (char)(rand() % 26 + 'a');
	}*/
	int ans = 0;
	int hash1 = 0, hash2 = 0;
	for (int i = n / 2; i >= 1; i--) {
		hash1 = hash2 = 0;
		for (int j = 0; j < i; j++) {
			//hash1 = add(hash1, mult(s[j],	p1powers[j]));
			hash1 = (hash1 + ((s[j] * 1LL * p1powers[j]) % mod)) % mod;
			//hash2 = add(hash2, mult(s[j], p2powers[j]));
			hash2 = (hash2 + ((s[j] * 1LL * p2powers[j]) % mod)) % mod;
		}
		unordered_map<pair<int, int>, int, hash_pair> occ;
		occ[{hash1, hash2}] = 0;
		int lastP1 = p1powers[i-1];
		int lastP2 = p2powers[i-1];
		for (int j = 1; j + i - 1 < n; j++) {
			hash1 = ((hash1 - s[j - 1] + mod) * 1LL * invP1) % mod;
			//hash1 = (hash1 * 1LL * invP1) % mod;
			hash1 = (hash1 + ((s[j + i - 1] * 1LL * lastP1) % mod)) % mod;

			hash2 = ((hash2 - s[j - 1] + mod) * 1LL * invP2) % mod;
			//hash2 = (hash2 * 1LL * invP2) % mod;
			hash2 = (hash2 + ((s[j + i - 1] * 1LL * lastP2) % mod)) % mod;

			if (occ.find({ hash1, hash2 }) != occ.end()) {
				if (j - occ[{hash1, hash2}] >= i) {
					cout << i;
					return 0;
				}
			}
			else {
				occ[{hash1, hash2}] = j;
			}
		}
	}
	cout << ans;

}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M;
int A[1000],B[1000],C[1000];
int D[1000],E[1000],F[1000];
bool vis[3010][3010];
vector<pair<int,int> >WX[3010],WY[3010];
bool wx[3010][3010],wy[3010][3010];
main()
{
	cin>>N>>M;
	vector<long>X,Y;
	X.push_back((long)-2e9);
	X.push_back(0);
	X.push_back((long)2e9);
	Y.push_back((long)-2e9);
	Y.push_back(0);
	Y.push_back((long)2e9);
	for(int i=0;i<N;i++)
	{
		cin>>A[i]>>B[i]>>C[i];
		X.push_back(A[i]);
		X.push_back(B[i]);
		Y.push_back(C[i]);
	}
	for(int i=0;i<M;i++)
	{
		cin>>D[i]>>E[i]>>F[i];
		X.push_back(D[i]);
		Y.push_back(E[i]);
		Y.push_back(F[i]);
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	for(int i=0;i<N;i++)
	{
		A[i]=lower_bound(X.begin(),X.end(),A[i])-X.begin();
		B[i]=lower_bound(X.begin(),X.end(),B[i])-X.begin();
		C[i]=lower_bound(Y.begin(),Y.end(),C[i])-Y.begin();
		WX[C[i]].push_back(make_pair(A[i],B[i]));
	}
	for(int i=0;i<M;i++)
	{
		D[i]=lower_bound(X.begin(),X.end(),D[i])-X.begin();
		E[i]=lower_bound(Y.begin(),Y.end(),E[i])-Y.begin();
		F[i]=lower_bound(Y.begin(),Y.end(),F[i])-Y.begin();
		WY[D[i]].push_back(make_pair(E[i],F[i]));
	}
	WX[0].push_back(make_pair(0,X.size()+1));
	WX[Y.size()].push_back(make_pair(0,X.size()+1));
	for(int i=0;i<=Y.size();i++)
	{
		sort(WX[i].begin(),WX[i].end());
		for(int j=0;j<WX[i].size();)
		{
			int L=WX[i][j].first,R=WX[i][j].second;
			while(j<WX[i].size()&&WX[i][j].first<=R)
			{
				R=max(R,WX[i][j].second);
				j++;
			}
			for(int k=L;k<R;k++)wx[i][k]=true;
		}
	}
	WY[0].push_back(make_pair(0,Y.size()+1));
	WY[X.size()].push_back(make_pair(0,Y.size()+1));
	for(int i=0;i<=X.size();i++)
	{
		sort(WY[i].begin(),WY[i].end());
		for(int j=0;j<WY[i].size();)
		{
			int L=WY[i][j].first,R=WY[i][j].second;
			while(j<WY[i].size()&&WY[i][j].first<=R)
			{
				R=max(R,WY[i][j].second);
				j++;
			}
			for(int k=L;k<R;k++)wy[i][k]=true;
		}
	}
	queue<pair<int,int> >P;
	vector<int>sx,sy;
	{
		int id=lower_bound(X.begin(),X.end(),0)-X.begin();
		sx.push_back(id-1);
		sx.push_back(id);
	}
	{
		int id=lower_bound(Y.begin(),Y.end(),0)-Y.begin();
		sy.push_back(id-1);
		sy.push_back(id);
	}
	for(int x:sx)for(int y:sy)
	{
		vis[x][y]=true;
		P.push(make_pair(x,y));
	}
	while(!P.empty())
	{
		int x=P.front().first,y=P.front().second;
		P.pop();
		if(!wy[x][y]&&!vis[x-1][y])
		{
			vis[x-1][y]=true;
			P.push(make_pair(x-1,y));
		}
		if(!wx[y][x]&&!vis[x][y-1])
		{
			vis[x][y-1]=true;
			P.push(make_pair(x,y-1));
		}
		if(!wy[x+1][y]&&!vis[x+1][y])
		{
			vis[x+1][y]=true;
			P.push(make_pair(x+1,y));
		}
		if(!wx[y+1][x]&&!vis[x][y+1])
		{
			vis[x][y+1]=true;
			P.push(make_pair(x,y+1));
		}
	}
	long long ans=0;
	for(int i=0;i<X.size();i++)for(int j=0;j<Y.size();j++)
	{
		if(!vis[i][j])continue;
		if(i==0||j==0||i+1==X.size()||j+1==Y.size())
		{
			cout<<"INF"<<endl;
			return 0;
		}
		ans+=(X[i+1]-X[i])*(Y[j+1]-Y[j]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 23696
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N,K;
    cin >> N >> K;
    double p[400000]={0};
    double A[400000]={0};
    for(int i=0;i<N;++i) cin >> p[i], A[i]=(p[i]+1)*p[i]/2/p[i];
    double B=0;
    double ans=0;
    for(int i=0;i<K;++i){
        ans+=A[i];
    }
    B=max(B,ans);
    for(int i=0;i<N;++i){
        ans=ans-A[i]+A[K+i];
        B=max(B,ans);
    }
    cout << fixed << setprecision(15) << B;
}


Measured memory_bytes: 6528
n = gets.to_i
n.times{
    h, m = gets.chomp.split(':').map(&:to_i)
    longhand = m * 6
    shorthand = h * 30 + 0.5 * m
    min, max = [shorthand, longhand].minmax
    kakudo = [max - min, 360 - max + min].min
    result = "safe"
    if kakudo < 30
        result = "alert"
    elsif kakudo < 90
        result = "warning"
    end
    puts result
}


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

using namespace std;

int main() {
	int n;
	vector<int> m;
	cin >> n;
	m.resize(n);

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

	while (true) {
		int min = *min_element(m.begin(), m.end());
		int d = 0;
		for (int i = 0; i < m.size(); i++) {
			if (m[i] % min != 0) {
				d++;
				m[i] %= min;
			}
		}
		if (d == 0) {
			cout << min << endl;
			break;
		}
	}

	return 0;
}

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

int main(){
  int L,i,k;
  cin>>L;
  for(i=0;i<=20;i++){
  	if(L>>i&1) k=i;
  }
  int N=k+1;
  int LL=L-(1<<(N-1));
  int M=2*N-2;
   for(i=0;i<20;i++){
	if(LL>>i&1) M+=1;
  }
  cout<<N<<" "<<M<<endl;
  for(i=1;i<N;i++){
	cout<<i<<" "<<i+1<<" "<<(1<<(N-i-1))<<endl;
	cout<<i<<" "<<i+1<<" "<<0<<endl;
  }
  int PP=L;
  for(i=0;i<20;i++){
	if(LL>>i&1){
		cout<<1<<" "<<N-i<<" "<<PP-(1<<i)<<endl;
		PP-=(1<<i);
	}
  }
  return 0;
}

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
int INF=1e5+1;

int main(){
	int n;
	cin >> n;
	int a[n];
	int maxi=-1;
	int mini=INF;
	FOR(i,n) {
		cin >> a[i];
		maxi=max(maxi,a[i]);
		mini=min(mini,a[i]);
	}
	cout << maxi-mini;

	return 0;
}

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

int main() {

	int N,K;
	cin >> N >> K;

	int syurui = 0;
	int ans = 0;
	
	int A[200010] = {0};



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

	}

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

	sort(A,A+200010);
	for (int i = 0; syurui > K; i++)
	{
		if(A[i]){
		ans += A[i];
		--syurui;
		}
		
	}
	

	cout << ans << endl;





}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        
        for(int i=0; i<n; i++){
            int h = sc.nextInt();
            if(h >= k){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 50088
package main

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

var INF int32 = math.MaxInt32
var INF64 int64 = math.MaxInt64

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineNum64s(bf *bufio.Reader) []int64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int64{}
	for _, field := range fields {
		num, _ := strconv.ParseInt(field, 10, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	nr := readLineNums(bf)
	N, R := nr[0], nr[1]
	if N >= 10 {
		fmt.Println(R)
	} else {
		fmt.Println(R+100*(10-N))
	}
}


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

int main()
{
    string str;
    string s[8] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
    int a[150] = {};
    int b[8][3];

    for( int i = '0'; i < '0' + 10; i++ )
        a[i] = i - '0';
    for( int i = 'a'; i < 'a' + 6; i++ )
        a[i] = i - 'a' + 10;

    for( int i = 0; i < 8; i++ )
    {
        if( i / 4 == 0 )
            b[i][0] = 0;
        else
            b[i][0] = 255;

        if( i == 0 || i == 1 || i == 4 || i == 5 )
            b[i][1]= 0;
        else
            b[i][1] = 255;   

        if( i % 2 == 0 )
            b[i][2] = 0;
        else
            b[i][2] = 255;
    }

    while( cin >> str )
    {
        if( str == "0" )
            break;
            
        int r = a[str[1]] * 16 + a[str[2]], g = a[str[3]] * 16 + a[str[4]], d = a[str[5]] * 16 + a[str[6]];
        int res = 0;
        int min = 100000000;
        for( int i = 0; i < 8; i++ )
        {
            if( ( b[i][0] - r ) * ( b[i][0] - r ) + ( b[i][1] - g ) * ( b[i][1] - g ) + ( b[i][2] - d ) * ( b[i][2] - d ) < min )
            {
                min = ( b[i][0] - r ) * ( b[i][0] - r ) + ( b[i][1] - g ) * ( b[i][1] - g ) + ( b[i][2] - d ) * ( b[i][2] - d );
                res = i;
            }
        }
        cout << s[res] << endl;
    }


    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    int n, mi = 10000, ma = 0, a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        mi = min(mi,a);
        ma = max(ma,a);
    }
    cout << ma-mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000000
#define mod 998244353

vector<ll> f(200005);
ll modpow(ll a,ll n){//繰り返し二乗法
    if(n==0) return 1;
    if(n==1) return a%mod;
    if(n%2==1) return (a*modpow(a,n-1))%mod;
    ll t=modpow(a,n/2);
    return (t*t)%mod;
}
 
ll combi(ll n,ll r){
    return f[n]*modpow(f[n-r],mod-2)%mod*modpow(f[r],mod-2)%mod;
}
/*mainに

f[0]=1;
for(ll i=1;i<=200000;i++){f[i]=(f[i-1]*i)%mod;}を入れる

*/
int main(){
    ll n,m,k,i;//m:色の種類 k:同色で隣接可能な数
    cin>>n>>m>>k;

    f[0]=1;
    for(ll i=1;i<=200000;i++){f[i]=(f[i-1]*i)%mod;}

    ll ans=0;
    for(i=0;i<=k;i++){
        ans+=((combi(n-1,i)*m)%mod)*modpow(m-1,n-1-i)%mod;
        ans%=mod;
    }
    //combi(n-1,i):分け方
    //m*modpow(m-1,n):色の割り当て方

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4648
def f():
  A=[raw_input() for _ in range(h)]
  x,y=0,0
  while 1:
    s="><v^.x".index(A[y][x])
    A[y]=A[y][0:x]+'x'+A[y][x+1:]
    if s==0: x+=1
    elif s==1: x-=1
    elif s==2: y+=1
    elif s==3: y-=1
    elif s==4: return " ".join(map(str,[x,y]))
    else: return "LOOP"
  
while 1:
  h,w=map(int,raw_input().split())
  if h==w==0: break
  print f()

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

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

using namespace std;

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

    int A, B, C;
    cin >> A >> B >> C;
    int AB = abs(A - B);
    int BC = abs(B - C);
    int CA = abs(C - A);
    cout << min(AB + BC, min(BC + CA, CA + AB)) << '\n';
}

Measured memory_bytes: 256