akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_long long.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Blong long = mp::cpp_long long;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    string s;
    cin>>s;
    cout<<s.substr(0,4)<<" "<<s.substr(4,s.size()-4)<<endl;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,a,b;  
  cin>>n>>a>>b;
  int na=abs(n-a),su=abs(a-b),nasu=abs(b-n);
  cout<<na+su+nasu-max(max(nasu,na),su)<<'\n';
  return 0;
}


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

int main()
{
	static const std::string empty_string = "";

	for(;;)
	{
		std::vector<int> vec;

		std::string str;

		getline(std::cin,str);

		if(std::cin.eof())
		{
			break;
		}

		std::stringstream ss;

		int k;

		for(size_t i=0; i<str.length(); ++i)
		{
			ss << str[i];

			ss >> k;

			vec.push_back(k);
			
			ss.str(empty_string);

			ss.clear();
		}

		const int vecNum = vec.size();

		for(int i=0; i<vecNum-1; ++i)
		{
			for(size_t i=0; i<vec.size()-1; ++i)
			{
				vec[i] = (vec[i]+vec[i+1])%10;
			}

			vec.pop_back();
		}

		std::cout << vec[0] << '\n';
	}
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, d, ans;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n)rep(j, d)cin >> x[i][j];
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            double now = 0;
            rep(k, d){
                now += pow(x[i][k]-x[j][k], 2);
            }
            if(sqrt(now) == floor(sqrt(now)))ans++;
        }
    }
    cout << ans  << endl;
}
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		int ans = (x-z)/(y+z);

		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

/*int solve(int a[],int b[],int c[],int l,int m,int n)
{
    if(l<=0 || m<=0 || n<=0)
    return 0;
    else
    {
         if(l==m&&m==n)
         return max(max(b[l-1]+solve(a,b,c,l,l-1,l),c[l-1]+solve(a,b,c,l,l,l-1)),max(a[l-1]+solve(a,b,c,l-1,l,l),c[l-1]+solve(a,b,c,l,l,l-1)));
         else
         {
             if(l<m)
             return max(b[l-1]+solve(a,b,c,l,l-1,l),c[l-1]+solve(a,b,c,l,l,l-1));
             else if(m<n)
             return max(a[m-1]+solve(a,b,c,m-1,m,m),c[m-1]+solve(a,b,c,m,m,m-1));
             else
             return max(b[n-1]+solve(a,b,c,n,n-1,n),a[n-1]+solve(a,b,c,n-1,n,n-1));
         }
    }
}*/

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    int dp[n+1][3];
    memset(dp,0,sizeof(dp));
   
    for(int i=1;i<=n;i++)
    {
         int a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    
    
}


Measured memory_bytes: 4792
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X, Y, Z = lr()
    A = [0]*3
    A[0] = Z
    A[1] = X
    A[2] = Y
    print(*A, sep=' ')
resolve()

Measured memory_bytes: 38256
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
# sort_A = sorted(A, reverse=True)
heapq.heapify(A)
for m in range(M):
    ma = heapq.heappop(A)
    # print(ma, ma//2)
    heapq.heappush(A, -(-ma // 2))

# print(A)
print(-sum(A))

Measured memory_bytes: 72088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
             1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int K;
    cin >> K;
    cout << arr[K - 1] << endl;
}

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

int main() {
  
  string S, answer;
  cin >> S;
  answer = "No";
  
  for(int i = 0;i < 3;i++){
    for(int j = i + 1;j < 3;j++){
      if(S.at(i) != S.at(j)){
        answer = "Yes";
      }
    }
  }
  
  
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int n, x;
int a[200000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	std::sort(a, a + n);
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i])x = 1;
	}
	if (x)printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 896
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int M = stdIn.nextInt();
		int D = stdIn.nextInt();
		int count = 0;
		if(D >= 22) {
			for(int i = 1; i <= M; i++) {
				for(int j = 22; j <= D; j++) {
					int temp = j;
					int d1 = temp%10;
					int d10 = temp/10;
					if(d1 >= 2 && d1 * d10 == i) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		else {
			System.out.println(0);
		}

	}

}

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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			Team[] teams = new Team[N];
			for (int i = 0; i < N; ++i) {
				int id = sc.nextInt();
				int u = sc.nextInt();
				int a = sc.nextInt();
				int p = sc.nextInt();
				teams[i] = new Team(id, u, a, p);
			}
			Arrays.sort(teams);
			int[] count = new int[1001];
			int pass = 0;
			for (int i = 0; i < N; ++i) {
				Team t = teams[i];
				if ((pass < 10 && count[t.u] < 3) || (pass < 20 && count[t.u] < 2) || (pass < 26 && count[t.u] < 1)) {
					++pass;
					count[t.u]++;
					System.out.println(t.id);
				}
			}
		}
	}

	static class Team implements Comparable<Team> {
		int id, u, a, p;

		Team(int id, int u, int a, int p) {
			this.id = id;
			this.u = u;
			this.a = a;
			this.p = p;
		}

		public int compareTo(Team o) {
			if (this.a != o.a) return o.a - this.a;
			if (this.p != o.p) return this.p - o.p;
			return this.id - o.id;
		}
	}
}

