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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 1000005;
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> div(int N) {
    vector<int> res;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i != 0) continue;
        res.emplace_back(i);
        if (i != N/i) res.emplace_back(N/i);
    }
    return res;
}

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

    vector<int> A(N);
    for (auto &i : A) cin >> i;

    vector<int> count(MAX);
    for (auto &i : A) count[i]++;

    int ans = 0;
    for (auto &i : A) {
        vector<int> d = div(i);

        bool res = true;
        for (auto &j : d) {
            if (j != i) {
                res &= count[j] == 0;
            } else {
                res &= count[j] == 1;
            }
        }

        ans += res;
    }

    cout << ans << endl;
}

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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> hs(h), ws(w);
  set<P> s;
  rep(i,n) {
    int r, c;
    cin >> r >> c;
    --r; --c;
    hs[r]++;
    ws[c]++;
    s.emplace(r,c);
  }
  int mh = 0, mw = 0;
  rep(i,h) mh = max(mh, hs[i]);
  rep(j,w) mw = max(mw, ws[j]);
  vector<int> is, js;
  rep(i,h) if (mh == hs[i]) is.push_back(i);
  rep(j,w) if (mw == ws[j]) js.push_back(j);
  int ans = mh+mw;
  for (int i : is) for (int j : js) {
    if (s.count(P(i,j))) continue;
    cout << ans << endl;
    return 0;
  }
  --ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 23876
#include <vector>
#include <map>

struct factorization {
private :
	std::vector<int> table;

public :
	factorization(std::size_t n) : table(n + 2, 0) {
		for (int i = 2; i <= n; i++) if (table[i] == 0) {
			for (int j = i; j <= n; j += i) {
				if (table[j] == 0) table[j] = i;
			}
		}
	}

	std::map<int, int> operator() (int x) {
		std::map<int, int> fact;
		while (x > 1) {
			const int &factor = table[x];
			fact[factor]++; x /= factor;
		}
		return fact;
	}

};


#include <iostream>
#include <cassert>

template<int Modulus>
struct modint {
	using value_type = int;

	static constexpr int mod = Modulus;
	static_assert(mod > 1, "Modulus must be greater than 1");

private :
	value_type x;

	template<class T>
	static constexpr value_type normalize (T value) noexcept {
		if (value < 0) {
			value = (-value) % mod;
			return (value ? value : mod - value);
		}
		return (value % mod);
	}

public :
	explicit constexpr modint () noexcept : x(0) { }

	template<class T>
	constexpr modint (T value) noexcept : x(normalize(value)) { }

	constexpr modint operator+ () const noexcept {
		return modint(*this);
	}

	constexpr modint operator- () noexcept {
		if (x != 0) x = mod - x;
		return modint(*this);
	}

	constexpr modint &operator+= (const modint &p) noexcept {
		if ((x += p.x) >= mod) x -= mod;
		return (*this);
	}

	constexpr modint &operator-= (const modint &p) noexcept {
		if ((x += mod - p.x) >= mod) x -= mod;
		return (*this);
	}

	constexpr modint &operator*= (const modint &p) noexcept {
		x = (int)(1LL * x * p.x % mod);
		return (*this);
	}

	constexpr modint &operator/= (const modint &p) noexcept {
		return ((*this) *= p.inverse());
	}

	constexpr modint operator+ (const modint &p) const noexcept {
		return (modint(*this) += p);
	}

	constexpr modint operator- (const modint &p) const noexcept {
		return (modint(*this) -= p);
	}

	constexpr modint operator* (const modint &p) const noexcept {
		return (modint(*this) *= p);
	}

	constexpr modint operator/ (const modint &p) const noexcept {
		return (modint(*this) /= p);
	}

	constexpr modint pow (long long exp) const noexcept {
		modint value(1), buff(x);
		while (exp) {
			if (exp & 1) value *= buff;
			buff *= buff;
			exp >>= 1;
		}
		return value;
	}

	constexpr modint inverse () const noexcept {
		return pow(Modulus - 2);
	}

	friend std::ostream &operator<< (std::ostream &os, const modint &p) {
		return (os << p.x);
	}

	friend std::istream &operator>> (std::istream &is, modint &p) {
		long long v;
		is >> v;
		p = modint(v);
		return (is);
	}

};


#include <iostream>
#include <vector>
#include <map>
#include <tuple>

