akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
const ll M = 500005;
ll a[M] , pos[M] , bit[M];
vii v[M];
ll n,q;
void update(ll i,ll val){
	for( ;i<=n;i += (i&-i)) bit[i] += val;
}
ll sum(ll i){
	ll res=0;
	for( ;i>0;i -= (i&-i)) res+= bit[i];
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>q;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<=q;i++){
		ll l,r;
		cin>>l>>r;
		v[r].pb({l,i});
	}
	for(ll i=1;i<=n;i++) pos[i]=-1;
	ll ans[q+1];
	for(ll i=1;i<=n;i++){
		if(pos[a[i]]!=-1) update(pos[a[i]] , -1);
		pos[a[i]] = i;
		update(i,1);
		
		for(auto x:v[i]){
			ans[x.second] = sum(i) - sum(x.first-1);
		}
	}
	
	for(ll i=1;i<=q;i++) cout<<ans[i]<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 44240
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, a;
	cin >> n >> a;
	if ((n % 500) <= a) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
function split(s,delim)
         local a = {}
         local pat = "(.-)" .. delim .. "()"
         local lastPos
         for w,z in string.gmatch(s, pat) do
             table.insert(a, w);
             lastPos=z
         end
         table.insert(a, string.sub(s, lastPos));
         return a
end



e1 = io.read()
e2 = split(e1," ")
N = tonumber(e2[1])
T = tonumber(e2[2])

max = 2000
ans = max
cnt = 0
while cnt < N do
      e3 = io.read()
      e4 = split(e3," ")
      c = tonumber(e4[1])
      t = tonumber(e4[2])
      if t <= T and c <= ans then
         ans = c
      end
      cnt = cnt + 1
end

if ans >= max then
  print("TLE")
else
  print(ans)
end


Measured memory_bytes: 760
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;

int b[maxn];

int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=2*b)
    cout<<0<<endl;
    else
    cout<<a-2*b<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  bool ok = n % 2 == 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 && s[i] != 'i') ok = 0;
    if (i % 2 == 0 && s[i] != 'h') ok = 0;
  }
  if (ok) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef VP::iterator VPI;

int main()
{
  while(true){
    int n;
    cin >> n;
    if(!n) break;

    int m, p, q, r, x[5000], y[5000];
    cin >> m >> p >> q >> r;
    for(int i = 0; i < m; i++) cin >> x[i] >> y[i];

    VP c;
    c.push_back(make_pair(1, r));

    for(int i = 0; i < m; i++){
      for(int j = 0; j < c.size(); j++){
	if(c[j].first <= x[i] && x[i] < c[j].second && c[j].second <= y[i]){
          c.push_back(make_pair(x[i] + 1, c[j].second));
	  c[j].second = x[i];
	}
	else if(x[i] < c[j].first && c[j].first <= y[i] && y[i] < c[j].second){
	  c.push_back(make_pair(y[i] + 1, c[j].second));
	  c[j].second = y[i];
	}
	else if(c[j].first <= x[i] && y[i] < c[j].second){
	  c.push_back(make_pair(x[i] + 1, y[i]));
	  c.push_back(make_pair(y[i] + 1, c[j].second));
	  c[j].second = x[i];
	}
	
	if(c[j].second <= x[i]){
	  c[j].first += n - x[i];
	  c[j].second += n - x[i];
	}
	else if(y[i] < c[j].first){
	  c[j].first += - y[i];
	  c[j].second += - y[i];
	}
	else{
	  c[j].first += - x[i] + n - y[i];
	  c[j].second += - x[i] + n - y[i];
	}    
      }
    }

    int ans = 0;
    for(int i = 0; i < c.size(); i++){
      if(p <= c[i].first && c[i].second <= q) ans += c[i].second - c[i].first + 1;
      else if(c[i].first < p && p <= c[i].second && c[i].second <= q) ans += c[i].second - p + 1;
      else if(p <= c[i].first && c[i].first <= q && q < c[i].second) ans += q - c[i].first + 1;
      else if(c[i].first < p && q < c[i].second) ans += q - p + 1;
    }
    
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int rs = 0;
    int sofar = 0;
    for (int i = 0; i < 3; i++){
        if (s[i] == 'R'){
            sofar++;
            rs = max(sofar,rs);
        }
        else{
            sofar = 0;
        }
        // ctn(i);
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3640
n = int(input())
h = [int(i) for i in input().split()]
ans = 0
def water(list):
    global ans
    if list == []:
        return 0

    if 0 in list:
        ind = list.index(0)
        left = list[:ind]
        right = list[ind+1:]
        water(left)
        water(right)

    else:
        mmin = min(list)
        ans += mmin
        for i in range(len(list)):
            list[i] = list[i] - mmin
        water(list)
water(h)
print(ans)

Measured memory_bytes: 3188
local n = io.read("*n")
local t = {}
for i = 1, n do
  table.insert(t, io.read("*n"))
end
local ans = 0
for i = 1, #t - 1 do
  local sum = 0
  for j = i + 1, #t do
    sum = sum + t[j]
  end
  ans = ans + sum*t[i]
end
print(ans)

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int maxx = 2e5 + 5;
//int a[101];
 
/*bool cmp(pair<int , int>p ,pair<int , int >q ){
	if(p.second == q.second){
		return p.first > q.first;
	}
	else{
		return p.second > q.second;
	}
} 
*/
 
 
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif 
       ios_base::sync_with_stdio(false);  
       cin.tie(0);
char ch[2];
cin>>ch;
ch[0]++;
cout<<ch;  
}  

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
    long long h, n, a;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        h -= a;
    }

    if (h <= 0)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

char c,last='.';
bool band;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    do{
        c = getchar();
        band|=(c==last);
        last = c;
    }while(last>='0' && last<='9');

    if(band) cout << "Bad";
    if(!band) cout << "Good";

    return 0;
}


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

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

