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

int n, m;
vector<vector<double>> v, dp;
vector<vector<vector<double>>> sum;

long double solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> m >> n;
  v.assign(m, vector<double>(n + 1, 0.0L));
  for(int i = 0; i < m; ++i)
    for(int j = 0; j < n; ++j) cin >> v[i][j];
  cout << solve() << endl;
  return 0;
}

long double solve() {
  dp.assign(2, vector<double>(1LL << m, 0));
  sum.assign(2, vector<vector<double>>(
                    m, vector<double>(1LL << m, 0.0L)));
  for(int i = n; i >= 0; --i)
    for(int j = 0; j < (1LL << m); ++j) {
      dp[i % 2][j] = 0;
      if(i == n)
        dp[i % 2][j] = 1;
      else
        for(int k = 0; k < m; ++k) {
          sum[i % 2][k][j] =
              sum[(i + 1) % 2][k][j] * v[k][i];
          if(j >> k & 1)
            dp[i % 2][j] =
                max(dp[i % 2][j],
                    sum[i % 2][k][j - (1LL << k)]);
        }
      for(int k = 0; k < m; ++k)
        if(!(j >> k & 1))
          sum[i % 2][k][j] += dp[i % 2][j] * (1 - v[k][i]);
    }
  return dp[0][(1LL << m) - 1];
}


Measured memory_bytes: 29212
#include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

int flag = 0;

void printUruyear(int year_begin, int year_end)
{

    if(flag == 1){
        std::cout << std::endl;
    }
    flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

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

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    int r = (t + 0.5)/a;
    int sum = b * r;
    cout << sum << endl;
}

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

int main()
{
	int a,b;
	string result="";

	cin >> a >> b;

	int min, max;

	if (a < b) {
		min = a;
		max = b;
	}
	else {
		min = b;
		max = a;
	}

	for (int n = 0; n < max; n++) {
		result += to_string(min);
	}

	cout << result<<endl;
}



Measured memory_bytes: 256
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

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

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = mul(ans, i);
    }
    return ans;
}

int main() {
    int A, B;
    cin >> A >> B;
    A = (A + 11) % 13;
    B = (B + 11) % 13;
    if (A > B) cout << "Alice" << endl;
    else if (A == B) cout << "Draw" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int gcd (int x, int y) {
  if(x==0) return y;
  return gcd(y%x,x);
}

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

  ll ans = 0;

  reps(a, k)reps(b, k)reps(c, k){
    ans += gcd(a, gcd(b, c));
  }

  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int red=0;
    int blue=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')red++;
        else blue++;
    }
    cout << min(red,blue)*2 << endl;
}

Measured memory_bytes: 512
import numpy as np

N,K = map(int, input().split())
S = [int(x) for x in input()]

memo = np.zeros(10**5+1, dtype = np.int64)
W = min(2*K, 10**5)

current = 1 # 最初は1が0個ある
p = 0

for x in S:
  if x == current:
    memo[p] += 1
  else:
    current = 1 - current
    p += 1
    memo[p] += 1

ans = memo[:W+1].sum()
x = ans
for r in range(2,10**5+1,2):
  if r+W > 10**5:
    break
  x = x-memo[r-2]-memo[r-1]+memo[r+W]+memo[r+W-1]
  if x > ans:
    ans = x

print(ans)

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

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

using namespace std;

