akhauriyash/Code-Regression huggingface dataset:
from collections import deque

def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    b = sum(r.count("#") for r in s)
    m = [[9999] * w for _ in range(h)]
    m[0][0] = 1
    n = deque([(0, 0)])
    d = set()
    while n:
        x, y = n.popleft()
        if (x, y) in d:
            continue
        if x == w - 1 and y == h - 1:
            break
        d.add((x, y))
        if x > 0 and s[y][x - 1] == ".":
            m[y][x - 1] = min(m[y][x - 1], m[y][x] + 1)
            n.append((x - 1, y))
        if x < w - 1 and s[y][x + 1] == ".":
            m[y][x + 1] = min(m[y][x + 1], m[y][x] + 1)
            n.append((x + 1, y))
        if y > 0 and s[y - 1][x] == ".":
            m[y - 1][x] = min(m[y - 1][x], m[y][x] + 1)
            n.append((x, y - 1))
        if y < h - 1 and s[y + 1][x] == ".":
            m[y + 1][x] = min(m[y + 1][x], m[y][x] + 1)
            n.append((x, y + 1))
    if m[h - 1][w - 1] == 9999:
        print(-1)
    else:
        print(h * w - b - m[h - 1][w - 1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#include<cstdio>
using namespace std;
int q,h,s,d,n;
long long ans;
int main()
{
	scanf("%d%d%d%d",&q,&h,&s,&d);
	q*=4;h*=2;
	if (s>=q) s=q;
	if (s>=h) s=h;
	scanf("%d",&n);
	if (s*2<=d) ans=(long long)s*(long long)n;
	else 
	{
		ans=(long long)d*(long long)(n/2);
		n%=2;
		ans+=s*n;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  sort(ALL(a));
  a.resize(k);
  kek(accumulate(ALL(a), 0LL));
}


Measured memory_bytes: 3652
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
String S =sc.next();
char a= S.charAt(0);
char b= S.charAt(1);
char c= S.charAt(2);
if(a!=b || b!=c){
  System.out.println("Yes");
}
else{
  System.out.println("No");
}

  }


}


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

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        var a = new int[26];

        string S = Console.ReadLine();
        foreach(var x in S)
        {
            a[x - 'a']++;
        }
        for (int i = 1; i < N; i++)
        {
            string T = Console.ReadLine();
            var b = new int[26];
            foreach(var x in T)
            {
                b[x - 'a']++;
            }
            for(int j = 0; j < 26; j++)
            {
                if (a[j] > b[j]) a[j] = b[j];
            }
        }

        string ans = "";
        for (int i = 0; i < 26; i++)
        {
            while(a[i] > 0)
            {
                ans += ((char)('a' + i)).ToString();
                a[i]--;
            }
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll A, B;

int main() {
    fast_io;

    cin >> A >> B;
    cout << (A ^ B) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int l[10], v[2], all, i;
	double t;

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0], &v[1]) != EOF){
		all = 0;

		for(i = 0; i < 10; i++){
			all += l[i];
		}

		t = (double)all / (double)(v[0]+v[1]);
		t *= v[0];

		i = 0;
		while(t > 0){
			t -= (double)l[i];
			i++;
		}

		printf("%d\n", i);
	}

	return 0;
}

Measured memory_bytes: 596
n,l = map(int, input().split())
aji_apple = [l + x - 1 for x in range(1,n+1)]

aji_pie = []
for i in range(0,n):
    v = abs(sum(aji_apple) - (sum(aji_apple) - aji_apple[i]))
    aji_pie.append(v)

min_index = aji_pie.index(min(aji_pie))

print(sum(aji_apple) - aji_apple[min_index])



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

