akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/

vector<vector<int> > G(200005);
int cost[200005];
int flag[200005];
int ans[200005];

void solve(int now, int value) {

	//cout << "now= " << now << " value = " << value << endl;
	ans[now] = value;
	flag[now] = 1;
	//cout << ans[now] << endl;

	for (auto itr : G[now]) {

		if (flag[itr] == 0) {
			solve(itr, value + cost[itr]);
		}
	}
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, q;
	cin >> n >> q;

	for (int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (a > b) {
			swap(a, b);
		}

		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 0; i < q; i++)
	{
		int p, x;
		cin >> p >> x;
		p--;
		cost[p] += x;
	}




	solve(0, cost[0]);


	for (int i = 0; i < n; i++)
	{
		if (i == 0) {
			cout << ans[i];
		}
		else
		{
			cout << " " << ans[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 21760
#include<stdio.h>
int main()
{
	int l, r;
	scanf("%d %d", &l, &r);
	int i, j;
	int ans = 2020;
	for (i = l; i < l + 2500 && i < r; i++)
		for (j = i + 1; j < i + 2500 && j <= r; j++)
			if (ans > ((i % 2019) * (j % 2019)) % 2019)
				ans = ((i % 2019) * (j % 2019)) % 2019;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B
#???????????? 17:55~

def maxHeapify(heap, index):
    left_index = 2 * index
    right_index = 2 * index + 1

    if left_index < len(heap) and heap[left_index] > heap[index]:
        largest_index = left_index
    else:
        largest_index = index

    if right_index < len(heap) and heap[right_index] > heap[largest_index]:
        largest_index = right_index

    if not largest_index == index:
        heap[index], heap[largest_index] = heap[largest_index], heap[index]
        maxHeapify(heap, largest_index)
    
def main():
    n_node = int(input())
    target_list = [""] + [int(n) for n in input().split()]
    for i in range(1, int(len(target_list) / 2) + 1)[::-1]:
        maxHeapify(target_list, i)
        
    print(*target_list)
if __name__ == "__main__":
    main()

Measured memory_bytes: 65848
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstring>
#include<functional>
#include<cmath>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)

using namespace std;

int main(){
	int I,ans(0);
	vector<int> a(5);
	rep(i,0,5){
		cin >> a[i];
		if(a[I] % 10 > a[i] % 10 && 0 != a[i] % 10) I = i; 
	}
	rep(i,0,5){
		if(I != i){
			if(a[i] % 10) a[i] += 10 - (a[i] % 10);
			ans += a[i];
		}
		
	}
	cout << ans + a[I] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N=1008;
char a[N][N];
int main(void)
{
	int n,m,pa,pb,i,j,nn,mm;
	scanf("%d%d%d%d",&n,&m,&pa,&pb);nn=n;mm=m;
	for(i=1;i<=n;i++){for(j=1;j<=m;j++)a[i][j]='.';a[i][m+1]=0;}
	if(n&1){for(i=1;i<=m-(m&1);i+=2)if(pa){pa--;a[n][i]='<';a[n][i+1]='>';}else break;}
	if(m&1){for(i=1;i<=n-(n&1);i+=2)if(pb){pb--;a[i][m]='^';a[i+1][m]='v';}else break;}
	n-=n&1;m-=m&1;
	for(i=1;i<=n;i+=2)
	for(j=1;j<=m;j+=2)
	if(pa>=2){a[i][j]=a[i+1][j]='<';a[i][j+1]=a[i+1][j+1]='>';pa-=2;}
	else if(pb>=2){a[i][j]=a[i][j+1]='^';a[i+1][j]=a[i+1][j+1]='v';pb-=2;}
	else if(pa&&pb&&(nn%2)&&(mm%2)&&i+1==n&&j+1==m)
	{
		pa--;pb--;
		a[i][j]='^';a[i+1][j]='v';
		a[i][j+1]='<';a[i][j+2]='>';
		if(a[i+1][j+2]!='.'){a[i+1][j+2]='^';a[i+2][j+2]='v';}
	}
	else if(pa){a[i][j]='<';a[i][j+1]='>';pa--;}
	else if(pb){a[i][j]='^';a[i+1][j]='v';pb--;}
	if(pa==0&&pb==0){printf("YES\n");for(i=1;i<=nn;i++)printf("%s\n",&a[i][1]);}
	else printf("NO");
	return 0;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K = map(int, input().split())

lst = [0] * (K + 1)

for i in range(K, 0, -1):
    a = K // i
    tmp = pow(a, N, MOD)
    for j in range(i + i, K + 1, i):
        tmp -= lst[j]
    lst[i] = tmp

ans = 0
for i in range(K + 1):
    ans += i * lst[i]
    ans %= MOD

print (ans)

Measured memory_bytes: 11244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 動物の総数
		int x = sc.nextInt();
		// 足の数
		int y = sc.nextInt();

		// yが奇数の場合はNo
		if (y % 2 != 0) {
			System.out.println("No");
			return;
		}
		// すべてカメと仮定する b:カメの数
		int b = x;
		if (4 * b == y) {
			// すべてカメの場合
			System.out.println("Yes");
			return;
		} else if (4 * b < y) {
			System.out.println("No");
			return;
		} else {
			// 差分の足の数鶴の数
			int a = (4 * b - y) / 2;
			if ((4 * b - y) % 2 != 0) {
				// 割り切れない場合
				System.out.println("No");
				return;
			}
			b -= a;
			if (a >= 0 && b >= 0 && (2 * a + 4 * b == y)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 35888
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(0) != S.charAt(2)){
      System.out.println("Yes");
    } else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(0) != S.charAt(1)){
      System.out.println("Yes");
    } else if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1)){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 20564
n = int(input())
h = list(map(int, input().split()))

def mizuyari(h):
    if len(h)==0:
        return 0
    elif len(h)==1:
        return h[0]

    m = min(h)
    l = 0
    r = 0
    sm = 0

    while r < len(h):
        if h[r]==m:
            sm += mizuyari(list(map(lambda x: x-m, h[l:r])))
            l = r+1
        r += 1
    sm += mizuyari(list(map(lambda x: x-m, h[l:r])))

    return m + sm

print(mizuyari(h))

Measured memory_bytes: 9092
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>

#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define eb emplace_back
#define ef emplace_front
#define dbg(x) cout<<#x" = "<<((x))<<endl
#define fs first
#define sc second
     
using namespace std;

#define mod 1000000007     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  string str;

  cin >> str;
  ll N = str.size();

  ll dp[N+1][13];

  for(int i = 0; i <= N; ++i){
    for(int j = 0; j < 13; ++j){
      dp[i][j] = 0;
    } // j
  } // i

  dp[0][0] = 1;

  ll mul = 1;
  for(int i = 1; i <= N; ++i){
    if(str[N-i] == '?'){
      for(int j = 0; j < 13; ++j){
        for(int k = 0; k < 10; ++k){
          dp[i][(j + mul*k)%13] += dp[i-1][j];
          dp[i][(j + mul*k)%13] %= mod;
        }
      } // j
    } else {
      int c = str[N-i] - '0';
      for(int j = 0; j < 13; ++j){
        dp[i][(j + mul*c)%13] = dp[i-1][j];
      } // j
    }
    mul *= 10;
    mul %= 13;
  } // i

  cout << dp[N][5] << endl;

  return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
int n,a[100],ans;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n-2;i++)
		if (a[i]<a[i+1]&&a[i+1]<a[i+2])
			ans++;
		else if (a[i]>a[i+1]&&a[i+1]>a[i+2])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        vector<char>a(w);
        for(int r=0;r<w;r++){
             cin >> a[r];
             cout << a[r];
        }
        cout << endl;
        for(int r=0;r<w;r++){
             cout << a[r];
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
s = gets.chomp.split("").map(&:to_i)
n = s.length
all = 2 ** (n - 1)
answer = 0
all.times do |i|
  array = []
  (n - 1).times do |j|
    if i.odd?
      array << j
    end
    i /= 2
  end

  sum = 0
  tmp = []
  n.times do |k|
    tmp << s[k]
    if array.include?(k) || k == (n - 1)
      num = tmp.join("").to_i
      sum += num
      tmp = []
    end
  end

  answer += sum
end

puts answer

Measured memory_bytes: 1916
// atcoder/yahoo-procon/2019-qual/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> a(n);
    cin >> a;

    const int N = 2 * 1e5 + 5;
    static lli dp[N][5];
    const lli inf = 1LL << 60;
    fill(&dp[0][0], &dp[N - 1][5 - 1] + 1, inf);
    dp[0][0] = 0;

    for (int i = 0; i < n; ++i) {
      {
        setmin(dp[i + 1][0], dp[i][0] + a[i]);
      }

      {
        lli x = (a[i] == 0) ? 2 : (a[i] % 2);
        setmin(dp[i + 1][1], dp[i][0] + x);
        setmin(dp[i + 1][1], dp[i][1] + x);
      }

      {
        lli x = (a[i] == 0) ? 1 : !(a[i] % 2);
        setmin(dp[i + 1][2], dp[i][0] + x);
        setmin(dp[i + 1][2], dp[i][1] + x);
        setmin(dp[i + 1][2], dp[i][2] + x);
      }

      {
        lli x = (a[i] == 0) ? 2 : (a[i] % 2);
        setmin(dp[i + 1][3], dp[i][0] + x);
        setmin(dp[i + 1][3], dp[i][1] + x);
        setmin(dp[i + 1][3], dp[i][2] + x);
        setmin(dp[i + 1][3], dp[i][3] + x);
      }

      {
        lli x = a[i];
        setmin(dp[i + 1][4], dp[i][0] + x);
        setmin(dp[i + 1][4], dp[i][1] + x);
        setmin(dp[i + 1][4], dp[i][2] + x);
        setmin(dp[i + 1][4], dp[i][3] + x);
        setmin(dp[i + 1][4], dp[i][4] + x);
      }
    }

    lli mn = inf;
    setmin(mn, dp[n][0]);
    setmin(mn, dp[n][1]);
    setmin(mn, dp[n][2]);
    setmin(mn, dp[n][3]);
    setmin(mn, dp[n][4]);
    cout << mn << endl;
  }

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;

int n;
priority_queue<int> q;
unordered_map<int,int> chart;

int main(){
    cin.tie();
    cin >> n;
    int x;
    for(int i=0 ; i<n ; i++){
        cin >> x;
        q.push(x);
        chart[x]++;
    }

    long long maxFir = -1 , maxSec = -1;
    int found = 0;
    while(q.size()){
        int it = q.top();
        q.pop();
        if(found == 0){
            if(chart[it] >= 2){
                maxFir = it;
                chart[it] -= 2;
                found++;
            }
        }
        else if(found == 1){
            if(chart[it] >= 2){
                maxSec = it;
                chart[it] -= 2;
                found++;
            }
        }
        else
            break;
    }
    if(maxFir < 0 || maxSec < 0)
        cout << 0 << "\n";
    else
        cout << maxFir * maxSec << "\n";
}


Measured memory_bytes: 4764
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		if(n.contains("7")){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		 
		sc.close();
	}
	
}

Measured memory_bytes: 35596
#!/usr/bin/env python
while 1:
    n=int(raw_input())
    if n==0: break
    grass=map(int, raw_input().split())
    for i in range(n+1):
        h=[ x for j,x in enumerate(grass) if i!=j ]
        g=[ h[j+1]-h[j] for j in range(len(h)-1) ]
        if len(set(g))==1:
            print grass[i]
            break

Measured memory_bytes: 4232
#include<stdio.h>
int main(){	
 int n;
 char s[100],t[100];
 scanf("%d",&n);
 scanf("%s %s",s,t);
 for(int i=0;i<n;i++){
 	 printf("%c%c",s[i],t[i]);
 }
 return 0;
}

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

using namespace std;
main(){

long long int W,N;
cin>>N>>W;
long long int w[N],v[N],sumv=0;
for(int i=0;i<N;i++){
cin>>w[i]>>v[i];
sumv+=v[i];
}
//cout<<sumv;
long long dp[sumv+1][2];
for(int i=0;i<=sumv;i++){dp[i][0]=1e10;dp[i][1]=1e10;}
dp[0][0]=0;
dp[0][1]=0;
for(int i=0;i<N;i++){for(int j=1;j<=sumv;j++){
//cout<<j<<v[i]<<"  ";
if(j<v[i]){dp[j][i%2]=dp[j][(i+1)%2];}
else{dp[j][i%2]=min(w[i]+dp[j-v[i]][(i+1)%2],dp[j][(i+1)%2]);}
//cout<<dp[j][(i)%2]<<"  ";}cout<<endl<<endl;}
}}
int ret=0;
for(int i=0;i<=sumv;i++){if(dp[i][(N-1)%2]<=W)ret=i;}
cout<<ret;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const int inf = 1e9;

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1, ~0);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	lli ans = 0;
	int last = 0;
	int bit = a[0];
	for(int i=0; i<n; i++){
		while(last < n-1 && (bit & a[last+1])==0){
			bit |= a[last+1];
			last++;
		}
		ans += last -i+1;
		bit &= ~a[i];
	}	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define M 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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

struct uf {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rcount;

    uf(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%M+M)%M) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= M) x -= M;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += M-a.x) >= M) x -= M;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= M;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime M
    mint inv() const {
        return pow(M-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int main(){
	int n,k;cin>>n>>k;
	double ans=0;
	FOR(i,1,n){
		if(i>=k)ans+=1.0;
		else{
			int c=1,j=0;
			while(c*i<k){
				c*=2;
				j++;
			}
			ans+=1.0/pow(2,j);
		}
	}
	ans*=1.0/n;
	printf("%.10lf\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a==5 && b==5 && c==7){
        printf("YES\n");
    } else if(a==7 && b==5 && c==5){
        printf("YES\n");
    } else if(a==5 && b==7 && c==5){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 600031;

int n;
vector<int> perm;
set<int> ans;

vector<int> normalize(vector<int> v)
{
	vector<int> ret;

	for (int i = 1; i + 1 < v.size(); i++)
	{
		vector<int> cur;
		cur.push_back(v[i - 1]);
		cur.push_back(v[i]);
		cur.push_back(v[i + 1]);
		sort(cur.begin(), cur.end());
		ret.push_back(cur[1]);
	}
	return ret;
}

int eval(vector<int> v)
{
	if (v.size() == 1)
		return v[0];
	return eval(normalize(v));
}

/*
vector<int> magic_struct(int len, int need)
{
	vector<int> v;
	for (int i = need - 1; i >= 1; --i)
		v.push_back(i);
	v.push_back(need);
	for (int i = len * 2 - 1; i > need; --i)
		v.push_back(i);
	return v;
}
*/

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);


	/*int n;
	int need;
	cin >> n >> need;
	perm = magic_struct(n,need);
	cout << eval(perm) << endl;
	*/
	/*while (cin >> n)
	{
		perm.clear();
		for (int i = 0; i < n; i++)
		{
			int val;
			cin >> val;
			perm.push_back(val);
		}
		cout << eval(perm) << endl;
	}
	cin >> n;
	for (int i = 1; i < n * 2; i++)
	{
		perm.push_back(i);
	}

	
	do
	{
		int here = eval(perm);
		
		ans.insert(here);
	} while (next_permutation(perm.begin(), perm.end()));

	set<int>::iterator it;

	for (it = ans.begin(); it != ans.end(); it++)
	{
		cout << (*it) << " ";
	}
	cout << endl;
	*/
	int x;

	cin >> n >> x;
	if (x == 1 || x == n * 2 - 1)
	{
		cout << "No" << endl;
		return 0;
	}

	vector<int> good;
	
//	cout << "Yes" << endl;

	vector<int> res;

	if (x < n)
	{
		int F = n - x;
		for (int i = n * 2 - F; i <= n * 2 - 1; i++)
		{
			res.push_back(i);
		}
		for (int i = 1; i < n * 2 - F; i++)
		{
			res.push_back(i);
		}
	}
	else
	{
		int F = x - n+1;
		for (int i = F; i <= n * 2 - 1; i++)
		{
			res.push_back(i);
		}
		for (int i = 1; i < F; i++)
		{
			res.push_back(i);
		}
	}

	cout << "Yes" << endl;
	for (int i = 0; i < res.size(); i++)
	{
		if (i)
			cout << " ";
		cout << res[i];
	}
	cout << endl;
	//cout << eval(res) << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int ll;
struct Bug{int a, b;};

bool comp(const Bug &x, const Bug &y){
	return (x.b == y.b ? x.a > y.a : x.b < y.b);
}

bool C(vector<Bug> va, int k){
	priority_queue<int> pqa;
	int n = va.size();
	ll sum = 0;
	for(int i = n - 1; i >= 0; i--){
		if(i < n - k + 1){
			if(sum + va[i].a <= (ll)k * (ll)va[i].b) return true;
		}
		pqa.push(va[i].a);
		sum += va[i].a;
		if(i < n - k + 1){
			sum -= pqa.top();
			pqa.pop();
		}
	}
	return false;
}

int main(){
	int N;
	cin >> N;
	vector<Bug> va(N);
	for(int i = 0; i < N; i++) cin >> va[i].a >> va[i].b;
	sort(va.begin(), va.end(), comp);
	int lb = 0, ub = N + 1;
	while(ub - lb > 1){
		int mid = lb + (ub - lb) / 2;
		if(C(va, mid)) lb = mid;
		else ub = mid;
	}
	cout << lb << endl;
	return 0;
}



Measured memory_bytes: 10684
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int[] a = new int[n.length()+1];
        for (int i = 1; i < n.length()+1; i++) {
            a[i] = Integer.parseInt(n.substring(i-1, i));
        }
        long ans = 0;
        int[] b = new int[n.length()+1];
        for (int i = a.length-1; i > 0; i--) {
            a[i] += b[i];
            if(5 < a[i]){
                b[i-1]++;
                ans += 10 - a[i];
            }else if(a[i] == 5 && 5 <= a[i-1]){
                b[i-1]++;
                ans += 10 - a[i];
            }else{
                ans += a[i];
            }
        }
        ans += b[0];
        System.out.println(ans);
        sc.close();

    }

}


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

ll H,W,N,K;
int t[100][100];

ll mpow(ll a,ll b){
  if(b==0)return 1;
  ll res= mpow( a*a%K , b/2 );
  if(b&1)res=(res*a)%K;
  return res;
}

int main(){
  ll sum=0;
  cin>>H>>W>>N>>K;
  for(int a=0;a<H;a++){
    for(int b=0;b<W;b++){
      cout<<"? "<<a<<' '<<b<<' '<<a<<' '<<b<<endl;
      cin>>t[a][b];
      sum+=t[a][b];
      if(sum==N)break;
    }
  }

  ll ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans+=(t[i][j] * mpow(2, i*W+j) );
      ans%=K;
    }
  }
  cout<<"! "<<ans<<endl;
  return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int H, W, c[10][10], tmp;

int main() {
    cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    int minc[10];
    for (int i = 0; i < 10; i++) {
        minc[i] = c[i][1];
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                minc[j] = min(minc[j], c[j][k]+minc[k]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H*W; i++) {
        cin >> tmp;
        if (tmp == -1) continue;
        ans += minc[tmp];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
A.sort()
INF=int(1e9+7)
if N%2==1:
    if A[0]!=0:
        print(0)
        quit()
    for i in range((N-1)//2):
        if A[2*i+1]!=2*(i+1) or A[2*i+2]!=2*(i+1):
            print(0)
            quit()
    print(2**((N-1)//2)%INF)
else:
    for i in range(N//2):
        if A[2*i]!=2*i+1 or A[2*i+1]!=2*i+1:
            print(0)
            quit()
    print(2**(N//2)%INF)


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

int main(){
    string s;
    cin>>s;
    bool isok=true;
    const string st[4]={"dream","dreamer","erase","eraser"};

    for(int i=s.size()-1;i>=0;){
        if(s[i]=='r'){
            if(i-2>=0){
                if(s[i-2]=='m' && i-6>=0){
                    for(int j=0;j<7;j++){
                        if(s[i-j]!=st[1][6-j]){
                            isok=false;
                        }
                    }
                    i-=7;
                }
                else if(s[i-2]=='s' && i-5>=0){
                    for(int j=0;j<6;j++){
                        if(s[i-j]!=st[3][5-j]){
                            isok=false;
                        }
                    }
                    i-=6;
                }
                else{
                    isok=false;
                    break;
                }
            }
            else{
                isok=false;
                break;
            }

        }
        else if(s[i]=='m'){
            for(int j=0;j<5;j++){
                if(i-j<0 || s[i-j]!=st[0][4-j]){
                    isok=false;
                }
            }
            i-=5;
        }
        else if(s[i]=='e'){
            for(int j=0;j<5;j++){
                if(i-j<0 || s[i-j]!=st[2][4-j]){
                    isok=false;
                }
            }
            i-=5;
        }
        else{
       isok=false;
        }
        if(!isok) break;

    }
    if(isok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}
                         

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    char c; cin >> c;
    if(c == 'A') cout << 'T' << endl;
    if(c == 'T') cout << 'A' << endl;
    if(c == 'C') cout << 'G' << endl;
    if(c == 'G') cout << 'C' << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int x[100];
int y[100];
ld ang[100];
const ld PI = 4 * atan((ld)1);
const ld eps = 1e-9;

ld getAngle(int x1, int y1, int x2, int y2) {
    ld ret = atan2((ld)y2 - y1, (ld)x2 - x1);
    return ret;
}

int main() {
    scanf("%d", &n);
    if (n == 2) {
        printf("0.5\n0.5\n");
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", x + i, y + i);
    }
    cout.precision(50);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) ang[j] = -100;
            else ang[j] = getAngle(x[i], y[i], x[j], y[j]);
        }
        sort(ang, ang + n);
        ld ans = 0;
        int ch = 1;
        for (int j = 1; j < n; ++j) {
            int k = j % (n - 1) + 1;
            ld v = ang[k] - ang[j];
            if (v < -eps) v += PI + PI, ch = 0;
            if (v > PI + eps) {
                ans = v - PI;
                ch = 0;
                break;
            }
        }
        if (ch) ans = PI;
        cout << (ans / (PI + PI)) << '\n';
    }
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    if (n > m + 1 || m > n + 1) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for (int i = 2; i <= n; ++i) {
        ans *= i;
        ans %= (long long)1e9 + 7;
    }
    for (int i = 2; i <= m; ++i) {
        ans *= i;
        ans %= (long long)1e9 + 7;
    }
    if ((n + m) % 2 == 0) {
        ans *= 2;
        ans %= (long long)1e9 + 7;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S,T;
    int Q,a,b,c,d;
    cin >> S >> T >> Q;
    int ssum[100010] = {},tsum[100010] = {};
    for(int i = 1;i <= S.length();i++){
        ssum[i] = ssum[i-1] + (S[i-1]=='A'?1:2);
    }
    for(int i = 1;i <= T.length();i++){
        tsum[i] = tsum[i-1] + (T[i-1]=='A'?1:2);
    }
    for(int i = 0;i < Q;i++){
        cin >> a >> b >> c >> d;
        if((ssum[b]-ssum[a-1])%3 == (tsum[d]-tsum[c-1])%3){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
mod = 10 **9 + 7
broken = [0] * M
for i in range(M):
    broken[i] = int(input())

dp = [0] * (N+3)
dp[0] = 1
for i in range(M):
    dp[broken[i]] = -1 * float('inf')

for i in range(N):
    if dp[i] >= 0:
        dp[i+1] = (dp[i+1] + dp[i]) % mod
        dp[i+2] = (dp[i+2] + dp[i]) % mod

print(dp[N] % mod)


Measured memory_bytes: 49752
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 1000) cout << 1000 - n % 1000;
    else cout << 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n,k;cin >> n >> k;
  vector<long>h(n);
  long  ans = 0;
  for(int i = 0; i < n; i++)
    cin >>h.at(i);
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  for(int i = 0; i < n; i++){
    if(k > 0){
      k--;
    }
    else
      ans += h.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, t;
  cin >> a >> b >> c;
  cin >> t;
  int n = max(a, max(b, c));
  int r = a + b + c - n;
  while (t--) {
    n *= 2;
  }
  r += n;
  cout << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int ans=0;
int main()
{
	for(int i=0;i<4;i++){
		int tmp;cin>>tmp;
		ans+=tmp;
	}
	printf("%d\n%d\n",ans/60,ans%60);
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
const ll INF = 1LL << 60;

int main() {

    int N,L;
    cin >> N >> L;

    int R[N];
    rep(i,N){
        R[i] = (L + i);
    }

    int abs_min = 10000;
    int abs_idx;
    rep(i,N){
        if(abs_min > (R[i]*R[i])){
            abs_min = (R[i]*R[i]);
            abs_idx = i;
        }
    }

    int sum = 0;
    rep(i,N){
        sum += R[i];
    }

    sum -= R[abs_idx];

    cout << sum << endl;

}

Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
  int x=0,y=0,i,ans=0,kari=0;

  scanf("%d%d",&x,&y);

  if( y > x )
  {
    kari = x;
    x = y;
    y = kari;
  }

  ans = x % y;

  while( ans != 0 )
  {
    x = y;
    y = ans;
    ans = x % y;
  }

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

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
const int INF = 1 << 30;

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> dp(h,vector<int>(w,INF));
  dp[0][0] = 1;
  
  int w_cnt = 0;
  rep(i,h)rep(j,w){
    if(s[i][j] == '.') w_cnt++;
  }
  
  queue<pair<int,int>> q;
  q.push({0,0});
  
  while(!q.empty()){
    pair<int,int> p = q.front();q.pop();
    int y = p.first; int x = p.second;
    
    rep(i,4){
      int nx = x+dx[i]; int ny = y+dy[i];
      if(nx >= 0 && nx < w && ny >=0 && ny < h){
        if(s[ny][nx] == '.' && dp[y][x]+1 < dp[ny][nx]){
          dp[ny][nx] = dp[y][x]+1;
          q.push({ny,nx});
        }
      }
    }
  }
  
  if(dp[h-1][w-1] == INF){
    cout << "-1" << endl;
  }else{
    cout << w_cnt-dp[h-1][w-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int D = scanner.nextInt(), N = scanner.nextInt();

        if (N == 100) N++;

        for (int i = 0; i < D; i++) {
            N *= 100;
        }

        System.out.println(N);
    }
}


Measured memory_bytes: 23764
N = int(input())
a_list = [int(a) for a in input().split()]
b_list = [int(a) for a in input().split()]

if sum(a_list) < sum(b_list):
    print("-1")
else:
    d_list = [a - b for a, b in zip(a_list, b_list)]
    d_list.sort()
    minus = [d for d in d_list if d < 0]
    deficit = sum(minus)
    ans = len(minus)
    if deficit == 0:
        print("0")
    else:
        for i in range(N):
            deficit += d_list[-i - 1]
            if deficit >= 0:
                ans += i + 1
                break
        print(str(ans))


Measured memory_bytes: 19068
import java.util.Scanner;

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

		var a = new String[] {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
		System.out.println(a[n % 10]);
	}
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CWalkingTakahashi {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int X, K, D;
        cin >> X >> K >> D;
        X = abs(X);
        int num = X / D;
        if (num >= K) {
            cout << X - K * D << endl;
            return;
        }

        K -= num;
        int res = X - D * num;
        if (K % 2 == 0) {
            cout << res << endl;
        } else {
            cout << abs(D - res) << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CWalkingTakahashi solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int N, a[40], b[40];
    char A[40], B[40];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> a[i];
        B[i] = A[i];
        b[i] = a[i];
    }

    //bubble
    for (int i = 0; i < N; ++i) {
        for (int j = N - 1; j > i; --j) {
            if (a[j] < a[j - 1]) {
                int t = a[j]; char s = A[j];
                a[j] = a[j - 1]; A[j] = A[j - 1];
                a[j - 1] = t; A[j - 1] = s;
            }
        }
    }
    //selection
    for (int i = 0; i < N; ++i) {
        int minj = i;
        for (int j = i; j < N; ++j) {
            if (b[j] < b[minj]) minj = j;
        }
        int t = b[i]; char s = B[i];
        b[i] = b[minj]; B[i] = B[minj];
        b[minj] = t; B[minj] = s;
    }

    for (int i = 0; i < N; ++i) {
        if (i) cout << ' ';
        cout << A[i] << a[i];
    }
    cout << endl << "Stable" << endl;
    for (int i = 0; i < N; ++i) {
        if (i) cout << ' ';
        cout << B[i] << b[i];
    }
    cout << endl;
    bool stable = true;
    for (int i = 0; i < N; ++i) {
        if (!(a[i] == b[i] && A[i] == B[i])) {
            stable = false;
            break;
        }
    }
    if (stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;

int main(){
  int n;
  int dat[1000];
  cin >> n;
  for(int i=0;i<2*n;i++){
    cin >> dat[i];
  }
  sort(dat,dat+(2*n));
  int sum = 0;
  for(int i=0;i<2*n;i+=2){
    sum += min(dat[i],dat[i+1]);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65 and m+f<80:
        print('B')
    elif m+f>=50 and m+f<65:
        print('C')
    elif m+f>=30 and m+f<50 and r>=50:
        print('C')
    elif m+f>=30 and m+f<50 and r<50:
        print('D')
    elif m+f<30:
        print('F')


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int64_t h;
	cin >> h;

	int64_t ans = 1;
	while (true) {
		ans *= 2;
		h /= 2;
		if (h == 0) {
			break;
		}
	}

	ans--;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,i,count=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[10005]={0};int i,j,k;
	for(i=1;;i++)
	{
		if(i*i*6>10000)
		break;
		for(j=i;;j++)
		{
			if(i*i+j*j*3+i*j*2>10000)
			break;
			for(k=j;;k++)
			{
				if(i*i+j*j+k*k+i*j+j*k+k*i>10000)
				break;
				if(i==j&&k==j)
				a[i*i+j*j+k*k+i*j+j*k+k*i]+=1;
				else if(i!=k&&k!=j&&i!=j)
				a[i*i+j*j+k*k+i*j+j*k+k*i]+=6;
				else
				a[i*i+j*j+k*k+i*j+j*k+k*i]+=3;
			}
		}
	}
	int n;cin>>n;
	for(i=1;i<=n;i++)
	cout<<a[i]<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define out(ans) cout << ans << endl
#define in(n) cin >> n
ll n;
ll ans;

void solve();

int main()
{
    solve();
}

void solve()
{
    in(n);
    vector<ll> v(n);
    floop(i, n)
    {
        in(v[i]);
    }
    sort(v.begin(), v.end());
    ans = v[n / 2] - v[n / 2 - 1];
    out(ans);
}

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

int main()
{
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k)
    cout<<s<<endl;
  else
  {
    for(int i=0;i<k;i++)
    {
      cout<<s.at(i);
    }
    cout<<"..."<<endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int k;
  string s;
  cin >> s >> k;
  set<string> st;
  int ss = s.size();
  for (int i = 0; i < ss; ++i) {
    for (int j = 1; i + j <= ss; ++j) {
      if (j > k) continue;
      string ss = s.substr(i, j);
      st.insert(ss);
    }
  }
  int cnt = 0;
  for (auto ans : st) {
   if (cnt != k - 1)
      cnt++;
    else {
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 5e5 + 3;
const LL mod = 1e9 + 7;
string s;
int main() {
	ios::sync_with_stdio(false);
    cin>>s;
    if(s[0]=='S')cout<<"Cloudy\n";
    else if(s[0]=='C')cout<<"Rainy\n";
    else cout<<"Sunny\n";
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $w, $b);
$w--;
$b--;
$size = 64;
for($i = 0; $i < $size/2; $i++){
  $map[$i] = array_fill(0, $size, "#");
  $map[$i+$size/2] = array_fill(0, $size, ".");
}
for($i = 0; $i < $w; $i++)$map[intdiv($i*2,$size)*2][$i*2%$size] = ".";
for($i = 0; $i < $b; $i++)$map[$size - 1 - intdiv($i*2,$size)*2][$i*2%$size] = "#";
echo "$size $size\n";
for($i = 0; $i < $size; $i++){
  echo implode("", $map[$i]),"\n";
}


Measured memory_bytes: 4856
import java.util.*;

/**
 * A
 */
public class Main {

    int n;
    int[] A;
    boolean res;

    void run() {

        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        A = new int[n];

        for(int i=0; i<n; i++) {
            A[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] M = new int[q];

        for (int i = 0; i < q; i++) {
            M[i] = sc.nextInt();
        }

        sc.close();

        for(int i=0; i<q; i++) {
            
            boolean ans = solve(0, M[i]);
            
            if(ans) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }

        }

    }
    
    boolean solve(int i, int m) {

        if (m == 0) {
            return true;
        }
        if (i >= n) {
            return false;
        }

        res = solve(i + 1, m) || solve(i + 1, m - A[i]);

        return res;
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 27084
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    println(problem123b(a, b, c, d, e))
}

fun problem123b(a: Int, b: Int, c: Int, d: Int, e: Int): Int {
    var sum = 0
    val list = listOf(a, b, c, d, e)
    val zeros = list.filter { it.toString().last().toString().toInt() == 0 }
    val other = list.sortedByDescending { it.toString().last().toString().toInt() }
        .filter { it.toString().last().toString().toInt() != 0 }
    return other
        .map { if (it >= 10) (it.toString().dropLast(1).toString().toInt() + 1) * 10 else 10 }
        .dropLast(1)
        .sum() + zeros.sum() + (other.lastOrNull() ?: 0)
}

Measured memory_bytes: 33920
n, k = map( int, input().split() )
mod = 10 ** 9 + 7
 
numer = [ 1 ] * ( n + 1 )
demon = [ 1 ] * ( n + 1 )
 
for i in range( 1, n + 1 ):
  numer[ i ] = numer[ i - 1 ] * i % mod

demon[ n ] = pow( numer[ n ], mod - 2, mod )
for i in range( n, 0, -1 ):
  demon[ i - 1 ] = ( demon[ i ] * i ) % mod

def nCr( n, r ):
  if r < 1:
    return 1
  return ( numer[ n ] * demon[ r ] % mod ) * demon[ n - r ] % mod
 
ans = 0
for i in range( min( k, n - 1) + 1 ):
  ans = ( ans + nCr( n, i ) * nCr( n - 1, i )) % mod
print( ans )

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

using namespace std;

int main(){
  int n,k,i,j,c=0;
  vector<int> s,t;
  
  cin>>n>>k;
  for(i=0;i<n;i++){
    cin>>j;
    s.push_back(j);
    t.push_back(k-j);
  }
  
  for(i=0;i<n;i++)
    c+=min(s[i],t[i])*2;
  
  cout<<c<<endl;
  
  return 0;
  
  
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include<string.h>

int main(void){
    int A,B;
    scanf("%d %d",&A,&B);
    if(A+B >= A-B && A+B >= A*B)printf("%d",A+B);
    else if(A-B>=A+B && A-B>=A*B)printf("%d",A-B);
    else printf("%d",A*B);
    return 0;    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i+1][k]=max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) res=max(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < 3;i++) {
        if(s[i] == '1') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long a[n];
    long long lng=0, shrt=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=n-1; i>0; i--){
        if(a[i]==a[i-1]){
            if(lng==0){lng=a[i];i--;}
            else if(shrt==0){shrt=a[i];break;}
        }
    }

    cout << lng*shrt << endl;
    return 0;
}

Measured memory_bytes: 1024