akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left, bisect_right
from math import ceil

def main():
    n,k = map(int, input().split())
    al = list(map(int, input().split()))
    al.sort()

    al_n = []
    al_p = []
    al_n_p = []
    zero_cnt = 0
    for a in al:
        if a < 0: 
            al_n.append(a)
            al_n_p.append(-1*a)
        elif a > 0: 
            al_p.append(a)
        else: 
            zero_cnt += 1
    al_n_p = al_n_p[::-1]

    n_cnt = len(al_n)
    p_cnt = len(al_p)

    m_n_cnt = n_cnt*p_cnt
    m_p_cnt = n_cnt*(n_cnt-1)//2 + p_cnt*(p_cnt-1)//2
    m_zero_cnt = zero_cnt*(n_cnt+p_cnt) + zero_cnt*(zero_cnt-1)//2


    if k <= m_n_cnt:
        left = (-1)*(10**18)
        right = -1
        while right-left>1:
            curr_num = left + (right-left)//2
            curr_cnt = 0
            num_exist = False
            for an in al_n:
                targt_p = abs(curr_num)//abs(an)
                p_ind = bisect_right(al_p,targt_p)
                ok_p_cnt = len(al_p) - p_ind
                curr_cnt += ok_p_cnt
                if p_ind > 0 and al_p[p_ind-1]*an == curr_num:
                    num_exist = True
            
            if curr_cnt > k-1:
                right = curr_num
            elif curr_cnt < k-1:
                left = curr_num
            else:
                if num_exist:
                    print(curr_num)
                    exit()
                else:
                    left = curr_num


    elif m_n_cnt < k <= m_n_cnt+m_zero_cnt:
        print(0)
        exit()

    else:
        k = k - m_n_cnt - m_zero_cnt # 1-index
        right = (10**18)
        left = 0
        while right-left > 1:
            cnt = k
            # print(f'k:{k}')
            # print('----')
            curr_num = left + (right-left)//2
            curr_cnt = 0
            num_exist = False
            # curr_num = 6
            # print(curr_num, left, right)
            for i, an in enumerate(al_n_p):
                targt_p = abs(curr_num)//abs(an)
                ok_p_cnt = max(bisect_right(al_n_p,targt_p)-i-1, 0)
                cnt -= ok_p_cnt
            
            for i, an in enumerate(al_p):
                # print(f'----- {an} -----')
                targt_p = abs(curr_num)//abs(an)
                
                ok_p_cnt = max(bisect_right(al_p,targt_p)-i-1, 0)
                cnt -= ok_p_cnt
                # print(ok_p_cnt)

            if cnt > 0:
                left = curr_num
            else:
                right = curr_num

        print(right)


if __name__ == "__main__":
    main()

Measured memory_bytes: 118984
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    string s; cin >> s;
    int cnt = 0, ans = 0;
    rep(i, 0, s.size()) {
        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
           cnt++;
           (cnt > ans) ? ans = cnt : ans = ans;
        }
        else {
            (cnt > ans) ? ans = cnt : ans = ans;
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int x;
    cin>>x;
    if(x>=400&&x<=599){
        cout<<8;
    }
    if(x>=600&&x<=799){
        cout<<7;
    }
    if(x>=800&&x<=999){
        cout<<6;
    }
    if(x>=1000&&x<=1199){
        cout<<5;
    }
    if(x>=1200&&x<=1399){
        cout<<4;
    }
    if(x>=1400&&x<=1599){
        cout<<3;
    }
    if(x>=1600&&x<=1799){
        cout<<2;
    }
    if(x>=1800&&x<=1999){
        cout<<1;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V &Mx(const V &_x){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		V x(n*n);
		V e(n*n);
		z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1)e=Me(e,x);
			x=Mx(x);
		}
		V s(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		for(i=0;i<n-1;i++)printf("%d ",((const V&)e[slice(i*n,n,1)]*s).sum()%m);
		printf("%d\n",((const V&)e[slice(i*n,n,1)]*s).sum()%m);
	}
}

Measured memory_bytes: 1088
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    s ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", a[i] ^= s, " \n"[i + 1 == n]);
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using vec = vector<ll>;
using mat = vector<vec>;

mat mul(const mat& a, const mat& b) {
  int n = a.size();
  mat c(n, vec(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
      }
    }
  }
  return c;
}