using namespace std;

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

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T    In(T& x){ cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

int main()
{
  fast_io();

  int n;
  cin >> n;
  vector<int> a;
  inpt(a, n);
  sort(a);

  vector<int> pa;
  pa.reserve(100);
  int last = min(10, (int)a.size());
  for (int i = 0; i < last; i++){
    for (int j = 0; j < last; j++){
      if (i == j) continue;
      int v;
      stringstream ss;
      ss << a[i] << a[j];
      ss >> v;
      pa.push_back(v);
    }
  }
  sort(pa);
  cout << pa[2] << "\n";

  return (0);
}

Measured memory_bytes: 1272
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int x[200100];
int res[200100];

void solve() {
    vector<P> vec(n);
    for (int i = 0; i < n; i++) {
        vec[i] = P(x[i], i);
    }
    sort(ALL(vec));
    for (int i = 0; i < n; i++) {
        if (i < n/2) {
            res[vec[i].second] = vec[n/2].first;
        } else {
            res[vec[i].second] = vec[n/2-1].first;
        }
    }
    for (int i = 0; i < n; i++) cout << res[i] << endl;
}

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

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

    input();
    solve();
}


Measured memory_bytes: 5376
#include <array>
#include <iostream>
#include <string>

template <typename T> struct Queue {
  int head{}, tail{};
  std::array<T, 100000> v;

  void enqueue(T x) {
    v[tail++] = x;
    if (tail == (int)v.size())
      tail = 0;
  }
  T dequeue() {
    T p = v[head++];
    if (head == (int)v.size())
      head = 0;
    return p;
  }
  bool empty() { return head == tail; }
};

struct Process {
  std::string name;
  int time;
};

int main() {
  Queue<Process> pq;
  int n, q;
  std::cin >> n >> q;

  for (int i = 0; i < n; i++) {
    Process p = {};
    std::cin >> p.name >> p.time;
    pq.enqueue(p);
  }

  int t = 0;
  while (!pq.empty()) {
    Process p = pq.dequeue();
    p.time -= q;
    if (p.time > 0) {
      t += q;
      pq.enqueue(p);
    } else {
      t += q + p.time;
      std::cout << p.name << " " << t << std::endl;
    }
  }
}



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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


string s,t;

