akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int h, w, k;
    string a[310];

    cin >> h >> w >> k;
    REP(i, h)
    cin >> a[i];

    int res[310][310];

    memset(res, -1, sizeof(res));

    int id = 1;

    REP(i, h)
    {
        int last = -1;
        bool exist = false;
        REP(j, w)
        {
            if (a[i][j] == '#')
            {
                exist = true;
                last = j;
            }
        }

        if (!exist)
            continue;

        REP(j, w)
        {
            res[i][j] = id;

            if (j != last && a[i][j] == '#')
                id++;
        }

        id++;
    }

    REP(i, h)
    {
        REP(j, w)
        {
            if (i > 0 && res[i][j] == -1 && res[i - 1][j] != -1)
                res[i][j] = res[i - 1][j];
        }
    }

    for (int i = h - 1; i >= 0; i--)
    {
        REP(j, w)
        {
            if (res[i][j] == -1 && res[i + 1][j] != -1)
                res[i][j] = res[i + 1][j];
        }
    }

    REP(i, h)
    {
        REP(j, w)
        {
            cout << res[i][j] << (j < w - 1 ? " " : "\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
int main(void)
{
	int N,ans=0;
	scanf("%d",&N);
	int a=105;
	int b=135;
	int c=165;
	int d=189;
	int e=195;
	
	if(N>=a)ans++;
	if(N>=b)ans++;
	if(N>=c)ans++;
	if(N>=d)ans++;
	if(N>=e)ans++;
	printf("%d\n",ans);
	return 0;
}


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

using ll = long long;

int main() {
    int Q;
    cin >> Q;
    while(Q--) {
        string s;
        cin >> s;
        int n = 0;
        for(int i=0; i<8; ++i) {
            n <<= 4;
            if(isdigit(s[i])) {
                n += s[i] - '0';
            } else {
                n += s[i] - 'a' + 10;
            }
        }
        double res = 0;
        double d = 1;
        {
            int t = n & ((1LL << 31) - 1);
            res += (t >> 7);
        }
        int cnt = 1;
        for(int i=6; i>=0; --i) {
            d /= 2;
            if(n & (1 << i)) {
                res += d;
                cnt = 6 - i + 1;
            }
        }
        cout << fixed << setprecision(cnt);
        if(n & (1 << 31)) {
            cout << -res << endl;
        } else {
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int n, i;
	ll a[200001];
	ll p[200001];
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		p[i] = a[i] + p[i - 1];
	}
	ll ans = 1e16;
	ll diff[4];
	ll l = 1, r = 3;
	for (i = 2; i < n; i++) {
		while (l < i&&abs(p[l] - (p[i] - p[l])) >= abs(p[l + 1] - (p[i] - p[l + 1])))l++;
		while (r < n&&abs((p[r] - p[i]) - (p[n] - p[r])) >= abs((p[r + 1] - p[i]) - (p[n] - p[r + 1])))r++;
		diff[0] = p[l];
		diff[1] = p[i] - p[l];
		diff[2] = p[r] - p[i];
		diff[3] = p[n] - p[r];
		sort(diff, diff + 4);
		ans = min(ans, diff[3] - diff[0]);
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
def main():
    import sys
    input=sys.stdin.readline
    l=lambda: list(map(int,input().split()))
    n,d,a=l()
    xh=[]
    for i in range(n):
        xi,hi=l()
        xh.append([xi,hi])
    xh.sort()
    
    
    right_index=[]
    
    #尺取り法
    tmp=0
    for i in range(n):
        j=tmp
        while xh[j][0]<=xh[i][0]+2*d:
            j+=1
            if j==n: break
        j-=1
        right_index.append(j)
        tmp=j

    
    ans=0
    cnt=0
    damage=[0]*(n+1)
    for i in range(n):
    	xh[i][1]-=(ans-cnt)*a
    	damage_cnt=max(0,(xh[i][1]-1)//a + 1)
    	ans+=damage_cnt
    	damage[right_index[i]]+=damage_cnt
    	cnt+=damage[i]
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 53552
n = int(input())
c = 0
for p in range(2, int(n**0.5)+1): #nが合成数
  e = 0
  while n%p == 0:
    n //= p
    e += 1
  i = 1
  while e >= i:
    e -= i
    c += 1
    i += 1
if n != 1: #nが素数
  c += 1
print(c)

Measured memory_bytes: 63664
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int n;

int main(){
  int ans = 0;
  cin >> n;
  if(n>=105) ans ++;
  if(n>=165) ans ++;
  if(n>=195) ans ++;
  if(n>=135) ans ++;
  if(n>=189) ans ++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<bool> color(8, false);
  int pro = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    cin >> a;
    if (a >= 3200)
      pro++;
    else {
      for (int j = 0; j < 8; j++) {
        if (400 * j <= a && a < 400 * (j + 1)) color[j] = true;
      }
    }
  }
  int rateColor = 0;
  for (int i = 0; i < 8; i++)
    if (color[i] == true) rateColor++;
  cout << (pro == n ? 1 : rateColor) << " " << rateColor + pro << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>


struct edge{
	int v, val, nxt;
}e[11234], eb[11234];
int fir[11234], fir2[11234], siz;
inline void add(int u, int v, int val){
	e[++siz].v = v; e[siz].val = val;
	e[siz].nxt = fir[u]; fir[u] = siz;
}

inline void add1(int u, int v){
	eb[++siz].v = v; 
	eb[siz].nxt = fir2[u]; fir2[u] = siz;
}

int dis[11234]; 
bool inque[11234];
int c1[11234], c2[11234];
int n, m, p;
const int inf = 1e9;
bool invalid[11234];

bool spfa(){
	if(invalid[1]) return true;
	std::queue<int> q;
	q.push(1);
	for(int i(2); i <= n; ++i) dis[i] = -inf;
	while(!q.empty()){
		int now = q.front();
		inque[now] = false; q.pop();
		for(int itr(fir[now]); itr; itr = e[itr].nxt){
			int to = e[itr].v; if(invalid[to]) continue;
			if(dis[now] + e[itr].val > dis[to]){
				if((c1[to] = c1[now] + 1) >= n){
					return true;
				}
				dis[to] = dis[now] + e[itr].val;
				if(!inque[to]){
					if((++c2[to]) >= n){
						return true;
					}
					inque[to] = true;
					q.push(to);
				}
			}
		}
	}
	return false;
}

inline void topo(){
	for(int i(1); i < n; ++i){
		invalid[i] = true;
	}
	std::queue<int> q;
	q.push(n);
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(int itr(fir2[now]); itr; itr = eb[itr].nxt){
			int to = eb[itr].v;
			if(invalid[to]){
				invalid[to] = false;
				q.push(to);
			}
		}
	}
}

int main(){
	scanf("%d%d%d", &n, &m, &p);
	for(int i(1); i <= m; ++i){
		int u, v, val; scanf("%d%d%d", &u, &v, &val);
		add(u, v, val - p); add1(v, u);
	}
	topo();
	if(spfa()){
		printf("-1\n");
	}
	else{
		printf("%d\n", std::max(0, dis[n]));
	}
	return 0;
}


Measured memory_bytes: 640
N = gets.chomp.to_i
txy_array = [[0,0,0]]
N.times do |n|
  txy_array.push(gets.chomp.split(' ').map(&:to_i))
end

ans = true
(0..(N-1)).each do |ind|
  txy_current = txy_array[ind]
  txy_next = txy_array[ind+1]
  t = txy_next[0] - txy_current[0]
  x = txy_next[1] - txy_current[1]
  y = txy_next[2] - txy_current[2]
  if x + y > t
    ans = false
    break
  elsif (t-x-y)%2 == 0
  else
    ans = false
    break
  end
end

print ans ? 'Yes' : 'No'

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int a, b, k;
    cin >> a >> b >> k;
    rep(i, k)
    {
        if (i % 2 == 0)
        {
            b += (a / 2);
            a /= 2;
        }
        else
        {
            a += (b / 2);
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N+1);
    rep(i,N+1) cin>>a[i];
    int now=1;
    ll cnt=0;
    rep(i,N+1) cnt+=a[i];
    cnt--;
    vll dp(N+1);
    dp[0]=1LL;
    rep(i,N){
        ll extra=dp[i]-a[i];
        if (extra<=0){
            cout<<"-1\n";
            return 0;
        }
        if (extra<=cnt){
            cnt-=extra;
            dp[i+1]=2LL*extra;
        }else{
            dp[i+1]=2LL*cnt + (extra-cnt);
            cnt=0;
        }
    }
    if (dp[N]!=a[N]){
        cout<<"-1\n";
        return 0;
    }
    ll ans=0;
    rep(i,N+1){
        ans+=dp[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4788
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int n;
	cin >> n;
	
	int counter = 0;
	for (int i = 1; i <= n; i++)
	{
		int number = i;
		
		int digit_counter = 0;
		while (number != 0)
		{
			number /= 10;
			digit_counter++;
		}
		
		if ((digit_counter % 2) != 0)
		{
			counter++;
		}
	}
	
	cout << counter << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
int a[MAX_N];
int d[MAX_N];

int main()
{
    int n;
    RI(n);
    REP(i, n) {
        RI(a[i]);
    }

    int ans = 1, prev = 0, cur = 0;
    REP(i, 1, n) {
        int diff = a[i] - a[i-1];
        if(diff > 0) {
            cur = 1;
        } else if (diff < 0){
            cur = -1;
        } else {
            cur = prev;
        }

        //print(a[i], prev, cur);
        if(prev * cur == -1) {
            ans += 1;
            prev = 0;
        } else {
            prev = cur;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    char str[5];
    int i=0,j;
    scanf("%s",str);
    for(j=0;j<4;j++)
    {
         if(str[j]=='+')
         {
             i++;
         }
         else
         {
             i--;
         }
    }
    printf("%d",i);
   return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<long long, long long>> vpl;

/**
 * Solves the single-use Discrete (0-1) Knapsack problem.
 * Params: A vector of objects as {volume, value}, and an integer max-weight
 * Returns: A vector of max_value vs. volume occupied
 */

vll knapsack(const vpl &obj, ll max_weight) {
    ll n = obj.size();
    vll dp(max_weight + 1, 0);
    for (int i = 0; i < n; i++) {
        vll next(max_weight + 1, 0);
        for (int j = 0; j <= max_weight; j++) {
            next[j] = obj[i].first > j
                          ? dp[j]
                          : max(dp[j], dp[j - obj[i].first] + obj[i].second);
            if (j > 0)
                next[j] = max(next[j], next[j - 1]);
        }
        dp = next;
    }
    return dp;
}

int main() {
    long long n, k;
    cin >> n >> k;
    vector<pair<long long, long long>> obj(n);
    for (int i = 0; i < n; i++)
        cin >> obj[i].first >> obj[i].second;
    vll dp = knapsack(obj, k);
    cout << dp[k] << endl;
}

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

#define ll long long
#define pb push_back

int main()
{
	ll n;
	cin >> n;
	
	ll mn=100,cnt=0;
	while(mn<n){
		mn +=mn/100;
		cnt++;
	}
	cout<<cnt<<endl;

}

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

int main() {
  ll n;
  cin>>n;

  int h[100010];
  for (int i=0; i<n; i++) {
    scanf("%d",h+i);
  }
  int dp[100010];
  dp[0]=0; dp[1]=abs(h[1]-h[0]);
  for (int i=2; i<n; i++) {
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

vi DX = {0, 0, -1, 1};
vi DY = {-1, 1, 0, 0};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int H, W; cin >> H >> W;
	int CH, CW; cin >> CH >> CW; --CH; --CW;
	int DH, DW; cin >> DH >> DW; --DH; --DW;
	vector<vector<bool>> grid (H, vector<bool> (W));
	vector<vector<int>> dist (H, vector<int> (W, 1e9));

	F0R(i, H) F0R(j, W) {
		char c; cin >> c;
		grid[i][j] = c == '#';
	}
	dist[CH][CW] = 0;
	deque<pair<int, int>> q;
	q.push_front({CH, CW});
	while (!q.empty()) {
		pair<int, int> pos = q.front();
		int ph = pos.first;
		int pw = pos.second;
		q.pop_front();
		F0R(i, 4) {
			int nh = ph + DX[i];
			int nw = pw + DY[i];
			if (0 <= nh && nh < H && 0 <= nw && nw < W && !grid[nh][nw]) {
				if (dist[ph][pw] < dist[nh][nw]) {
					dist[nh][nw] = dist[ph][pw];
					q.push_front({nh, nw});
				}
			}
		}
		for (int nh = ph - 2; nh <= ph + 2; ++nh) {
			for (int nw = pw - 2; nw <= pw + 2; ++nw) {
				if (0 <= nh && nh < H && 0 <= nw && nw < W && !grid[nh][nw]) {
					if (dist[ph][pw] + 1 < dist[nh][nw]) {
						dist[nh][nw] = dist[ph][pw] + 1;
						q.push_back({nh, nw});
					}
				}
			}
		}
	}
	print((dist[DH][DW] == (int) 1e9) ? -1 : dist[DH][DW]);
}

Measured memory_bytes: 7752
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int a=sc.nextInt();
      int b=sc.nextInt();
      if(a>=1&&a<=9&&b>=1&&b<=9)
      System.out.println((a*b));
      else
      System.out.println("-1");
    }
}


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

int main()
{
    int d;
    cin >> d;
    cout << "Christmas";
    for (int i = 0; i < 25 - d; i++)
    {
        cout << " Eve";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int s=0;
  for(int i=0;i<k;i++)
    s+=a.at(i);
  cout<<s<<endl;
}

Measured memory_bytes: 3628
n = int(input().rstrip())
cl = [ord(c) for c in input().rstrip().rstrip()]
for i in range(len(cl)):
	v = cl[i] + n
	cl[i] = v if v <= ord('Z') else (ord('A') + v - ord('Z') - 1)

r = ''
for i in range(len(cl)):
	r += chr(cl[i])

print(r)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    long n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    vec<long> ten(101,0);
    long div =2;
    while (div < n)
    {
        div *= 5;
      	ten.at(0) += n/div;
        for (size_t i = 0; i < 100; i++)
        {
            ten.at(i+1) = ten.at(i)/div;
        }
    }

    long sum = accumulate(ten.begin(),ten.end(),0LL);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

const int N = 22;
const int M = 1e5 + 10;
const int INF = 0x3f3f3f3f;

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

set<int, greater<int> > x;
set<int, greater<int> >::iterator it, i2;

int main ()
{
	int n, m, a;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++){
		scanf("%d", &a); x.insert(a);
	}
	
	int f = 0, cnt = 0;
	for(it = x.begin(); it != x.end(); it++){
	//	printf("%d %d\n", cnt++, *it);
		i2 = ++it; it--;
		if(i2 == x.end()) break;
		x.insert((*it) - (*i2));
	}
//	puts("OK?");
	
	for(it = x.begin(); it != x.end() && !f; it++){
	//	printf("*it = %d\n", *it);
		if(*it == m) f = 1;
		if(*it > m && x.find((*it)%m) != x.end()) f = 1;
		if(*it < m && x.find(m + (*it)) != x.end()) f = 1;
	}
	
	printf("%s\n", f ? "POSSIBLE" : "IMPOSSIBLE");
	
	return 0;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
    }
    if( n>= m)
    {
        cout<<0;
        return 0;
    }
    sort( a , a+m);
    int d [m-1];
    ll total =0;
    for(int i=0;i<m-1;i++ )
    {
        d[i] = a[i+1]- a[i];
        total += d[i];
    }
    sort( d , d+m-1);
    for(int i=0;i<n-1;i++)
    {
        total = total - d[m-1 -i - 1];
    }
    cout<<total ;
}

Measured memory_bytes: 4200
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
from itertools import *
ans = 0
for bit in range(1<<(h+w)):
    c = 0
    for i, j in product(range(w, h+w), range(w)):
        if bit>>i & 1 and bit>>j & 1: c += C[i-w][j] == '#'
    if c == k: ans += 1
print(ans)


Measured memory_bytes: 9068
n = int(input())
l = list(map(int,input().split()))
l.sort()

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k]:continue
            if l[k] - l[j] < l[i] < l[j] + l[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9188
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int main() {
  int n, p;
  while (true) {
    cin >> n >> p;
    if (n == 0 && p == 0) break;

    int a[n], wan = p;
    memset(a, 0, sizeof(a));
    int i = 0;
    while (true) {
      if (wan == 0) {
	wan = a[i];
	a[i] = 0;
      }else {
	a[i]++;
	wan--;
	if (a[i] == p) {
	  std::cout << i << std::endl;
	  break;
	}
      }
      i = (i+1)%n;
    }
  }
}

Measured memory_bytes: 1168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

#define SIZE 200005
#define PI acosl(-1) //3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
#define Sort(a, t) qsort(a, sizeof(a)/sizeof((a)[0]), sizeof(t), comp) //compを使って1次元配列をソート
#define assert(c) if(!(c)) return 0

typedef long long ll; typedef long double ld;

int f(int n) {
    if (n == 0) return 0;
    return f(n % __builtin_popcount(n)) + 1;
}

int main() {
    int i, N, popcount = 0, pop, b;
    char s[SIZE];
    scanf("%d %s", &N, s);
    int *X = array(N, int);
    int *count = array(N, int);
    rep(i, N) {
        X[i] = s[i] - '0';
        popcount += X[i];
    }

    // popcountが増えるか減るかの2通りを試す
    rep(b, 2) {
        pop = (b == 0) ? (popcount + 1) : (popcount - 1);
        if (pop <= 0) continue;
        // 元の数をpopcountで割った余りを求める
        int r0 = 0;
        rep(i, N) {
            r0 = (r0 << 1) % pop;
            r0 += X[i];
        }
        // 下の桁から余りの変化を見る
        int r, k = 1;
        for (i = N - 1; i >= 0; i--) {
            if (X[i] == b) {
                if (b == 0) r = (r0 + k) % pop;
                else r = (r0 - k + pop) % pop;
                count[i] = f(r) + 1;
            }
            k = (k << 1) % pop;
        }
    }

    rep(i, N) printf("%d\n", count[i]);

    free(X);
    free(count);
    return 0;
}

Measured memory_bytes: 3404
#include<stdio.h>
#include<math.h>
 
int main()
{
	long long int HP, enemy = 1, total = 1;
	scanf("%lld", &HP);
	for(;HP > 1;) {
		HP /= 2;
		enemy *= 2;
		total += enemy;
	}
	printf("%lld\n", total);
 
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
#define PI = acos(-1.0);
//#define local

using namespace std;

const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;

int main() {
#ifdef local
    if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
#endif
    int a[5];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a+3);
    printf("%d\n", a[2]*10 + a[1] + a[0]);
#ifdef local
    fclose(stdin);
#endif
    return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

const string defaultval = "753";

ll dfs(string s, ll n)
{
	ll x  = stoll(s);
	if(x > n)
		return 0;
	ll ret = 0;
	if(count(s.begin(), s.end() , '7') > 0 &&count(s.begin(), s.end() , '5') > 0 && count(s.begin(), s.end() , '3') > 0)
		ret = 1;

	for(char c :defaultval)
	{
		s.push_back(c);
		ret += dfs(s, n);
		s.pop_back();
	}
	return ret;
}		



int main()
{
	ll n;
	cin>>n;
	string start = "0";
	cout<<dfs(start, n);

}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<int> b(4);
        for (int i = 0; i < n; i++) {
                int x; cin >> x;
                x %= 4;
                if (x == 3) x = 1;
                b[x]++;
        }

        if (b[2]) b[0]--;

        if (b[1] > b[0] + 1) cout << "No";
        else cout << "Yes";
        //1, 0, 1, 0, 1,
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3612
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
int tax(int per,int yen) {return yen * (100 +per) / 100;}
void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		auto taxed = new int [s];
		foreach(int i,ref t;taxed)t = tax(x,i);
		foreach(i;1..s){
			foreach(j;i..s){
				if (taxed[i] + taxed[j] == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}

Measured memory_bytes: 2904
from collections import deque
h, w =map(int, input().split())
s = [input() for i in range(h)]
s_x, s_y = 0, 0
##ある場所を塗る。その上でBFS。最大値を求める。
#最短経路で辿り着く時、塗りつぶす手は最大になる。
#最短経路の時は、通るますが考えうる中で一番少ないからねえ。そりゃそうか。
max = 0
c = [[0] * w for i in range(h)]
#cを定義する時は、横に並べてからそれを縦に並べる。つまり、列数を指定してから、その外で
#行数を指定する。ただ、要素にアクセスするときは、c[行番号][列番号]
#外側ほど、左側の要素になる？
def BFS():
    q = deque()
    q.append((s_x, s_y))

    while len(q) > 0:
        y, x = q.popleft()
        if y == h - 1 and x == w - 1:
            return c[y][x]
        if x < w - 1:
            if s[y][x+1] == '.' and c[y][x+1] == 0:
                q.append((y, x+1))
                c[y][x+1] = c[y][x] + 1
        if x > 0:
            if s[y][x-1] == '.' and c[y][x-1] == 0:
                q.append((y, x-1))
                c[y][x-1] = c[y][x] + 1
        if y < h - 1:
            if s[y+1][x] == '.' and c[y+1][x] == 0:
                q.append((y+1, x))
                c[y+1][x] = c[y][x] + 1
        if y > 0:
            if s[y-1][x] == '.' and c[y-1][x] == 0:
                q.append((y-1, x))
                c[y-1][x] = c[y][x] + 1

    return(-1)

area = h*w
blunk_num_origin = 0
for ch1 in s:
    for ch2 in ch1:
        if ch2 == '#':
            blunk_num_origin += 1

min_grid = BFS()
if min_grid == -1:
    print(min_grid)
else:
    sol = area-blunk_num_origin-2-(min_grid-1)
    #print(area,min_grid,blunk_num_origin)
    print(sol)


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

int main() {
  int A, B;
  cin >> A >> B;

  int count = 1;
  int kosu = 0;
  

  while (count < B) {
    count = (count - 1 + A);
    kosu++;
  }

  cout << kosu << endl;
}


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

int gcd(int a, int b ){
    int r;
    if(a < b){
        swap(a,b);
    }
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


int main(){
  int n,x;
  cin >> n >> x;
  
  int d;
  cin >> d;
  d = abs(x -d);
  for(int i =1;i <n; i++){
      int ai;
      cin >> ai;
      d = gcd(d, abs(x - ai));
  }
  cout << d << endl;
}

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

ans = 0

if a[0] > 0:
    if n == 0 and a[0] == 1:
        print(1)
        exit()
    else:
        print(-1)
        exit()

# node_list_1 は深いところから見たNode数の最大値
# node_list_2 は根から見たNode数の最大値
node_list_1 = [0] * (n + 1)
node_list_2 = [0] * (n + 1)

node_list_1[n] = a[n]
node_list_2[0] = 1

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

for j in range(1, n+1):
    node_list_2[j] = (node_list_2[j-1] - a[j-1]) * 2
    if node_list_2[j] < a[j]:
        print(-1)
        exit()

for k in range(n+1):
    ans += min(node_list_1[k], node_list_2[k])

print(ans)


Measured memory_bytes: 679988
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
	// 入力
    ll N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    
    for (int i = 0; i < N; ++i) A[i] = A[i] - (i + 1);
    sort(A, A + N);
    ll med;
    if (N%2==0){
        med = (A[(N/2)-1] + A[N/2]) / 2;
    }
    else{
        med = A[N/2];
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) ans += abs(A[i] - med);

    cout << ans << endl;
}
 


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<int> x(N);
	for (int i = 0; i < N; i++)
		scanf("%d", &x[i]);
	x.push_back(INT_MAX);
	int L; cin >> L;
	vector<vector<int> > dp(N + 1, vector<int>(20));
	dp[N][0] = N;
	for (int i = 0; i < N; i++)
		dp[i][0] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
	for (int k = 1; k < 20; k++)
		for (int i = 0; i <= N; i++)
			dp[i][k] = dp[dp[i][k - 1]][k - 1];
	int Q; cin >> Q;
	while (Q--) {
		int s, t; scanf("%d%d", &s, &t);
		s--; t--;
		if (s > t) swap(s, t);
		int lb = 0, ub = N;
		while (ub - lb > 1) {
			int mid = (lb + ub) / 2;
			int i = s;
			for (int k = 0; k < 20; k++)
				if (mid>>k & 1)
					i = dp[i][k];
			if (i >= t) ub = mid;
			else lb = mid;
		}
		printf("%d\n", ub);
	}
}


Measured memory_bytes: 12920
H,W=map(int,input().split())

mat=[[x=="#" for x in input()] for _ in range(H)]
#print(mat)

answer=0
visited_set=set()
for i in range(H):
  for j in range(W):
    if not mat[i][j] or (i,j) in visited_set:
      continue      

    queue=[(i,j)]
    d=0
    num_black=num_white=0
    while queue:
      new_queue=set()
      for q in queue:
        ii,jj=q
        visited_set.add((ii,jj))
        if d%2==0:
          num_black+=1
        else:
          num_white+=1
        
        if ii>0 and mat[ii][jj]!=mat[ii-1][jj] and not (ii-1,jj) in visited_set:
          new_queue.add((ii-1,jj))
        if ii<H-1 and mat[ii][jj]!=mat[ii+1][jj] and not (ii+1,jj) in visited_set:
          new_queue.add((ii+1,jj))
        if jj>0 and mat[ii][jj]!=mat[ii][jj-1] and not (ii,jj-1) in visited_set:
          new_queue.add((ii,jj-1))
        if jj<W-1 and mat[ii][jj]!=mat[ii][jj+1] and not (ii,jj+1) in visited_set:
          new_queue.add((ii,jj+1))
          
      queue=list(new_queue)
      d+=1
      
    #print(i,j,num_black,num_white)
    answer+=num_black*num_white

print(answer)

Measured memory_bytes: 84824
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    int n;
    cin >> n;
    double x;
    string u;
    double sum=0,sum1 =0;
    for(int i =0;i<n; i++) {
        cin >> x >> u;
        if (u == "JPY") {
            sum+= x;
        } else {
            sum1+= x;
        }
    }
    cout << sum + sum1 * 380000 << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	unsigned long N;
	unsigned long M;
	unsigned long ans = 0;

	cin >> N >> M ;

	for (unsigned long i = 1; i * i <= M; i++)
	{
		if (M % i == 0)
		{
			unsigned long D = M / i;
			if (M / i >= N)
			{
				if (i > ans) ans = i;
			}
			if (M / D >= N)
			{
				if (D > ans) ans = D;
			}
		}
	}

	cout << ans << endl;

	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int n,k;cin>>n>>k;
    vector<int >x(n,0);
    for(int i=0;i<n;i++)cin>>x[i];
    int final=0;
    for(int i=0;i<n;i++){
        final+=min(2*x[i],2*(k-x[i]));
    }
    cout<<final;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 1000000000
int main(){
	int n,k;
	while(cin >> n >> k,n+k){
		int d[110][110];
		for(int i = 0; i < 110; i++)for(int j = 0; j < 110; j++)d[i][j] = i==j?0:INF;
		for(int i = 0; i < k; i++){
			int a;
			cin >> a;
			int from,to,cost;
			if(a == 1){
				cin >> from >> to >> cost;
				from--;to--;
				if(d[from][to] > cost){
					d[from][to] = d[to][from] = cost;
					for(int i = 0; i < n; i++){
						for(int j = 0; j < n; j++){
							//from to を経由する
							d[i][j] = min(d[i][j],d[i][from]+d[from][to]+d[to][j]);
							d[i][j] = min(d[i][j],d[i][to]+d[to][from]+d[from][j]);
							d[j][i] = d[i][j];
						}
					}
				}
			}
			else{
				cin >> from >> to;
				from--;to--;
				if(d[from][to] == INF)puts("-1");
				else cout << d[from][to] << endl;
			}
		}
	}
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[100005];
//! [足場iにたどり着くまでの]=最小コスト
ll dp[100005];

int main()
{
    int N, K;
    cin >> N >> K;
    REP(i, N)
    {
        cin >> H[i + 1];
    }
    H[0] = H[1];

    dp[0] = dp[1] = 0;
    FOR(i, N + 1, 2)
    {
        ll m = INF;
        FOR(j, K + 1, 1)
        {
            if (i - j < 0)
                break;
            m = std::min(m, dp[i - j] + abs(H[i] - H[i - j]));
        }
        dp[i] = m;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
from io import StringIO
import unittest

def resolve():
    n = input()

    if n[0] == "7":
        print("Yes")
        return
    if n[1] == "7":
        print("Yes")
        return
    if n[2] == "7":
        print("Yes")
        return
    print("No")
    return
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """117"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """123"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """777"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 70992
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H + 2, vector<char>(W + 2, '.'));
  for (int i = 1; i < H + 1; i++)
  {
    for (int j = 1; j < W + 1; j++)
    {
      cin >> S.at(i).at(j);
    }
  }
  
  for (int i = 1; i < H + 1; i++)
  {
    for (int j = 1; j < W + 1; j++)
    {
      if (S.at(i).at(j) == '.')
      {
        int n = 0;
        if (S.at(i - 1).at(j - 1) == '#') n++;
        if (S.at(i - 1).at(j    ) == '#') n++;
        if (S.at(i - 1).at(j + 1) == '#') n++;
        if (S.at(i    ).at(j - 1) == '#') n++;
        if (S.at(i    ).at(j + 1) == '#') n++;
        if (S.at(i + 1).at(j - 1) == '#') n++;
        if (S.at(i + 1).at(j    ) == '#') n++;
        if (S.at(i + 1).at(j + 1) == '#') n++;
        cout << n;
      }
      else cout << '#';
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    string S;
    cin >> S;
    int r, g, b;
    r = 0;
    g = 0;
    b = 0;
    REP(i, N)
    {
        if (S[i] == 'R')
            r++;
        if (S[i] == 'G')
            g++;
        if (S[i] == 'B')
            b++;
    }
    int ans = r * g * b;
    REP(i, N)
    {
        REP(j, N)
        {
            if (j + i + 1 + i + 1 >= N)
                break;
            if (S[j] != S[j + i + 1])
            {
                if (S[j + i + 1 + i + 1] != S[j + i + 1])
                {
                    if (S[j + i + 1 + i + 1] != S[j])
                        ans--;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int j=0;
  if(S.size()==1)
    j++;
  else{
  for(int i=0;i<S.size()/2;i++){
    if(S.size()==2*i+1||S.size()==2*i+3){
      j++;
      break;
    }
    else{
      if(S.at(2*i)!='h'){
        j++;
        break;
      }
      else if(S.at(2*i+1)!='i'){
        j++;
        break;
      }
    }
  }
  }
  if(j==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

int main() {
	int N, d[110];

	cin >> N;
	for (int i = 0; i < N; i++)cin >> d[i];

	set<int> values;

	for (int i = 0; i < N; i++) {
		values.insert(d[i]);
	}

	cout << values.size() << endl;

	return 0;
}

Measured memory_bytes: 256
/*input
5 3
10 30 40 50 20

*/
/**
 * B Frog 2
 * @author: Raj
 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#define endl '\n'
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define MOD 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb(n) emplace_back(n)
#define pb(n) push_back(n)
#define F first
#define S second
#define int long long int
#define double long double
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
void note_to_myself(){
	//new_data_set s;
	//logn operations
	//cout << *(s.find_by_order(i)) << " ";
	//cout << "The index of number 6::" << p.order_of_key(6) << endl; 
}
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mul(int x, int y) {
	return ((long long)x * y) % MOD;
}
inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
	a %= MOD;
	if (a < 0) a += MOD;
	int b = MOD, u = 0, v = 1;
	while (a) {
		int t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	assert(b == 1);
	if (u < 0) u += MOD;
	return u;
}
const int INF = 1e9+5;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	vi h(n),dp(n,INF);
	for (int i = 0; i < n; ++i){
		cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 0; i < n; ++i){
		for (int j = i+1; j <= i+k; ++j){
			if(j < n){
				dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]));
			}
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y123123123
#define int ll

using namespace std;

const int N = 2e5 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;

int n, m, k;
string s;
int a[N], b[N], mn1, mn2;
int ans;
main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> m >> k;
    mn1 = inf * inf;
    mn2 = inf * inf;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        mn1 = min(mn1, a[i]);
    }
    for(int i = 1; i <= m; ++i) {
        cin >> b[i];
        mn2 = min(mn2, b[i]);
    }
    ans = mn1 + mn2;
    for(int i = 1; i <= k; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        ans = min(ans, a[x] + b[y] - z);
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include<iostream>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=2;i<=n/i;i++)
	{
		if(n%i==0)
		{
			int cnt=0;
			int res=1;
			while(n%i==0)
			{
				n/=i;
				cnt++;
				if(cnt==res)
				{
					cnt=0;
					res++;
					ans++;
				}
			}
		}
	}
	if(n>1)ans++;
	printf("%lld\n",ans);
}

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

int main()
{
	int dat[5];
	for(int i=0; i<3; i++) cin >> dat[i];
	sort(dat, dat+3);
	for(int i=0; i<3; i++) {
		cout << dat[i];
		if(i!=2) cout << " ";
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
string s; 
ll dp[N][2];
int n;
ll go(int idx,int c){
	if(idx==n){
		return 1;
	}
	ll ret = dp[idx][c];
	if(ret!=-1)return ret;
	ret = 0;
	if(s[idx]=='0'){
		ret+=go(idx+1,c);
		ret%=mod;
		if(c==1){
			ret+=2ll*go(idx+1,1);
			ret%=mod;
		}
	}
	else{
		ret+=go(idx+1,1);
		ret%=mod;
		ret+=2ll*go(idx+1,c);
		ret%=mod;
	}
	return dp[idx][c] = ret;
}
void solve(){
	memset(dp,-1,sizeof dp);
	cin>>s;
	n = s.size(); 
	cout<<go(0,0)<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 11516
N = int(input())
# = str(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

A = list(sorted(A))
count = A[-1]
if N % 2 == 0:
    for i in range(2, N//2+1):
        count += 2 * A[-i]

else:
    for i in range(2, N//2 +1):
        count += 2*A[-i]
    count += A[-(N//2+1)]

print(count)


Measured memory_bytes: 31368