constexpr std::size_t MAX = 1'000'000;
constexpr int MOD = 1'000'000'007;

int main() {
	std::size_t n;
	std::cin >> n;
	std::vector<int> a(n);
	for (int &e : a) std::cin >> e;

	factorization fact(MAX);
	
	std::map<int, int> map;
	for (int x : a) for (auto p : fact(x)) {
		map[p.first] = std::max(map[p.first], p.second);
	}
	
	modint<MOD> lcm = 1, ans = 0;
	for (auto p : map) lcm *= modint<MOD>(p.first).pow(p.second);
	for (auto x : a) ans += (lcm / x);

	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 7672
n = int(input())
a = list(map(int,input().split()))
pos = set()

# n桁分のbit探索
for i in range(1 << n):
    point = 0
    for j in range(n):
        # j個目の商品が含まれるか
        if (i >> j)&1:
            point += a[j]
    pos.add(point)

q = int(input())
m = list(map(int,input().split()))

for i in m:
    if i in pos:
        print("yes")
    else:
        print("no")


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

int main() 
{
    int N;
    cin >> N;
    
    vector<long long> L;
    if (N == 0) {
        L.push_back(2);
    }else{
        L.push_back(2);
        L.push_back(1);
    }
    
    for (long long i = 2; i < N+1; i++) {
        L.push_back(L[i-1] + L[i-2]);
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 256
import copy

n, t = map(int, raw_input().split())
a = map(int, raw_input().split())

minA = copy.copy(a)
maxA = copy.copy(a)
for i in range(n-1):
    minA[i+1] = min(minA[i], a[i+1])

for i in reversed(range(n-1)):
    maxA[i] = max(maxA[i+1], a[i])

T = [maxA[i]-minA[i] for i in range(n)]

maxT = max(T)

ans_list = set()
for i in range(n):
    if T[i] == maxT:
        ans_list.add(minA[i])

print len(ans_list)


Measured memory_bytes: 16532
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi coins;
	FOR(i, 1, 17) {
		coins.push_back(i*i);
	}

	vi dp(300+1, 0);
	dp[0] = 1;
	REP(i, 17) {
		FOR(j, 1, 300) {
			if(j-coins[i] >= 0) {
				dp[j] += dp[j-coins[i]];
			}
		}
	}

	int n;
	while(cin >> n, n) {
		cout << dp[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define ld long double
#define iii tuple<int, int, int>


int main() {

    int n;
    scanf("%d", &n);

    int x = ceil((double) n/1000);

    int ans = (x * 1000) - n;

    printf("%d\n", ans);

}


Measured memory_bytes: 3824
n=int(input())
if n%2==1:
    ans=[]
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i<j:
                if not i+j==n:
                    ans.append([i,j])
    print(len(ans))
    for i in ans:
        print(i[0],i[1])
else:
    ans=[]
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i<j:
                if not i+j==n+1:
                    ans.append([i,j])
    print(len(ans))
    for i in ans:
        print(i[0],i[1])


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

signed main() {
  int n; cin >> n;
  int sum = 0;
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v.at(i);
    sum += v.at(i);
  }

  int m; cin >> m;
  for(int i = 0; i < m; i++) {
    int p, x; cin >> p >> x;
    int cpSum = sum;
    cpSum = cpSum - v.at(p-1) + x;
    cout << cpSum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    bool c[26] = {false};
    for(int i = 0; i < S.length();i++){
        if(c[S[i] - 'a'] == false){
            c[S[i] - 'a'] = true;
        }else{
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int main2() {
  ll X, Y; cin >> X >> Y;
  int ans = 0;
  ll x = X;
  while (x <= Y) {
    ans++;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  for(int i=0;i<W+2;i++)
    cout << '#';
  cout << endl;
  for(int i=0;i<H;i++){
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  for(int i=0;i<W+2;i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if(B<(A*N)){
    cout<<B<<endl;
  }
  else if(B==(A*N)){
    cout<<B<<endl;
  }
  else{
    cout<<A*N<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int d=sc.nextInt();
        int[][] nums=new int[n][d];
        for(int i=0;i<n;i++){
            for(int j=0;j<d;j++){
                nums[i][j]=sc.nextInt();
            }
        }
        int ans=0;
        int tmp;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                tmp=0;
                for(int k=0;k<d;k++){
                    tmp+=Math.pow(Math.abs(nums[i][k]-nums[j][k]),2);
                }
                if(Math.sqrt(tmp)%1==0)ans++;
            }
        }
        System.out.println(ans);
    }
}


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


ll x[203];
ll n;
string s;
ll ans;

int main(){
	cin >> n >> s;
	for(int i=1;i<=n;i++){
		if(s[i-1] == 'B'){
			x[i] = 1;
		}else if(s[i-1] == 'W'){
			x[i] = 2;
		}
	}
	ll dir;
	for(int i=1;i<=n;i++){
		bool dame = false;
		if(x[i])continue;
		if(x[i-1] != 1 && x[i+1] != 1)continue;
		if(x[i-1] == 1 && x[i+1] == 1)continue;
		if(x[i-1] == 1){
			dir = -1;
		}else {
			dir = 1;
		}
		ll nv = i;
		while(1){
			nv -= dir;
			if(x[nv] == 1){
				dame = true;
				//cout << "!" << endl;
				break;
			}else if(x[nv] == 0){
				break;
			}
		}
		nv = i;
		ll cnt = 0;
		while(1){
			nv += dir;
			if(x[nv] == 1){
				cnt++;
			}else if(x[nv] == 2){
				break;
			}else{
				cnt = 0;
				break;
			}
		}
		if(!dame)ans = max(ans, cnt);
		//cout << cnt << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3196
#!/usr/bin/env python3
"""
数列777...は奇数故，Kが偶数だったら×

"""
from numba import njit


@njit(cache=True)
def func(a, b):
    return a * b


def main():
    import sys
    input = sys.stdin.readline

    K = int(input())

    # mod Kを考える(mod=module(剰余))
    x = 7 % K
    for i in range(1, K + 1):
        if x == 0:
            print(i)
            return
        x = (x * 10 + 7) % K
    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91816
def main():
    N, M = map(int, input().split())

    ans = 0

    Scc_pair_count = min(N, M // 2)
    N -= Scc_pair_count
    M -= Scc_pair_count * 2
    ans += Scc_pair_count

    if N == 0:
        ans += M // 4

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

int s;
int hou,min,sec;

scanf("%d",&s);

sec = s % 60;
min = ((s % 3600) - sec) / 60;
hou = s / 3600;
printf("%d:%d:%d\n",hou,min,sec); 

	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;


int cal(int x1, int y1, int x2, int y2, vector<vector<int> >& board)
{
  int ret = board[y2][x2] - board[y2][x1] - board[y1][x2] + board[y1][x1];
  return ret;
}

int main()
{
  int N, K;
  scanf("%d %d", &N, &K);
  vector<vector<int> > board(2 * K + 1, vector<int>(2 * K + 1, 0));
  for (int i = 0; i < N; ++i) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);
    if (c == 'W') { x += K; }
    x %= (2 * K);
    y %= (2 * K);
    ++board[y + 1][x + 1];
  }

  for (int y = 1; y <= 2 * K; ++y) {
    for (int x = 1; x <= 2 * K; ++x) {
      board[y][x] += board[y][x - 1] + board[y - 1][x] - board[y - 1][x - 1];
    }
  }
  // fprintf(stderr, "DEBUG: after cumulative summing\n");
  // for (int i = 0; i <= 2 * K; ++i) {
  //   for (int j = 0; j <= 2 * K; ++j) {
  //     fprintf(stderr, "%3d |", board[i][j]);
  //   }
  //   fprintf(stdout, "\n");
  // }
  int ans = 0;
  for (int x = 1; x <= K; ++x) {
    for (int y = 1; y <= K; ++y) {
      int x0 = 0, y0 = 0;
      int x1 = x, y1 = y;
      int x2 = x + K, y2 = y + K;
      int x3 = 2 * K, y3 = 2 * K;
      int cnt = cal(x0, y0, x1, y1, board) +
        cal(x2, y0, x3, y1, board) +
        cal(x1, y1, x2, y2, board) +
        cal(x0, y2, x1, y3, board) +
        cal(x2, y2, x3, y3, board);
      // fprintf(stderr, "DEBUG: (x, y)=(%d, %d), cnt=%d\n", x, y, cnt);
      ans = max(ans, cnt);
      ans = max(ans, N - cnt);
    }
  }
  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    string S;
    cin >> S;

    ll n = 3;
    for (ll bit = 0; bit < (1<<n); bit++) {
        ll tmp = S[0]-'0';
        string ans = "";
        ans += S[0];
        for (ll i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                tmp += (S[i+1]-'0');
                ans += "+";
            } else {
                tmp -= (S[i+1]-'0');
                ans += "-";
            }
            ans += S[i+1];
        }

        if (tmp == 7) {
            cout << ans + "=7" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

long long y;

long long dfs(long long n, bool is_prev_reversed) {
    long long ans = 2e9 + 1000;
    if(n == y) {
        return 0;
    }

    if(y >= n) {
        ans = std::min(ans, y - n);
    }
    if(-y >= n) {
        ans = std::min(ans, -y - n + 1);
    }
    if(!is_prev_reversed) {
        ans = std::min(ans, dfs(-n, true) + 1);
    }
    return ans;
}

int main() {
    long long x;

    std::cin >> x >> y;

    std::cout << dfs(x, false) << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    string a, b, c; cin >> a >> b >> c;
    cout << char(a[0]+('A' -'a')) << char(b[0]+('A' -'a'));
    cout << char(c[0]+('A' -'a')) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 100005;

int n, m, ans, ts, s, vis[N];

queue<int> cur, nxt;
set<pii> adj[N];

void dfs (int C, int V) {
	if(!vis[C]) nxt.push(C);
	vis[C] = ts;
	while(true) {
		auto it = adj[C].lower_bound(pii(V,0));
		if(it == adj[C].end() || (it->X) != V) break;
		if(vis[it->Y] != ts && (!vis[it->Y] || vis[it->Y]>s)) dfs(it->Y, V);
		adj[C].erase(it);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		int A, B, C;
		scanf("%d%d%d",&A,&B,&C);
		adj[A].insert(pii(C, B));
		adj[B].insert(pii(C, A));
	}
	vis[1] = ++ts; cur.push(1);
	while(!vis[n] && !cur.empty()) {
		s = ts;
		while(!cur.empty()) {
			int C = cur.front(); cur.pop();
			while(!adj[C].empty()) {
				auto it = adj[C].begin();
				int A, B; tie(A, B) = (*it); ts++;
				if(!vis[B] || vis[B]>s) dfs(B, A);
				adj[C].erase(it);
			}
		}
		swap(cur, nxt); ans++;
	}
	printf("%d\n",(vis[n] ? ans : -1));
}


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

using ll = long long;

ll N, A[101010], B[101010];

priority_queue<pair<ll, ll>> pq;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    for (int i = 0; i < N; ++i) {
        pq.emplace(A[i]+B[i], i);
    }

    ll ans = 0;
    int sign = 1;
    for (int i = 0; i < N; ++i) {
        int idx = pq.top().second;
        ans += sign * (i % 2 == 0 ? A[idx] : B[idx]);
        sign *= -1;
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x; cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
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 = 1e16;

ll a,b,n;
ll floor(ll x){
    ll res = a*x/b-a*(x/b);
    return res;
}

int main(){
    cin >> a >> b >> n;
    ll now = min(n,b-1);
    cout << floor(now) << endl;

    return 0;
}


Measured memory_bytes: 3636
using System;

class Program {
    static void Main(string[] args) {

        int n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');

        int[] result = new int[n];

        for(int num = 0; num < n; num++) {
            result[int.Parse(a[num])-1] = num+1;
        }

        for(int num = 0; num < n; num++) {
            Console.Write(result[num]);
            if (num != n - 1) Console.Write(" ");
        }
    }
}



Measured memory_bytes: 22620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3636
s = int(input())

li = [s]
k = 0

while True:
    if li[k] % 2 == 0:
        li.append(int(li[k] / 2))
    else:
        li.append(3 * li[k] + 1)

    for n in range(len(li) - 1):
        for m in range(n + 1, len(li)):
            if li[n] == li[m]:
                print(m + 1)
                quit()
    k += 1

Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void) {
 
int A, B, C, D;
 
scanf("%d %d %d %d", &A, &B, &C, &D);
 
while (1) {
    C -= B;
    if (C <= 0) {
        printf("Yes\n");
        break;
    }
    A -= D;
    if (A <= 0) {
        printf("No\n");
        break;
    }
}
 
return 0;
 
}

Measured memory_bytes: 1616
package main

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

func main() {
	n := getInt()
	hs := getIntSlice(n)

	ans := "Yes"
	for i := 1; i < n; i++ {
		if hs[i]-1 >= hs[i-1] {
			hs[i]--
		} else if hs[i] < hs[i-1] {
			ans = "No"
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// tmp := 200001
	// sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );

//#define pout cerr;

int main(void){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);

  vector<ll> ms(n);

  rep(i,n) cin>>a[i];

  ll sum=0;
  rep(i,n) sum+=a[i];

  vector<ll> ds;
  for(ll i=1;i<=sqrt(sum);i++){
    if( sum%i==0 ){
      ds.push_back(i);
      ds.push_back(sum/i);
    }
  }
  sort( begin(ds),end(ds),greater<ll>() );
  for(auto x:ds){
    //cerr << x << endl;
    ll sum1=0,sum2=0;
    rep(i,n){
      ms[i]=a[i]%x;
      sum2+=x-ms[i];
    }
    sort( begin(ms),end(ms) );
    /*
    for(auto y:ms){
      cerr << y << " ";
    }
    cerr << endl;
    */
    if(sum1==sum2 && sum1<=k){
      cout << x << endl;
      return 0;
    }
    rep(i,n){
      sum1+=ms[i];
      sum2-=(x-ms[i]);
      //cerr << sum1 << ","<< sum2 << endl;
      if(sum1==sum2 && sum1<=k ){
        cout << x << endl;
        return 0;
      }
    }
    
  }

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


Measured memory_bytes: 256
s = gets.chomp
n = s.size

if n == 1
  p 0
  exit
end

d, m = n.divmod(2)
s0 = '01' * d + '0' * m
s1 = '10' * d + '1' * m

def diff_count(a, b)
  a.chars.zip(b.chars).count { |(b0, b1)| b0 != b1 }
end

p [diff_count(s, s0), diff_count(s, s1)].min


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

ans = float('inf')

if X<=Y:
  ans = min(ans, Y-X)
if -X <= Y:
  ans = min(ans, Y+X+1)
if X <= -Y:
  ans = min(ans, -Y-X+1)
if -X <= -Y:
  ans = min(ans, -Y+X+2)
  
print(ans)

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

#define debug(a) cerr << #a << " = " << (a) << endl; 
#define get(t, i) get<(i)>((t))
#define fst first
#define snd second

template<typename T> ostream& operator<<(ostream& o, const vector<T>& v) {
  int b = 0; for (const auto& a : v) o << (b++ ? " " : "") << a; return o;
}

template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << p.fst << ' ' << p.snd; return o;
}

typedef long long ll;
ll n, k;
ll A[101010][2];
ll dp[2][101010];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> A[i][0] >> A[i][1];

  // max val with weight <= j
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j - A[i][0] >= 0)
        dp[i%2][j] = max(dp[(i+1)%2][j-A[i][0]]+A[i][1], dp[(i+1)%2][j]);
      else
        dp[i%2][j] = dp[(i+1)%2][j];
    }
  }

  cout << dp[(n-1)%2][k] << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
    #include <set>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
     
    #define INF 100000000
    #define MOD 100000007
     
    #define writeln(n) cout<<n<<endl
     
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;
     
    template<class T>
    inline bool chmax(T &a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
    }
     
    template<class T>
    inline bool chmin(T &a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
    }
     
    llong pownew(llong m, llong n) {
        if (n == 0) { return 1; }
        if (n % 2 == 0) { return pow(m*m, n/2); }
        return pow(m, n-1) * m;
    }
     
    bool isprime(int p) {
        if (p == 1) return false;
        for (int i = 2; i < p; i++) {
            if (p%i == 0) return false;
        }
        return true;
    }
     
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
     
    const int inf=100000000;
     
    long long modpow(long long a, long long n, long long mod) //a^n
    {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }
     
    llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }
    //setprecision(10);
     
     
     
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int a,b,c; cin>>a>>b>>c;
        if(b+c>=a) cout<<b+c-a<<endl;
        else cout<<0<<endl;
     
     
        return  0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  string S;
  cin >> N >> S;
  vi countE(N+1);
  rep(i,N) {
    countE[i+1]=countE[i];
    if(S[i]=='E') countE[i+1]++;
  }
  
  int ans=N;
  rep(i,N)
    ans=min(ans,i-countE[i]+countE[N]-countE[i+1]);
  
  cout << ans << endl;
}

Measured memory_bytes: 1796
use std :: io ;
fn main(){
 
    let mut no = String::new();

  io :: stdin()
    .read_line(&mut no)
    .expect("failed to read line ");

 let no : i32 = no.trim().parse().expect("error!");

if no == 0 {
    println!("1");
 } else if no == 1 {
        println!("0");
    }else {
        println!("...");
    }
}

Measured memory_bytes: 2132
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
px=[0]*(h*w)
py=[0]*(h*w)
for i in range(h):
  for j in range(w):
    px[a[i][j]-1]=j
    py[a[i][j]-1]=i
dis=[0]*(h*w+1)
for i in range(d,h*w):
  dis[i]=dis[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d])
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(dis[r-1]-dis[l-1])

Measured memory_bytes: 12968
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int n;
vector<int> vec[150000];
double ans[150000];
double p[150000];
// 0-rootでそのノード以下で訪れる期待値

double dfs1(int d, int from=-1){
  double ret=0;
  int cnt=0;
  for(auto to : vec[d]) if(to != from){
    ret += dfs1(to, d);
    cnt++;
  }
  if(cnt==0) ret = 1.0;
  else ret = ret/cnt + 1.0;

  return p[d] = ret;
}

void dfs2(int d, int from=-1, double pass=0){
  double acc = pass;
  for(auto to : vec[d]) if(to != from) acc += p[to];
  ans[d] = acc/vec[d].size() + 1.0;

  for(auto to : vec[d]) if(to != from){
    double tmp;
    if(vec[d].size()==1) tmp = 1.0;
    else tmp = (acc - p[to])/(vec[d].size()-1) + 1.0;
    dfs2(to, d, tmp);
  }
}

int main(){
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    vec[a].pb(b);
    vec[b].pb(a);
  }

  dfs1(0);
//  rep(i,n) dbg(p[i]);
  dfs2(0);

  rep(i,n) printf("%.7f\n", ans[i]-1.0);

  return 0;
}


Measured memory_bytes: 18048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;
//abc178a

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int x;
    cin>>x;
    out(1^x);
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
  
  int solve(vector<int>&a,vector<int>&b,vector<int>&c){
     vector<int>dp(3);
     dp[0]=a[0];
     dp[1]=b[0];
     dp[2]=c[0];
     int x,y,z;
     for(int i=1;i<a.size();i++){
         x=max(dp[1]+a[i],dp[2]+a[i]);
          y=max(dp[0]+b[i],dp[2]+b[i]);
           z=max(dp[1]+c[i],dp[0]+c[i]);
        //   cout<<x<<" "<<y<<" "<<z<<endl;
           dp[0]=x;
           dp[1]=y;
           dp[2]=z;
     }
     return max({dp[0],dp[1],dp[2]});
     
  }




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<solve(a,b,c)<<endl;
    
   
   
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(){
    int i,n,d=0;
    scanf("%d",&n);
    int a[n],b[n],c[n-1];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&b[i]);
        d=d+b[i];
    }
    int g;
    for(i=0;i<n-1;i++){
        scanf("%d",&c[i]);
    }
    for(i=0;i<n-1;i++){
        if(a[i]==a[i+1]-1){
            g=a[i];
            d=d+c[g-1];
        }
    }

    printf("%d",d);
}


Measured memory_bytes: 128
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int F = sc.nextInt();
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		ArrayList<String> list = new ArrayList<String>();
		String[][] str = new String[N][];
		for(int i = 0; i < N; i++) {
			int M = sc.nextInt();
			str[i] = new String[M];
			for(int j = 0; j < M; j++) {
				str[i][j] = sc.next();
				if(map.containsKey(str[i][j])) continue;
				else {
					map.put(str[i][j], list.size());
					list.add(str[i][j]);
				}
				
			}
		}
		int[][] num = new int[list.size()][list.size()];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < str[i].length; j++) {
				for(int k = j+1; k < str[i].length; k++) {
					if(j == k) continue;
					num[map.get(str[i][j])][map.get(str[i][k])]++;
					num[map.get(str[i][k])][map.get(str[i][j])]++;
				}
			}
		}
		ArrayList<Data> l = new ArrayList<Data>();
		for(int i = 0; i < list.size(); i++) {
			for(int j = i+1; j < list.size(); j++) {
				if(num[i][j] >= F) {
					l.add(new Data(list.get(i),list.get(j)));
				}
			}
		}
		Collections.sort(l);
		System.out.println(l.size());
		for(int i = 0; i < l.size(); i++) {
			System.out.println(l.get(i).a + " " + l.get(i).b);
		}
	}
	static class Data implements Comparable<Data> {
		String a;
		String b;
		Data(String a, String b) {
			String[] kk = {a,b};
			Arrays.sort(kk);
			this.a = kk[0];
			this.b = kk[1];
		}
		@Override
		public int compareTo(Data o) {
			if(o.a.equals(this.a)) return -o.b.compareTo(this.b);
			return -o.a.compareTo(this.a);
		}
	}
}

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

int main()
{int  A,B,C,D;
cin >> A >> B >> C >> D;
 if(min(B,D) >= max(A,C)){
cout << min(B,D) - max(A,C) << endl;}
 else{cout << 0 << endl;}
return 0;}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int count = 0;
	int counter = 0;
	int a[10000][3];
	while (1){
		for (int i = 0; i < 3; i++){
			cin >> a[count][i];
		}
		if (a[count][0] == -1 && a[count][1] == -1 && a[count][2] == -1){
			break;
		}
		count += 1;
	}
	while (1){
		if (a[counter][0] == -1 || a[counter][1] == -1){
			cout << "F" << endl;
		}
		else if (a[counter][0] + a[counter][1] >= 80){
			cout << "A" << endl;
		}
		else if (a[counter][0] + a[counter][1] >= 65){
			cout << "B" << endl;
		}
		else if (a[counter][0] + a[counter][1] >= 50){
			cout << "C" << endl;
		}
		else if (a[counter][0] + a[counter][1] >= 30){
			if (a[counter][2] >= 50){
				cout << "C" << endl;
			}
			else{
				cout << "D" << endl;
			}
		}
		else{
			cout << "F" << endl;
		}
		counter += 1;
		if (counter == count){
			break;
		}
	}
	return 0;
}

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

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int sum = 0;
			String res = "No";
			int[] array = new int [n];
			for(int i = 0;i<n;i++) {
				array[i] = sc.nextInt();
				sum+=array[i];
			}
			int max = array[0];
			for(int numb:array) {
				if(numb>=max) 
					max = numb;
				}
			if(max<sum-max) {
				res = "Yes";
			}
		
			System.out.println(res);
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}