int gcd(int a,int b){ return b ? gcd(b,a%b) : a;}
 
int main() {
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    int G = 0;
    rep(i,N){
        cin >> A[i];
        G = gcd(G,A[i]);
    }
    sort(A.begin(),A.end());
    int M = A[N-1];

    if(K%G == 0 && K <= M) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
} 

Measured memory_bytes: 640
k,n = map(int,input().split())
a = list(map(int, input().split()))
a.append(a[0])
total = 0
mx = 0
for i,item in enumerate(a):
    if(i + 1 >= len(a)):
        break
    d = a[i+1] - a[i]
    if(d < 0) :
        d = k - a[i] + a[i+1]
    total += d
    mx = max([d,mx])
print(total - mx)


Measured memory_bytes: 25840
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 2005;
const int logn = 12;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n, x;
int a[mxN], mn[logn][mxN];

int minQ(int l, int r) { // [l; r)
	int t = __lg(r - l);
	return min(mn[t][l], mn[t][r - (1 << t)]);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n >> x;
	rep(i, n) cin >> a[i];
	memcpy(mn[0], a, sizeof a);
	for(int l = 0; l < logn - 1; l++){
		for(int i = 0; i + (2 << l) <= n; i++){
			mn[l + 1][i] = min(mn[l][i], mn[l][i + (1 << l)]);
		}
	}
	ll ans = 1e18;
	rep(i, n){
		//makes no sense to do more than n - 1 rotations
		ll cost = (ll)(1LL * i * x);
		//now we find the min for each one
		rep(j, n){
			//we do the prefix, then the suffix
			ll lo = 1e18;
			if(j >= i){
				lo = minQ(j - i, j + 1);		
			}
			else{
				lo = minQ(0, j + 1);		
				ll rem = i - j;
				lo = min(lo, (ll)minQ(n - rem, n));
			}
			cost += lo;
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3740
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
using ll = long long;
using namespace std;
constexpr ll INF = 1LL << 60;

ll n, a[111];

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

	ll ans = 1000000;
	for (int i = 1; i <= 100; ++i) {
		ll tmp = 0;
		for (int j = 0; j < n; ++j) {
			tmp += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, tmp);
	}
	cout << ans;
	return 0;
}

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

int main(){
 	
  char str[3];
  cin>>str[0];
  int flag=1;
  for(int i=1;i<3; ++i){
    cin>>str[i];
  	if(str[i] != str[0]){
      flag = 0;
    	break;
    }
  }
  if(flag) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let s: Vec<usize> = (0..N)
        .map(|_| {
                let mut line: String = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                line.trim().parse().unwrap()
        })
        .collect();

    const M: usize = 10000;
    let mut dp = vec![false; M + 1];
    dp[0] = true;
    for i in 0..N { for j in (s[i]..(M + 1)).rev() { if dp[j - s[i]] { dp[j] = true; } } }
    let ans = (0..(M + 1)).rev().find(|&i| dp[i] && i % 10 != 0).unwrap_or(0);

    println!("{}", ans);
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;


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

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = (b - a) / 2;
    if((b-a) % 2 == 0){
        cout << ans << endl;
    }else{
        ll ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
        cout << ans << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<p> array;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        array.push_back(p(a, b));
    }
    sort(array.begin(), array.end());
    ll ans = 0, sum = 0;
    do{
        sum += array[ans].second;
        ans++;
    }while(sum < k);
    cout << array[ans - 1].first << endl;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int X = tx - sx;
  int Y = ty - sy;
  for (int i = 0; i < X; i++) cout << 'R';
  for (int i = 0; i < Y; i++) cout << 'U';
  for (int i = 0; i < X; i++) cout << 'L';
  for (int i = 0; i < Y; i++) cout << 'D';
  cout << 'D';
  for (int i = 0; i <= X; i++) cout << 'R';
  for (int i = 0; i <= Y; i++) cout << 'U';
  cout << 'L';
  cout << 'U';
  for (int i = 0; i <= X; i++) cout << 'L';
  for (int i = 0; i <= Y; i++) cout << 'D';
  cout << 'R';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define M (ll)(1e9 + 7)

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

    ll n, k;
    ll sum = 0;
    cin >> n >> k;
    ll sumn = n * (n + 1) / 2;
    for(ll i = k; i <= n; i++){
        ll sumk = i * (i - 1) / 2;
        ll nk = n - i;
        ll sumnk = nk * (nk + 1) / 2;
        // cout << sumnk << endl;
        sum += (sumn - sumnk - sumk + 2 * M + 1) % M;
        // cout << sum << endl;
    }
    cout << (sum  + 1) % M << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  rep(i, N)
    cin >> A[i];
  //ここまで入力

  //縦と横の辺
  long long edge1, edge2;

  //mappingの作成
  map<int, int> mapp;
  rep(i, N)
    mapp[A[i]]++;
    
  pair<int, int> max = make_pair(0, 0);
  //二本以上ある辺のうち，最大のものを探す
  for(auto m : mapp)
    if(m.first > max.first && m.second >= 2)
      max = m;
  mapp[max.first] = 0;
  edge1 = max.first;

  //最大長の辺で正方形が作れるとき
  if(max.second >= 4){
    cout << edge1 * edge1 << endl;
    return 0;
  }
    
  //二本以上ある辺のうち，二番目に大きいものを探す
  max = make_pair(0, 0);
  for(auto m : mapp)
    if(m.first > max.first && m.second >= 2)
      max = m;
  edge2 = max.first;

  //面積
  cout << edge1 * edge2 << endl;

  return 0;
}


Measured memory_bytes: 5376
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
 
namespace ConsoleApp
{
    class Program
    {
       
        static void Main(string[] args)
        {
            var arr = ReadLine().Split().Select(int.Parse).OrderBy(x=>x).ToArray();
            if (arr[0] == arr[1] && arr[1] != arr[2])
                WriteLine("Yes");
            else
            if(arr[0] != arr[1] && arr[1] == arr[2])
                WriteLine("Yes");
            else
            WriteLine("No");

        }

    }
 
 
    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }
 
        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }
 
 
 
		
    }
}

