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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (998244353)

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

u64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

int main() {
  cout << setprecision(18);

  i64 K;
  string S;
  cin >> K >> S;

  if (S.size() > K) {
    for (u32 i = 0; i < K; ++i) {
      cout << S[i];
    }
    cout << "...";
    cout << endl;
  } else {
    cout << S << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
# ABC167a


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    s = input()
    t = input()
    if len(s) + 1 != len(t):
        print('No')
        exit(0)
    if s != t[:-1]:
        print('No')
        exit(0)
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8984
as, bs = gets.split
a = as.to_i

b = 0
fp = 0
if (i = bs.index '.')
  b = (bs[0, i] + bs[i+1..-1]).to_i(10)
  fp = bs.size - i - 1
else
  b = bs.to_i
end

c = a * b
cs = c.to_s

if cs.size <= fp
  puts "0"
else
  puts cs[0...-fp]
end


Measured memory_bytes: 14396
function Main(input){
  const r = Number(input);
  let S, L;
  S = (r * r * Math.PI).toFixed(6);
  L = (r * 2 * Math.PI).toFixed(6);
  console.log(S + " " + L);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15096
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++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 SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string s, t;
    cin >> s >> t;

    cout << t << s << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length(),dp[100005]={0};
dp[0]=1;
rep(i,0,n-1)
{
	if(i>=4)
	{
		if(s.substr(i-4,5)=="dream")
		dp[i+1]|=dp[i-4];
		if(s.substr(i-4,5)=="erase")
		dp[i+1]|=dp[i-4];
	}
	if(i>=5)
	{
		if(s.substr(i-5,6)=="eraser")
		dp[i+1]|=dp[i-5];
	}
	if(i>=6)
	{
		if(s.substr(i-6,7)=="dreamer")
		dp[i+1]|=dp[i-6];
	}
}
if(dp[n])ol("YES");
else ol("NO");
return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, k, x, y;
  std::cin >> n >> k >> x >> y;
  if (n <= k)
    std::cout << x * n << "\n";
  else
    std::cout << x * k + y * (n - k) << "\n";
}


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

ll s(ll x, ll y) {
	ll X = x, Y = y;
	while (1) {
		y = y % x;
		swap(x, y);
		if (x == 0)
			return X / y * Y;
		if (y == 0)
			return X / x * Y;
	}
}

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	//Cで割れる
	ll canc = B / C - (A - 1) / C;
	//Dで割れる
	ll cand = B / D - (A - 1) / D;
	//CとDの最小公倍数で割れる
	ll cd = s(C, D);
	ll cancd = B / cd - (A - 1) / cd;
	//cout << cd << endl;
	ll ans = B - (A - 1) - (canc + cand - cancd);
	cout << ans << endl;
}

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

int a, b, c;
int x;
int solver() {
	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				int tmp = i * 500 + j * 100 + k * 50;
				if (tmp == x)ans++;
			}
		}
	}
	return ans;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> a >> b >> c >> x;
	int ans = solver();

	cout << ans << endl;
}

Measured memory_bytes: 3616
N = int(input())
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
 
cnt = 0
 
if B[0] > A[0]:
    amari = B[0] - A[0]
    cnt += A[0]
else:
    amari = 0
    cnt +=  B[0]
    
for i in range(1,N):
    if A[i] > amari:
        cnt += amari
        nokori = A[i] - amari
    else:
        cnt += A[i]
        nokori = 0
    
    if nokori > B[i]:
        cnt += B[i]
        amari = 0
    else:
        cnt += nokori
        amari = B[i] - nokori
        
if amari > A[N]:
    cnt += A[N]
else:
    cnt += amari
print(cnt)

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

void input(string& rsColor)
{
  cin >> rsColor;
}

int calcMaxRemove(string sColor)
{
  vector<int> vnColor(2);

  for (int i = 0; i < sColor.size(); i++)
    vnColor[ sColor[i] - '0' ]++;

  return min(vnColor[0], vnColor[1]) * 2;
}
 
