akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int[] ta = ReadAndParseIntArr();
            int t = ta[0];
            int a = ta[1];
            int[] h = ReadAndParseIntArr();

            int ans = 0;
            double diff = double.MaxValue;
            for(int i=0;i<h.Length;++i)
            {
                double d = Math.Abs(t - h[i] * 0.006 - a); 
                if( d < diff)
                {
                    diff = d;
                    ans = i;
                }
            }
            Console.WriteLine(ans + 1);
        }
        
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

#define ll long long

using namespace std;

int main()
{
    string s;
    cin>>s;
    ll len=s.size();
    ll f=0,c=0,k=1,l=1;
    for(int i=0; i<len; i=i+2) {
        if(s[i]=='R'||s[i]=='U'||s[i]=='D')f=1;
        else {k=0;break;}
    }
       for(int i=1; i<len; i=i+2) {
        if(s[i]=='L'||s[i]=='U'||s[i]=='D')c=1;
        else {l=0;break;}
    }
    if(k==1&&l==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    from string import ascii_lowercase

    n = int(readline())
    s = input()
    ans = 0
    counter = Counter()

    for char in s:
        counter[char] += 1
        t = 1
        for char2 in ascii_lowercase:
            if char == char2:
                continue
            t *= (counter[char2] + 1)
            t %= MOD
        ans += t
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int p = 1;
	for (int i = 0; i < n; ++i) {
		if (p * 2 < p + k) {
			p = p * 2;
		}else {
			p = p +  k;
		}
	}
	cout << p;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N, K;
	int n = 1;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		n = (n * 2 > n + K) ? n + K : n * 2;
	}
	printf("%d", n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c){
    if (4*a*b < (c-a-b)*(c-a-b) && c-a-b > 0) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt;
pair<int, pii> dp[3005][3005];
pii last[3005][3005];
ll ans;
char s[3005], t[3005];
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  scanf("%s %s", s+1, t+1);
  n = strlen(s+1);
  m= strlen(t+1);
  FOR(i, 1, n) {
    FOR(j, 1, m) {
      if (s[i] == t[j]) {
        dp[i][j] = {dp[i-1][j-1].fi + 1, {i, j}};
        if (dp[i-1][j-1].fi == 0) last[i][j] = {-1,-1};
        else last[i][j] = dp[i-1][j-1].se;
      }
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  int len = dp[n][m].fi;
  x = dp[n][m].se.fi;
  y = dp[n][m].se.se;
  string ans = "";
  FOR(i, 1, len) {
    ans += s[x];
    pii tmp = last[x][y];
    x = tmp.fi;
    y = tmp.se;
  }
  reverse(all(ans));
  if (len > 0) cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 176512
import java.util.*;

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

    int a = sc.nextInt();
    String s = sc.next();

    if(a<3200){
      System.out.println("red");
    }else{
      System.out.println(s);
    }

    }
}

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

int main(){
  int N;
  cin>>N;
  string S;
  if(N==0)S="0";
  while(N!=0){
    if(N<0&&N%-2!=0){
      N=N/-2+1;
      S+="1";
    }else if(N%-2!=0&&N>0){
      N=N/-2;
      S+="1";
    }else{
      N=N/-2;
      S+="0";
    }//else
  }//while
reverse(S.begin(),S.end());
cout<<S<<endl;
}//main()

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

int main(){
  int X,A,B ;
  cin >> X >> A >> B ;
  if(B <= A )
    cout << "delicious" << endl;
  else if (B <= X+A)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
bool judge(string s0){
    ll n=s0.length();
    if(n%2==1)return false;
    if(s0.substr(0,n/2)==s0.substr(n/2,n/2))return true;
    return false;
}
int main(void){
    string s;
    cin>>s;
    ll n=s.length();
    rep(0,i,n){
        string s0=s.substr(0,n-1-i);
        if(judge(s0)){
            cout<<s0.length();
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define MAX_N 1000001
#define mod(x, M) ((x % M) + M) % M

using namespace std;

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

ll M[MAX_N], S[MAX_N];


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

ll frac[MAX_N];
void init(ll N) {
    frac[0] = 1;
    for (ll i = 1; i < N; ++i) {
        frac[i] = mod(frac[i - 1] * i, MOD);
    }
}

ll comb(ll n, ll r) {
    return mod(frac[n] * mod_pow(mod(frac[n - r] * frac[r], MOD), MOD - 2, MOD), MOD);
}


int main() {
    ll N;
    cin >> N;
    init(N);
    
    M[0] = 0;
    for (ll i = 0; i < N; ++i) {
        if (i - 1 < (N-1) - i) {
            S[i] = 0;
        } else {
            S[i] = mod(comb(i - 1, (N-1) - i) * frac[i], MOD);
        }
        if (i != 0) {
            M[i] = mod(S[i] - mod(S[i - 1] * (N - i), MOD), MOD);
        }
    }
    
    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        ans = mod(ans + mod(mod(M[i] * frac[(N-1) - i], MOD) * i, MOD), MOD);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 23680
s = input()
yes = False
for i in range(len(s) - 1):
    for j in range(i + 1, len(s)):
        if s[i] == "C" and s[j] == "F":
            yes = True
            break
    if yes:
        break
        
if yes:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll unsigned long long
using namespace std;

long long power(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
    }
    
  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
void Sieve(ll int n) 
{ 
    bool prime[10000000];
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
  int a,b;
  cin>>a>>b;
  ll int l=a*b;
  cout<<l<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];

bool solve(ll a){
	//a回でできますか？
	num = 0;
	for(i=0;i<n;i++){
		b = x[i] + a;
		num += (b+1)/(n+1);
	}
	//pe("a = ");pe(a);
	//pe("num = ");p(num);
	if(num == a){
		return true;
	}
	return false;
}


int main(){	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
		sum += x[i];
	}
	a = n * (n-1);
	//sum - a回　~ sum - a + n * n回の中にある
	//O(n^3)
	for(ll i=sum-a;i<=sum-a+n*n;i++){
		if(solve(i)){
			p(i);
			return 0;
		}
	}


	

	
	return 0;
}

Measured memory_bytes: 8064
local mfl = math.floor
local function lower_bound(ary, x)
  if(x <= ary[1]) then return 1 end
  local num = #ary
  if(ary[num] < x) then return num + 1 end
  local min, max = 1, num
  while(1 < max - min) do
    local mid = mfl((min + max) / 2)
    if(ary[mid] < x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
table.sort(a)
local max = a[n]
table.remove(a)
local idx = lower_bound(a, max / 2)
if(idx == n) then
  idx = n - 1
elseif(1 < idx) then
  if(math.abs(max - 2 * a[idx - 1]) < math.abs(max - 2 * a[idx])) then
    idx = idx - 1
  end
end
print(max .. " " .. a[idx])


Measured memory_bytes: 3056
import copy, math

def f(n, d, D, res, buil):
    global sd, ans
    d += D
    res.append(n)
    if sd is not None and sd <= d:
        return
    elif n == g:
        ans = res
        sd = d
        return
    else:
        new_buil = copy.deepcopy(buil)
        A = new_buil[n]
        del new_buil[n]
        for m in new_buil:
            B = new_buil[m]
            D = py(A, B)
            if D:
                f(m, d, D, res[:], new_buil)
            
def py(A, B):
    x = 0
    y = 1
    D = math.sqrt((B[x]-A[x])**2+(B[y]-A[y])**2)
    if D <= 50:
        return D

while True:
    N = input()
    if N == 0: break
    buil = {}
    for i in range(N):
        n, x, y = map(int, raw_input().split())
        buil[n] = (x, y)
    for i in range(input()):
        s, g = map(int, raw_input().split())
        sd = None
        ans = None
        f(s, 0, 0, [], buil)
        if ans:
            print ' '.join(map(str, ans))
        else:
            print 'NA'

Measured memory_bytes: 4652
# -*- coding: utf-8 -*-
import numpy as np
N, M, C = map(int, input().split())
A = np.zeros((N, M))

B = np.array(list(map(int, input().split())))
for i in range(N):
  aa = np.array(list(map(int, input().split())))
  A[i, :] = aa

sum = 0
for i in range(N):
  val = np.inner(B, A[i]) + C
  if(val > 0):
    sum += 1

print(sum)


Measured memory_bytes: 12396
#include <stdio.h>
// #include <algorithm>
// using namespace std;

int main(int argc, char const *argv[]) {
  int c[3][3];
  for (int i = 0; i < 3; i ++) {
    for (int j = 0; j < 3; j ++) {
      scanf("%d", &c[i][j]);
    }
  }
  if (
    (c[0][0] - c[0][1] != c[1][0] - c[1][1] || c[1][0] - c[1][1] != c[2][0] - c[2][1] || c[2][0] - c[2][1] != c[0][0] - c[0][1]) ||

    (c[0][1] - c[0][2] != c[1][1] - c[1][2] || c[1][1] - c[1][2] != c[2][1] - c[2][2] || c[2][1] - c[2][2] != c[0][1] - c[0][2]) ||

    (c[0][2] - c[0][0] != c[1][2] - c[1][0] || c[1][2] - c[1][0] != c[2][2] - c[2][0] || c[2][2] - c[2][0] != c[0][2] - c[0][0])
  ) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef tuple<long long, int, int, int> tup;
typedef tuple<int, int, int> triplet;

bool operator< (const tup &tup1, const tup &tup2){
    return  get<0>(tup1) <  get<0>(tup2);
};

int main() {
    int X, Y, Z, K;
    vector<long long> A(1001, 0);
    vector<long long> B(1001, 0);
    vector<long long> C(1001, 0);

    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];

    sort(A.begin(), A.end(), greater<long long>());
    sort(B.begin(), B.end(), greater<long long>());
    sort(C.begin(), C.end(), greater<long long>());

    priority_queue<tup, vector<tup>, less<tup>> pq;
    pq.push(make_tuple(A[0] + B[0]+ C[0], 0, 0, 0));
    int count = 0;
    set<triplet> st;

    while(!pq.empty() && count < K) {
        tup top = pq.top();
        cout << get<0>(top) << endl;
        pq.pop();
        count++;

        int a = get<1>(top);
        int b = get<2>(top);
        int c = get<3>(top);

        if (a + 1 < X && st.find(make_tuple(a+1,b,c)) == st.end()) {
            pq.push(make_tuple(A[a+1] + B[b] + C[c], a+1, b, c));
            st.insert(make_tuple(a+1,b,c));
        }
        if (b + 1 < Y && st.find(make_tuple(a,b+1,c)) == st.end() ) {
            pq.push(make_tuple(A[a] + B[b+1] + C[c], a, b+1, c));
            st.insert(make_tuple(a,b+1,c));
        }
        if (c + 1 < Z && st.find(make_tuple(a,b,c+1)) == st.end() ) {
            pq.push(make_tuple(A[a] + B[b] + C[c+1], a, b, c+1));
            st.insert(make_tuple(a,b,c+1));
        }
    }

    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		int h=0,m=0;
		Scanner kbd = new Scanner(System.in);
		int s = kbd.nextInt();
		if(s>0){
			h =s/3600;m = (s/60)%60;s=s%60;
		}
		System.out.println(h+":"+m+":"+s);

	}

}

Measured memory_bytes: 26384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<int> color[3];
int d[35][35];
ll cost[3][35]; // グループiをc色に塗り替えるコスト

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

    rep(i, c) rep(j, c) {
        cin >> d[i][j]; 
    }

    rep(i, n) rep(j, n){
        int a;
        cin >> a;
        a--;
        color[(i+j)%3].push_back(a);
    }

    rep(g, 3){
        rep(i, c) {
            ll tmp = 0;
            rep(j, color[g].size()){
                tmp += d[color[g][j]][i];
            }
            cost[g][i] = tmp;
        }
    }

    ll ans = LINF;

    rep(i, c) rep(j, c) rep(k, c){
        if (i == j || j == k || k == i) continue;
        ans = min(cost[0][i] + cost[1][j] + cost[2][k], ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4360
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

char ope(int i);

int main()
{
	int N;
	cin >> N;
	int dig[4] = { 0, 0, 0, 0 };
	for (auto i = 0; i < 4; i++){
		int den = (int)pow(10, 3 - i);
		dig[i] = N / den;
		N = N % den;
	}
	for (auto i = 0; i < 2; i++){
		for (auto j = 0; j < 2; j++){
			for (auto k = 0; k < 2; k++){
				int ret = dig[0];
				if (i == 0){
					ret += dig[1];
				}
				else{
					ret -= dig[1];
				}

				if (j == 0){
					ret += dig[2];
				}
				else{
					ret -= dig[2];
				}

				if (k == 0){
					ret += dig[3];
				}
				else{
					ret -= dig[3];
				}
				if (ret == 7){
					cout << dig[0] << ope(i) << dig[1] << ope(j) << dig[2] << ope(k) << dig[3] << '='<< 7 <<endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

char ope(int i){
	if (i == 0){
		return '+';
	}
	else{
		return '-';
	}
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]

INF = H + W

dp = [[INF] * W for _ in range(H)]

if S[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(H):
    for j in range(W):
        if i - 1 >= 0:
            if S[i][j] == '#' and S[i-1][j] == '.':
                dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j])
        if j - 1 >= 0:
            if S[i][j] == '#' and S[i][j-1] == '.':
                dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j-1])

print(dp[H-1][W-1])

Measured memory_bytes: 3188
R=list()
n=0
s=list()
p=list()
N=int(input())
for i in range(N):
  S,P=input().split()
  P=int(P)
  s.append([S,100-P,i+1])
  p.append(P)
  n=S
s=sorted(s)
for i in range(N):
  print(s[i][2])

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  bool ok = false;
  int a, b, c, i = 0, ans = 0;
  cin >> a >> b >> c;
  do{
    i += a;
    if(i % b == c){
      //cout << i << endl; 
      ok = true;
      break;
    }
  }while(i <= 10000);

  if(ok)cout << "YES" << endl;
  else cout << "NO" << endl;;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

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

int main(){
  string up, down;
  cin >> up >> down;
  
  if(up.at(0) == down.at(2)
     && up.at(1) == down.at(1)
     && up.at(2) == down.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#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 << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  map<string, int> b;
  map<string, int> r;
  int n;
  cin >> n;
  forn(i,n) {
    string s;
    cin >> s;
    b[s]++;
  }
  cin >> n;
  forn(i,n){
    string s;
    cin >> s;
    r[s]++;
  }
  int ans = 0;
  for (auto pp: b){
    setmax(ans, pp.ss - r[pp.ff]);
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
1000000000000000000


*/

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
#define MAX_N 100000
const int INF = 1e9;
int N;
int h[MAX_N];
int dp[MAX_N + 1];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < MAX_N; i++) dp[i] = INF;
    dp[0] = 0, dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));  
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using lint = long long;
using ldouble = long double;

void solve() {
    int a, b, c;
    std::cin >> a >> b >> c;
    std::cout << (!(a == b && b == c) &&
                          (a == b || b == c || c == a)
                      ? "Yes"
                      : "No")
              << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
mod=10**9+7
N=10**5+1+34
p=[1]*N #assume all are primes from start 
for i in range(2,N):
    if p[i]==1:
        for j in range(2*i,N,i):
            p[j]=0
primes=[]
for i in range(2,N):
    if p[i]==1:
        primes.append(i)

#print(primes)
fact=[1]*N
for i in range(2,N):
    fact[i]=(i*fact[i-1])%mod
ifact=[1]*N
ifact[N-1]=pow(fact[N-1],mod-2,mod)
for i in range(N-2,0,-1):
    ifact[i]=((i+1)*ifact[i+1])%mod
ans=1
#print(ifact[:10])
for x in primes:
    if x>m:
        break
    cnt=0
    #print(m,end=' before\n')
    while m%x==0:
        m//=x
        cnt+=1
    if cnt==0:
        continue
#    print(x,cnt)
    #print(m,end=' after\n')
 #   print(fact[n-1+cnt],ifact[cnt],ifact[n-1])
    val=(fact[n-1+cnt]*(ifact[cnt]*ifact[n-1])%mod)%mod
  #  print(val)
    ans=(ans*val)%mod
if m>1:
    ans=(ans*n)%mod
print(ans)


Measured memory_bytes: 12140
import collections

n = int(input())
l = list(map(int, input().split()))
l = sorted(l, reverse=True)

i = 1
a = 0
b = 0
while i < n:
    if l[i] == l[i-1]:
        if a == 0:
            a = l[i]
        else:
            b = l[i]
            break
        i += 2
    else:
        i += 1

print(a*b)

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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;


  long long aa = max((long long)0,a-k);
  long long bb = max((long long)0,b-(max((long long)0,k-a)));
  cout << aa << " " << bb << endl;
}

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

int main(void)
{

    int Num_Long;
    string Str;
    cin >> Str;
    Num_Long = Str.length();

    int left =0, right = Num_Long-1;
    int tmp_i=0;
    while(left < right)
    {
        if(Str[left]!= Str[right])
        {
            tmp_i++;
        }
        left++;
        right--;
    }
    cout << tmp_i << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<unordered_map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int function2(int arr[],int initial,int final,int mat[][13],int value,int total,int n,int memo[][4101])
{
	if(initial>final)
	{
		if(value==total)
		   return 0;
		else
		   return 1000000000;
	}
	if(memo[initial][value]!=-1)
	    return memo[initial][value];
	else
	{
		int newval=value;
		int j;
		for(j=0;j<n;j++)
		{
			if(mat[initial][j]==1)
			{
				newval|=power(2,j);
			}
		}
		int x=arr[initial]+function2(arr,initial+1,final,mat,newval,total,n,memo);
		int y=function2(arr,initial+1,final,mat,value,total,n,memo);
		memo[initial][value]=min(x,y);
		return memo[initial][value];
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int odd=(n+1)/2;
	double prob=(double)(odd)/n;
	printf("%.10f\n",prob);
}


Measured memory_bytes: 3768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class D
{
	public static void Main()
	{
		string[] args;
		
		args = Console.ReadLine().Split(' ');
		int H = Int32.Parse(args[0]);
		int W = Int32.Parse(args[1]);

		int[,] c = new int[10,10];
		for(int i = 0; i < 10; i++)
		{
			args = Console.ReadLine().Split(' ');
			for(int j = 0; j < 10; j++)
			{
				c[i,j] = Int32.Parse(args[j]);
			}
		}

		int[] num = new int[10];
		for(int i = 0; i < H; i++)
		{
			args = Console.ReadLine().Split(' ');
			for(int j = 0; j < W; j++)
			{
				int A = Int32.Parse(args[j]);
				if(A != -1)
					num[A]++;
			}
		}

		int[] minCost = new int[10];
		for(int i = 0; i < 10; i++)
			minCost[i] = Int32.MaxValue;
		minCost[1] = 0;
		
		int[] perm = new int[10] {0,1,2,3,4,5,6,7,8,9};
		do
		{			
			int tmpCost = 0;
			for(int i = 0; i < 10; i++)
			{
				if(perm[i] == 1)
					break;
				
				tmpCost += c[perm[i],perm[i+1]];
			}

			minCost[perm[0]] = Math.Min(minCost[perm[0]], tmpCost);

		} while (nextPermutation(ref perm));
		
		int ans = 0;
		for(int i = 0; i < 10; i++)
			ans += num[i] * minCost[i];

		Console.WriteLine(ans);
	}


	private static bool nextPermutation(ref int[] array)
	{
		int len = array.Length;
		int i = len - 2;
		while((i >= 0) && (array[i] > array[i + 1]))
			i--;
		if(i < 0)
			return false;

		int pivot = array[i];
		int j = i + 1;
		while((j < len - 1) && (array[j + 1] > pivot))
			j++;
		
		int tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;
		
		Array.Reverse(array, i + 1, len - i - 1);

		return true;
	}
}





Measured memory_bytes: 13140
def is_prime(num):
    if num == 1:
        return False
    limit = int(num ** 0.5) + 1
    for i in range(2, limit):
        if num % i == 0:
            return False
    return True


cumsum = [0] * (10**5 + 2)

count = 0
for num in range(1, 10**5, 2):
    if is_prime(num):
        if is_prime((num+1)//2):
            count += 1

    cumsum[num] = count
    cumsum[num+1] = count

q = int(input())
for i in range(q):
    left, right = map(int, input().split())
    res = cumsum[right] - cumsum[left-1]
    print(res)

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

#define x first
#define y second
#define int64 long long
#define debug(x) cerr << #x << " is " << x << endl;
#define MaxN 100

int op[MaxN+1];
int v[MaxN+1];
int N;

int main(){


    int i, j, k, ok = 1, t;

    scanf("%d", &N);
    for(i = 1; i <= N; ++i) scanf("%d", &v[i]);
    for(i = N; i >= 1; --i)
    {
        t = 0;
        for(j = i; j >= 1; --j)
        if(v[j] == j)
        {
            op[i] = j;
            t = j;
            break;
        }

        for(k = j; k < i; ++k) v[k] = v[k+1];
        if(!t) ok = 0;
    }

    if(!ok) { printf("-1\n"); return 0; }
    else
        for(i = 1; i <= N; ++i) printf("%d\n", op[i]);


return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll v[40];//ナップザックにおける価値（最大化対象）
ll w[40];//ナップザックにおける重量（制約）
//半分全列挙
//[l,r)についてsum(w)<=mwを満たすすべての組み合わせを返す(重さ, 価値)
vector<P> rekkyo(int l,int r,ll mw)
{
	vector<P> ret;
	int cnt=r-l;
	for(ll bit=0;bit<(1LL<<cnt);bit++)
	{
		auto ele=make_pair(0LL,0LL);
		for(int i=0;i<cnt;i++)
		{
			ll tmp=(bit&(1LL<<i));
			if(tmp>0)
			{
				ele.first+=w[l+i];
				ele.second+=v[l+i];
			}
		}
		if(ele.first<=mw)
			ret.push_back(ele);
	}
	return ret;
}


int main()
{
	int n;
	ll tar;
	ll ans=0;
	cin>>n>>tar;
	for(int i=0;i<n;i++)
		cin>>v[i]>>w[i];
	vector<P> left;//左側n/2
	vector<P> right;//右側n/2
	left=rekkyo(0,n/2,tar);
	right=rekkyo(n/2,n,tar);
	sort(right.begin(),right.end());
	ll nowv=right[0].second;
	for(int i=0;i<right.size();i++)
	{
		if(nowv<right[i].second)
			nowv=right[i].second;
		else
			right[i].second=nowv;
	}
	for(int i=0;i<left.size();i++)
	{
		P p=left[i];
		auto itr=upper_bound(right.begin(),right.end(),P(tar-p.first+1,0));
		if(itr==right.begin())
			continue;
		itr--;
		if((*itr).first+p.first<=tar)
			ans=max(ans,p.second+(*itr).second);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 43632
function Main(input){
  var inp = input.split('\n');
  var a = inp[0];
  var b = inp[1];

  if(a[0] === b[2] && a[1] === b[1] && a[2] === b[0]){
    console.log('YES');
  } else {
    console.log('NO');
  }
}

/* エラー(WA)になるケースがある
  input = input.replace('\r\n', ''); // 改行コードを削除
  input = input.replace('\n', ''); 　// 改行コードを削除

  var revInput = input.split('').reverse().join('');
  input === revInput ? console.log('YES') : console.log('NO');
*/

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

Measured memory_bytes: 11340
import sys
import math

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, H = map(int, readline().split())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, readline().split())
        A.append(a)
        B.append(b)
    B.sort(reverse=True)
    B.append(0)
    A_max = max(A)
    ans = 0
    for b in B:
        if b<A_max:
            ans += math.ceil(H/A_max)
            print(ans)
            break
        else:
            H -= b
            ans += 1
            if H<=0:
                print(ans)
                break

if __name__ == '__main__':
    main()


Measured memory_bytes: 17344
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll n,k;
  cin >> n >> k;
  
  vector<ll> p(n);
  rep(i,n){
  cin>>p[i];
  }
  
  vector<ll> q(n);
  vector<ll> r(n);
  rep(i,n){
    rep(j,i){
      if(p[j]<p[i]) q[i]++;
    }
    for(int j=i+1;j<n;j++){
      if(p[j]<p[i]) r[i]++;
    }
  }
  
  ll ans=0;
  rep(i,n){
    
    ans+=(q[i]*(k-1))%mod*k;
    ans%=mod;
    ans+=(r[i]*k)%mod*(k+1);
    ans%=mod;
  }
    
  cout << (ans%2==0? ans/2:(ans+mod)/2) << endl;
  
}


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

int main(){
  int n;
  double sum1=0;
  cin >> n;
  vector<double> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  for(int j=0; j<n; j++){
    sum1+=1/a.at(j);
  }
  cout << 1/sum1 << endl;
}

Measured memory_bytes: 256
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
int l[n];
for(auto &x:l)
cin>>x;
int cnt=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n;j++)
	{
		for(int k=j+1;k<n;k++)
		{
			if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i]&&(l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]))
				cnt++;
		}
	}
}
cout<<cnt;
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

using namespace std;

const int MAX_N = 2e5 + 10;

int num1[MAX_N], num2[MAX_N];
vector<int> g1[MAX_N], g2[MAX_N];

void dfs(int g, int v, int num[], int k)
{
	num[v] = k;

	if (g == 1)
	{
		for (int u: g1[v])
		{
			if (num[u] == 0)
				dfs(g, u, num, k);
		}//for u
	}//if
	else
	{
		for (int u: g2[v])
		{
			if (num[u] == 0)
				dfs(g, u, num, k);
		}//for u
	}//else

	return;
}//dfs

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N, K, L, p, q, r, s;

	cin >> N >> K >> L;
	for (int i = 0; i < K; i++)
	{
		cin >> p >> q;
		g1[p].emplace_back(q);
		g1[q].emplace_back(p);
	}//for i

	for (int i = 0; i < L; i++)
	{
		cin >> r >> s;
		g2[r].emplace_back(s);
		g2[s].emplace_back(r);
	}//for i

	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= N; i++)
	{
		if (num1[i] == 0) dfs(1, i, num1, ++cnt1);

		if (num2[i] == 0) dfs(2, i, num2, ++cnt2);
	}//for i

	unordered_map<long long, int> mp;
	for (int i = 1; i <= N; i++)
	{
		mp[(long long)num1[i] * N + num2[i]]++;
	}//for i

	for (int i = 1; i <= N; i++)
		cout << mp[(long long)num1[i] * N + num2[i]] << " \n"[i == N];

	return 0;
}//main


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a; cin>>n;
	map<int,int> ct;
	for (int i=0; i<n; i++)
		cin>>a, ct[a]++;
	multiset<ll> mst;
	for (const auto &it : ct)
		for (int i=0; i<it.second/2; i++)
			mst.insert(it.first);
	if(mst.size()<2) {
		cout<<0<<"\n";
		return 0;
	}
	ll x=*mst.rbegin();
	mst.erase(mst.find(x));
	ll y=*mst.rbegin();
	mst.erase(mst.find(y));
	cout<<x*y<<"\n";
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
h = list(map(int, input().split()))
dp = [10e9] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])


for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))

print(dp[-1])

Measured memory_bytes: 13980
S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)


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

int main(){

    int input_num;
    cin >> input_num;

    string str_buf;

    str_buf = to_string(input_num);

    int i;

    for (i=0; i<str_buf.size(); i++){
        if (str_buf.at(i) == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll a[100001];
ll b[100001];
map<ll,ll> mp;
int main() {
  int x;
  cin >> x;
  int sq = sqrt(x);
  int mx = 1;
  reps(i, sq){
    if(i == 1)continue;
    int tm = i;
    while(tm*i<= x){
      tm *= i;
    }
    mx = max(tm, mx);
  }
  cout << mx << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] flds = line.split(" ");
		int n = Integer.parseInt(flds[0]);
		int k = Integer.parseInt(flds[1]);
		long sum = k;
		for (int i=1; i<n; i++) {
			sum *= (k - 1);
		}
		System.out.println(sum);
		long end = System.currentTimeMillis();
		//System.out.println((end-start) + "ms");
	}

}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

const int MAX = 510000;
const int MOD = 1000000007;

void	ComInit(vector<long> &fac, vector<long> &finv, vector<long> &inv) {
	fac.at(0) = 1;
	fac.at(1) = 1;
	finv.at(0) = 1;
	finv.at(1) = 1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = (fac.at(i-1)*i) %MOD;
		inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
		finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD; 
	}
}

long	COM(int N, int K, vector<long> &fac, vector<long> &finv) {
	if (N<K)
		return 0;
	if ((N<0)||(K<0))
		return 0;
	return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int	main() {
	// Array
	vector<long> fac(MAX);
	vector<long> finv(MAX);
	vector<long> inv(MAX);
	// Initialize
	ComInit(fac, finv, inv);
	//
	long N;
	cin >>N;
	vector<long> x(N, 0);
	for (long i=0; i<N; i++)
		cin >>x.at(i);
	long NN=N-1;
	for (long i=0; i<NN; i++)
		x.at(i) =x.at(i+1)-x.at(i);
	x.pop_back();
	//
	long NNN=fac.at(NN);
	vector<long> y(NN, 0);
	long SS=0;
	for (long i=0; i<NN; i++) {
		SS +=NNN*inv.at(i+1);
		SS %=MOD;
		y.at(i)=SS;
	}
	long S=0;
	for (long i=0; i<NN; i++) {
		long SS=x.at(i)*y.at(i);
		SS %=MOD;
		S +=SS;
		S %=MOD;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 13824
n, m = map(int, input().split())
X = sorted([int(x) for x in input().split()])
Y = []


def main() -> None:
    global Y
    for i in range(m - 1):
        Y += [X[i + 1] - X[i]]

    Y.sort()
    for i in range(n - 1):
        if len(Y) == 0:
            break
        Y.pop()

    if len(Y) == 0:
        print(0)
    else:
        print(sum(Y))


if __name__ == "__main__":
    main()


Measured memory_bytes: 57768
#include <iostream>

using namespace std;

#define INF 1e9

int main() {
    int N;
    int A, B, C;
    int X, Y;

    int a = 0;
    int b = 0;
    int c = 0;

    cin >> A >> B >> C >> X >> Y;

    int m = 2 * max(X, Y);
    N = INF;
    for (int i = 0; i <= m; ++i) {
        int t = C * i;
        int p = max(0, X - i / 2);
        int q = max(0, Y - i / 2);
        N = min(N, t + p * A + q * B);
    }


//    N = a * A + b * B + c * C;
    cout << N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int coin;
    scanf("%d", &coin);
    int happiness1000, happiness5;
    happiness1000 = coin / 500;
    happiness5 = (coin - happiness1000 * 500) / 5;
    int outcome;
    outcome = 1000 * happiness1000 + 5 * happiness5;
    printf("%d\n", outcome);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean blnFound = false;
        for ( long h = 1; h < 3501; h++ ) {
            for ( long n = 1; n < 3501; n++ ) {
                long p = h * n;
                long s = h + n;
                long a = N * p;
                long b = 4 * p - N * s;
                if ( b <= 0 ) continue;
                long r = a % b;
                if ( r != 0 ) continue;
                blnFound = true;
                long w = a / b;
                System.out.println(String.format("%s %s %s", h, n, w));
                break;
            }
            if ( blnFound ) break;
        }
    }
}

Measured memory_bytes: 25684
#include<cstdio>

int main(){
	int g[10];
	int i = 0;
	int t;
	while(scanf("%d", &t) + 1){
		if(t){
			g[i] = t;
			i++;
		}else{
			i--;
			printf("%d\n", g[i]);
		}
	}
	return 0;
}

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


void solve(std::string S){
    int a= 0;
    int ans=0;
    for(auto&s :S){
        if(s=='R'){
            a+=1;
        }
        else{
            if(ans<a){
                ans=a;
            }
            a=0;
        }
    }
    cout<<max(a,ans)<<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(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;
void solve() {
	int n;
	cin >> n;
	vector <int> v;
	int count = 0;
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		if(x != i+1)
			count++;
		v.push_back(x);
	}
	if(count == 2 || count == 0)
		cout << "YES" << '\n';
	else
		cout << "NO" << '\n';
	return ;
}

int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}



Measured memory_bytes: 256
def main():
    S = input()
    a = S.count("a")
    b = S.count("b")
    c = S.count("c")
    diff = max((a, b, c)) - min((a, b, c))
    if diff <= 1:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define X first
#define Y second 
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a) 
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 1e9+7, inf = 0x3f3f3f;
ll a[N]; 


int main()
{
	IOS;
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	ll ans = max(b*d, a*c);
	ans = max(ans, a*d);
	ans = max(ans, b*c);
	cout<<ans<<nl;
	
	AC;
} 

Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
flag = False
count1 = 0
count2 = 0
flag = False
for i in range(N):
  if A[i]%2 == 0:
    count1 += 1
    if A[i]%3==0 or A[i]%5==0:
      count2 += 1
      
if count1 == count2:
  flag = True

if flag:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064