Measured memory_bytes: 13396
var n,a,b,s,i,m:Longint;
begin
	read(n,a,b);
	for i:=1 to n do begin
		m:=m+1;
		if i mod 10000 = 0 then m:=1
		else if i mod 1000 = 0 then m:=m-27
		else if i mod 100 = 0 then m:=m-18
		else if i mod 10 = 0 then m:=m-9;
		if (a<=m)and(m<=b)then s:=s+i;
	end;
	writeln(s);
end.


Measured memory_bytes: 128
INF = 10**9

N, M = map(int, input().split())
key = []
for _ in range(M):
    ab = list(map(int, input().split()))
    box = list(map(int, input().split()))
    index = sum(list(map(lambda x:2**(x-1), box)))
    ab.append(index)
    key.append(ab)
dp = [[key[0][0] if (i & ~key[0][2]) == 0 else INF for i in range(2**N)]]
dp[0][0] = 0
for j in range(1, M):
    next = [0 for _ in range(2**N)]
    for i in range(2**N):
        next[i] = min(dp[j-1][i], dp[j-1][(i & ~key[j][2])]+key[j][0])
    dp.append(next)
if dp[-1][-1] > 10**7:
    print(-1)
else:
    print(dp[-1][-1])



Measured memory_bytes: 102852
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n; n--;
	if(n == 1){
		cout << "2 2" << endl;
		cout << "1 2 0" << endl;
		cout << "1 2 1" << endl;
		return 0;
	}
	
	vi d;
	for(int m = n; m; m /= 2) d.pb(m % 2);
	
	int N = d.size();
	vector<tuple<int,int,int>> e;
	for(int i = 0; i < N - 1; i++){
		e.emplace_back(i, i + 1, 0);
		e.emplace_back(i, i + 1, 1 << N - i - 2);
	}
	int sum = 1 << N - 1;
	for(int i = N - 2; i > 0; i--){
		if(d[i]){
			e.emplace_back(0, N - i - 1, sum);
		}
		sum += d[i] << i;
	}
	if(d[0]) e.emplace_back(0, N - 1, sum + 1);
	e.emplace_back(0, N - 1, sum);
	
	dbg(d, sum);
	
	cout << N << " " << e.size() << endl;
	for(auto j : e) cout << get<0>(j)+1 << " " << get<1>(j)+1 << " " << get<2>(j) << endl;
	
	return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	string s1,s2,s3,s4;
	int d1=x2-x1,d2=y2-y1;
	while(d1--){
		s3+='L';
		s4+='R';
	}
	while(d2--){
		s1+='U';
		s2+='D';
	}
	cout<<s1<<s4<<s2<<s3;
	cout<<'L'<<s1<<'U'<<s4<<"RD";
	cout<<'R'<<s2<<'D'<<s3<<"LU\n";
	return 0;
}