int main(){
  cin>>s>>t;
  ll len=s.length();
  for(ll i=0;i<=len;i++){
    s=s[len-1]+s.substr(0,len-1);
//    cout<<s<<endl;
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

int main(){
    char s[10];
    scanf("%s", s);
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) cout << "Yes" << endl;
    else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ac[200010], ce;
bool wa[1000010];
vector<int> tle;
int main()
{
	cin >> ce;
	for(register int uke=1; uke<=ce; uke++) cin >> ac[uke];
	sort(ac+1, ac+ce+1);
	for(register int uke=1; uke<=ce; uke++){
		if(uke!=1&&ac[uke]==ac[uke-1]&&tle.size()&&tle[tle.size()-1]==ac[uke]) tle.pop_back();
		if(!wa[ac[uke]]){
			tle.push_back(ac[uke]);
			for(register int mle=ac[uke]; mle<=1000000; mle+=ac[uke]) wa[mle]=true;
		}
	}
	cout << tle.size() << endl;
	return 0;
}

Measured memory_bytes: 5356
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int k; cin >> k;
    ll ans = 0;
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(l,1,k+1){
                ans += __gcd(i,__gcd(j,l));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
from sys import stdin
n = int(stdin.readline())
di = {}
fi = {}
a = map(int,stdin.readline().split())
ans = 'YES'
for i in a:
 di[i] = di.get(i,0) + 1
m = int(stdin.readline())
b = map(int,stdin.readline().split())
for i in b:
 fi[i] = fi.get(i,0) + 1
for i in fi:
 if fi[i] > di.get(i,0):
  ans = 'NO'
print ans

Measured memory_bytes: 50808
n = int(input())
A = list(map(int, input().split()))

rate = [0]*8
f = 0

for a in A:
    if a >= 3200:
        f += 1
    else:
        rate[a//400] = 1

if sum(rate) > 0:
    print(f"{sum(rate)} {sum(rate)+f}")
else:
    print(f"{min(f, 1)} {f}")

Measured memory_bytes: 61696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll k;
    ll num=7;
    cin>>k;
    ll sum=7LL%k;
    ll fac=10LL%k;
   ll cnt=1;
   while(sum%k && cnt<=10000000){
       sum+=(num%k*fac)%k;
       num=num%k*fac;
       cnt++;
   }
   if(sum%k==0){
       cout<<cnt<<endl;
   }else{
       cout<<-1<<endl;
   }
}

Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> result = new ArrayList<Integer>();
		Scanner insert = new Scanner(System.in);
		int n = -1;
		int m = -1;
		while(true) {
			String line = insert.nextLine();
			String array[] = line.split(" ");
			n = Integer.parseInt(array[0]);
			m = Integer.parseInt(array[1]);
			if((n==0) && (m == 0)) {
				break;
			}
			ArrayList<Integer> sums = new ArrayList<Integer>();
			int[] input = new int[n];
			line = insert.nextLine();
			String array2[] = line.split(" ");
			for(int i =0; i < n; i++) {
				input[i] = (Integer.parseInt(array2[i]));
			}
			for(int i = 0; i < (n - 1); i ++) {
				for(int j = (i + 1); j < n; j++) {
					sums.add(input[i] + input[j]);
				}
			}
			Collections.sort(sums,Comparator.reverseOrder());
			for(int i = 0; i < sums.size(); i++) {

				if(sums.get(i) <= m) {
					result.add(sums.get(i));
					break;
				}
				if(i == (sums.size() - 1)) {
					result.add(-1);
				}
			}

		}
		for(int i = 0;i < (result.size());i++) {
			if(result.get(i) == -1) {
				System.out.println("NONE");
			}
			else {
				System.out.println(result.get(i));
			}
		}
	}
}



Measured memory_bytes: 77040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N, M; cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  rep(i, M) cin >> s.at(i) >> c.at(i);
  vector<int> num(N, -1);
  bool ok = true;
  rep(i, M){
    if(num.at(s.at(i)-1) == -1){
      num.at(s.at(i)-1) = c.at(i);
    } else if (!(num.at(s.at(i)-1) == c.at(i))){
      ok = false;
      break;
    }
  }
  int ans = 0;
  if(!(N == 1) && num.at(0) == 0) ok = false;
  if(!(N == 1) && num.at(0) == -1) num.at(0) = 1;
  rep(i, N) if(num.at(i) == -1) num.at(i) = 0;
  if(ok){
    rep(i, N) ans += num.at(i) * pow(10, N-1-i);
  } else {
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll a1, a2, a4, a8, n, r;

int main() {
	cin >> a1 >> a2 >> a4 >> a8 >> n;
	a1 *= 4, a2 *= 4, a4 *= 4, a8 *= 4, n*= 4;
	if (n>=8) {
		ll mn = min(8*a1, min(4*a2, min(2*a4, a8)));
		ll m = n/8;
		r += mn * m;
		n -= m*8;
	}
	if (n>=4) {
		ll mn = min(4*a1, min(2*a2, a4));
		ll m = n/4;
		r += mn * m;
		n -= m*4;
	}
	if (n>=2) {
		ll mn = min(2*a1, a2);
		ll m = n/2;
		r += mn * m;
		n -= m*2;
	}
	if (n==1) {
		r += a1;
		n -= 1;
	}
	cout << r/4 << ln;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    int ans=0;
    for(int n=0; n<N; n++) {
        int A;
        cin >> A;
        
        ans += (D-1)/A+1;
    }
    cout << ans+X << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 11000

struct Info{
	int small,big;
};

int main(){
	int table[NUM],limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	Info data_array[NUM];
	int pre = 2;
	data_array[2].small = 0;
	data_array[2].big = 0;

	for(int i=3; i < NUM; i++){
		if(table[i] == 1){
			if(i - pre == 2){
				data_array[i].small = pre;
				data_array[i].big = i;
			}else{
				data_array[i] = data_array[i-1];
			}
			pre = i;
		}else{
			data_array[i] = data_array[i-1];
		}
	}


	int n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d %d\n",data_array[n].small,data_array[n].big);
	}


	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>

int main(int argc, char *argv[]){
    int A=700;
    int i;
    char buf[128];
    scanf("%s", buf);
    for(i=0;i<3;i++){
        if(buf[i]=='o'){
            A=A+100;
        }
    }
    printf("%d",A);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll h;

ll cal(ll num){
	ll ans = 0;
	if(num==1)return 1;
	return cal(num/2)*2+1;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>h;
	print(cal(h));
	return 0;
}

Measured memory_bytes: 256
<?php
# 整数の入力
fscanf(STDIN, "%d %d %d", $n , $a , $b);
# 出力
if( $n == 2 ){
echo 'Borys';
} elseif(($b - $a)%2 == 0){
echo 'Alice';
}else
echo 'Borys';
?>

Measured memory_bytes: 3828
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x = na()
a = [1]
p = [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])

print(f(n,x))

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int H,W;
  cin>>H>>W;
  int C;
  cin>>C;
  vector<int> color(C);
  for (int i = 0; i < C; i++)
  {
    cin>>color[i];
  }
  vector<vector<int> > GRID(H,vector<int>(W,0));
  bool rev = 0;
  int cpos = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int Curent_Color = cpos;
      Curent_Color++;
      color[cpos]--;
      if(rev == 0)
      {
        GRID[i][j] =Curent_Color;
      }
      else
      {
        GRID[i][W-j-1] = Curent_Color;
      }
      if(color[cpos] == 0)cpos++;

    }
    rev ^=1;
    
  }
  
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(j!=0)cout<<" ";
      cout<<GRID[i][j];
    }
    cout<<endl;
    
  }
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, K;
string s;
int ans;