Measured memory_bytes: 23764
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

char col[4] = {'R','Y','G','B'};
char a[511][511];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,k; cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			a[i][j] = col[((i+j)%(2*k) >= k)*2 + ((i-j+(2*k)*10000)%(2*k) >= k)%2];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cout<<a[i][j];
		}
		cout<<'\n';
	}
}


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

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

using namespace std;

const int inf = 1e9 + 7;

int main() {
	int x;
	cin >> x;
	int ans = 0;
	for(int i=1;i<=x;i++){
		for(int j=2;j<10;j++){
			if(ans <= pow(i,j) && pow(i,j) <= x){
				ans = pow(i,j);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
cnt = 0
for i in range(n):
    l,r = inpl()
    cnt += r-l+1
print(cnt)

Measured memory_bytes: 39280
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int N = scanner.nextInt();
			
			if( A + B >= N ) 
			{
				System.out.println("Yes");
			}
			else 
			{
				System.out.println("No");
			}
			
		    scanner.close(); }
		  }

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

import math

if abs(N-M)>=2:
  print(0)
else:
  if (N+M)%2==0:
    print((2*(math.factorial(N)%1000000007)*(math.factorial(M)%1000000007))%1000000007)
  else:
    print(((math.factorial(N)%1000000007)*(math.factorial(M)%1000000007))%1000000007)


Measured memory_bytes: 4096
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int i,j,sum;
        int[] num = new int[3];
        int[][] a;
        int[] b;
        while(true){
            str = scan.nextLine();
            String[] x = str.split(" ", 0);
            for(i = 0; i < 3; i++){
                num[i] = Integer.valueOf(x[i]);
            }
            if(num[0]==-1&&num[1]==-1&&num[2]==-1){
                break;
            }
            if(num[0]==-1||num[1]==-1){
                System.out.println("F");
                continue;
            }
            if(num[0]+num[1]>=80){
                System.out.println("A");
                continue;
            }
            if(num[0]+num[1]>=65){
                System.out.println("B");
                continue;
            }
            if(num[0]+num[1]>=50){
                System.out.println("C");
                continue;
            }
            if(num[0]+num[1]>=30){
                if(num[2]>=50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
                continue;
            }
            System.out.println("F");
            continue;
        }
        
        scan.close();
    }
}


Measured memory_bytes: 26284
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);