int main()
{
	int N;
	int first[101], second[101], third[101];
	int num[200][3], ten[200];

	//?????????
	for (int i = 0; i < 101; i++)
	{
		first[i] = second[i] = third[i] = 0;
	}

	cin >> N;

	//?????????
	rep(i, N)
	{
		ten[i] = 0;
	}

	rep(i, N)
	{
		cin >> num[i][0] >> num[i][1] >> num[i][2];

		first[num[i][0]]++;
		second[num[i][1]]++;
		third[num[i][2]]++;
	}

	rep(i, N)
	{
		if (first[num[i][0]] == 1)
		{
			ten[i] += num[i][0];
		}
		if (second[num[i][1]] == 1)
		{
			ten[i] += num[i][1];
		}
		if (third[num[i][2]] == 1)
		{
			ten[i] += num[i][2];
		}
	}

	rep(i, N)
	{
		cout << ten[i] << endl;
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
const int maxn=1;
char s[55][55];
int sx[4]={1,0,0,-1};
int sy[4]={0,-1,1,0};
int m,n;
bool sea(int x,int y)
{
    int i,a,b;
    for(i = 0;i<4;i++)
    {
        a=x+sx[i];
        b=y+sy[i];
        if(a>=0&&a<m&&b>=0&&b<n)
        {
            if(s[a][b]=='#')
                return true;
        }
    }
    return false;
}
int main()
{
    int i,j;
    bool f=true,ff=true;
  scanf("%d%d",&m,&n);
   for(i = 0;i<m;i++)
    scanf("%s",s[i]);
   for(i =0;i<m&&ff;i++)
    for(j = 0 ;j< n;j++)
   {
       if(s[i][j]=='#')
       if(!sea(i,j))
       {
           f=false;
           //cout<<i<<' '<<j<<endl;
           ff=false;
           break;
       }
   }
   if(!f)
    printf("No\n");
   else
    printf("Yes\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int i,n,cnt=0;
	cin>>n;
	for(i=1;i<=n;i++){
		if(i%3&&i%5){
			cnt+=i;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll t,n,m,i,a,b;
    cin>>a>>b;
    for(i=1;i<4;i++)
    {
        if(a!=i&&b!=i)
        {
            cout<<i;
            break;
        }
    }   
 }
    


Measured memory_bytes: 3592
N, X, Y = map(int, input().split())

d = dict(zip(range(1, N), [0]*(N-1)))
for i in range(1, N):
  for j in range(i+1, N+1):
    l1 = j - i
    l2 = abs(X - i) + 1 + abs(Y - j)
    l = min(l1, l2)
    d[l] += 1

for k in d:
  print(d[k])

Measured memory_bytes: 3572
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
ookii=[0]*n
num=[0]*n
for i in range(n):
    for j in range(n):
        if a[i]<a[j] and i!=j:
            ookii[i]+=1
            if i>j:
                num[i]+=1
ans=0
for i in range(n):
    ans+=k*(2*num[i]+(k-1)*ookii[i])//2
    ans%=1000000007
print(ans)

Measured memory_bytes: 41836
using System;

namespace C___Remainder_Minimization_2019
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var l = int.Parse (input[0]);
            var r = int.Parse (input[1]);
            var min = int.MaxValue;
            for (var i = l; i < r; i++)
            {
                for (var j = i + 1; j <= r; j++)
                {
                    min = Math.Min (min, (i % 2019) * (j % 2019) % 2019);
                    if (min == 0)
                        goto END;
                }
            }
            END:
                Console.WriteLine (min);
        }
    }
}

Measured memory_bytes: 11092
import numpy as np 
a,b,x=map(int,input().split())
hanbun=a*a*b/2
if x<hanbun:
    teihen = x/(a*b/2)
    katamuki = b/teihen
    kakudo = np.rad2deg(np.arctan(katamuki))
else:
    teihen = (a*a*b-x)/(a*a/2)
    katamuki = teihen/a
    kakudo = np.rad2deg(np.arctan(katamuki))
print(kakudo)

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

using namespace std;

int main(){
	long long n, d, count = 0;
	long long a, b;
	cin >> n >> d;
	for(int i = 0; i < n; ++i){
		cin >> a >> b;
		if(a * a + b * b <= d * d){
			count++;
			}
		}
	cout << count;
	return 0;
}


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

int main(){
	int n,a,count=0,ti;
	cin >> n;
	cin >> a;
	while(a%2==0){
		count++;
		a=a/2;
	}
	ti = count;
	for(int i=1;i<n;i++){
		count = 0;
		cin >> a;
		while(a%2==0){
			count ++;
			a=a/2;
		}
		ti = min(ti,count);
	}
	cout << ti << endl;
	return 0;
}

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

int main(){
  long N,M,answer;
  cin>>N>>M;
  if( N-M <=1 && -1<= N-M ){
    int mod = 1000000007;
    answer = 1;
    for(int i=1;i<=N;i++){
      answer = (answer*i)%mod;
    }
    for(int j=1;j<=M;j++){
      answer = (answer*j)%mod;
    }
    if(N-M==0){
      answer =(answer*2)%mod;

    }
    cout<<answer<<endl;

  }else{
    cout<<0<<endl;
  }
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

#define LEN 200000
int main(void){
  int N;
  scanf("%d",&N);
  int a[LEN+1]={0};
  int tmp=0,i;
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    tmp^=a[i];
  }

  for(i=0;i<N;i++)
    printf("%d ",a[i]^tmp);
  printf("\n");
   return 0;
}


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

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

  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];
  rep(i, 0, n - 1) cin >> c[i];

  int ans = accumulate(b.begin(), b.end(), 0);
  rep(i, 0, n - 1) {
    if (a[i + 1] - a[i] == 1) ans += c[a[i] - 1];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	// vi a(5);
	int x, y;
	cin >> x >> y;
	if (y&1) {
		cout << "No\n";
		return 0;
	}
	if (2*x <= y && y <= 4*x) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3640
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> a, b;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x >= 0) {
      a.push_back(x);
    } else {
      b.push_back(-x);
    }
  }
  reverse(b.begin(), b.end());
  int ans = 1'000'000'000;
  for (int it = 0; it < 2; ++it) {
    for (int i = 0; i < (int)a.size() && i + 1 <= m; ++i) {
      int rem = m - i - 1;
      if (rem > (int)b.size()) {
        continue;
      }
      int cur = a[i];
      if (rem > 0) {
        cur *= 2;
        cur += b[rem - 1];
      }
      ans = min(ans, cur);
    }
    a.swap(b);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

long gcd(long a, long b)
{
	while(b)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}

int main()
{
	fio;
	long a, b;
	cin >> a >> b;
	long g = gcd(a, b);
	int ans = 1;
	for(int i=2; i*1ll*i<=g; i++)
	{
		if(g % i == 0)
		{
			ans++;
			while(g % i == 0)
				g /= i;
		}
	}
	if(g > 1)
		ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int arr[][] = new int[m][2];
		for (int i=0; i<m; i++){
			arr[i][0] = scanner.nextInt();
			arr[i][1] = scanner.nextInt();
		}

		arr = sort(arr);

		int ans = 0;
		int begin = 0;
		int end = n;
		for(int i=0; i<m; i++){
			begin = Math.max(begin, arr[i][0]);
			end = Math.min(end, arr[i][1]);
			if (begin>=end) {
				ans++;
				begin = arr[i][0];
				end = arr[i][1];
			}
		}
		ans++;
		System.out.println(ans);

	}

	static int[][] sort(int[][] arr){
		Arrays.sort(arr, (o1, o2) -> {
			if (o1[0] == o2[0]) {
				return o1[1] - o2[1];
			} else {
				return o1[0] - o2[0];
			}
		});
		return arr;
	}

}