Measured memory_bytes: 12000
/**
*   @Author : MeGaCrazy
*   @InitTime : Sat Dec 29 14:11:04 2018
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
bool vis[10];
int valid(int n){
	 while(n){
	     if(vis[(n%10)])return 0;
	     n/=10;
	 }
	 return 1;
} 
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<k;i++){
       int a;
       scanf("%d",&a);
       vis[a]=1;
    }
    for(int i=n;i<=10000000;i++){
    	if(valid(i)){
    		printf("%d",i);
    		return 0;
    	}
    }



}

Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
typedef long long ll;
#define n_MAX 100000
#define w_MAX 10000
using namespace std;

int n,k;
ll T[n_MAX];

// 積載量 P で積める荷物量
int check(ll P){
  int i=0;
  for (size_t j = 0; j < k; j++) {
    ll s=0;
    while (s+T[i]<=P) {
      s += T[i];
      i++;
      if (i==n) return n; // 全て積めた
    }
  }
  return i;
}

int solve(){
  ll left = 0;
  ll right = n_MAX * w_MAX;
  ll mid;
  while (right - left > 1) {
    mid = (left + right) / 2;
    int v = check(mid);
    if (v >= n) right = mid;
    else left = mid;
  }
  return right;
}

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

  std::cin >> n >> k;

  for (size_t i = 0; i < n; i++) std::cin >> T[i];

  ll ans = solve();

  std::cout << ans << '\n';

  return 0;
}



Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
ll f[N],b[N],a[N];

int main(){
	int n;
	cin >> n;
	fu(i,1,n)cin >> a[i];
	fu(i,1,n){
		f[i] = gcd(a[i],f[i-1]);	
	}
	fd(i,n,1){
		b[i] = gcd(a[i],b[i+1]);	
	}
	ll ans = 0;
	fu(i,1,n){
		ll pos = gcd(f[i-1],b[i+1]);
		ans = max(ans, pos);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 2560
N = int(raw_input())
B = map(int, raw_input().split())

maximum_sum = 0

for i in range(N):
  if i == 0:
    maximum_sum += B[0]
  elif i == N - 1:
    maximum_sum += B[-1]
  else:
    maximum_sum += min(B[i - 1], B[i])

print maximum_sum


Measured memory_bytes: 2568
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ALLOC(size,type) ((type*) calloc ((size), sizeof (type)))

typedef struct arm {
  i32 x, y;
} node;

int cmp (const void *a, const void *b) {
  i32 d = ((node *)a)->x - ((node *)b)->x;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  node *p = ALLOC (m, node);
  for (i32 i = 0; i < m; ++i) {
    i32 x, y;
    scanf ("%" SCNi32 "%" SCNi32, &x, &y);
    y--;
    p[i] = (node) {x, y};
  }
  qsort (p, m, sizeof (*p), cmp);
  i32 *up = ALLOC (n, i32);
  i32 *down = ALLOC (n, i32);
  for (i32 i = 0; i < n; ++i) {
    up[i] = down[i] = i;
  }
  for (i32 i = 0; i < m; ++i) {
    i32 y = p[i].y;
    down[y + 1] = MIN(down[y + 1], down[y]);
    up[y] = MAX(up[y], up[y + 1]);
  }
  for (i32 i = n - 2; i >= 0; --i) {
    down[i] = MIN(down[i], down[i + 1]);
  }
  for (i32 i = 1; i < n; ++i) {
    up[i] = MAX(up[i], up[i - 1]);
  }
  for (i32 i = 0; i < n; ++i) {
    printf ("%" PRIi32, up[i] - down[i] + 1);
    putchar (i == n - 1 ? '\n' : ' ');
  }
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 4132
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    map<int, int> m;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ans = max(ans, m[x] = (m[x - 1] + 1));
    }

    cout << n - ans << "\n";
}

Measured memory_bytes: 10604
# include <iostream>
# include <math.h>

using namespace std;


int main()
{
    int X, Y;

    cin >> X >> Y;

    if (Y / X >= 2 && (double)Y/(double)X <= 4 && Y%2==0 )
    {
        cout << "Yes";
    }
    else
        cout << "No";


    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int a = 0; a <= n; ++ a) {
		for (int b = 0 ; b <= m; ++ b) {
			if (a * b + (n - a) * (m - b) == k) {
				return 0 * puts("Yes");
			}
		}
	}
	puts("No");
}



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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (char ch : s) {
        if (st.count(ch) == 0) st.insert(ch);
    }
    for (char ch = 'a'; ch <= 'z'; ch++) {
        if (st.count(ch) == 0) {
            cout << ch << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

int main(){

    int n, m;
    cin >> n >> m;

    map<int, int> dict;

    for (int i=0; i<n; i++){
        int k;
        cin >> k;
        for (int j=0; j<k; j++){
            int temp;
            cin >> temp;
            dict[temp]++;
        }
    }

    int ans = 0;
    for (auto p: dict){
        auto value = p.second;

        if (value == n){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main(){double a,b,c,d,e,f,g,h,i,j,k,l,x,y,t,u;while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=-1){j=g=a*d;k=e*a;h=d*b;i=c*d;l=f*a;t=h-k;u=i-l;y=u/t;h=k=b*e;g=e*a;i=c*e;j=d*b;l=f*b;t=g-j;u=i-l;x=u/t;if(x==-0)x=0;if(y==-0)y=0;printf("%.3lf %.3lf\n",x,y);}exit(0);}

Measured memory_bytes: 0
#include <stdio.h>         
#include <stdlib.h>         
#define N 3
#define NIL -1
#define NN 100

int p8[N][N];
int temp[N][N];
int dx[4] = { 0, 1, 0,-1};
int dy[4] = { 1, 0,-1, 0};
void et(int *,int *);
int cl();
void swap(int *,int *);
int dfs(int,int,int,int, int);


int main(){
  int i,j,d,a,x=0,y=0;
  for (i = 0; i < N; ++i){
    for (j = 0; j < N; ++j){
      scanf("%d", &p8[i][j]);
    }
	}
  et(&x, &y);

  for (d = 0; d < NN; d++){
    for (i = 0; i < N; i++){
      for(j = 0; j < N; j++){
	temp[i][j] = p8[i][j];
      }
    }
    a = dfs(x, y, -1, 0, d);
    if (a != -1){  
      printf("%d\n", a);
      break;
    }

    for (i = 0; i < N; ++i){
      for(j = 0; j < N; ++j){
       p8[i][j] = temp[i][j];
      }
    }
    a = NIL;
    if (d == NN-1)
      printf("%d\n", a);
  }


  return 0;
}
void et(int *x, int *y){
  int i,j;
  for (i = 0; i < N; i++){
    for (j = 0; j < N; j++){
      if (!p8[i][j]){
	*x = j;
	*y = i;
	
	return;
      }
    }
  }
}

int cl(){

  int sm = 0,i,a;
  for (i = 0; i < 9; ++i){
     a = p8[i / 3][i % 3];
    if (a){
      a--;
      sm += abs(i / 3 - a / 3) + abs(i % 3 - a % 3);
    }
  }
  return sm;
}

int dfs(int x, int y, int p, int dp, int lim){
  int h,i,y1,x1,re;
  h = cl();
  if (h == 0)
    return dp;

  if (dp + h > lim) return NIL;
  for (i = 0; i < 4; ++i){
     x1 = x + dx[i];
     y1 = y + dy[i];
    if (p != NIL && i == (p + 2) % 4)continue;
    if (0 <= x1 && x1 < N && 0 <= y1 && y1 < N){
      swap(&p8[y][x], &p8[y1][x1]);
      re = dfs(x1, y1, i, dp + 1, lim);
      if (re != NIL)return re;
      
      swap(&p8[y][x], &p8[y1][x1]);
    }
  }

  return NIL;
}
void swap(int *a, int *b){

  int temp = *a;
  *a = *b;
  *b = temp;
}



Measured memory_bytes: 2108
class RangeMinQuery:
    inf = 2 ** 31 - 1
    def __init__(self, N):
        self.n = 1
        while self.n < N: self.n *= 2
        self.dat = [self.inf] * (2 * self.n - 1)
 
    def update(self, k, x):
        k += self.n - 1
        self.dat[k] = x
        while (k > 0):
            k = (k - 1) / 2
            self.dat[k] = min(self.dat[2 * k + 1], self.dat[2 * k + 2])
 
    # [a, b); call query(a, b)
    def query(self, a, b, k = 0, l = 0, r = -1):
        if r == -1: r = self.n
        if r <= a  or b <= l: return self.inf
        if a <= l and r <= b: return self.dat[k]
 
        vl = self.query(a, b, 2 * k + 1, l, (l + r) / 2)
        vr = self.query(a, b, 2 * k + 2, (l + r) / 2, r)
        return min(vl, vr)
 
n, q = map(int, raw_input().split())
rmq = RangeMinQuery(n)
for i in xrange(q):
    c, x, y = map(int, raw_input().split())
    if c == 0:
        rmq.update(x, y)
    else:
        print rmq.query(x, y + 1)

Measured memory_bytes: 7156
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0
need = 0
sup = []
for i in range(n):
    k = B[i] - A[i]
    if k > 0:
        need += k
        cnt += 1
    else:
        sup.append(-k)
sup.sort()
while need > 0:
    if sup:
        need -= sup.pop()
        cnt += 1
    else:
        print(-1)
        break
else:
    print(cnt)

Measured memory_bytes: 18396
n, m = [int(i) for i in input().split()]
lst_pena = [[False, 0] for i in range(n)]
cnt_pena = 0
cnt_ca = 0
for i in range(m):
	n, m = [j for j in input().split()]
	n = int(n) - 1
	if lst_pena[n][0] == False and m == 'AC':
		lst_pena[n][0] = True
		cnt_ca += 1
	elif lst_pena[n][0] == False and m == 'WA':
		lst_pena[n][1] += 1
sum_pena = sum([i[1] if i[0] else 0 for i in lst_pena])
print(f'{cnt_ca} {sum_pena}')

Measured memory_bytes: 18156
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 100009;
ll x,y,c = 1;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>x>>y;
    while(1){
        x*=2;
        if(x > y) break;
        c++;
    }
    cout<<c;
    return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 60);

double PI = 3.14159265358979323846;

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll A, B, H, M;
  scanf("%lld %lld %lld %lld", &A, &B, &H, &M);

  // A -> 12時間 -> 720分
  // B -> 1時間  -> 60分

  ll mins1 = H * 60 + M;
  ll mins2 = (H * 60 + M) % 60;

  double a1 = PI * 2 * mins1 / 720;
  double a2 = PI * 2 * mins2 / 60;

  double x1 = A * cos(a1);
  double y1 = A * sin(a1);

  double x2 = B * cos(a2);
  double y2 = B * sin(a2);

  double d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);

  double ans = sqrt(d);

  cout << ans << endl;
}


Measured memory_bytes: 4192
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){
    int i,a[3],b[3];

    for(i=0;i<3;i++){
        cin>>a[i];
    }

   b[0]=a[2];
   b[1]=a[0];
   b[2]=a[1];

   for(i=0;i<3;i++){
        cout<<b[i]<<" ";
    }

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

fn main() {
    let (n, k) = {
        let v = read_values::<usize>();
        (v[0], v[1])
    };

    let mut tree = vec![Vec::new(); n];
    let mut edges = Vec::new();
    for _ in 0..(n - 1) {
        let v = read_values::<usize>();
        let from = v[0] - 1;
        let to = v[1] - 1;
        tree[from].push(to);
        tree[to].push(from);

        edges.push((from, to));
    }

    if k % 2 == 1 {
        let mut max = 0;
        for edge in &edges {
            let (from, to) = *edge;
            let ans = dfs(&tree, from, to, 0, k / 2) + dfs(&tree, to, from, 0, k / 2);
            max = cmp::max(max, ans);
        }
        println!("{}", n - max);
    } else {
        let mut max = 0;
        for v in 0..n {
            let ans = dfs(&tree, v, n, 0, k / 2);
            max = cmp::max(ans, max);
        }
        println!("{}", n - max);
    }
}

fn dfs(tree: &Vec<Vec<usize>>, v: usize, p: usize, dist: usize, k: usize) -> usize {
    if dist > k {
        return 0;
    }
    let mut count = 1;
    for next in tree[v].iter() {
        if *next == p {
            continue;
        }
        count += dfs(tree, *next, v, dist + 1, k);
    }
    count
}

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

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

int main(){
  string ac;
  cin >> ac;
  int cnt = 0;
  int count = 0;
  string ans = "AC";
  
  if(ac[0] != 'A') ans = "WA";
  
  for(int i = 2; i < ac.size() - 1; i++){
    if(ac[i] == 'C') cnt++;
  }
  for(int i = 1; i < ac.size(); i++){
    if(isupper(ac[i])) count++;
  }

  if(cnt != 1 || count != 1) ans = "WA";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll n, m;
map<pair<ll, ll>, ll> node;
bool valid(ll x, ll y) {
	if(x < n && x >=0 && y < m && y >= 0) {
		return true;
	}
	return false;
}
ll dist[401][401];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, k, x, y, num = 0, ans = 0, l;
    cin>>n>>m;;
    string s[n];
    for(i=0; i<401; i++) {
    	for(j=0; j<401; j++) {
    		if(i == j) {
    			dist[i][j] = 0;
    		} 
    		else {
    			dist[i][j] = 1e9;
    		}
    	}
    }
    for(i=0; i<n; i++) {
    	cin>>s[i];
    	for(j=0; j<m; j++) {
    		if(s[i][j] == '.') {
    			node[mp(i, j)] = num++;
    		}
    	}
    }

    for(i=0; i<n; i++) {
    	for(j=0; j<m; j++) {
    		if(s[i][j] == '#') {
    			continue;
    		}
    		for(l = 1; l>=0; l--) {
    			for(k=0; k<=1; k++) {
    				if(abs(l) == abs(k)) {
    					continue;
    				}
    				if(!valid(i + l, j + k)) {
    					continue;
    				}
    				x = i + l;
    				y = j + k;
    				if(s[x][y] == '#') {
    					continue;
    				}
    				dist[node[mp(i, j)]][node[mp(x, y)]] = 1;
    				dist[node[mp(x, y)]][node[mp(i, j)]] = 1;

    			}
    		}
    	}
    }
    for(i=k=0; k<num; k++) {
    	for(i=0; i<num; i++) {
    		for(j=0; j<num; j++) {
    			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    		}
    	}
    }
    for(i=0; i<num; i++) {
    	for(j=0; j<num; j++)
			ans = max(ans, dist[i][j]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 1536
#include <stdio.h>

void Sort(int *a, int n){
	int i, c;
	for(i = 1; n > i; i++){
		for(c = 0; n > c; c++){
			printf("%d", a[c]);
			if(n-1 > c) printf(" ");
		}
		printf("\n");
		int v = a[i];
		int j = i-1;
		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
	}
}
int main(void) {
	int n, i, a[1000] = {};
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%d", &a[i]);
	}
	Sort(a, n);
		for(i = 0; n > i; i++){
			printf("%d", a[i]);
			if(n-1 > i) printf(" ");
		}
		printf("\n");
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define min 0.000000001
using namespace std;

int main(){
  double a,b,c,d,e,f,x,y;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
    x = (c*e - b*f)/(a*e - b*d);
    y = (a*f - c*d)/(a*e - b*d);
    if(abs(x) < min) x = 0;
    if(abs(y) < min) y = 0;
    printf("%.3lf %.3lf\n",x,y);
  }
return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
using namespace std;
 
int main(){
    int H=0,W=0;
    int i,k;

while(1){    



    cin >> H >> W;
	if(H==0&&W==0){
		break;
	}
    
    for(k=0;k<H;k++){//???
    	for(i=0;i<W;i++){//???
    		if((k+i)%2==0){
    			cout << "#";
    		}else{
    			cout << ".";
    		}
    	}
    	cout << endl;
		}
    cout << endl;
    }

return 0;
}

Measured memory_bytes: 1152
aaa = []
for i in range(3):
    a, b = map(int, input().split())
    aaa.append(a)
    aaa.append(b)

aaa.sort()
cnt = 0
prev = aaa[0]
c = []
for i, aa in enumerate(aaa):
    if aa == prev:
        cnt += 1
    else:
        c.append(cnt)
        prev = aa
        cnt = 1
c.append(cnt)
c.sort()
if [1, 1, 2, 2] == c:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38512
n,k=map(int,input().split())

if n==k:
  print(0)

elif k > n:
  if k-n<=n:
    print(k-n)
  else:
    print(n)
  
else:
  amari = n%k
  com3 = k -amari
  if amari<= com3:
    print(amari)
  else:
    print(com3)


Measured memory_bytes: 2940
n = gets.to_i
cards = gets.split.map(&:to_i)

(1..cards.size-1).each do |i|
  puts cards.join(' ')
  c = cards[i]
  j = i - 1
  while(j >= 0 and cards[j] > c)
    cards[j + 1] = cards[j]
    j-=1
  end
  cards[j + 1] = c
end

puts cards.join(' ')


Measured memory_bytes: 6892
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const double PI = acos(-1);
const double INF = 1e15;
double dp[10010][20][20];

int n;
double r, theta;
double x[20], y[20];

double dist(double x1, double y1, double x2, double y2){
    x1 -= x2, y1 -= y2;
    return sqrt(x1 * x1 + y1 * y1);
}

double dot(double x1, double y1, double x2, double y2){
    return x1 * x2 + y1 * y2;
}

bool check(int v, int u, int pre){
    double ax = x[v] - x[pre];
    double ay = y[v] - y[pre];
    double bx = x[u] - x[v];
    double by = y[u] - y[v];
    double da = dist(x[v], y[v], x[pre], y[pre]);
    double db = dist(x[u], y[u], x[v], y[v]);
    double t = abs(acos(dot(ax, ay, bx, by) / da / db));
    //cerr << "\t\t" << v << " " << u << " " << pre << " " << t << endl;
    return t <= theta;
}

bool can[20][20][20];

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

    theta *= 2 * PI / 360.0;

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

    for(int i = 0; i < 10010; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                dp[i][j][k] = INF;
            }
        }
    }

    for(int v = 0; v < n; v++){
        for(int u = 0; u < n; u++){
            for(int pre = 0; pre < n; pre++){
                if(v == u) continue;
                can[v][u][pre] = check(v, u, pre);
            }
        }
    }

    //cout << check(2, 0, 1) << endl;
    //return 0;

    dp[0][0][0] = 0;
    for(int i = 0; i <= 10000; i++){
        for(int v = 0; v < n; v++){
            for(int pre = 0; pre < n; pre++){
                double d = dp[i][v][pre];
                if(d >= 1e14) continue;
                //cerr << i << " " << v << " " << pre << " " << d << endl;
                for(int u = 0; u < n; u++){
                    if(v == u) continue;
                    if(i != 0 && !can[v][u][pre]) continue;
                    //cerr << "\t" << v << " " << u << endl;
                    double ndist = d + dist(x[v], y[v], x[u], y[u]);
                    if(ndist <= r && dp[i + 1][u][v] > ndist){
                        dp[i + 1][u][v] = ndist;
                    }
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i <= 10000; i++){
        for(int v = 0; v < n; v++){
            for(int pre = 0; pre < n; pre++){
                double d = dp[i][v][pre];
                if(d >= 1e14) continue;
                ans = max(ans, i);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 34828
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    A.sort()
    # First cond: all 0
    if A[-1] == 0:
        print('Yes')
        return
    # Second cond: N//3 -> 0, 2N//3 -> x
    if N % 3 == 0:
        if A[(2*N//3)-1] == 0 and A[-(N//3)] == A[-1]:
            print('Yes')
            return
    # Third cond: N//3 -> x, N//3 -> y, N//z -> 0 s.t. x^y^z=0
    if N % 3 == 0:
        if A[0] == A[(N//3)-1] and A[N//3] == A[(2*N//3)-1] and A[2*N//3] == A[N-1] \
                and A[0] ^ A[N//3] ^ A[2*N//3] == 0:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 14116
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

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

template <typename T> void max_self(T& a, T b){
	a = max(a,b);
}

void swap(int* a, int* b){
	int t = *a;
	*a = *b;
	*b = t;
}

void solve(){	
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout <<a<<" "<<b<<" "<<c<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //int t; cin >> t;
    //while(t--) solve();
    //
    solve();
    return 0;
}


Measured memory_bytes: 256
n=int(input())
dic={}
count={}

for i in range(n):
  s,p=map(str,input().split()) 
  p=int(p)
  dic[p]=s
  count[p]=i+1
  
a=sorted(dic.items(),reverse=True)
a=sorted(a,key=lambda x:x[1])

for p,s in a:
  for q,i in count.items():
    if p==q:
      print(i)

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

bool used[100010];

signed main()
{
	string s;cin>>s;
	int n=s.size();

	int c[2] = {0, 0};

	rep(i, n) c[s[i]-'0']++;

	cout << min(c[0], c[1])*2 << endl;
}


Measured memory_bytes: 512
'use strict'

const main = (input) => {
    const X = parseInt(input.split(' ')[0])
    const A = parseInt(input.split(' ')[1])
    const B = parseInt(input.split(' ')[2])
    const diff = A - B
    if(diff >= 0){
        console.log('delicious')
    } else if(diff < 0 && diff >= -X){
        console.log('safe')
    } else{
        console.log('dangerous')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : usize = get_one();
    let mut v : Vec<usize> = Vec::new();
    for _i in 0..n {
        let x : usize = get_one();
        v.push(x-1);
    }
    let mut visited = vec![false; n];
    let mut cur : usize = 0;
    let mut ans = false;
    let mut cnt = 0;
    loop {
        //println!("{}", cur);
        if visited[cur] {
            break;
        }
        if cur == 1 {
            ans = true;
            break;
        }
        cnt += 1;
        visited[cur] = true;
        cur = v[cur];
    }
    if ans {
        println!("{}", cnt);
    }
    else {
        println!("{}", -1);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#ifndef LIB_DEBUG_HPP
#define LIB_DEBUG_HPP
#ifdef DEBUG
#include <cassert>
#define debug(a) a
#else
#define debug(a)
#endif
#endif
#ifndef repeat
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#endif
#ifndef repeat_from
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)
#endif
#ifndef repeat_one
#define repeat_one(i,n) for (int i = 1; i <= (n); ++i)
#endif
#ifndef repeat_rev
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; --i)
#endif
#ifndef foreach
#define foreach(it, cont) for (typeof(cont.begin()) it = cont.begin(); it != cont.end(); ++it)
#endif
#ifndef LIB_TYPEDEF_LL_HPP
#define LIB_TYPEDEF_LL_HPP
typedef long long ll;
typedef unsigned long long ull;
#endif
#ifndef LIB_DEBUG_HPP
#define LIB_DEBUG_HPP
#ifdef DEBUG
#include <cassert>
#define debug(a) a
#else
#define debug(a)
#endif
#endif
using namespace std;
const int D4[4][2] = { {0,-1}, {0,1}, {-1,0}, {1,0} };
int H, W;
vector<vector<bool> > tile;
vector<vector<bool> > used;
int dfs(int h, int w) {
    if (used[h][w]) return 0;
    used[h][w] = true;
    int acc = 1;
    repeat (d,4) {
        int h0 = h + D4[d][0];
        int w0 = w + D4[d][1];
        if (0 <= h0 and h0 < H and 0 <= w0 and w0 < W and not used[h0][w0]) {
            if (tile[h0][w0] == false) {
                acc += dfs(h0, w0);
            }
        }
    }
    return acc;
}
int main() {
    ios_base::sync_with_stdio(false);
    while (true) {
        cin >> W >> H; cin.ignore();
        if (W == 0 and H == 0) break;
        tile = vector<vector<bool> >(H, vector<bool>(W));
        pair<int,int> p;
        repeat (h,H) {
            repeat (w,W) {
                char c; cin >> c;
                if (c == '.') {
                    tile[h][w] = false;
                } else if (c == '#') {
                    tile[h][w] = true;
                } else if (c == '@') {
                    tile[h][w] = false;
                    p = make_pair(h,w);
                } else {
                    debug (assert (false));
                }
            }
            cin.ignore();
        }
        used = vector<vector<bool> >(H, vector<bool>(W, false));
        cout << dfs(p.first, p.second) << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
int main(void){
  int x,b,c,nokori;
  char s[101];
  
  scanf("%d",&x);
  scanf("%d",&b);
  scanf("%d",&c);
  
  x=x-b;
  nokori=x-(x/c*c);
  printf("%d",nokori);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long a = 26L;
		
		char[] al = new char[26];
		String[] alp = new String[26]; 
		ArrayList<String> alph = new ArrayList<String>();
		for(int i = 0; i<26;i++) {
			al[i] = (char)(97+i);
			alp[i] = String.valueOf(al[i]);
			alph.add(alp[i]);
		}
		
		ArrayList<String> list = new ArrayList<String>();
		
		//141167095653375
		
		while(true) {
			if(n < 27) {
				list.add(alph.get((int)n-1));
				break;
			}
			long end = n % a;
			
			if(end == 0) {
				end = 26;
			}
			//System.out.println(end);
			list.add(alph.get((int)end-1));
			long ans = (n-end) / a;
			//System.out.println(ans);
			if(ans < 27) {
				list.add(alph.get((int)ans-1));
				break;
			}
			n = ans;
				
		}
		Collections.reverse(list);
		for(String item:list) {
			System.out.print(item);
		}
	}

}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  deque<ll> q;
  rep(i,n){
    ll idx=lower_bound(all(q), a[i])-q.begin();
    if(idx==0) q.push_front(a[i]);
    else q[idx-1]=a[i];
  }
  cout<<q.size()<<endl;
  
}

Measured memory_bytes: 1920
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string

	fmt.Scan(&n, &s)

	count := 1

	for i := 0; i < n-1; i++ {
		if s[i] == s[i+1] {
		} else {
			count++
		}
	}
	fmt.Println(count)
}


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

int main() {
	string s;
	cin >> s;
	s.push_back('@');
	int r = 0;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] != s[i + 1])r++;
	}
	cout << r - 1 << endl;
	return 0;
}

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

int main(){
    int a, b, ans = 0;
    scanf("%d%d", &a, &b);
    int cnt = 1;
    while(1){
        if(cnt >= b) break;
        cnt += a-1;
        ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }

int main(){
    ll X;
    cin >> X;
    ll max = 1;
    FOR(i, 1, X+1) {
        bool can = false;
        FOR(b, 1, i+1) {
            if (can) break;
            FOR(p, 2, i+1) {
                if (pow(b, p) > X) break;
                if (pow(b, p) == i) {
                    can = true;
                    break;
                }
            }
        }
        if (can) max = i;
    }
    cout << max << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vbool vector<bool>
#define vvbool vector<vector<bool>>
#define INF 100000009

int main(){
    ll N,W;
    cin >> N >> W;
    vvll knap(N+1,vll(W+1));
    rep1(i,N+1){
        ll w,v;
        cin >> w >> v;
        rep(j,W+1){
            if(j < w) knap[i][j] = knap[i-1][j];
            else if(knap[i-1][j] < knap[i-1][j-w] + v)
                knap[i][j] = knap[i-1][j-w] + v;
            else
                knap[i][j] = knap[i-1][j];
        }
    }
    cout << knap[N][W] << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  if (s == "000"){
  	cout << 0 << endl;
  }
  
  else if (s == "001"){
    cout << 1 << endl;
  }
  
  else if (s == "010"){
    cout << 1 << endl;
  }

  else if (s == "100"){
    cout << 1 << endl;
  }
  
  else if (s == "011"){
    cout << 2 << endl;
  }
  
  else if (s == "110"){
    cout << 2 << endl;
  }
  
  else if (s == "101"){
    cout << 2 << endl;
  }
  
  else if (s == "111"){
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << 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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int x, y;
    cin >> x >> y;
    rep(i, x + 1) {
        if (i * 2 + (x - i) * 4 == y) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}

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


Measured memory_bytes: 3644
# import math
import fractions as math
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
diff = [x[i] - x[i-1] for i in range(1,len(x))]
gcf = diff[0]
for d in diff:
    gcf = math.gcd(gcf, d)
print(gcf)


Measured memory_bytes: 16280
cou=0
s,p=[],[]
s.extend(input())
p.extend(input())
s_length=len(s)
p_length=len(p)
for i in range(s_length):
    s_0=s[0]
    s=s[1:s_length]
    s.append(s_0)
    if s[0:p_length]==p:
        cou=1
        break
if cou==1:
    print("Yes") 

else :
    print("No")     



Measured memory_bytes: 5564
#include <iostream>

using namespace std;

int main(void){
	double a, mx, mn;
	cin >> a;
	mx = mn = a;
	while(1){
		if(cin.eof()){
			break;
		}
		cin >> a;
		mx = max(mx,a);
		mn = min(mn,a);
	}
	cout << mx - mn << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int sum;

bool chk(int i, int j, vector<string> &s) {
	if(i < 0 || j < 0 || s.size()-1 < i || s[i].size()-1 < j)
		return false;
	if(s[i][j] == '*') {
		s[i][j] = ' ';
		return true;
	}
	return false;
}

int dfs(int i, int j, vector<string> &s, int x, int y) {
	if(chk(i, j+1, s))
		return dfs(i, j+1, s, x+1, y);

	if(chk(i+1, j+1, s))
		return dfs(i+1, j+1, s, x, y+1);
	if(chk(i+1, j, s))
		return dfs(i+1, j, s, x, y+1);
	if(chk(i+1, j-1, s))
		return dfs(i+1, j-1, s, x, y+1);

	if(chk(i, j-1, s))
		return dfs(i, j-1, s, x+1, y);

	if(chk(i-1, j-1, s))
		return dfs(i-1, j-1, s, x, y);
	if(chk(i-1, j, s))
		return dfs(i-1, j, s, x, y);
	if(chk(i-1, j+1, s))
		return dfs(i-1, j+1, s, x, y);

	return x * y / 2;
}

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

	int n;
	bool flg = false;
	while(cin >> n, n) {
		if(flg)
			cout << "----------" << endl;
		flg = true;
		cin.ignore();
		vector<string> s(n);
		REP(i, n)
			getline(cin, s[i]);

		map<int, int> m;
		REP(i, n) {
			REP(j, s[i].size()) {
				if(s[i][j] == '*') {
					int res = dfs(i, j, s, 2, 1);
					m[res] = m[res] + 1;
				}
			}
		}

		for(auto i: m)
			cout << i.first << ' ' << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
    int count = 0;
    REP(i, N) {
        int sum = 0;
        REP(j, M)
            sum += B[j] * A[i][j];
        if (sum + C > 0) count++;
    }
    cout << count << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;

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

  vector<ll> f(n + 1);
  f[0] = 1;
  for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;

  vector<map<int, ll>> dp(2 * n + 1);
  dp[0][0] = 1;
  for (int i = 0; i < 2 * n; i++) {
    for (auto e : dp[i]) {
      if ((e.first + int(s[i] == 'W')) % 2 == 0) {
        if (e.first + 1 <= n) (dp[i + 1][e.first + 1] += e.second) %= mod;
      } else {
        if (e.first - 1 >= 0) (dp[i + 1][e.first - 1] += e.second * e.first % mod) %= mod;
      }
    }
  }
  cout << dp[2 * n][0] * f[n] % mod << endl;
}


Measured memory_bytes: 23044
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
mod = 10**9 + 7
n, m = map(int, input().split())

def make_tables(n, mod = 10 ** 9 + 7):
    fac = [1, 1] # 階乗テーブル
    finv = [1, 1] #逆元の階乗テーブル
    inv = [0, 1] #逆元テーブル

    for i in range(2, n + 1):
        fac.append((fac[-1] * i) % mod)
        inv.append((mod -inv[mod % i] * (mod // i)) % mod)
        finv.append((finv[-1] * inv[-1]) % mod)
    return fac, finv

def nCk(n, k, mod = 10 ** 9 + 7):
    k = min(k, n-k)
    return fac[n] * finv[k] * finv[n-k] % mod

##########################
fac, finv = make_tables(m)

a_sum = fac[m] * finv[m - n] % mod

ng = 0
kaburi = [0]
for i in range(1, n + 1):
    c = (nCk(n, i) * fac[(m - i)] * finv[m - n] % mod)
    kaburi.append(c)

for i in range(1, n + 1):
    if i % 2:
        ng += kaburi[i]
    else:
        ng -= kaburi[i]

print((a_sum * (a_sum - ng)) % mod)






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

using namespace std;

long long mask = 0;

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

    int n; cin >> n;
    long long arr[n]; for(auto &i : arr) cin >> i;
    for(auto i : arr) mask ^= i; mask = ~mask;
    for(auto &i : arr) i &= mask;
    sort(arr, arr + n, greater<long long>());

    vector<long long> root;
    for(auto i : arr)
    {
        for(auto j : root)
            i = min(i, i ^ j);
        if(i) root.push_back(i);
    }

    long long ans = 0;
    for(auto i : root) ans = max(ans, ans ^ i);

    cout << ans + (~mask ^ ans);
    return 0;
}


Measured memory_bytes: 1024