int mod9(int A) {
    int tmp = 0;
    while (A > 0) {
        tmp += A % 10;
        A /= 10;
    }
    return tmp;
}

//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    int ans = 100000;
    REP_1(A, N / 2) {
        int B = N - A;
        ans = min(ans, mod9(A) + mod9(B));
    }
    print(ans);
}


Measured memory_bytes: 256
s = int(input())
ans = []
i=1
ans.append(s)
while True:
    i += 1
    if s % 2 == 0:
        s = s / 2
        if s in ans:
            print(i)
            exit()
        else:
            ans.append(s)
    else:
        s = s * 3 + 1
        if s in ans:
            print(i)
            exit()
        else:
            ans.append(s)

Measured memory_bytes: 3060
from collections import deque
####not yet
def DFS_Stack_matrix(matrix,start): #隣接行列のDFS
    list_nodes = [start]
    n = len(matrix[0])
    stac = deque()
    flag = False
    while len(list_nodes) <  n :#start以外全部訪れたらおわり
        for i in range(n):
            if matrix[start][i] == 1:
                stac.append(i)  #startに隣接する要素を追加
        while stac:# if stac is not emnpty
            start = stac.pop() # stac から次に訪問するノードを取り出す
            if start in list_nodes:
                continue#訪問済みなら新しいstartを探す
            else:
                list_nodes.append(start) #訪問済みリストに追加
                break
        else:
            break
    else:
        flag = True
    return flag