int n;
ll k;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  mat a(n, vec(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  mat ans(n, vec(n));
  for (int i = 0; i < n; i++) {
    ans[i][i] = 1;
  }
  while (k) {
    if (k%2) ans = mul(ans, a);
    a = mul(a, a);
    k /= 2;
  }
  ll ret = 0;
  for (auto& v : ans) for (ll i : v) ret = (ret + i) % MOD;
  cout << ret << nl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(string N, long long K){
  vector<vector<vector<long long>>> dp(N.size(), vector<vector<long long>>(K+1, vector<long long>(2, 0)));
  dp[0][0][0] = 1LL;
  dp[0][1][0] = static_cast<long long>(N[0] - '1');
  dp[0][1][1] = 1LL;
  for (int i = 1; i < N.size(); ++i) {
    for (int j = 0; j < K+1; ++j) {
      if (N[i] == '0') {
        dp[i][j][1] += dp[i-1][j][1];
      } else if (j > 0) {
        dp[i][j][1] += dp[i-1][j-1][1];
      }

      if (N[i] != '0') {
        dp[i][j][0] += dp[i-1][j][1];
      }

      dp[i][j][0] += dp[i-1][j][0];

      if (N[i] != '0' and j > 0) {
        dp[i][j][0] += dp[i-1][j-1][1] * static_cast<long long>(N[i] - '1');
      }

      if (j > 0) {
        dp[i][j][0] += dp[i-1][j-1][0] * 9LL;
      }
    }
  }
  std::cout << dp[N.size()-1][K][0] + dp[N.size()-1][K][1] << std::endl;
}

int main(){
  string N;
  std::cin >> N;
  long long K;
  scanf("%lld",&K);
  solve(N, K);
  return 0;
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  ll H;
  cin >> H;
  ll k = 1;
  int c = 0;//Hが２の何乗より大きいか
  while(H >= k){
    k *= 2;
    c++;
  }
  
  c -= 1;
  ll ans = 0;
  for(int i = 0;i<=c;i++){
    ans += kzyou(2,i);
  }
  cout << ans << endl;

 }


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        /*
        Set NG dattaka...
        TreeSet <Integer> s = new TreeSet<Integer>();
        s.add(a);
        s.add(b);
        s.add(c);

        StringBuilder ret = new StringBuilder();
        for (Iterator<Integer> iterator = s.iterator(); iterator.hasNext();) {
        	ret.append(" ");
			ret.append(iterator.next());
		}
		*/
        int[] tmp = new int[3];
        tmp[0] = a;
        tmp[1] = b;
        tmp[2] = c;
        Arrays.sort(tmp);

        System.out.printf("%d %d %d\n",tmp[0], tmp[1], tmp[2]);
    }
}

Measured memory_bytes: 17304
#include <iostream>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	lli amax=0, rb;
	for(int i=0; i<n; i++){
		lli a,b;
		cin >> a >> b;
		if(a > amax){
			amax = a;
			rb = b;
		}
	}
	cout << amax+rb << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}






#define int long long int 

int32_t main()
{
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    
}


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

int main() {
  int const M = 1e6+10;
  // Mより小さい正四面体数を求める。
  vector<int> tet[2];
  for (int i=1; i<M; i++) {
    int t = i * (i+1) * (i+2) / 6;
    if (t >= M) break;
    tet[0].push_back(t);
    if (t % 2 == 1) {
      tet[1].push_back(t);
    }
  }
  int ans[2][M];
  for (int i=0; i<=1; i++) { // 両方並行して行う。
    ans[i][0] = 0;
    for (int j=1; j<M; j++) {
      int min = M;
      for (unsigned int k=0; k<tet[i].size(); k++) {
	if (tet[i][k] > j) break;
	if (min > ans[i][j-tet[i][k]] + 1) {
	  min = ans[i][j-tet[i][k]] + 1;
	}
      }
      ans[i][j] = min;
    }
  }
  int N;
  while (scanf("%d", &N) != EOF && N) {
    printf("%d %d\n", ans[0][N], ans[1][N]);
  }
}

Measured memory_bytes: 9008
N,K=map(int,input().split())
ab=[]
for i in range(N):
    a,b=map(int,input().split())
    ab.append([a,b])