int main()
{
  string sColor;

  input(sColor);
  cout << calcMaxRemove(sColor) << endl;

  return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator
const int SIZE=2e5;
ll ar[SIZE];
void solve() {
    ll n, t;
    cin>>n>>t;
    for(int i=0;i<n;i++) cin>>ar[i];
    ll res=0;
    for(int i=1;i<n;i++) {
        if(ar[i]-ar[i-1] < t) res += ar[i]-ar[i-1];
        else res += t;
    }
    cout<<res+t<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1792
n,m = map(int,input().split())
query = [list(map(lambda x:int(x)-1,input().split())) for i in range(m)]
query.sort(key=lambda x:x[1])

l_end = -1
ans = 0
for i in range(m):
    a,b = query[i]
    if a>=l_end:
        l_end = b
        ans+=1
print(ans)

Measured memory_bytes: 29088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  int N,W; cin>>N>>W;
  vi wgt(N); vi value(N);
  rep(i,N) {cin>>wgt[i]; cin>>value[i];}
  vi w(4);
  rep(i,4) w[i] = wgt[0]+i;
  vvi v(4,vi(0));
 
  rep(i,N){
    if(wgt[i] == w[0]) v[0].push_back(value[i]);
    else if(wgt[i] == w[1] ) v[1].push_back(value[i]);
    else if(wgt[i] == w[2] ) v[2].push_back(value[i]);
    else if(wgt[i] == w[3] ) v[3].push_back(value[i]);
  }
  rep(i,4) {
    sort(all(v[i]),greater<int>());
    rep2(j,1,(int)v[i].size()) v[i][j] += v[i][j-1]; 
    v[i].insert(v[i].begin(),0);
  }

  int w0max = W/w[0];
  int ans =0;  
  for(int i= w0max; i>=0; i--){
    rep(j, (int)v[1].size()){
      if (i*w[0]+j*w[1] > W) break;
      rep(k,(int)v[2].size()){
      if (i*w[0]+j*w[1]+k*w[2] > W) break;
        rep(l,(int)v[3].size()){
          if (i*w[0]+j*w[1]+k*w[2]+l*w[3] > W) break;
  	      ans = max(ans, v[0][i]+v[1][j]+v[2][k]+v[3][l]);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ARestricted {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    if(a+b >= 10) out << "error" << endl;
	    else out << a+b << endl;
	}
};


int main() {
	ARestricted solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string s;
	cin >> s;
	string res = "";
	REP(i, s.size()) {
		if (s[i] == 'B') {
			if (!res.empty()) res.pop_back();
		}
		else res.push_back(s[i]);
	}
	cout << res << "\n";
	

	return 0;
}

Measured memory_bytes: 256
N = int(input())
c = list(map(int,input().split()))
b = [0]*8
cnt = 0
for a in c:
    if 0<a<400:
        b[0]=1
    elif 399<a<800:
        b[1]=1
    elif 799<a<1200:
        b[2]=1
    elif 1199<a<1600:
        b[3]=1
    elif 1599<a<2000:
        b[4]=1
    elif 1999<a<2400:
        b[5]=1
    elif 2399<a<2800:
        b[6]=1
    elif 2799<a<3200:
        b[7]=1
    else:
        cnt += 1
print(max(1, b.count(1)), end = " ")
print(b.count(1) + cnt)

Measured memory_bytes: 9104
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
  var N = nextInt();
  var eigyo = new Array(N);
  var rieki = new Array(N);
  for(var i = 0; i < N; i++){
    eigyo[i] = nextIntArray();
  }
  for(var i = 0; i < N; i++){
    rieki[i] = nextIntArray();
  }
  var output = Math.pow(10,12) * -1;
  //0:月曜午前、1:月曜午後、2:火曜午前、・・・9:金曜午後
  var maxPattern = 10;
  for(var i = 1; i < (1 << maxPattern); i++){
    var selected = [];
    for(var j = 0; j < maxPattern; j++){
      if((i & (1 << j)) != 0){
        //選ぶ
        selected.push(j);
      }
    }
    var sum = 0;
    for(var j = 0; j < N; j++){
      var same = 0;
      for(var k = 0; k < selected.length; k++){
        if(eigyo[j][selected[k]] == 1){
          same++;
        }
      }
      sum += rieki[j][same];
    }
    
    output = Math.max(output, sum);
  }
  myout(output);
}


Measured memory_bytes: 34040
N = gets.to_i
T, A = gets.split(' ').map(&:to_i)
H = gets.split(' ').map(&:to_i)

cities = []
H.each_with_index do |h, i|
  cities.push([(A - (T - h * 0.006)).abs, i + 1])
end

cities.sort_by!{|city| city[0]}
puts cities[0][1]

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
  int a=0;
  int b=0;
  int sum[100];
  int i=0;

  i=0;
  while(scanf("%d%d",&a,&b)!=EOF){
    sum[i] = a + b;
    a = 0;
    while(sum[i] != 0){
      sum[i] = sum[i] / 10;
      a++;
    }
    printf("%d\n",a);
    i++;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdbool.h>

#define MAX 1000000

int main(void)
{
    int i, j;

    bool isPrime[MAX];
    isPrime[0] = isPrime[1] = false;
    for (i = 2; i < MAX; i++) {
        isPrime[i] = true;
    }

    for (i = 2; i < MAX; i++) {
        if (isPrime[i] == true) {
            for (j = i + i; j < MAX; j += i) {
                isPrime[j] = false;
            }
        }
    }

    int n;
    int cnt;
    while (scanf("%d", &n) != EOF) {
        cnt = 0;
        for (i = 2; i <= n; i++) {
            if (isPrime[i] == true) {
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}

Measured memory_bytes: 1572
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int num=0;
  int n;
  cin >> n;
  int ma = 0;
  int count;
  for(int i=1; i<=n ; i++){
    int a = i;
    count = 0;
    for(;;){
      if(a%2 !=0)break;
      a = a/2;
      count ++;
    }
    if(ma <= count){
      ma = count ;
      num = i;
    }
  }
  cout << num <<endl;
}

Measured memory_bytes: 256
n=int(input())
s=int(input())
if s>n:
  print(-1)
elif s==n:
  print(n+1)
else:
  # 2<=b<=n**0.5 で全探索
  for b in range(2,int(n**0.5)+1):
    tmp=0
    n0=n
    while n0>0:
      tmp+=n0%b
      n0//=b
    if tmp==s:
      print(b)
      exit()
  # n**0.5<bについて
  for p in range(int(n**0.5)+1,0,-1):
    b=(n-s)/p+1
    if not b.is_integer():continue
    b=int(b)
    tmp=0
    n0=n
    while n0>0:
      tmp+=n0%b
      n0//=b
    if tmp==s:
      print(b)
      exit()
  print(-1)



Measured memory_bytes: 40924
#include <stdio.h>

#define min(a,b)	(a<b?a:b)

int main(){
	long long int N;
	long long int limit[5];
	long long int i;
	long long int m=1000000000000001;
	long long int ans;
	
	scanf("%lld",&N);
	for(i=0;i<5;i++)	scanf("%lld",&limit[i]);
	
	for(i=0;i<5;i++){
		m=min(m,limit[i]);
	}
	
	if(m>=N)	printf("5\n");
	else{
		ans=0;
		
		ans+=N/m;
		if(N%m!=0)	ans++;
		ans+=4;
		
		printf("%lld\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    int[] cmb;
    static void Main(string[] args)
    {
        int[] HW = ReadLineParseIntArray();
        int[,] map = new int[HW[0], HW[1]];
        string[] s = new string[HW[0] + 1];
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < HW[0]; i++)
        {
            sb.Append(ReadLine());
            sb.Append("#");
            s[i] = sb.ToString();
            sb.Clear();
        }
        for (int x = 0; x <= HW[1]; x++)
            sb.Append("#");
        s[HW[0]] = sb.ToString();
        
        for(int y = 0; y < HW[0]; y++)
        {
            int start = -1;
            for(int x = 0; x <= HW[1]; x++)
            {
                if (s[y][x] == '.' && start == -1)
                    start = x;
                if(s[y][x] == '#' && start != -1)
                {
                    for (int i = start; i < x; i++)
                        map[y,i] += x - start;
                    start = -1;
                }
            }
        }
        
        for(int x = 0; x < HW[1]; x++)
        {
            int start = -1;
            for(int y = 0; y <= HW[0]; y++)
            {
                if (s[y][x] == '.' && start == -1)
                    start = y;
                else if(s[y][x] == '#' && start != -1)
                {
                    for (int i = start; i < y; i++)
                        map[i, x] += y - start;
                    start = -1;
                }
            }
        }
        int max = 0;
        for (int y = 0; y < HW[0]; y++)
        {
            for (int x = 0; x < HW[1]; x++)
                if (map[y, x] > max)
                    max = map[y, x];
        }
        WriteLine(max - 1);
    }
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	map<int, int> D;
	for( int i = 0; i < N; ++i ) {
		int a;
		cin >> a;
		D[a] += 1;
	}

	int M;
	cin >> M;
	string result = "YES";

	for( int i = 0; i < M; ++i ) {
		int t;
		cin >> t;
		D[t] -= 1;

		if( D[t] < 0 ) {
			result = "NO";
			break;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  i64 K;
  cin >> N >> K;
  vector<int> as(N), fs(N);
  F0R(i, N) {
    cin >> as[i];
  }
  F0R(i, N) {
    cin >> fs[i];
  }

  sort(rng(as));
  sort(rrng(fs));

  struct AF {
    int a, f;
    i64 af;
  };
  vector<AF> afs(N);
  F0R(i, N) {
    afs[i].a = as[i];
    afs[i].f = fs[i];
    afs[i].af = (i64)as[i] * fs[i];
  }
  auto afcmp = [](const AF& l, const AF& r) {
    return l.af < r.af;
  };
  sort(rrng(afs), afcmp);

  // 最大完食時間を指定した値以下にするために必要な修行回数
  auto check = [&](i64 k) ->i64 {

    i64 rs = 0;
    F0R(i, N) {
      rs += max<i64>(afs[i].a - k / afs[i].f, 0);
    }
    return rs;
  };

  i64 ok = INT64_MAX/2, ng = -1;
  while (abs(ok - ng) > 1) {
    i64 mp = (ok + ng) / 2;
    if (check(mp) <= K) {
      ok = mp;
    }
    else {
      ng = mp;
    }
  }

  cout << ok;
}
#endif


Measured memory_bytes: 4992
/*input
7 4 2
3

*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#include <tuple>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+100;
typedef long long int lld;
typedef long long ll;

#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }


#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

pair<ll,ll> intersection(ll a,ll b,ll c,ll d) {
    // Error(a,b,c,d);
    if(b<c or d<a) return make_pair(-1,-1);
    return make_pair(max(a,c),min(b,d));
}


vector<ll> V;
ll Array[lim], C[lim];

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    cin>>a>>b>>c>>k;
    while(b<=a) b*=2,k--;
    while(c<=b) c*=2,k--;
    // Error(k);

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

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


void solve() {
  int N, M; cin >> N >> M;
  Graph Tree(N);
  vector<set<int>> Parent(N);
  rep(i,N-1+M) {
    int a, b; cin >> a >> b; --a; --b;
    Tree[a].push_back(b);
    Parent[b].insert(a);
  }
  queue<int> q;
  rep(i,N) {
    if (Parent[i].empty()) {
      Parent[i].insert(-1);
      q.push(i);
      break;
    }
  }
  while (!q.empty()) {
    int p = q.front(); q.pop();
    for (auto v : Tree[p]) {
      if (Parent[v].size() > 1) {
        Parent[v].erase(p);
      } else {
        q.push(v);
      }
    }
  }
  rep(i,N) cout << *begin(Parent[i]) + 1 << endl;
}


/* -------- <programs end> -------- */


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int a,b,c;
  cin >> a >> b >> c;
  string ans;

  if ((a<c&&c<b) || (b<c&&c<a)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

typedef std::pair<int, int> P;

class Edge{
public:
	int to;
	int cost;

	Edge(){
		return;
	}
	~Edge(){
		return;
	}
};

int main(int argc, char **argv){
	std::vector<std::vector<Edge> >  G;
	std::vector<long> min_cost;
	std::priority_queue<P, std::vector<P>, std::greater<P> > que;

	int n, u, k, v, c;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	G.resize(n);
	min_cost.resize(n, 1000000000) ;

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> u >> k;
#else
		std::cin >> u >> k;
#endif
		for(int j = 0; j < k; j++){
#if INPUT_FROM_FILE
			ifs >> v >> c;
#else
			std::cin >> v >> c;
#endif
			Edge e;
			e.to = v;
			e.cost = c;

			G[u].push_back(e);

		}
	}

	min_cost[0] = 0;
	que.push(P(0, 0));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;

		if(min_cost[v] < p.first){ 
			continue;
		}

		for(int i = 0; i < G[v].size(); i++){
			Edge e = G[v][i];
			if(min_cost[e.to] > min_cost[v] + e.cost){
				min_cost[e.to] = min_cost[v] + e.cost;
				que.push(P(min_cost[e.to], e.to));
			}
		}
	}

	for(int i = 0; i < n; i++){
		std::cout << i << " " << min_cost[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3112
bingo = []
for i in range(3):
    a, b, c = map(int, input().split())
    bingo += [a, b, c]

b_list = []
for i in range(int(input())):
    b_list.append(int(input()))

for i in range(len(bingo)):
    if bingo[i] in b_list:
        bingo[i] = 'X'

pattern_list =[[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
flag = 0
for i in range(len(pattern_list)):
    if bingo[pattern_list[i][0]] == 'X' and bingo[pattern_list[i][1]] == 'X' and bingo[pattern_list[i][2]] == 'X':
        flag = 1
        break

if flag == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
n = int(input())
a = [[False]*n for i in range(n)]
  
for i in range(n):
    v = list(map(int, input().split()))
    u = v[0]
    k = v[1]
    for j in range(k):
        a[u - 1][v[2 + j] - 1] = True

d = [0] * n
f = [0] * n
isDiscovered = [False] * n
time_stamp = 0

def dfs(x):
    global time_stamp
    isDiscovered [x] = True
    time_stamp = time_stamp + 1
    d[x] = time_stamp
    for i in range(n):
        if a[x][i]and not isDiscovered[i]:
            dfs(i)
    time_stamp = time_stamp + 1
    f[x] = time_stamp

for i in range(n):
    if not isDiscovered[i]:
        dfs(i)

for i in range(n):
    print(i+1, d[i], f[i])

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

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

    static class abc156_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int x[] = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt();
            }
            int min = Integer.MAX_VALUE;
            for (int i = 1; i <= 100; i++) {
                int val = 0;
                for (int j = 0; j < N; j++) {
                    val += (x[j] - i) * (x[j] - i);
                }
                min = Math.min(min, val);
            }
            out.println(min);
        }

    }
}



Measured memory_bytes: 21716
package main

import (
	"fmt"
)

func main() {
	lines := [3]int{}
	var round int
	fmt.Scan(&round)
	for r := 0; r < round; r++ {
		fmt.Scan(&lines[0], &lines[1], &lines[2])

		if lines[0] > lines[1] && lines[0] > lines[2] {

		} else if lines[2] > lines[1] {
			tmp := lines[0]
			lines[0] = lines[2]
			lines[2] = tmp
		} else {
			tmp := lines[0]
			lines[0] = lines[1]
			lines[1] = tmp
		}

		if lines[1]*lines[1]+lines[2]*lines[2] == lines[0]*lines[0] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}



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

int32_t main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            cnt++;
        } else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans << '\n';
}


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

int64_t lucas_num(int n, vector<int64_t>& nums) {
  if (n == 0) {
    return 2;
  }
  if (n == 1) {
    return 1;
  }
  if (nums.at(n) != 0) {
    return nums.at(n);
  }
  nums.at(n) = lucas_num(n-1, nums) + lucas_num(n-2, nums);
  return nums.at(n);
}

int main() {
  int N;
  cin >> N;
  vector<int64_t> lucasnum(N+1, 0);
  lucasnum.at(0) = 2;
  lucasnum.at(1) = 1;
  int64_t ans = lucas_num(N, lucasnum);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
 
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main() {
    IOS
    int n, risan;
    cin >> n;
    bool adaEv = true;
    
    for(int i=0; i<n; i++){
      cin >> risan;
      if(risan % 2 == 0) {
        if(risan % 3 != 0 && risan % 5 != 0) { 
          adaEv = false;
          break;
        }
      }
    }
    
    if(adaEv) 
      cout << "APPROVED\n";
    else 
      cout << "DENIED\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int R,G,B,N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for(int i=0;i*R<=N;i++)
    {
      for(int j=0;j<=min(G*j,N-i*R);j++)
	{
	  if((N-R*i-G*j)>=0 && (N-R*i-G*j)%B==0)
	    {
	      //	      cout << i << " " << j << " " << (N-R*i-G*j)/B << endl;
	      ans++;
	    }
	}
     }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque

def enable_color(vertex, color_count, used_color):
    used = used_color[vertex]
    for i in range(1, color_count+1):
        if i not in used:
            return i

def main():
    N = int(input())
    AB = [list(map(int,input().split())) for _ in range(N-1)]

    leafs = [[] for _ in range(N+1)]
    for a, b in AB:
        leafs[a].append(b)

    # 各頂点についてBFS
    q = deque()
    q.append(1)
    color = [0] * (N + 1)

    while q:
        root = q.popleft()
        used_color = color[root]
        c = 1
        for leaf in leafs[root]:
            if c == used_color:
                c += 1
            color[leaf] = c
            c += 1
            q.append(leaf)
    print(max(color))
    for _, b in AB:
        print(color[b])


if __name__ == "__main__":
    main()

Measured memory_bytes: 36820
h,w=map(int,input().split())
s=[input() for i in range(h)]
res=True
a=[0,-1,1,0]
b=[-1,0,0,1]
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            continue
        else:
            res=False
            for k in range(4):
                if 0<=a[k]+i<h and 0<=b[k]+j<w:
                    if s[a[k]+i][b[k]+j]=="#":
                        res=True
        if not res:
            break
    if not res:
        break

if res:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9216
import sys
from collections import deque

def input():
    return sys.stdin.readline().strip()

def main():
    H,W = map(int,input().split())
    S = [list(input()) for _ in range(H)]
    dp = [[float('inf') for _ in range(W)] for _ in range(H)]

    def bfs(x,y):
        que = deque()
        que.append((x,y))
        if S[y][x] == '.':
            dp[y][x] = 0
        else:
            dp[y][x] = 1
        while que.__len__():
            x,y = que.popleft()
            for dx,dy in ((1,0),(0,1)):
                sx = x + dx
                sy = y + dy
                if sx == W or sy == H:
                    continue
                if S[y][x] == '.' and S[sy][sx] == '#':
                    tmp = 1
                else:
                    tmp = 0
                dp[sy][sx] = min(dp[y][x]+tmp,dp[sy][sx])
                if (sx,sy) not in que:
                    que.append((sx,sy))
    bfs(0,0)
    print(dp[H-1][W-1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  int ans = 0;
  vector<int> A(3);
  rep(i,0,3){cin >> A[i];}
  sort(A.begin(),A.end());
  ans = A[2] - A[0];
  co(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)
 
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  int S,W;

  cin >> S >> W;

  if(S>W)
    cout << "safe" << endl;
  else
    cout << "unsafe" << endl;

  return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            string ans = "";
            if ((N + 1) / 2 >= M)
                ans = "YES";
            else 
                ans = "NO";

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28212
// 2020-08-02 21:28:09
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct FenwickTree {
  int N;
  vll bit;
  void init(int n) {
    N = n;
    bit.assign(n+2, 0);
  }
  void add(int i, ll a) {
    while(i <= N) {
      bit[i] += a;
      // chmax(bit[i], a);
      i += (i & -i);
    }
  }
  ll sum(int i) {
    ll res = 0;
    while(i > 0) {
      res += bit[i];
      // chmax(res, bit[i]);
      i -= (i & -i);
    }
    return res;
  }
  int lower_bound(ll w) {
    int k = 1;
    while(k <= N) k *= 2;
    k /= 2;
    int x = 0;
    while(k > 0) {
      if(x+k <= N && bit[x+k] < w) {
        w -= bit[x+k];
        x += k;
      }
      k /= 2;
    }
    return x+1;
  }
};

using T = tuple<int, int, int>; // r, l, i

void answer() {
  int n, q;
  cin >> n >> q;
  vector<int> cs(n), last(n+1, -1), ans(q);
  rep(i, n) cin >> cs[i];
  vector<T> qs(q); // r, l, i
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    qs[i] = T(r, l, i);
  }
  sort(ALL(qs));
  FenwickTree bit;
  bit.init(n);
  int cur_r = 1;
  rep(qi, q) {
    int l, r, ansi;
    tie(r, l, ansi) = qs[qi];
    for(; cur_r <= r; cur_r++) {
      int c = cs[cur_r-1];
      if(last[c] >= 0) {
        bit.add(last[c], -1);
      }
      last[c] = cur_r;
      bit.add(last[c], 1);
    }
    ans[ansi] = bit.sum(r) - bit.sum(l-1);
  }
  rep(i, q) cout << ans[i] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 19392
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

void foreach_permutation(int n, function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

static double dsum = 0.0;
static vector<pair<int, int>> positions;

static int n;
static int patterns = 0;

// 3
// 0 0
// 1 0
// 0 1

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

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);

    positions.push_back(make_pair(x, y));
  }

  foreach_permutation(n, [](int *indexes) {
    double d = 0.0;
    // cout << "###" << endl;
    for (int i = 0; i < n - 1; i++) {
      int index = indexes[i];
      int index2 = indexes[i + 1];

      int ox = positions[index].first - positions[index2].first;
      int oy = positions[index].second - positions[index2].second;
      int k = ox * ox + oy * oy;
      d += pow(k, 0.5);

      // cout << "-------------" << endl;
      // cout << index << endl;
      // cout << positions[index].first << "," << positions[index].second <<
      // endl; cout << positions[index2].first << "," <<
      // positions[index2].second
      //      << endl;
      // cout << "-------------" << endl;
    }
    dsum += d;
    patterns++;
  });

  cout << dsum / patterns << endl;
}


Measured memory_bytes: 512
n = int(input())
u = [[0,0,0]]
for i in range(n):
    u.append(list(map(int,input().split())))

dp = [[0,0,0],u[1]]
for i in range(2,n+1):
    dp.append([0,0,0])
for i in range(2,n+1):
    dp[i][0]=max(dp[i-1][1]+u[i][0],dp[i-1][2]+u[i][0])
    dp[i][1]=max(dp[i-1][2]+u[i][1],dp[i-1][0]+u[i][1])
    dp[i][2]=max(dp[i-1][0]+u[i][2],dp[i-1][1]+u[i][2])

print(max(dp[n]))

Measured memory_bytes: 76376
#include <stdio.h>
#include <math.h>

int main(){
int mono=0,kane=0,tmono,tkane,t=0;

while(0<=scanf("%d,%d",&tkane,&tmono)){
mono+=tmono;
kane+=(tmono*tkane);
if(tmono!=0)
t++;
}

printf("%d\n%d\n",kane,(int)(((double)mono)/((double)t)+0.5)); 
return 0;
} 

Measured memory_bytes: 0
while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break
    else:
        for x in range(h):
            if x == 0 or x == h - 1:
                print("#" * w)
            else:
                str = ""
                for y in range(w):
                    if y == 0 or y == w - 1:
                        str += "#"
                    else:
                        str += "."
                print(str)
        print("")



Measured memory_bytes: 5616
r, g, b = map(int, input().split())
k = int(input())

ans = "No"
if r < g < b:
    ans = "Yes"
else:
    g_multi_num = 0
    b_multi_num = k
    for _ in range(k+2):
        if r < g * (2 ** g_multi_num) < b * (2 ** b_multi_num):
            ans = "Yes"
        g_multi_num += 1
        b_multi_num -= 1
print(ans)


Measured memory_bytes: 9248
import java.util.*;
public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == (b + c)){
			System.out.println("Yes");
		}else if(b == (a + c)){
			System.out.println("Yes");
		}else if(c == (a + b)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 9676