n,m = map(int,input().split())
mat = [[0]*n for i in range(n)]
ind = []
for i in range(m):
    u,v = map(int,input().split())
    mat[u-1][v-1] =1
    mat[v-1][u-1] = 1
    ind.append([u,v])

cnt = 0
for u,v in ind:
    mat[u-1][v-1] = 0
    mat[v-1][u-1] = 0
    if DFS_Stack_matrix(mat,0):
        pass
    else:
        cnt +=1
    mat[u-1][v-1] = 1
    mat[v-1][u-1] = 1
print(cnt)


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 201

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ll n;
    cin >> n;
    ll s = sqrt(n);
    while (s > 0) {
        if (n%s == 0) {
            if (s <= 9 && n/s <= 9)
                cout << "Yes\n";
            else
                cout << "No\n";
            break;
        }
        s--;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 16
int a,b,n,x,y,cnt;
bool field[MAX][MAX];
void rec(int x,int y)
{
  if(field[x][y]==false)return;
  if(x==a-1&&y==b-1){
    cnt++;
    return;
  }
  if(x+1<a)rec(x+1,y);
  if(y+1<b)rec(x,y+1);
  return;
}
int main()
{
  int i,j;
  while(cin>>a>>b>>n,a|b){
    for(i=0;i<a;i++)for(j=0;j<b;j++)field[i][j]=true;
    while(n-->0){
      cin>>x>>y;
      field[x-1][y-1]=false;
    }
    cnt=0;
    rec(0,0);
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 864
def counting_sort(n, A, k=10001):
    C = [0 for _ in range(k)]
    B = [0 for _ in range(n)]

    for i in range(n):
        C[A[i]] += 1

    for i in range(1, k):
        C[i] = C[i] + C[i-1]

    for j in range(n-1, -1, -1):
        # C[A[j]]はA[j]以下にどれくらいの要素があるかを表している
        # したがって一番大きい数字はnになるので、-1をしてインデックス
        # をずらす必要がある
        B[C[A[j]]-1] = A[j] 
        C[A[j]] -= 1

    return B


def main():
    n = int(input())
    A = list(map(int, input().split()))
    print(*counting_sort(n, A))


if __name__ == '__main__':
    main()



Measured memory_bytes: 224392
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   int[] b = new int[N];
   for(int i=0;i<N;i++) 
   {
     a[i]= sc.nextInt();
     b[i]= a[i];
   }
   Arrays.sort(a);
   int ans=0;
   for(int i=0;i<N;i++)
   {
     if(b[i]<=a[(N/2)-1]) ans = a[N/2];
     else ans = a[(N/2)-1];
     System.out.println(ans);
   }
 }
}

Measured memory_bytes: 95748