ab.sort()
i=0
for a,b in ab:
    if i<K<=i+b:
        print(a)
        quit()
    i+=b


Measured memory_bytes: 60632
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll x,y;

int main(){
	cin>>x>>y;
	int t=0;
	while(x<=y){
		x*=2;
		t++;
	}
	cout<<t<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map(String::toInt).toIntArray()
    val cntmax = (Math.log(a.min()!!.toDouble()) / Math.log(2.0)).toInt()
    var cnt = 0
    cntr@ for (i in 1..cntmax) {
        for (j in 0 until n) {
            if (a[j] and 1 == 1) break@cntr
            a[j] = a[j] shr 1
        }
        cnt++
    }
    println(cnt)
}


Measured memory_bytes: 38328
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {

        var line = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();
        int P = line[0];
        int Q = line[1];
        int R = line[2];

        if(P + Q <= Q + R && P + Q <= R + P)
        {
            Console.WriteLine(P + Q);
        }
        else if(Q + R <= P + Q && Q + R <= R + P)
        {
            Console.WriteLine(Q + R);
        }
        else
        {
            Console.WriteLine(R + P);
        }
    }

}

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

#define is_uruu main
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
    
int bubble(int A[],int N){
	int j,count=0;
	bool flag = 1;
	while(flag){
		flag = 0;
		ROF(j,N-1,0){
			if(A[j] < A[j-1]){
				swap(A[j], A[j-1]);
				count++;
				flag = 1;
			}
		}
	}
	return count;
}
    
int is_uruu() {
    int N,count,A[100];
    cin >> N;
    FOR(i,0,N)cin >> A[i];
    
    count = bubble(A,N);
    
    FOR(i,0,N-1)cout << A[i] << " ";
    cout << A[N-1] << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector <int> h(N);
  for (int i = 0; i < N; i++) {
	  cin >> h[i];
	}
  sort(h.begin(), h.end());
  int ans = 1e9;
  for (int i = 0; i < N - K + 1; i++) {
	  ans = min(ans, h[i + K - 1] - h[i]);
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
 
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k,t=1;

void solve()
{
   cin>>n;
   vector<ll>v(n-1);
   for(ll i=0;i<n-1;i++)
   cin>>v[i];
   
   ll sum=v[0];
   for(ll i=1;i<=n-2;i++)
   {
       
       sum+=min(v[i],v[i-1]);
   }
   sum+=v[n-2];
   //for(ll i=0;i<n;i++)cin>>v[i];
    cout<<sum;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val n = sc.nextInt()
    val map = mutableMapOf<String, Int>()
    for (i in 0 until n) {
        val s = sc.nextLine()
        map[s] = (map[s] ?: 0) + 1
    }
    val max = map.values.max()!!
    val lst = map.keys.filter { map[it] == max }.toMutableList()
    lst.sort()
    val ans = StringBuilder()
    for (s in lst) {
        ans.appendln(s)
    }
    println(ans.toString())
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 86444
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    ll w,x;
    cin>>a>>d;
    d=2*d+1;
    if(a%d) sum++;
    sum+=a/d;
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int n;

int read(){
    int s=0,f=1;
    register char c=getchar();
    while(c>'9'|| c<'0') { if(c=='-') f=-1;c=getchar();}
    while(c<='9' && c>='0')  {s=(s<<3)+(s<<1)+c-'0';c=getchar();}
    return s*=f;
}

int change(int x)
{
	if(x%10==1) return 9;
	return 1;
}

int main()
{
	int n1=0;
	n=read();
	n1=change(n)+10*change(n/10)+100*change(n/100);
	printf("%d\n",n1);
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
    for (r <- io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))) {
        var (rem, res, i) = (r(0), 0, r(2))
        while (i > 0) {
            rem = rem % r(1) * 10
            res += rem / r(1)
            i -= 1
        }
        println(res)
    }
}

Measured memory_bytes: 44048
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    ll i;
    ll x[MAX];
    
    for(i=0; i<N; i++) cin >> x[i];
    
    ll ans=0;
    ll p=x[0];
    for(i=1; i<N; i++) {
        ans+=min(A*(x[i]-p), B);
        p=x[i];
    }
    
    pt(ans);
}