Measured memory_bytes: 3676
package main

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

var r = bufio.NewReader(os.Stdin)

func main() {
    var a, b int
    fmt.Fscan(r, &a, &b)
    c := a*b
    d :=(a+b)*2
    fmt.Printf("%v %v\n" ,c,d)
}


Measured memory_bytes: 1144
mod=1000000007
n=int(input())
a=input()
#b=input()
#1 22
#1
d=[1]
for i in range(1,n):
    if a[i-1]==a[i]:
        d[-1]+=1
    else:
        d.append(1)
ans=[3,6][d[0]-1]
for i in range(1,len(d)):
    if d[i-1]==d[i]==2:
        t=3
    elif d[i-1]==2 and d[i]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;


int n,a,b,minimum=1e9;

int getSum(int x){
	int somme=0;
	
	while(x!=0){
		somme+=x%10;
		x/=10;
	}
	
	return somme;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    
    for(int depart=1;depart<=n/2;depart++){
		
		minimum=min(minimum,getSum(depart)+getSum(n-depart));
	
}

	cout << minimum << '\n';
    
    return 0;
}

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

#define INIT_CAP 1000

typedef struct Vector {
    int size;
    int capacity;
    int *data;
} Vector;

static inline void v_init(Vector* v) {
    v->size = 0;
    v->capacity = INIT_CAP;
    v->data = (int *)malloc(sizeof(int) * v->capacity);
}

static inline void v_double(Vector* v) {
    v->capacity *= 2;
    v->data = (int *)realloc(v->data, sizeof(int) * v->capacity);
}

static inline void v_free(Vector* v) {
    free(v->data);
}

static inline void v_push(Vector* v, int data) {
    if (v->size >= v->capacity) {
        v_double(v);
    }
    
    v->data[v->size++] = data;
}

static inline void v_dump(Vector* v) {
    for (int i=0; i<v->size; i++) {
        if (i != 0) printf(" ");
        printf("%d", v->data[i]);
    }
    printf("\n");
}

static inline void v_clear(Vector* v) {
    v->size = 0;
}

int test() {
	int n = 1;
    Vector V[n];
    for (int i=0; i<n; i++) {
        Vector v;
        v_init(&v);
        V[i] = v;
    }

	v_clear(&V[0]);
	v_push(&V[0], -228629733);
	v_dump(&V[0]);
}