signed main(){
    cin >> N >> K >> s;
    int l = -1;
    int cnt = 0;
    for(int r = 0; r < N; r++){
        if(r == 0){
            if(s[0] == '0'){
                cnt++;
            }
        }
        else {
            if(s[r] == '0' && s[r - 1] == '1'){
                cnt++;
                //printf("cnt++ %d\n", r);
            }
        }
        while(l < r && cnt > K){
            l++;
            if(s[l] == '0' && s[l + 1] == '1'){
                cnt--;
            }
        }
        //printf("%d %d cnt:%d\n", l , r, cnt);
        ans = max(ans, r - l);
    }
    cout << ans << endl;


    return 0;
}

/*

*/

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

ll md=1e9+7;
ll c[2010][2010];


int main() {
    int n;
    cin >> n;
    int a,b;
    vector<pair<int,int>> p;
    for (int i=0;i<n;i++) {
        cin >> a >> b;
        p.push_back(make_pair(b,a));
    }
    sort(p.begin(),p.end());
    bool flag=true;
    ll t=0;
    for (int i=0;i<n;i++) {
        a=p[i].second;
        b=p[i].first;
        t+=a;
        if (t>b) flag=false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 2420
import sys
readline = sys.stdin.readline

N,A,B,C,D = map(int,readline().split())

X = abs(B - A)
n = N - 1

# n回で絶対値Xを作れるか

if n * C <= X <= n * D:
  print("YES")
  exit(0)

# n * Cより小さい数を作る必要があるため、Cを何回使うかを基準に考える
for i in range(1, n):
  rest_1 = abs(C * i - X)
  rest_2 = X + C * i
  # 絶対値restを残り使える数で作れるか
  useful_num = n - i # 残り使える数
  # 残りの数を割って、C <= 商 <= Dに収まるなら作れる
  if (C <= (rest_1 / useful_num) <= D) or (C <= (rest_2 / useful_num) <= D):
#    print("i",i,"rest_2",rest_2,"useful_num",useful_num)
#    print("rest_2 // useful_num",rest_2 // useful_num)
    print("YES")
    break
else:
  print("NO")


Measured memory_bytes: 9148
// C++ program to illustrate Edge Coloring 
#include <bits/stdc++.h> 
using namespace std; 

// function to determine the edge colors 
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra, 
				vector<int>& edgeColors, bool isVisited[]) 
{ 
	queue<int> q; 
	int c = 0; 

	set<int> colored; 

	// return if isVisited[ptr] is true 
	if (isVisited[ptr]) 
		return; 

	// Mark the current node visited 
	isVisited[ptr] = 1; 

	// Traverse all edges of current vertex 
	for (int i = 0; i < gra[ptr].size(); i++) { 
		// if already colored, insert it into the set 
		if (edgeColors[gra[ptr][i].second] != -1) 
			colored.insert(edgeColors[gra[ptr][i].second]); 
	} 

	for (int i = 0; i < gra[ptr].size(); i++) { 
		// if not visited, inset into the queue 
		if (!isVisited[gra[ptr][i].first]) 
			q.push(gra[ptr][i].first); 

		if (edgeColors[gra[ptr][i].second] == -1) { 
			// if col vector -> negative 
			while (colored.find(c) != colored.end()) 

				// increment the color 
				c++; 

			// copy it in the vector 
			edgeColors[gra[ptr][i].second] = c; 

			// then add it to the set 
			colored.insert(c); 
			c++; 
		} 
	} 

	// while queue's not empty 
	while (!q.empty()) { 
		int temp = q.front(); 
		q.pop(); 

		colorEdges(temp, gra, edgeColors, isVisited); 
	} 

	return; 
} 

// Driver Function 
int main() 
{ 
	set<int> empty; 

	// declaring vector of vector of pairs, to define Graph 
	vector<vector<pair<int, int> > > gra; 

	vector<int> edgeColors; 

	bool isVisited[100000] = { 0 }; 

	// Enter the Number of Vertices 
	// and the number of edges 
	int n;
	cin>>n;
	int ver = n; 
	int edge = n-1; 

	gra.resize(ver); 
	edgeColors.resize(edge, -1); 

	for(int i=0;i<n-1;i++){
		int a,b; cin>>a>>b; a--; b--;
		gra[a].push_back(make_pair(b, i)); 
		gra[b].push_back(make_pair(a, i)); 
	}
	colorEdges(0, gra, edgeColors, isVisited); 
	int maxi=-1;
	map<int,int> mp;
	int k=1;
	for(int i=0;i<edge;i++){
		empty.insert(edgeColors[i]);
		if(mp.find(edgeColors[i]) ==mp.end())
			mp[edgeColors[i]]=k++;
	}
	cout<<empty.size()<<endl;
	for (int i = 0; i < edge; i++) 
		cout<<mp[edgeColors[i]] << "\n"; 

	return 0; 
} 


Measured memory_bytes: 60416
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 100;
static const int INF = (1<<24);

int n;
int A[MAX];

void solve(){
    int minv = INF;
    int v;
    for (int i = 0; i <= 400; i++){
        v = 0;
        for (int j = 0; j < n; j++){
            v += (A[j] - i) * (A[j] - i);
        }
        minv = min(minv, v);
    }

    cout << minv << endl;

    return;
}

int main(){
    cin >> n;

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3]; cin >> A[0] >> A[1] >> A[2];
    sort(A, A+3);
    if(A[0]+A[1]==A[2]) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
BINGO_ROW_NO = 3

A  = []
for i in range(BINGO_ROW_NO):
    A.append(input().split())

N = int(input())


# ２次元配列検索処理
def SetBingo(A, b):
    for y in range(BINGO_ROW_NO):
        for x in range(BINGO_ROW_NO):
            if A[y][x] == b:
                A[y][x] = ''
                return 
    return 

for _ in range(N):
    b = input()
    SetBingo(A, b)

isBingo = False

# ビンゴチェック
for i in range(BINGO_ROW_NO):
    if A[i][0] == '' and A[i][1] == '' and A[i][2] == '':
        isBingo = True

for i in range(BINGO_ROW_NO):
    if A[0][i] == '' and A[1][i] == '' and A[2][i] == '':
        isBingo = True

if A[0][0] == '' and A[1][1] == '' and A[2][2] == '':
    isBingo = True

if A[0][2] == '' and A[1][1] == '' and A[2][0] == '':
    isBingo = True

if isBingo:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import java.util.Scanner;

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

		int N = sc.nextInt();

		String list[][] = new String[N][2];
		for(int s=0; s<N; s++){
			for(int t=0; t<2; t++){
				list[s][t] = sc.next();
			}
		}

		double sum = 0;

		for(int i=0; i<N; i++){
			if(list[i][1].matches("JPY")){
				sum +=  Double.parseDouble(list[i][0]);
			}else{
				sum +=  Double.parseDouble(list[i][0]) * 380000;
			}
		}
		
		System.out.println(sum);
    }
}