Measured memory_bytes: 95060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int n;
	int k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k - 1] += 32;
	cout << s << endl;
}


Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　    ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
}


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

class Cube {
public:
  int f[6];
  Cube(){}
  void roll_z() {
    roll(1,2,4,3);
  }
  void roll_y() {
    roll(0,2,5,3);
  }
  void roll_x() {
    roll(0,1,5,4);
  }
  void roll(int i,int j,int k,int l) {
    int t = f[i];
    f[i] = f[j];
    f[j] = f[k];
    f[k] = f[l];
    f[l] = t;
  }
};

bool eq(Cube c1,Cube c2) {
  for (int i=0; i<6; i++) {
    if (c1.f[i]!=c2.f[i]) {
      return false;
    }
  }
  return true;
}

bool equal(Cube c1,Cube c2) {
  for (int i=0; i<6; i++) {
    for (int j=0; j<4; j++) {
      if (eq(c1,c2)) {
        return true;
      }
      c1.roll_z();
    }
    if (i%2==0) {
      c1.roll_y();
    } else {
      c1.roll_x();
    }
  }
  return false;
}

int main(void) {
  Cube c1, c2;
  for (int i=0; i<6; i++) {
    cin >> c1.f[i];
  }
  for (int i=0; i<6; i++) {
    cin >> c2.f[i];
  }
  if (equal(c1,c2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int> a;
    int N;
    cin >> N;
    while(N--) {
        int b;
        cin >> b;
        if(a.find(b) != a.end()) a.erase(b);
        else a.insert(b);
    }
    cout << a.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
param_n = int(input())
param_str = str(input())

#print(param_n)print(param_str)

list_param_str = list(param_str)

#print(list_param_str)

param_R_count = list_param_str.count('R')

#print(param_R_count)

param_R_count_before_separation = list_param_str[0:param_R_count].count('R')

#
print(param_R_count - param_R_count_before_separation)

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

vector<vector<int>> dp(5010, vector<int>(5010, 0));

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    rrep(i, n){
        rrep(j, n){
            if(s[i] != s[j]){
                dp[i][j] = 0;
            }else{
                dp[i][j] = dp[i + 1][j + 1] + 1;
            }
        }
    }
    int ans = 0;
    rep(i, 0, n){
        rep(j, 0, n){
            if(i >= j) continue;
            else{
                int tmp = min(dp[i][j], j - i);
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 98432
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>

using namespace std;

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

int N;

int main() {
	cin >> N;
	vector<vector<int> > to(N), cost(N);
	vector<int> ans(N, -1);//-1は未塗装
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		to[u].push_back(v);
		to[v].push_back(u);
		cost[u].push_back(w);
		cost[v].push_back(w);
	}
	queue<int> que;
	ans[0] = 0;//頂点0を0で塗る
	que.push(0);

	while (!que.empty()) {
		int v = que.front();
		que.pop();
		int len = to[v].size();
		for (int i = 0; i < len; i++) {
			int u = to[v][i];
			int w = cost[v][i];
			if (ans[u] != -1) { continue; }
			ans[u] = (ans[v] + w) % 2;
			que.push(to[v][i]);
		}
	}

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

Measured memory_bytes: 11904
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
#define pb(v,e) v.push_back(e)

string sint(int i){
   stringstream buf;
   buf<<i;
   return buf.str();
}

/*
   ifstream fin("input.txt");
   ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int sol[15];

int alias[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

string print(int i,int e){
   if( i == -1)return "";
   if(e)return print(sol[i],0)+sint(alias[i])+"\n";
   return print(sol[i],0)+sint(alias[i])+" ";
}

string do_bfs(int j,int k){

   memset(sol,-1,sizeof(sol));
   sol[j] = -1;
   int stop = j;

   while(alias[stop] != k){
      int nx = stop;
      stop = (nx+1)%15;
      sol[stop] = nx;
   }

   return print(stop,1);
}

int main(){
   int u;
   scanf("%d",&u);
   rep(a,u){
      string sol = "1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 0 0";
      
      int j,k;
      scanf("%d %d",&j,&k);

      rep(i,15){
         if( alias[i] == j){
            string aux = do_bfs(i,k);
            if( sol.size() > aux.size()) sol = aux;
         }
      }
      printf("%s",sol.c_str());
   }
   return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>
  
int main(){
   int m, min, minn, i, j, n, c;
   int a[100];
   c=0;
   scanf("%d",&n);
   for(i=0;i < n;i++){
      scanf("%d",&a[i]);
   }
   for(i=0;i < n-1;i++){
      m=a[i];
      min=a[i];
      minn=i;
      for(j=i+1;j < n;j++){
         if(min > a[j]){
            min=a[j];
            minn=j;
         }
      }
      if(i != minn){
         a[i]=a[minn];
         a[minn]=m;
         c++;
      }
   }
   printf("%d",a[0]);
   for(i=1;i < n;i++){
      printf(" %d",a[i]);
   }
   printf("\n%d\n",c);
   return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int n, m, R; cin >> n >> m >> R;
  vector<int> r(R); FOR(i,0,R) cin >> r[i];
  sort(r.begin(), r.end());
  int a[m], b[m], c[m], dist[n+1][n+1];
  FOR(i,0,m) cin >> a[i] >> b[i] >> c[i];
  FOR(i,0,n+1){
    FOR(j,0,n+1){
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = 1e9;
    }
  }
  // 連結してるとこはcを代入
  FOR(i,0,m){
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  // ワーシャルフロイド
  FOR(k,1,n+1) FOR(i,1,n+1) FOR(j,1,n+1) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = 1e9;
  do {
    int d = 0;
    FOR(i,0,R-1) d += dist[r[i]][r[i+1]];
    ans = min(ans, d);
  } while(next_permutation(r.begin(), r.end()));
  cout << ans << endl;
  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<ll> A(N-1),sum(N);
    vector<vector<ll>> B(N,vector<ll>(M));
    for (int i=0;i<N-1;++i) cin >> A[i];
    for (int i=0;i<N-1;++i) sum[i+1]=sum[i]+A[i];
    for (int i=0;i<N;++i){
        for (int j=0;j<M;++j){
            cin >> B[i][j];
        }
    }
    vector<vector<ll>> imos(N+1,vector<ll>(N+1,0));
    for (int j=0;j<M;++j){
        priority_queue<pair<ll,int>> pq;
        for (int i=0;i<N;++i) pq.emplace(B[i][j],i);
        set<int> wall;
        while(!pq.empty()){
            auto p=pq.top(); pq.pop();
            int idx=p.second,l=-1,r=N;
            auto itr=wall.upper_bound(idx);
            if (itr!=wall.end()) r=*itr;
            if (itr!=wall.begin()) l=*(--itr);
            imos[l+1][idx]+=p.first; imos[idx+1][r]+=p.first;
            imos[l+1][r]-=p.first; imos[idx+1][idx]-=p.first;
            wall.emplace(idx);
        }
    }
    ll ans=0;
    for (int i=0;i<=N;++i){
        for (int j=0;j<N;++j){
            imos[i][j+1]+=imos[i][j];
        }
    }
    for (int j=0;j<=N;++j){
        for (int i=0;i<N;++i){
            imos[i+1][j]+=imos[i][j];
        }
    }
    for (int i=0;i<N;++i){
        for (int j=i;j<N;++j){
            ans=max(ans,imos[i][j]-sum[j]+sum[i]);
        }
    }
    cout << ans << '\n';
}

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

map<int, int> memo;

long long mod_pow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

void solve(int N, std::string X){
    int dp[N+1] = {};
    for (int i = 1; i <= N; i++) {
        int pc = __builtin_popcount(i);
        dp[i] = dp[i % pc] + 1;
        // cout << i << ":" << dp[i] << " ";
    }
    // cout << endl;

    int on = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            on++;
        }
    }
    // cout << "on: " << on << endl;
    int mod1 = on - 1;
    int mod2 = on + 1;

    int sum1 = 0;
    int sum2 = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            if (mod1) {
                sum1 = (sum1 + mod_pow(2, N - 1 - i, mod1)) % mod1;
            }
            sum2 = (sum2 + mod_pow(2, N - 1 - i, mod2)) % mod2;
        }
    }

    for (int i = 0; i < N; i++) {
        int first;
        if (X[i] == '1') {
            if (mod1) {
                first = (sum1 - mod_pow(2, N - 1 - i, mod1) + mod1) % mod1;
                // cout << first << "/" << mod1 << ":";
                cout << dp[first] + 1 << endl;
            } else {
                cout << 0 << endl;
            }
        } else {
            first = (sum2 + mod_pow(2, N - 1 - i, mod2) + mod2) % mod2;
                // cout << first << "/" << mod2 << ":";
            cout << dp[first] + 1 << endl;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int N;
    scanf("%d",&N);
    std::string X;
    std::cin >> X;
    solve(N, X);
    return 0;
}


Measured memory_bytes: 4592
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N;
LL C, K, T[112345];
LL ans;

int main()
{
	in >> N >> C >> K;
	rep(i, N) { in >> T[i]; }

	std::sort(T, T + N);
	LL first = T[0], num = 0;
	rep(i, N)
	{
		++num;
		if (T[i] - first > K || num > C)
		{
			++ans;
			first = T[i];
			num = 1;
		}
	}

	out << ans + 1 << std::endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int a,b,k;
  cin>>a>>b>>k;

  int cnt=0,ans=min(a,b)+1;
  while(cnt!=k)
  {
    ans--;
    if(a%ans==0 && b%ans==0)cnt++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
cla = []
num = []
fee = []
f_am=200
f_pm=300
while True:
    try:
        f = input().strip().split()
        cla.append(f[0])
        num.append(int(f[1]) + int(f[2]))
        fee.append(int(f[1])*f_am + int(f[2])*f_pm) 
    except EOFError:
        break

for i in range(len(cla)):
    print('%s %d %d' % (cla[i], num[i], fee[i]) )

Measured memory_bytes: 7508
N = int(input())
lst = []
for i in range(N):
	a, b = map(str, input().split())
	lst.append([a, int(b), i+1])

lst.sort(key = lambda x : x[1], reverse = True)
lst.sort(key = lambda x : x[0])

for i in range(N):
	print(lst[i][2])


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){

    int N,i;
    double ans,bunbo=0,A[100];

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

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

    ans = (1/bunbo);

    printf("%f",ans);
    return 0;
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
//---------------------------------------------------------------
int main(){
  int N,ma,mi;
  ll ans;
  cin>>N;
  ma = -2000;
  mi = 2000;
  vec a(N);
  rep(i,N){
    cin>>a.at(i);
    if(ma<a.at(i)){
      ma = a.at(i);
    }
    if(mi>a.at(i)){
      mi = a.at(i);
    }
  }
  ans = 20000000;
  if(ma==mi){
    ans = 0;
  }else{
  REP(i,mi,ma+1){
    int s = 0;
    rep(j,N){
        s+=(a.at(j)-i)*(a.at(j)-i);
    }
    if(s<ans)ans=s;
  }
}


  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
ll f[55][55][2555];
int main() {
	ios_base::sync_with_stdio(false);
	ll n,a; cin>>n>>a;
	ll v[55];
	for (ll i=0;i<n;i++) cin>>v[i];
	f[0][0][0]=1;
	for (ll x=0;x<n;x++) {
		ll val=v[x];
		for (ll c=0;c<=n;c++) {
			for (ll y=0;y<2555;y++) {
				ll ways=f[x][c][y];
				f[x+1][c][y]+=ways;
				if(y+val<2555) f[x+1][c+1][y+val]+=ways;
			}
		}
	}
	ll ans=0;
	for (ll c=1;c<=n;c++) {
		ll want=c*a;
		ans+=f[n][c][want];
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 52352
#include<bits/stdc++.h>
#define ll long  long
using namespace std;
ll a[5000];
ll dp[5000][5000]={0};
ll n;
ll solve(ll s=0,ll l=n-1){
	if(s>l){
		return 0;
	}
	if(dp[s][l]){
		return dp[s][l];
	}
	dp[s][l]=max(a[s]-solve(s+1,l),a[l]-solve(s,l-1));
	return dp[s][l];
	
	
}
int main(){
	cin>> n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<solve();
	
	
	return 0;
	
}

Measured memory_bytes: 118528
use std::cmp::min;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let (n, x) = {
        let t = read_vec::<i64>();
        (t[0], t[1])
    };
    let ans = solve(n,x);
    println!("{}",ans);
}

fn solve(n:i64,x:i64) -> i64 {
    if n == 0 {
        return if x >= 1 { 1 } else { 0 };
    }

    let mut sum = 1 ;
    for _ in 0..n {
        sum = 3 + sum * 2;
    }
    if x == 1 {
        0
    } else if x <= sum /2 {
        solve(n-1,x-1)
    } else if x == sum /2 + 1 {
        solve(n-1,x-1) + 1
    } else {
        let mut p = 1;
        for _ in 0..n-1 {
            p = 1 + p *2;
        }
        solve(n-1,x - sum/2 - 1) + 1 + p
    }

}


Measured memory_bytes: 4352
//?????????????????????, ?????°???????±\??´?????¨?????????????????\????????\?????????????????´??°??????
//cnt[i] = ??????[i, i + 1)?????????????????°???PC????????£????????????
//cnt[i]???????????????????????£???????????§????????????????????????imos????????¨????????°???????????????
//?????°???????±\??´??????PC??????, ?????°??????0/?????°??¢??????1?????§???????????????????????¨?????????????????????->???????????????????????????

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void solve() {
	int row_num;
	int t[1000], pc_id[1000], stu_id[1000], is_login[1000];
	int question_num;
	int start, last, stu;
	int i, j;
	
	cin >> row_num;
	for (i = 0; i < row_num; i++) {
		cin >> t[i] >> pc_id[i] >> stu_id[i] >> is_login[i];
	}
	
	cin >> question_num;
	for (i = 0; i < question_num; i++) {
		cin >> start >> last >> stu;
		
		int cnt[1300] = {0};
		for (j = 0; j < row_num; j++) {
			if (stu_id[j] != stu) continue;
			if (is_login[j]) cnt[t[j]]++;
			else cnt[t[j]]--;
		}
		
		for (j = 1; j < 1300; j++) {
			cnt[j] += cnt[j - 1];
		}
		
		int ans = 0;
		for (j = start; j < last; j++) {
			ans += (cnt[j] > 0);
		}
		cout << ans << endl;
	}
}

int main() {
	int pc_num, stu_num;
	while (cin >> pc_num >> stu_num) {
		if (!pc_num) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 3096
N,M,P = map(int,input().split())

adj = [list() for _ in range(N)]
inv = [list() for _ in range(N)]
edges = []

for _ in range(M):
    a,b,c = map(int,input().split())
    inv[b-1].append(a-1)
    adj[a-1].append(b-1)
    edges.append((a-1,b-1,P-c))

stack = [N-1]
reachable1 = {N-1}
while stack:
    v = stack.pop()
    for u in inv[v]:
        if u not in reachable1:
            stack.append(u)
            reachable1.add(u)

stack = [0]
reachable2 = {0}
while stack:
    v = stack.pop()
    for u in adj[v]:
        if u not in reachable2:
            stack.append(u)
            reachable2.add(u)

reachable = reachable1 & reachable2
edges = [(a,b,w) for a,b,w in edges if a in reachable and b in reachable]

dist = [float('inf')]*N
dist[0] = 0

for i in range(len(reachable)-1):
    for a,b,w in edges:
        dist[b] = min(dist[a]+w, dist[b])

# negative cycle
for a,b,w in edges:
    if dist[b] > dist[a] + w:
        print(-1)
        break
else:
    print(max(0,-dist[-1]))

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

int main() {
  int64_t N;
  cin >> N;
  if(N % 2 != 0) {
    cout << 0 << endl;
  }
  else {
    int64_t count = 0;
    int64_t a = 10;
    while(N >= a) {
      count += N / a;
      a *= 5;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 200005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int X = 200005;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
}

//3. Structure or classes
struct Value{
    int value=-1;
};
//3. Ends here

//1. Data structures declaration here

//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    for (int zz = 0; zz < t; zz++)
    {
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;
    ll tot;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    tot=a[0];
    for(int i=1;i<n;i++){
        tot = tot^a[i];
    }
    //cout<<tot<<"\n";
    for(int i=0;i<n;i++){
        int ans = tot^a[i];
        cout<<ans<<" ";
    }
}



Measured memory_bytes: 4404
from copy import deepcopy
N=int(input())
a=list(map(int,input().split()))
b=deepcopy(a)
b.sort()
B1=b[N//2-1]
B2=b[N//2]
for i in a:
    if i<=B1:
        print(B2)
    else:
        print(B1)


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

#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)


// template
char tempatas[] = {'.', '.', '#', '#'};
char tempbawah[] = {'.', '#', '.', '#'};


int main() {
//	ios_base::sync_with_stdio(0);
//	cin.tie(0);
	
	int n;
	scanf("%d", &n);
	
	char in_buffer[10] = {};
	
	deque<char> atas;
	deque<char> bawah;
	
	deque<char> printatas;
	deque<char> printbawah;
	
	for(int i = 0; i < n; i++) {
		
		atas.push_front('.');
		bawah.push_front('.');
		
		bool check = false;
		for(int j = 0; j < 4; j++) {
			
			atas.pop_front();
			bawah.pop_front();
			atas.push_front(tempatas[j]);
			bawah.push_front(tempbawah[j]);
			
			printatas = atas;
			printbawah = bawah;
			
			while(!printatas.empty()) {
				printf("%c", printatas.front());
				printatas.pop_front();
			}
			printf("\n");
			while(!printbawah.empty()) {
				printf("%c", printbawah.front());
				printbawah.pop_front();
			}
			printf("\n");
			fflush(stdout);
			
			
			scanf("%s", in_buffer);
			if(strcmp(in_buffer, "end") == 0) {
				return 0;
			} else if(strcmp(in_buffer, "T") == 0) {
				check = true;
				break;
			}
		}
		
		if(!check) {
			break;
		}
	}
	atas.pop_front();
	bawah.pop_front();
	
	for(int i = 0; i < n; i++) {
		
		atas.push_back('.');
		bawah.push_back('.');
		
		bool check = false;
		for(int j = 0; j < 4; j++) {
			
			atas.pop_back();
			bawah.pop_back();
			atas.push_back(tempatas[j]);
			bawah.push_back(tempbawah[j]);
			
			printatas = atas;
			printbawah = bawah;
			
			while(!printatas.empty()) {
				printf("%c", printatas.front());
				printatas.pop_front();
			}
			printf("\n");
			while(!printbawah.empty()) {
				printf("%c", printbawah.front());
				printbawah.pop_front();
			}
			printf("\n");
			
			fflush(stdout);
			
			scanf("%s", in_buffer);
			if(strcmp(in_buffer, "end") == 0) {
				return 0;
			} else if(strcmp(in_buffer, "T") == 0) {
				check = true;
				break;
			}
		}
		
		if(!check) {
			break;
		}
	}
}


Measured memory_bytes: 724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <queue>
typedef long long lint;
const int N=2e5+5;
int n,nxt[N][26];
char str[N];
bool vis[N];
struct data{
	int pos,len;
};

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

void oput(const int *fr,const int pos,const char end){
	static char buk[N];
	char *pt=buk;
	*pt++=end;
	for(int i=pos; i; i=fr[i]) 
		*pt++=str[i];
	while(pt!=buk)
		putchar(*--pt);
	puts("");
}

void solve(){
	static int fr[N];
	std::queue <data> q;
	q.push((data){0,0});
	while(!q.empty()){
		data d=q.front();
		q.pop();
		for(int i=0; i<26; ++i){
			int y=nxt[d.pos][i];
			if(!y){
				oput(fr,d.pos,i+'a');
				return;
			}
			if(!vis[y]){
				vis[y]=1;
				fr[y]=d.pos;
				q.push((data){y,d.len+1});
			}
		}
	}
	assert(0);
}

int main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=n-1; i>=0; --i){
		memcpy(nxt[i],nxt[i+1],sizeof(nxt[i]));
		nxt[i][str[i+1]-'a']=i+1;
	}
	solve();
	return 0;
}


Measured memory_bytes: 21760
#include<bits/stdc++.h>
using namespace std;
int a,b,ans,f[60];
int main(){
	cin>>a>>b;
	for(int i=0;i<a;i++) cin>>f[i];
	sort(f,f+a);
	for(int i=0;i<=b;i++){
		ans+=f[a-i];
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
 
	int n;
	cin>>n;
	int val=0;
	while(n>0){
		if((n%10)==7)
			val=1;
		n=n/10;
	}
	if(val)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 
 	return 0;
}


Measured memory_bytes: 3608
n = int(input())

for i in range (1, n+1):
    if i%3==0:
        print(" %d" %i, end="")
    else:
        x = i
        while(x):
            if x%10==3:
                print(" %d" %i, end="")
                break
            x//=10
print()

            


Measured memory_bytes: 5868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int x[N], y[N];
    vector<int> d1, d2;
    rep(i, N){
        cin >> x[i] >> y[i];
        d1.pb(x[i]+y[i]), d2.pb(x[i]-y[i]);
    }
    sort(all(d1)), sort(all(d2));
    int ans = 0;
    rep(i, N){
        int a = x[i]+y[i], b = x[i]-y[i];
        chmax(ans, abs(a-d1.front())), chmax(ans, abs(a-d1.back()));
        chmax(ans, abs(b-d2.front())), chmax(ans, abs(b-d2.back()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6656
#include <cstdio>           // printf(), scanf()
#include <cmath>            // fabs(), sqrt()
#include <algorithm>        // min()

using namespace std;
#define equals(a, b) (fabs((a) - (b)) < EPS)

static const double EPS = 1e-10;
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}
	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
};

struct Segment
{
	Point p1, p2;
};

typedef Point Vector;
typedef Segment Line;

double
norm(Vector a)
{
	return a.x * a.x + a.y * a.y;
}

double
abs(Vector a)
{
	return sqrt(norm(a));
}

double
dot(Vector a, Vector b)
{
	return a.x * b.x + a.y * b.y;
}


double
cross(Vector a, Vector b)
{
	return a.x * b.y - a.y * b.x;
}

int
ccw(Point p0, Point p1, Point p2)
{
	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;

	if (cross(a, b) < -EPS)
		return CLOCKWISE;

	if (dot(a, b) < -EPS)
		return ONLINE_BACK;

	if (norm(a) < norm(b))
		return ONLINE_FRONT;

	return ON_SEGMENT;
}

bool
intersect(Point p1, Point p2, Point p3, Point p4)
{
	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
	        ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool
intersect(Segment s1, Segment s2)
{
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

double
getDistanceLP(Line l, Point p)
{
	return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}

double
getDistanceSP(Segment s, Point p)
{
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0)
		return abs(p - s.p1);

	if (dot(s.p1 - s.p2, p - s.p2) < 0.0)
		return abs(p - s.p2);

	return getDistanceLP(s, p);
}

double
getDistance(Segment s1, Segment s2)
{
	if (intersect(s1, s2))
		return 0.0;

	return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)), min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}

int
main(int argc, char** argv)
{
	int n;

	scanf("%d", &n);
	while (n--)
	{
		int s1x, s1y, s2x, s2y;
		int t1x, t1y, t2x, t2y;
		Segment s1, s2;

		scanf("%d %d %d %d %d %d %d %d", &s1x, &s1y, &s2x, &s2y, &t1x, &t1y, &t2x, &t2y);
		s1.p1.x = s1x, s1.p1.y = s1y;
		s1.p2.x = s2x, s1.p2.y = s2y;
		s2.p1.x = t1x, s2.p1.y = t1y;
		s2.p2.x = t2x, s2.p2.y = t2y;
		printf("%.10f\n", getDistance(s1, s2));
	}

	return 0;
}

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

int main()
{
    int n, k, q;
    cin>>n>>k>>q;
    vector<int> a(n);
    for(auto& e: a) cin>>e;
    a.push_back(0);

    int res=INT_MAX;
    for(int i=0; i<n; ++i) {
        int y=a[i];
        vector<int> v;
        priority_queue<int, vector<int>, greater<int>> q2;
        for(int j=0; j<=n; ++j) {
            if (a[j]>=y) {
                q2.push(a[j]);
            }
            else {
                while (q2.size()>=k) {
                    v.push_back(q2.top());
                    q2.pop();
                }
                while (q2.size()) q2.pop();
            }
        }
        if (v.size()>=q) {
            sort(begin(v), end(v));
            res=min(res, v[q-1]-y);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
x = int(input())

a = 0
b = 0
while True :
    b1 = 0
    b2 = 0
    y = a**5-x
    if y>0 :
        z = float(y)**0.2
        b1 = int(z)
        b2 = int(z) + 1
    elif y<0 :
        z = -((-float(y))**0.2)
        b1 = int(z)
        b2 = int(z) -1
    else :
        break

    if y==b1**5 :
        b = b1
        break
    elif y==b2**5 :
        b = b2
        break
    else :
        a = -a
        if a>=0 :
            a += 1
        
print(a,b)

Measured memory_bytes: 9480
#include  <stdio.h>

int main ()
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);

	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int solve(int now, int n, int a, int b, int c, vector<int> &l, int sua, int sub, int suc, int sza, int szb, int szc) {
  if(now == n) {
    if(sua == 0 || sub == 0 || suc == 0) return INF;
    vector<int> v = {sua, sub, suc};
    sort(v.begin(), v.end());
    return abs(c - v[0]) + abs(b - v[1]) + abs(a - v[2]) + 10 * (sza + szb + szc - 3);
  } else {
    return min(solve(now+1, n, a, b, c, l, sua, sub, suc, sza, szb, szc), min(solve(now+1, n, a, b, c, l, sua + l[now], sub, suc, sza + 1, szb, szc), min(solve(now+1, n, a, b, c, l, sua, sub + l[now], suc, sza, szb + 1, szc), solve(now+1, n, a, b, c, l, sua, sub, suc + l[now], sza, szb, szc + 1))));
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, a, b, c; cin >> n >> a >> b >> c;
  vector<int> l(n);
  for(int i=0;i<n;++i) {
    cin >> l[i];
  }
  cout << solve(0, n, a, b, c, l, 0, 0, 0, 0, 0, 0) << endl;
}


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

int main(){
    long long h;
    cin >> h;
    int ans = 0;
    int k = 1;
    while (h >= pow(2,k)){
        k++;
    }
    long long nans = pow(2,k) - 1;
    cout << nans << endl;
}

Measured memory_bytes: 256