int main(int argc, char *argv[]){
    int n, q, query, t, x;
    char a[18];

    fgets(a, 18, stdin); // FILE
    sscanf(a, "%d %d", &n, &q);
    
    Vector V[n];
    for (int i=0; i<n; i++) {
        Vector v;
        v_init(&v);
        V[i] = v;
    }
    
    while (q--) {
        fgets(a, 18, stdin); // FILE
        sscanf(a, "%d %d %d", &query, &t, &x);
        switch (query) {
            case 0:
                v_push(&V[t], x);
                break;
            case 1:
                v_dump(&V[t]);
                break;
            case 2:
                v_clear(&V[t]);
                break;
            default:
                printf("Invalid operation query = %d\n", query);
                exit(1);
        }
    }
    
}



Measured memory_bytes: 7868
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  string s;
  cin>>s;
  if(s.at(6)=='1'||s.at(6)=='2'||s.at(6)=='3'||s.at(6)=='4'){
    if(s.at(5)=='0'){
      cout<<"Heisei"<<endl;
    }else{
      cout<<"TBD"<<endl;
    }
  }else{
    cout<<"TBD"<<endl;
  }

  
}






Measured memory_bytes: 256
#include <cstdio>

#include <cstring>

#define rep(i,j,k) for (i=j;i<=k;i++)

using namespace std;

const int N=2e5+5;

int n,k,i,j,p,rev,a[N];

char s[N];

void trans(int x) { if (x) putchar('A'); else putchar('B'); }

int main()

{

	scanf("%d%d%s",&n,&k,s+1);

	rep(i,1,n) if (s[i]=='A') a[i]=1; else a[i]=0;

	for (j=0,p=1;j<k && p<=n;j++) {

		if (a[p]^rev) {a[p]^=1; continue;}

		rev^=1; p++;

	}

	if (j>=k) {

		rep(i,p,n) trans(a[i]^rev);

		rep(i,n+1,n+p-1) trans((n+p-i)&1);

	}

	else {

		if (n&1) {

			trans((k-j+1)&1);

			rep(i,2,n) trans(i&1);

		}

		else rep(i,1,n) trans((i+1)&1);

	}

	return 0;

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
string s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    int ans=1000;
    for (char i='a';i<='z';i++){
        int res=0;
        int l=0,r=0;
        while(l<s.length()){
            while(r<s.length()&&s[r]!=i){
                r++;
            }
            res=max(res,r-l);
            l=r+1;
            r++;
        }
        ans=min(ans,res);
    }
    cout <<ans<<"\n";
}

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

// why am I so weak

int n, k, l;
int par[2][200055];

typedef pair<int, int> P;

map<P, int> c;

int fin(int i, int j) {
	if (par[i][j] == j) return j;
	return par[i][j] = fin(i, par[i][j]);
}
int main() {
	scanf("%d %d %d", &n, &k, &l);

	for (int i = 0; i < n; i++) {
		par[0][i] = par[1][i] = i;
	}

	while (k--) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;

		par[0][fin(0, x)] = fin(0, y);
	}

	while (l--) {
		int x, y;

		scanf("%d %d", &x, &y);
		x--, y--;

		par[1][fin(1, x)] = fin(1, y);
	}

	for (int i = 0; i < n; i++) c[P(fin(0, i), fin(1, i))]++;

	for (int i = 0; i < n; i++) {
		if (i) printf(" ");
		printf("%d", c[P(fin(0, i), fin(1, i))]);
	}

	puts("");

	return 0;
}


Measured memory_bytes: 13568
#include<vector>
#include<algorithm>
#include<iostream>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
int main(){
    int N,M;
    cin>>N;
    M=N%2;
    if(M==0){
        cout<<N/2<<endl;
    }
    else{
        cout<<(N/2)+1<<endl;
    }
}

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

/*#ifndef ONLINE_JUDGE
    #include <lol.h>
#endif*/
#define mp make_pair
#define pb push_back
#define pf push_front
#define sz(a) (int)((a).size())
#define fr(i,n) for(ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define frk(i,k,n) for(ll i=k;i<n;i++)
#define rfr(i,n) for(ll i=n-1;i>=0;i--)
#define foa(i,a,n) for(ll i=0;i<n;i+=a)
#define f first
#define s second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vsort(x) sort(all(x))
#define debug cout<<"Hey Sweetie, Stop Right Here......"<<endl;