Measured memory_bytes: 22740
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    A.sort(reverse=True)

    ans = 0
    for i in range((N+1) // 2):
        ans += A[i] * 2
    
    ans -= A[0]

    if N % 2 == 1:
        ans -= A[N // 2]
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31608
import sys
import os
from sys import stdin

# stdin = open(os.path.dirname(__file__) + '/input.txt')  # local test
input = stdin.readline
sys.setrecursionlimit(20000000)


n, k = list(map(int, input().split()))
weights = list(map(int, input().split()))
weights += [0] * (k + 3)

dp = [9999999999] * (n + k + 3)
dp[0] = 0

for i in range(n - 1):
    current = weights[i]
    for step in range(1, k + 1):
        cost = abs(current - weights[i + step])
        dp[i + step] = min(dp[i + step], dp[i] + cost)

print(dp[n - 1])


Measured memory_bytes: 52444
l=input()
mod=10**9+7
n=len(l)
dp1=[1]
dp2=[1]
for i in range(1,n+1):
  dp1.append((dp1[i-1]*3)%mod)
  dp2.append(dp2[i-1])
  if l[n-i]=='1':
    dp2[i]=(dp2[i]*2+dp1[i-1])%mod
print(dp2[n])

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


int gcd(int m, int k){
    if (k==0){
        return m;
    }
    else{
        return gcd(k, m%k);
    }
}
int main(void){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i, n){
        cin>>v[i];
    }

    int ans=v[0];
    rep(i, n){
        ans=gcd(v[i], ans);
    }
    cout<<ans<<endl;
  
    
}

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

int main() {
	ll n; cin>>n;
	vector<ll> a(n);
	for (ll i=0; i<n; i++)
		cin>>a[i];
	
	//greedy?
	ll negs=0, zeroes=0, l=1e9+7, ans=0;
	for (ll i : a) {
		l = min(l,abs(i));
		ans += abs(i);
		if (i<0) negs++;
		if (i==0) zeroes++;
	}

	if (zeroes or negs%2==0) cout << ans << endl;
	else cout << ans-2*l << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <sstream>
#include <fstream>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define per(i,x,n) for(int i=n-1;i>=x;i--)
using namespace std;
#define ll long long
//head
int n, L;
int l, r, mid;
struct Bottle {
    int up, down, val;
    bool operator < (const Bottle a)const {
        return val > a.val;
    }
} a[100005];
ll b[100005], c[100005], sum[100005];
bool check(int x) {
    x--;
    rep(k, 1, n + 1) {
        if(c[k] <= x)
            continue;
        ll p = L - a[k].up, go = 0;
        if(k <= x && sum[x + 1] - a[k].val >= p)
            return 1;
        if(k > x && sum[x] >= p)
            return 1;
    }
    return 0;
}
inline char gc() {
    static char buf[1<<20], *head = buf, *tail = buf;
    return (head == tail && (tail = (head = buf) + fread(buf, 1, 1 << 20, stdin), head == tail)? -1: *head++);
}
template <typename T> inline bool read(T &x) {
    static bool f;
    static char c;
    for (c = gc(), f = false; !isdigit(c); c =gc()) {
        if (c == EOF)
            return false;
        else if (c == 45)
            f = true;
    }
    for (x = 0; isdigit(c); c = gc())
        x = x * 10 + c - 48;
    if (f)
        x = -x;
    return true;
}
int main() {
    read(n);read(L);
    rep(i, 1, n + 1)read(a[i].up),read(a[i].down),a[i].val = a[i].up - a[i].down;
    rep(i, 1, n + 1)read(b[i]);
    sort(a + 1, a + n + 1);
    rep(i, 1, n + 1)sum[i] = sum[i - 1] + a[i].val;
    ll cnt = 1, dis = 0;
    rep(i, 2, n + 1) {
        dis += (a[i].val - b[cnt]);
        if(dis <= 0)
            break;
        cnt++;
    }
    c[1] = cnt;
    int k = 2;
    for(; k <= n; k++) {
        if(cnt < k - 1 || cnt == n)
            break;
        dis += (a[k - 1].val - a[k].val);
        while(dis > 0 && cnt < n)
            cnt++, dis += (a[cnt + 1].val - b[cnt]);
        c[k] = cnt;
    }
    for(; k <= n; k++)
        c[k] = cnt;
    int day = 1;
    for(int i = 1; a[i].val > 0 && i <= n; i++, day++);
    l = 1, r = day;
    while(l < r) {
        mid = (l + r) / 2;
        if(check(mid))
            r = mid;
        else
            l = mid + 1;
    }
    if(check(l))
        cout << l << endl;
    else
        cout << -1 << endl;
    return 0;
}



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

int main() {
	// your code goes here
	int n;
	cin >> n;
	vector<int> v(n, 0), dp(n, 0);
	for(int i = 0; i < n; ++i) cin >> v[i];
	
	for(int i = 1; i < n; ++i){
		if(i > 0){
			dp[i] = abs(v[i] - v[i-1]) + dp[i-1];
		}
		if(i > 1){
			dp[i] = min(dp[i], abs(v[i] - v[i-2]) + dp[i-2]);
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
int k,len,t,imsi,gob,gob2,stlen,enlen; char arr[1010]; long long ans;
int main()
{
	scanf("%s %d",arr,&k);
	len=strlen(arr);
	char st=arr[0], en=arr[len-1]; enlen=len-1;
	if(st==en)
	{
		int gesu1=1,gesu2=1; stlen=1;
		while(arr[stlen]==st&&stlen<len)
		gesu1++, stlen++; 
		if(stlen==len) 
		{
            long long ansans=(long long)len*k/2;
			printf("%lld",ansans); return 0;
		} imsi+=gesu1/2;
		enlen=len-2;
		while(stlen<enlen&&arr[enlen]==en)
		gesu2++, enlen--; imsi+=gesu2/2;
		gob=gesu1+gesu2;
	} char im=0; gob/=2;
	for(int i=stlen;i<=enlen;i++)
	{
		if(im==0) im=arr[i];
		else if(im==arr[i]) gob2++, im=0;
		else im=arr[i];
	} ans=(long long)gob2*k; ans+=(long long)gob*(k-1); ans+=(long long)imsi;
	printf("%lld",ans);
}

Measured memory_bytes: 256
n, m = map(int, input().split())

list_A = []
for i in range(m):
    list_A.append(list(map(int, input().split())))

end = int("9"*n)
start = int("1" + "0"*(n-1))

if n == 1:
    end = int("9")
    start = int("0")

for i in range(start, end + 1):
    i = str(i)
    #個々の条件をクリアできるか
    flag = 0
    for j in list_A:

        #一つの条件の確認
        a, b = j
        if i[a-1] != str(b):
            break

        flag += 1

    if flag == len(list_A):
        print(int(i))
        exit()
print(-1)

Measured memory_bytes: 3064
S = input()
T = input()
U = [[i,j] for i,j in zip(S,T)]
U.sort()
s = U[0][0]
t = U[0][1]
for i,j in U:
    if  i != s:
        s = i
        t = j
    elif j != t:
        print("No")
        exit()
U.sort(key=lambda x:x[1])
s = U[0][0]
t = U[0][1]
for i,j in U:
    if j != t:
        s = i
        t = j
    elif i != s:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 29416
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        double n = sc.nextInt();
        double k = sc.nextInt();

        double ans = 0;

        for (double i = 1; i <= n; i++) {
            double kakuritu = 1;
            double point = i;

            while (point < k) {
                point *= 2;
                kakuritu *= 0.5;
            }

            ans += 1 / n * kakuritu;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21460
#include <stdio.h>

int main(void){
  int i,j,n,x,y,m,move,count=0,gem[21][21]={0};
  char dir,dummy;
  
  while(1){
    scanf("%d",&n);
    if(n==0){
    break;
    }
    for(i=0;i<n;i++){
      scanf("%d %d",&x,&y);
      gem[y][x]=1;
    }

    x = 10;
    y = 10;
    
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%c",&dummy);
      scanf("%c %d",&dir,&move);
      switch(dir){
      case 'N':
	for(j=0;j<move;j++){
	  y++;
	  if(gem[y][x]==1){
	    count++;
	    gem[y][x]-=gem[y][x];
	  }
	}
	break;
      case 'S':
	for(j=0;j<move;j++){
	  y--;
	  if(gem[y][x]==1){
	    count++;
	    gem[y][x]-=gem[y][x];
	  }
	}
	break;
      case 'E':
	for(j=0;j<move;j++){
	  x++;
	  if(gem[y][x]==1){
	    count++;
	    gem[y][x]-=gem[y][x];
	  }
	}
	break;
      case 'W':
	for(j=0;j<move;j++){
	  x--;
	  if(gem[y][x]==1){
	    count++;
	    gem[y][x]-=gem[y][x];
	  }
	}
	break;
      default:break;
      }
    }
    if(count==n){
      puts("Yes");
    }
    else{
      puts("No");
    }

    for(i=0;i<21;i++){
      for(j=0;j<21;j++){
	gem[i][j]=0;
      }
    }
    count-=count;
  }
  return 0;
}

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

int main(){
    int a;
    cin >> a;
    vector <int> x(30*8);
    int t=0;
    if(a<=3){
        cout << 1 << endl;
        return 0;
    }
    
    for(int i=2; i<10; i++){
        for(int j=2; j<32; j++){
            x[t]=pow(j, i);
        
            t++;
        }
    }
    x.push_back(a);
    sort(x.begin(), x.end());
    int it=find(x.begin(), x.end(), a)-x.begin()-1;
    if(x[it+1]==x[it+2]){
        cout << x[it+1] << endl;
        return 0;
    }
    cout << x[it] << endl;






    

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

vector<int> v;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n, q; 
    cin >> n;
    REP(i, n) {
        int a; cin >> a;
        v.push_back(a);
    }
    
    cin >> q;
    REP(i, q){
        int b, m, e; cin >> b >> m >> e;
        rotate(v.begin()+b, v.begin()+b+(e-b)-(e-m), v.begin()+e);
        
    }
    for(int i=0; i<n; ++i){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;

    vector<P> check(N, P(0, 0));
    int ac = 0, wa = 0;
    rep(i, M) {
        int p;
        string S;
        cin >> p >> S;
        if (S == "WA") {
            if (check[p - 1].first == 0) {
                check[p - 1].second++;
            }
        }
        else {
            if (check[p - 1].first == 0) {
                check[p - 1].first++;
                ac++;
                wa += check[p - 1].second;
            }
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	auto a = vector<string>(n);
	auto b = vector<string>(m);
	for(auto& x : a) cin >> x;
	for(auto& y : b) cin >> y;
	int ans = false;
	for(auto i = 0; i < n - m + 1; ++i){
		for(auto j = 0; j < n - m + 1; ++j){
			bool fit = true;
			for(auto k = 0; k < m; ++k){
				if(b[k] != a[i + k].substr(j, m)){
					fit = false;
					break;
				}
			}
			if(fit){
				ans = true;
				break;
			}
		}
		if(ans) break;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
//不合格をいくら集めても、正常なものは区別できない。
//合格したら、その3つは正常。不合格のなかから、正常なものは故障候補から外せる。
//他のものは、全部故障していてもおかしくないので、候補から外せない。(これが正常ならば…これは故障というのはあるけど、正常となり得るもの自体はたくさんある。)
//特に、ある検査(不合格)で1つだけ故障候補になっていれば、それは絶対に故障している。
#include<iostream>
using namespace std;

int a,b,c,d;
int n;
int input[1000][4];
int type[5000];

int main(){
	int i;
	while(1){
		cin >> a >> b >> c;
		if(a==0)break;
		cin >> n;
		
		for( i = 0; i < 5000; i++ )
			type[i] = 2;
			
		for( i = 0; i < n; i++ ){
			cin >> input[i][0] >> input[i][1] >> input[i][2] >> input[i][3];
			if( input[i][3] == 1 ){
				type[ input[i][0] ] = 1;
				type[ input[i][1] ] = 1;
				type[ input[i][2] ] = 1;
			}
		}
		
		for( i = 0; i < n; i++ ){
			if( input[i][3] == 1 )
				continue;
			
			if( type[ input[i][0] ] == 1 && type[ input[i][1] ] == 1 )
				type[ input[i][2] ] = 0;
			else if( type[ input[i][1] ] == 1 && type[ input[i][2] ] == 1 )
				type[ input[i][0] ] = 0;
			else if( type[ input[i][2] ] == 1 && type[ input[i][0] ] == 1 )
				type[ input[i][1] ] = 0;
		}
		
		for( i = 1; i <= a+b+c; i++ ){
			cout << type[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196