Measured memory_bytes: 1024
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        char[] a = sc.next().toCharArray();
        int count = 0;
        for (char b : a) {
            if (b == '1') {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	v.resize(K);
	cout << accumulate(v.begin(), v.end(), 0) << endl;
}

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

int main() {
    string S;
    cin >> S;
  sort(S.begin(), S.end());
  if(S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(1) != S.at(2)){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
 

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
using namespace std;

string T;
vector<int> qnum;

int main(){
    cin>>T;
    for(int i=0;i<T.size();++i){
        if(T[i]=='?'){
            qnum.push_back(i);
            T[i]='D';
        }
    }
    cout<<T<<endl;
    return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

int main() {

	ll n;
	cin >> n;
	vector<ll> a(26,INF);

	repn(i, n) {
		string S;
		cin >> S;

		rep(j, 26) {
			a[j] = min(count(S.begin(), S.end(), j + 'a'),a[j]);
		}

	}

	rep(j, 26) {
		rep(k, a[j]) {
			cout << (char)(j + 'a');
		}
	}
	
	system("PAUSE");
}


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


public class Main {

	public static void main(String[] args) {
		try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str;
            while ((str = br.readLine()) != null) {
            	int N = Integer.parseInt(str);
            	str = br.readLine();
            	String[] Field = str.split(" ");
            	int MaxDice = 1;
            	int tmp = 1;
            	for (int i = 0; i < N; i++) {
            		if (Field[i].equals("1")) {
            			tmp++;
            		} else {
            			MaxDice = Math.max(MaxDice, tmp);
            			tmp = 1;
            		}
            	}
            	MaxDice = Math.max(MaxDice, tmp);
            	System.out.println(MaxDice);
            }
            } catch (Exception e) {
                System.out.println(e);
            }
	}

}



Measured memory_bytes: 24356
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>


int main(){
    int N; //数列の長さ
    std::vector<int> a_vec;
    int a[101];//最大100個の要素を持つ数列
    std::cin >> N;
    for(int i = 0; i < N; i++){
        std::cin >> a[i];
    }
    for (int i = 0; i < N; ++i){
        a_vec.emplace_back(a[i]);
    }
    
    int min = *std::min_element(a_vec.begin(), a_vec.end());
    int max = *std::max_element(a_vec.begin(), a_vec.end());
    
    int abs = std::abs(min - max);
    
    std::cout << abs << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int N, K, X, Y; cin >> N >> K >> X >> Y;
  int res = 0;
  for(int i = 1; i <= N; i++){
    if(i <= K) res += X;
    else res += Y;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long a,b;
    cin >> a >> b;
    string ans;
    if(a<=0&&b>=0){
        ans="Zero";
    }else if(a<0&&b<=0){
        if((abs(a)-abs(b)+1)%2==1){
            ans="Negative";
        }else{
            ans="Positive";
        }
    }else if(a>0&&b>0){
        ans = "Positive";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
void error(const char* str) {
	puts(str);
	exit(0);
}
int main()
{
	int n, k;
	ll v;
	cin >> n >> k;
	vector<ll> a, b, c, d;
	rep(i, 0, n) {
		cin >> v;
		if (v > 0)a.push_back(v);
		else b.push_back(-v);
	}
	sort(all(a));
	sort(all(b));
	for (int i = a.size() % 2; i < a.size(); i += 2) {
		c.push_back(a[i] * a[i + 1]);
	}
	for (int i = b.size() % 2; i < b.size(); i += 2) {
		d.push_back(b[i] * b[i + 1]);
	}
	ll ans = 1;
	if (n == k) {
		rep(i, 0, b.size()) {
			ans *= -b[i];
			ans %= mod;
		}
		rep(i, 0, a.size()) {
			ans *= a[i];
			ans %= mod;
		}
		while (ans < 0)ans += (ll)mod;
		printf("%lld\n", ans % mod);
		return 0;
	}
	if (a.empty() && k % 2) {
		rep(i, 0, k) {
			ans *= -b[i];
			ans %= mod;
		}
		while (ans < 0)ans += (ll)mod;
		printf("%lld\n",ans);
		return 0;
	}
	while (k) {
		if (k >= 2 && d.size() && (a.size() <= 1 || (a.size() >= 2 && d.back() >= (a.back() * *(a.end() - 2))))) {
			ans *= d.back() % mod;
			d.pop_back();
			k -= 2;
		}
		else {
			ans *= a.back() % mod;
			a.pop_back();
			k--;
		}
		ans %= mod;
	}
	printf("%lld\n", ans % mod);
	return 0;
}


Measured memory_bytes: 6536
#include<iostream>
using namespace std;
int main()
{char b;
	cin >> b;
	if(b == 'A'){cout << 'T';}
	if(b == 'T'){cout << 'A';}
	if(b == 'C'){cout << 'G';}
	if(b == 'G'){cout << 'C';}
return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	int n; cin >> n;
	vec a(n);
	bool x = 0;
	rep(i, n) {
		int tmp; cin >> tmp;
		if (tmp % 2 == 0) {
			if (tmp % 3 == 0 || tmp % 5 == 0) {

			}
			else {
				x = 1;
			}
		}
	}
	cout << (x ? "DENIED" : "APPROVED") << endl;
	return 0;
}

Measured memory_bytes: 256
class Dice():
    #0:上面、1:前面、2:側面(見える方)、3:側面(裏側)、4:背面、5:底面
    def __init__(self,numlist):
        self.lst=numlist
    
    def roll(self,direction):
        for x in direction:
            if x=="S" : self.lst=[self.lst[4],self.lst[0],self.lst[2],self.lst[3],self.lst[5],self.lst[1]]
            elif x=="N" : self.lst=[self.lst[1],self.lst[5],self.lst[2],self.lst[3],self.lst[0],self.lst[4]]
            elif x=="W" : self.lst=[self.lst[2],self.lst[1],self.lst[5],self.lst[0],self.lst[4],self.lst[3]]
            elif x=="E" : self.lst=[self.lst[3],self.lst[1],self.lst[0],self.lst[5],self.lst[4],self.lst[2]]        
    
    def dice_set_make(self):
        self.dice_set=[]
        for x in ["","W","WW","WWW","SE","SW"]:
            self.work=Dice(self.lst[:])
            self.work.roll(x)
            self.dice_set.append(self.work.lst)
            for _ in range(3):
                self.work.roll("S")
                self.dice_set.append(self.work.lst)
        
n=int(input())
dices_set=[]
for _ in range(n): 
    lst=list(map(int,input().split()))
    d1=Dice(lst)
    d1.dice_set_make()
    dices_set.append(sorted(d1.dice_set))

for x in dices_set:
    if dices_set.count(x)>=2 :
        print("No")
        break
else : print("Yes")


Measured memory_bytes: 5852
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#define INF 100000000
#define MOD 1000000007
using namespace std;



int main(){
    int n;
    cin >> n;
    cout<<n/3<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
# define maxi 100000
# define maxw 100000
# define maxn 100000

using ll=long long;
int main() {
  ll n,k;
  cin>>n>>k;
  cout<<k*(int)pow(k-1,n-1);
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    string n;
    cin >> n;
    if(n[0]==n[1]&&n[1]==n[2] || n[1]==n[2]&&n[2]==n[3]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main(){
  string S, T;
  cin >> S >> T;

  T.erase(T.size()-1);

  if(T == S){
  cout << "Yes" << endl;
    }
   else{
     cout << "No" << endl;
   }

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
#define INF 999999999
int Value[51][51];
int dx[2] = {1, 0};
int dy[2] = {0, 1};

struct Data
{
	int X;
	int Y;
	int V;
};

void solve()
{
	for(int i = 0; i < 51; ++i)
	{
		for(int j = 0 ; j < 51; ++j)
		{
			Value[i][j] = INF;
		}
	}
	Value[0][0] = 0;
	int H, W;
	cin >> H >> W;
	vector< vector<char> > cicada(H);	//ツ静、
	for(int i = 0; i < H; ++i)
	{
		cicada[i].resize(W);
		for(int j = 0; j < W; ++j)
		{
			cin >> cicada[i][j];
		}
	}
	queue<Data> Que;
	Data d = {0, 0, 0};
	Que.push(d);
	queue<Data> NextQue;
	while(!Que.empty())
	{
		for(int i = 0; i  < 2; ++i)
		{
			int x = Que.front().X + dx[i];
			int y = Que.front().Y + dy[i];
			if((0 <= x && x < W) && (0 <= y && y < H) && (Que.front().V + cicada[y][x] - '0' < Value[y][x]))
			{
				Data next_d = {x, y, Que.front().V + cicada[y][x] -'0'};
				NextQue.push(next_d);
				Value[y][x] = Que.front().V + cicada[y][x] -'0';
			}	
		}
		Que.pop();
		if(Que.empty())
		{
			while(!NextQue.empty())
			{
				Que.push(NextQue.front());
				NextQue.pop();
			}
		}
	}
	cout << Value[H - 1][W - 1] << endl;
	
}

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

Measured memory_bytes: 0
A, B, C = map(int, input().split())
K = int(input())
f = False
for bit in range(2**K):
    b = B
    c = C
    for j in range(K):
        if (bit >> j) & 1:
            c *= 2
        else:
            b *= 2
    if A < b and b < c:
        f = True
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    string s;cin>>s;
    f(i,0,s.size())cout<<"x";
    return 0;  
} 

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 8000;

bool dpx[maxn+1][2*maxn+1]={0};
bool dpy[maxn+1][2*maxn+1]={0};

int main(){
    int x,y;
    int t=0;
    string s;
    cin >> s;
    cin >> x>>y;
    rep(i,2*maxn+1){
        dpx[0][i]=false;
        dpy[0][i]=false;
    }
    dpx[0][maxn]=dpy[0][maxn]=true;
    
    int p=0;
    while(s[p]=='F'){
        p++;
    }
    dpx[1][maxn+p]=true;
    t++;
    p+=1;
    
    int cnt=0;
    int t_x=2;
    int t_y=1;
    while(p<s.size()){
        if(s[p]=='F'){
            cnt++;
        }
        if(s[p]=='T'||p==s.size()-1){
            if(t%2==0){ //x
                rep(i,2*maxn+1){
                    if(i-cnt>=0)dpx[t_x][i]=dpx[t_x-1][i-cnt];
                    if(i+cnt<2*maxn+1&&!dpx[t_x][i])dpx[t_x][i]=dpx[t_x-1][i+cnt];
                }
                t_x++;
            }else{  //y
                rep(i,2*maxn+1){
                    if(i-cnt>=0)dpy[t_y][i]=dpy[t_y-1][i-cnt];
                    if(i+cnt<2*maxn+1&&!dpy[t_y][i])dpy[t_y][i]=dpy[t_y-1][i+cnt];
                }
                t_y++;
            }
            
            cnt=0;
            t++;
        }
        p++;
    }
    
    if(dpx[t_x-1][maxn+x]&&dpy[t_y-1][maxn+y]){
        Yes;
    }else{
        No;
    }
    
    return 0;
}


Measured memory_bytes: 127232
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main()
{
	ull n,a,b;
	cin>>n>>a>>b;
	
	if(n%(a+b)>a)
		cout<<n/(a+b)*a+a<< endl;
	else
		cout<<n/(a+b)*a+n%(a+b)<< endl;
		
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power( (num*num)%mod,g/2,mod);
}

int main(){
	int s,w;
	cin >> s >> w;
	if (w >= s){
		cout << "unsafe";
	}
	else {
		cout << "safe";
	}

}

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



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin >> a[i];

  multiset<int> ms;
  for(int i=0;i<n;++i){
    int s=a[i];
    auto itr=ms.lower_bound(s);
    if(itr!=ms.begin())ms.erase(--itr);
    ms.insert(s);
  }

  cout << ms.size() << endl;
  return 0;
}


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

int main(void){
	int N;
	scanf("%d",&N);

	int P[N];
	int max = 0;
	int maxNumber = -1;
	int sum = 0;

	for(int i = 0;i < N;i++){
		scanf("%d",&P[i]);
		if(P[i] > max){
			max = P[i];
			maxNumber = i;
		}
	}

	for(int i = 0;i < N;i++){
		if(i == maxNumber){
			sum += P[i]/ 2;
		}else{
			sum += P[i];
		}
	}
	printf("%d\n",sum);
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    // p p
    // p n
    // n p
    // n n
    long a, b;
    cin >> a >> b;
    if(a > 0 && b > 0)
        cout << "Positive" << endl;
    else if(a == 0)
        cout << "Zero" << endl;
    else if(a < 0 && b > 0)
        cout << "Zero" << endl;
    else if(b == 0)
        cout << "Zero" << endl;
    else {
        if((abs(a - b) + 1) % 2 == 1)
            cout << "Negative" << endl;
        else
            cout << "Positive" << endl;
    }
}

Measured memory_bytes: 3632
num753 = ['7', '5', '3']
N = int(input())
cnt = 0
for i in range(3, len(str(N))+1):
	for j in range(0, 3**i):
		m = j
		exists = [False, False, False]
		num = ''
		for k in range(0, i):
			num = num + num753[m%3]
			exists[m%3] = True
			m //= 3
		if False not in exists and int(num) <= N:
			cnt += 1
print(cnt)

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

using namespace std;

class range{
public:
	range(int x,int y){b = x; e = y;}
	int b,e;

	int length(void){
		return e - b + 1;
	}
};

int main(void){
	int n,k;

	while(cin >> n >> k){
		if((n|k) == 0) break;
		vector<int> v;
		int tmp,maxi = 1;
		for(int i=0;i<k;i++){
			cin >> tmp;
			v.push_back(tmp);
		}

		sort(v.begin(), v.end());
		tmp = 1;
		if(v[0] == 0){
			vector<range> v_r;
			int begin=v[1],end;
			for(int i=2;i<k;i++){
				if(v[i] == v[i-1] + 1){
					//end = v[i];
				}else{
					end = v[i-1];
					v_r.push_back(range(begin,end));
					begin = v[i];
				}
			}
			v_r.push_back(range(begin,v.back()));
			//for test
			for(int i=0;(unsigned int)i<v_r.size();i++){
				maxi = max(maxi,v_r[i].length() + 1); //its length + 1(wild card)
				if(i > 0){
					//calc the length of distance between itself and previous block
					if(v_r[i].b - v_r[i-1].e == 2){
						maxi = max(maxi, v_r[i].length() + v_r[i-1].length() + 1);
					}
				}
			}
		}else{
			for(int i=1;i<k;i++){
				if(v[i] == v[i-1] + 1){ // in case of continuous
					tmp++;
				}else{
					maxi = max(maxi,tmp);
					tmp = 1;
				}
			}
			maxi = max(maxi,tmp);
		}
		cout << maxi << endl;
	}
}

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

//typedef long long ll;

double fordo(double p){
    double pi=acos(-1);
    return p*180/pi;
}

int main(){
    double pi=acos(-1);
    double a,b,x;
    cin>>a>>b>>x;
    double sikii=a*b/2;
    double menseki=x/a;
    if(menseki>sikii){
        double L=a*b-menseki;
        double tany=L*2/(a*a);
        cout<<fixed<<setprecision(10)<<fordo(atan(tany))<<endl;
    }
    else if(menseki==sikii){
        cout<<fixed<<setprecision(10)<<fordo(atan(b/a))<<endl;
    }
    else{
        double tanRy=menseki*2/(b*b);
        double Ry=fordo(atan(tanRy));
        cout<<fixed<<setprecision(10)<<90-Ry<<endl;
    }
}

Measured memory_bytes: 256
from itertools import product

def zero_origin(s: str) -> int:
  return int(s) - 1

H, W, M = map(int, input().split())
h_obj = [0 for _ in range(H)]
w_obj = [0 for _ in range(W)]
obj = set()
for _ in range(M):
  h, w = map(zero_origin, input().split())
  h_obj[h] += 1
  w_obj[w] += 1
  obj.add((h, w))
max_h = max(h_obj)
max_w = max(w_obj)
h_list = [h for h in range(H) if h_obj[h] == max_h]
w_list = [w for w in range(W) if w_obj[w] == max_w]
for h, w in product(h_list, w_list):
  if (h, w) not in obj:
    print(max_h + max_w)
    break
else:
  print(max_h + max_w - 1)

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

#define PI 3.14159265358979323846264338327950L

int main(void){
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    long double h_to_min;
    h_to_min = 60 * h + m;
    
    long double w_t = 0.5;
    long double w_m = 6.0;
    long double rad;
    rad = (w_t * (long double)h_to_min - w_m * (long double)m) * PI / 180;
    
    long double x;
    x = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    printf("%.10Lf\n", x);
    return 0;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,2660){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192