typedef long long int ll;
typedef stack<ll> stll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef set<ll> sll;
typedef multiset<ll> msll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef long double ld;
ll modmulti(ll a, ll b, ll m) {
  return ((a % m) * (b % m)) % m;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll m)
{
  if (y == 0)
    return 1;
  ll p = power(x, y / 2, m) % m;
  p = (p * p) % m;

  return (y % 2 == 0) ? p : (x * p) % m;
}
ll power2(ll x, ll y)
{
  if (y == 0)
    return 1;
  ll p = power2(x, y / 2);
  p = (p * p);

  return (y % 2 == 0) ? p : (x * p);
}
bool cmp(pair<ll, ll>&a, pair<ll, ll>&b) {
  if (a.first == b.first) return (a.second < b.second);
  else return (a.first > b.first);
}

ll bin(vll a, ll left, ll right, ll x) {
  ll mid = left + (right - left) / 2;
  if (a[mid] == x) return mid;
  if (left <= right) {
    if (a[mid] < x) return bin(a, mid + 1, right, x);
    else if (a[mid] > x) return bin(a, left, mid - 1, x);
  }
  return -1;
}
ll findclosest(ll n) {
  ll i;
  for (i = 0; i <= 64; i++) {
    if (power2(2, i) <= n) continue;
    else break;
  }
  return power2(2, i - 1);
}
ll get_signi(ll n) {
  while (n >= 10) {
    n = n / 10;
  }
  return n;
}
ll get_digits(ll n) {
  ll i = 0;
  while (n >= 10) {
    n = n / 10;
    i++;
  }
  return i;
}
bool is_palindrome(string t) {
  for (int i = 0; i < t.size() / 2; i++) {
    if (t[i] != t[t.size() - i - 1]) return false;
  }
  return true;
}
int main() {
  fastio;
  ll x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 256
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 


N = int(input())

def fact(e, n):
  i = 2
  while(n > 1 and i <= n):
    if n % i == 0:
      n //= i
      if i in e:
        e[i] += 1
      else:
        e[i] = 1
    else:
      i += 1

def cnt75(elem_v, elem_75):
  ans = 1
  for i in range(len(elem_75)):
    n = 0
    for j in elem_v:
      if j >= elem_75[i]:
        n += 1
    ans *= (n-i)
  return ans    

def cnt75_2(elem_v):
  ans = 1
  n = 0
  m = 0
  for i in elem_v:
    if i >= 4:
      n += 1
    if i >= 2:
      m += 1
  return n*(n-1)//2 * (m-2)

elem = {}
for n in range(2, N+1):
  fact(elem, n)
elem_v = sorted(elem.values())

ans = cnt75(elem_v,[74])
ans += cnt75(elem_v,[24,2])
ans += cnt75(elem_v,[14,4])
ans += cnt75_2(elem_v)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  char s[3];
  char c;
  for(int i=0;i<3;i++){
    cin >> c;
    s[i]=c-'a'+1;
  }
  if(s[0]*s[1]*s[2]==6)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] As = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Console.WriteLine(Math.Abs(As.Max() - As.Min()));
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main(){

	int a, b;

	scanf("%d %d", &a, &b);

	do{

		if (a>b)
		{
			printf("%d %d\n", b, a);
		}
		else
		{
			printf("%d %d\n", a, b);
		}

		scanf("%d %d", &a, &b);

		if (a==0&&b==0)
		{
			break;
		}

	} while (a != 0 || b != 0);

	return 0;
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, l, a[N];

int main() {
	megaRandom();
	cin >> n >> l;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int t = -1;
	for(int i = 1; i < n; i ++) {
		if(a[i] + a[i + 1] >= l) {
			t = i;
			break;
		}
	}
	if(t == -1) {
		cout << "Impossible";
		return 0;
	} 
	cout << "Possible\n";
	for(int i = 1; i < t; i ++)
		cout << i << "\n";
	for(int i = n - 1; i >= t + 1; i --)
		cout << i << "\n";
	cout << t;
	return 0;  
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = n + 1;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll m = n / i;
        ans = min(ans, abs(i - 1) + abs(m - 1));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define OR(a,b) a > b ? a : b
#define AND(a,b) a > b ? b : a
#define NOT(n) 1 - (n - 1)

int p[3];
char str[81];

int formula(int i){
	if(isupper(str[i]))
		return p[str[i] - 'P'];
	else if(isdigit(str[i]))
		return str[i] - '0';
	else if(str[i] == '-')
		return NOT(formula(i + 1));
	else if(str[i] == '('){
		int j = i;
		int cen = 0;
		while(1){
			if(str[++j] == '(')
				cen++;
			else if(str[j] == ')')
				cen--;
			if(cen == 0 && (str[j] == '*' || str[j] == '+')){
				if(str[j] == '*')
					return AND(formula(i + 1),formula(j + 1));
				else
					return OR(formula(i + 1),formula(j + 1));
			}
		}
	}
}

int main(void){
	int count;
	gets(str);
	while(str[0] != '.'){
		str[strlen(str)] = '\0';
		count = 0;
		for(p[0] = 0;p[0] <= 2;p[0]++){
			for(p[1] = 0;p[1] <= 2;p[1]++){
				for(p[2] = 0;p[2] <= 2;p[2]++){
					if(formula(0) == 2)
						count++;
				}
			}
		}
		printf("%d\n",count);
		gets(str);
	}
	return 0;
}

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

int sum[5005][5005];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int a, b, x; scanf("%d%d%d", &a, &b, &x);
		sum[a][b]++; sum[a][b + 1]--;
		sum[a + x + 1][b]--; sum[a + x + 2][b + 1]++;
		sum[a + x + 1][b + x + 2]++; sum[a + x + 2][b + x + 2]--;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)sum[i][j] += sum[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)sum[i][j] += sum[i - 1][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)sum[i][j] += sum[i - 1][j - 1];
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)cnt += (sum[i][j] > 0);
	printf("%d\n", cnt);
}

Measured memory_bytes: 101008
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

cnt=0
for i in range(N):
    if B[i] >= A[i] + A[i+1]:
        cnt +=A[i] + A[i+1]
        A[i+1]=0
    
    elif B[i] < A[i] + A[i+1] and B[i] >= A[i] :
        
        A[i+1] -= B[i]-A[i]

        cnt += A[i] + (B[i]-A[i]) 

    elif B[i] < A[i] + A[i+1] and B[i] < A[i]:
        cnt +=B[i]

print(cnt)


Measured memory_bytes: 19000
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

long double dp[310][310][310];
Int N;

long double solve(Int i, Int j, Int k) {
	if (i==0&&j==0&&k==0) {//終端条件
		return dp[i][j][k] = 0.0;
	}
	if (dp[i][j][k]>=0) {//既に探索済みならreturn
		return dp[i][j][k];
	}

	long double res = 0.0;
	if (i > 0) {
		res += solve(i - 1, j, k) * i;
	}
	if (j>0) {
		res += solve(i + 1, j - 1, k) * j;
	}
	if (k>0) {
		res += solve(i, j + 1, k - 1) * k;
	}
	res += N;
	res *= 1.0 / (i + j + k);

	return 	dp[i][j][k] = res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;

	Int a;
	Int cnt1 = 0;
	Int cnt2 = 0;
	Int cnt3 = 0;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		if (a==1) {
			cnt1++;
		}
		else if (a==2) {
			cnt2++;
		}
		else {
			cnt3++;
		}
	}

	for (Int i = 0; i < 310; i++) {
		for (Int j = 0; j < 310; j++) {
			for (Int k = 0; k < 310; k++) {
				dp[i][j][k] = -1.0;
			}
		}
	}


	long double ans = solve(cnt1, cnt2, cnt3);
	cout << fixed << setprecision(10) << ans << "\n";
}


Measured memory_bytes: 465792
import java.lang.Math.floor

// Libraries
fun string(): String = readLine()!!
fun int(): Int = readLine()!!.toInt()
fun long(): Long = readLine()!!.toLong()
fun stringList(): List<String> = readLine()!!.split(" ")
fun intList(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun longList(): List<Long> = readLine()!!.split(" ").map(String::toLong)

// 最大公約数(ユーグリットの互除法)
tailrec fun gcd(a: Int, b: Int): Int = when {
    a < b -> gcd(b, a)
    b == 0 -> a
    else -> gcd(b, a % b)
}

fun min(a: Int, b: Int): Int = if(a < b) a else b
fun min(a: Long, b: Long): Long = if(a < b) a else b
fun max(a: Int, b: Int): Int = if(a > b) a else b
fun max(a: Long, b: Long): Long = if(a > b) a else b

fun main(args: Array<String>) {
    val (A, B) = intList().map(Int::toDouble)
    // v * 0.08 = A
    // v * 0.10 = B

    for(i in 1..1009) {
        val c = floor(i * 0.08)
        val d = floor(i * 0.10)
        if(A == c && B == d) {
            println(i)
            return
        }
    }
    println(-1)
}


Measured memory_bytes: 37896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	while(n<=k){
		ans++;
		n*=2;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        static int N = 101;
        static int K;
        static int dp[][][] = new int[N][4][2];

        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String number = in.next(); // n
            K = in.nextInt(); // number of non-0 digits in a number
            init_dp();
            int digits[] = getDigitsFrom(number);
            out.print(digitOcc(0, 0, true, digits));
        }

        static int digitOcc(int index, int partialCount, boolean tight, int digits[])
        {
            if (partialCount > K) return 0; // fails condition
            if (index == digits.length) return boolToInt(partialCount == K); // out of boundary
            int answer = dp[index][partialCount][boolToInt(tight)];
            if (answer >= 0)
                return answer;

            answer = 0;
            for (int i = 0; i <= 9; ++i)
            {
                if (tight && (i > digits[index])) break; // forming too big number, current number exceeds n
                boolean nextTight = tight && (i == digits[index]);
                int nextCount = partialCount + boolToInt(i != 0); // checking condition over current digit
                answer += digitOcc(index + 1, nextCount, nextTight, digits);
            }
            dp[index][partialCount][boolToInt(tight)] = answer;
            return answer;
        }

        private int[] getDigitsFrom(String number)
        {
            int[] digits = new int[number.length()];
            int i = 0;
            for (char digit : number.toCharArray())
            {
                digits[i] = digit - '0';
                i++;
            }
            return digits;
        }

        static int boolToInt(boolean b)
        {
            return b ? 1 : 0;
        }

        static void init_dp()
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        dp[i][j][k] = -1;
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

bool seisu(dou n){
    ll m = n;
    if(m == n)return true;
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,D;
    cin >> N >> D;
    vector<vector<ll>> vec(N,vector<ll>(D));
    rep(i,N)
    rep(j,D)cin >> vec[i][j];
    ll ans = 0;
    rep(i,N - 1){
        for(ll j = i + 1;j < N;j++){
            dou cnt = 0;
            rep(k,D){
                cnt += abs(vec[i][k] - vec[j][k]) * abs(vec[i][k] - vec[j][k]);
            }
            if(seisu(sqrt(cnt)))ans++;
        }
    }
    cout << ans << endl;
}

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

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

using namespace std;
using lint = long long;

unsigned euclid_gcd(unsigned a, unsigned b)
{
  if(a > b) return euclid_gcd(b, a);
  unsigned r;
  while(r = a % b){
    a = b;
    b = r;
  }
  return b;
}

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    if(find(a.begin(), a.end(), 1) == a.end()){
        cout << -1 << endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(a[i] == cnt+1){
            cnt++;
        }
    }
    cout << N - cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
def read(): return list(map(int, input().split()))


A = set([1, 3, 5, 7, 8, 10, 12])
B = set([2])
C = set([4, 6, 9, 11])

x, y = read()
if x in A and y in A or x in B and y in B or x in C and y in C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    string s; cin>>s;
    ll n=s.size();
    ll tmp=0, res=0;
    for(ll i=n-1; i>=0; i--){
        if(s[i]=='W') continue;
        res+=(n-1-tmp)-i;
        tmp++;
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

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

    int i;
    for(i=0;i!=s.size();i++)
    {
        if(i%2)
        {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
            {
                cout<<"No";
                exit(0);
            }
        }

        else
        {
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
            {
                cout<<"No";
                exit(0);
            }
        }
    }

    cout<<"Yes";

    return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

a,b,c=map(int,input().split())
S=a+b+c
if S>=22:
    print("bust")
else:
    print("win")

Measured memory_bytes: 38512