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

#define 	ll 						long long int
#define 	pb 						push_back
#define 	mp 						make_pair
#define 	fast 					ios_base::sync_with_stdio(false);cin.tie(NULL);
#define 	ff 						first
#define 	ss 						second
#define 	nil 					-10e+9
#define 	initial 				0
#define 	waiting 				1
#define 	visit 					2
#define 	inf  					10e+9
#define 	mx   					200005
#define 	mxx  					1000005
#define 	mod  					1000000007
#define 	pr   					pair<ll,ll>
#define 	pp_queue 			priority_queue<pr,vector<pr>, greater<pr> >
#define 	dp_queue 			priority_queue<int,vector<int>, greater<int> >
#define 	sp_queue 			priority_queue<int>
#define 	fr(i,p,q)			for(int i=p;i<q;++i)
#define 	frr(i,p,q) 		for(int i=p;i<=q;++i)
#define 	mem(a,b) 			memset(a,b,sizeof(a))
#define 	len(a)   			(int)a.size()
#define 	input  				freopen("input.txt", "r", stdin);
#define 	output 				freopen("output.txt", "w", stdout);
#define 	debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

ll power(ll a,ll b){ll aa=1;while(b){if(b&1){aa=aa*a;aa%=mod;}a=a*a;a%=mod;b/=2;}return aa;}

using namespace std;

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

	int a[n+1],b[n+1],c[n];

	fr(i,1,n+1) cin>>a[i];
	fr(i,1,n+1) cin>>b[i];

	fr(i,1,n) cin>>c[i];

	ll sum=0,prev=a[1];

	fr(i,1,n+1){
		if(prev==a[i]-1) sum+=b[a[i]]+c[a[i]-1];
		else
		sum+=b[a[i]];
		prev=a[i];
	}
	cout<<sum<<"\n";
  return 0;
}


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

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

inline unsigned long long min(unsigned long long a, unsigned long long b) {//最小
	if (a < b) return a;
	return b;
}

unsigned long long n;
unsigned long long a=0,ans=1000000000005;
unsigned long long x[1000000],y[1000000];
int t=0;
int main() {
	cin >> n;
	a=(unsigned long long)sqrt(n);
	for (int i = 1; i <= a + 1; i++) {
		if (n % i == 0) {
			x[t] = i;
			y[t] = n / i;
			t++;
		}
	}
	for (int i = 0; i < t; i++) {
		ans = min(ans, x[i] + y[i] - 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
//ABC132C
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}
int main(){
	int i;
	int n;
	scanf("%d",&n);
	int a[n];
	int num;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	quick_sort(a,0,n-1);
	num = a[n/2] - a[n/2-1];
	printf("%d",num);
}

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

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
#define outdicimal out << fixed << setprecision(10)//TODO 小数点以下の桁数の変更
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


class CMultiplication3 {
public:
	void solve(std::istream& in, std::ostream& out) {
    int a;
    double b;
    in >> a >> b;
    int t = round(b * 100);
    out << a * t / 100 << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CMultiplication3 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>
#define N 101

int n,adj[N][N];

int main() {
  int i,j,u,k,v;
  //ini
  for (i=1;i<=N;i++){
    for (j=0;j<N;j++){
      adj[i][j]=0;
    }
  }

  scanf ("%d",&n);
  for (i=1;i<=n;i++){
    scanf ("%d%d",&u,&k);
    for (j=1;j<=k;j++){
      scanf("%d",&v);
      adj[u][v]=1;
    }
  }

  for (i=1;i<=n;i++){
    for (j=1;j<=n;j++){
      if (j!=1){
	printf(" ");
      }
      /*
      if (adj[i][j]!=0){
	printf ("1");
      } else {
	printf ("0");
      }
      */
      printf("%d",adj[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 644
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    b.append(list(map(int,input().split())))
an=sorted(a, key=lambda x:-x[1])
bn=sorted(b)

count=0
for i in range(len(bn)):
    for j in range(len(an)):
        
        if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]:
            count+=1
            an.pop(j)
            break
 
print(count)

Measured memory_bytes: 3064
using System;

namespace AOJ01
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    Console.WriteLine(i + "x" + j + "=" + i * j);
                }
            }
        }
    }
}



Measured memory_bytes: 9056
#include<stdio.h>
int main()
{
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c) != EOF)
	{
		int flag = 0;
		if(a + b == c) printf("Yes\n");
		else if(a + c == b) printf("Yes\n");
		else if(b + c == a) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import math
lists=list(int(input()) for i in range(5))
modlists=list(lists[j]%10 for j in range(5))
x=set(modlists)
if 0 in x :
      x.remove(0)

      
else:
      x=set(modlists)
            
#a=list(set(modlists).remove(0) if 0 in modlists else set(modlists))
k=modlists.index(min(x)) if x else 0


b=0
for m in range(5):
      b+=math.ceil(lists[m]/10)*10
print(b-math.ceil(lists[k]/10)*10+lists[k])


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

int main() {
  int n, x, ans = 1, temp = 0;

  cin >> n >> x;

  vector<int> l(n);

  for (int i = 0; i < n; i++) cin >> l[i];

  for (int i = 0; i < n; i++) {
    temp += l[i];
    if (temp <= x) ans++;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+10
#define int long long
using namespace std;

int n,m,a[100000];
vector<int> nums;

bool C(int x){
	queue<int> que;
	for(int i = 0;i < n;i++){
		if(!a[i]) que.push(1);
		else if(a[i] < x) que.push(INF);
		else que.push(0);
	}
	for(int i = 0;i < (n - 1) / 2;i++){
		int b[3],ma = 0,sum = 0;
		for(int j = 0;j < 3;j++){
			b[j] = que.front();
			que.pop();
			ma = max(ma,b[j]);
			sum += b[j];
		}
		que.push(sum - ma);
	}
	int cnt = n - m - (lower_bound(nums.begin(),nums.end(),x) - nums.begin());
	return que.front() <= cnt;
}

signed main(){
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		if(i < m){
			int x,y;
			cin >> x >> y;
			a[y - 1] = x;
		}else{
			int x;
			cin >> x;
			nums.push_back(x);
		}
	}
	sort(nums.begin(),nums.end());
	int low = 0,up = INF;
	while(up - low > 1){
		int mid = (low + up) / 2;
		if(C(mid)) low = mid;
		else up = mid;
	}
	for(int i = 0;i <= 10;i++) C(i);
	cout << low << endl;
	return 0;
}

Measured memory_bytes: 5124
///....DH....///
#include <bits/stdc++.h>
#define task                "Built"
#define fi(a)               freopen(a, "r", stdin)
#define fo(a)               freopen(a, "w", stdout)

#define pii                 pair<int, int>
#define ft                  first
#define sd                  second
#define mp                  make_pair

#define pb                  push_back
#define pf                  push_front
#define popb                pop_back
#define popf                pop_front

#define reset(a, x)         memset(a, x, sizeof(a))
#define For(i, s, n, m)     for(int i = s; i <= n; i += m)
#define Ford(i, s, n, m)    for(int i = s; i >= n; i -= m)

using namespace std;

template <typename R, typename D> inline void Min(R &a, D b) {
    if(a>b)
        a=b;
}
template <typename D, typename R> inline void Max(D &a, R b) {
    if(a<b)
        a=b;
}

/** MOD **/                 const long long mod = 1e9 + 7;
/** size of array **/       const int maxn = 200005;

struct edge {
    int x, y, w;
    bool operator < (const edge &P) {
        return w < P.w;
    }
} a[maxn], b[maxn];
int cnt, n, res, p[maxn];

bool cmpx (edge P, edge Q) {
    return P.x < Q.x;
}

bool cmpy (edge P, edge Q) {
    return P.y < Q.y;
}

int Find(int u) {
    if(u == p[u])
        return u;
    return p[u] = Find(p[u]);
}

int dsu(edge e) {
    int x = Find(e.x);
    int y = Find(e.y);
    if(x == y)
        return 0;
    p[x] = y;
    return e.w;
}

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].w = i;
    }
    sort(a + 1, a + n + 1, cmpx);
    for(int i = 1; i < n; i++) {
        b[++cnt].x = a[i].w;
        b[cnt].y = a[i + 1].w;
        b[cnt].w = min(abs(a[i].x - a[i + 1].x), abs(a[i].y - a[i + 1].y));
    }
    sort(a + 1, a + n + 1, cmpy);
    for(int i = 1; i < n; i++) {
        b[++cnt].x = a[i].w;
        b[cnt].y = a[i + 1].w;
        b[cnt].w = min(abs(a[i].x - a[i + 1].x), abs(a[i].y - a[i + 1].y));
    }
    sort(b + 1, b + cnt + 1);
    for(int i = 1; i <= n; i++)
        p[i] = i;
    for(int i = 1; i <= cnt; i++) {
        res += dsu(b[i]);
    }
    cout << res;
}
//6 8 3 4 9 12 19 18 1 13 5 7 6 -> 8


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

void swa(int &a, int i, int j) {
  if((a & (1<<i)) && !(a & (1<<j))) a += -(1<<i) + (1<<j);
  else if( !(a & (1<<i)) && (a & (1<<j))) a += (1<<i) - (1<<j);
}

vector<int> solve(int n, int a, int b) {
  if(n == 1) return {a, b};

  int c = a^b;
  int top = n-1;
  for(int i=0;i<n;++i) {
    if((c>>i)==1) {
      top = i;
      break;
    }
  }

  if(top != n-1) {
    swa(a, n-1, top), swa(b, n-1, top);
  }

  int na = a & ~(1<<(n-1));
  auto former = solve(n-1, na, na^1);

  int nb = b & ~(1<<(n-1));
  auto later = solve(n-1, na^1, nb);

  vi res;
  if(a & (1<<(n-1))) {
    for(auto &e: former) {
      res.push_back(e ^ (1<<(n-1)));
    }
    for(auto &e: later) {
      res.push_back(e);
    }
  } else {
    for(auto &e: former) {
      res.push_back(e);
    }
    for(auto &e: later) {
      res.push_back(e ^ (1<<(n-1)));
    }
  }

  for(auto &e: res) {
    swa(e, n-1, top);
  }
  return res;
}

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

  int n, a, b; cin >> n >> a >> b;
  int c = a ^ b;
  int cnt = __builtin_popcount(c);
  if(cnt%2 == 0) {
    cout << "NO" << endl;
    return 0;
  }

  auto res = solve(n, a, b);
  cout << "YES" << endl;
  for(auto &v: res) {
    cout << v << " ";
  }
  cout << endl;

}


Measured memory_bytes: 1756
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;
ll f[1010101], rf[1010101];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(ll i=1; i<1010101; i++)
      f[i] = (f[i - 1] * i) % MOD;

    for(ll i=0; i<1010101; i++) 
      rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
  if(k < 0 or n < k)
    return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}

void solve(long long X, long long Y){
  init();
  if((2*X-Y)%3!=0) {
    std::cout << 0 << std::endl;
    return;
  }
  ll n = (2*X-Y)/3;
  std::cout << C(X-n, n) << std::endl;
  
}

int main(){
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  solve(X, Y);
  return 0;
}



Measured memory_bytes: 16128
#define first f
#define second s
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=1e5+5;
const int MOD=1e9+7;
const double PI=acos(-1);
const double e=2.718281828459;

int q[maxn],p[maxn];

int main()
{
    string s;
    cin>>s;
    bool fl=false,f=false;
    for(int i=0;i<3;i++){
        if(s[i]=='A'){fl=true;}
        if(s[i]=='B'){f=true;}
    }
    if(fl&&f){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	char a[105];
	scanf("%s",a);
	printf("%c%d%c",a[0],strlen(a)-2,a[strlen(a)-1]);
	return 0;
}

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

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

using namespace std;
typedef pair<int,int> pii;

const int INF = 0x3fffffff;

int V, E;
int C[1005];
int F[1005];
vector<pii> e[105];
int solve(int n, int c, bool bf[105]){
	if( n == V-1 ) return c;
	bf[n] = true;
	for(auto to: e[n]){
		int i = to.second;
		int cc = ( i>0 ? C[i]-F[i] : F[-i] );
		if( bf[to.first] || cc == 0 ) continue;
		int flow = solve(to.first, min(c, cc), bf); 
		if( flow > 0 ){
			F[ abs(i) ] += flow * (i/abs(i));
			return flow;
		}
	}
	return 0;
}

int main(){
	cin >> V >> E;
	for(int i=1; i<=E; i++){
		int u, v, c;
		cin >> u >> v >> c;
		e[u].emplace_back(v,  i);
		e[v].emplace_back(u, -i);
		C[i] = c;
	}
	int ans = 0;
	while(1){
		bool bf[105] = {};
		int add = solve(0, INF, bf);
		ans += add;
		if( add == 0 ) break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    set<ll> st = {1, 2, 3, 4, 5};
    rep(i, 5){
        ll tmp; cin >> tmp;
        if(tmp == 0) continue;
        st.erase(tmp);
    }
    cout << *st.begin() << endl;
}

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

using namespace std;

int main(void) {
    string s;
    cin >> s;

    int year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    int month = (s[5] - '0') * 10 + (s[6] - '0');
    int day = (s[8] - '0') * 10 + (s[9] - '0');

    if (year > 2019) {
        cout << "TBD" << endl;
    } else if (year < 2019) {
        cout << "Heisei" << endl;
    } else if (month > 4) {
        cout << "TBD" << endl;
    } else if (month <= 4) {
        cout << "Heisei" << endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int BEAM = 870;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
    if(i % 73 == 0)BEAM -= 100;
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 20488
def func(l, u, x, t):
    if len(l) == 0:
        return t+1
    else:
        p = l[-1]
        q = u[-1]
        if x == 1:
            return t
        elif 1 < x <= 1 + p:
            return func(l[:-1], u[:-1], x - 1, t)
        elif x == 2 + p:
            t += u[-1] + 1
            return t
        elif 2 + p < x <= 2 + 2 * p:
            t += u[-1] + 1
            return func(l[:-1], u[:-1], x - (2 + p), t)
        elif x == 3 + 2 * p:
            t += 2 * u[-1] + 1
            return t

n,x  = [int(_) for _ in input().split()]
l = []
for i in range(0, n):
    if i == 0:
        l.append(1)
    else:
        l.append(l[-1]*2+3)
u = []
for j in range(0, n):
    if j == 0:
        u.append(1)
    else:
        u.append(u[-1]*2+1)

print(func(l, u, x, 0))

Measured memory_bytes: 3064
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[n-1])


Measured memory_bytes: 13980
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
  int W, a, b; cin >> W >> a >> b;
  if(a+W < b) cout << b - a - W << endl;
  else if(b+W < a) cout << a - b - W << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
from collections import deque
while 1:
    M = int(input())
    if M == 0:
        break
    N = int(input())
    D = [0] + [int(input()) for i in range(N)] + [0]
    G = [[] for i in range(N+2)]

    u = [0]*(N+2)
    que = deque([0])
    u[0] = 1
    while que:
        v = que.popleft()
        for j in range(1, M+1):
            if D[min(v+j, N+1)] != 0:
                to = max(min(v+j+D[v+j], N+1), 0)
            else:
                to = min(v+j, N+1)
            if not u[to]:
                que.append(to)
                u[to] = 1
            G[to].append(v)

    z = [0]*(N+2)
    que = deque([N+1])
    z[N+1] = 1
    while que:
        v = que.popleft()
        for w in G[v]:
            if z[w]:
                continue
            z[w] = 1
            que.append(w)
    print("OK" if u == z else "NG")



Measured memory_bytes: 6024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
bool is_prime(T x){
	for(T i=2;i*i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return x!=1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  set<int> ans;
  int now=1;
  while(ans.size()!=n){
    if(is_prime(now) && now%5==1) ans.insert(now);
    now++;
  }
  for(auto itr:ans) cout<<itr<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cnt = sum(b) - sum(a)
diff1 = [] # a > b
diff2 = [] # b > a
for i, j in zip(a, b):
    if i > j:
        diff1.append(i - j)
    elif j > i:
        diff2.append(j - i)

if cnt < sum(diff1):
    print("No")
    sys.exit()
else:
    cnt -= sum(diff1)

a_add = cnt + sum(diff1) # 2を足す
b_add = cnt # 1を足す

c = []
for i in diff2:
    if i % 2 == 0:
        a_add -= i//2
    else:
        c.append(1)
        a_add -= (i - 1)//2
a_add -= sum(c)
b_add -= sum(c)
if a_add*2 == b_add and a_add >= 0 and b_add >= 0:
    print("Yes")
else:
    print("No")

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

int main(){

    string t;

    cin>>t;

    rep(i,t.size()){
        //cout<<t[i];
        if(t[i] == '?'){
            //cout<<"aaaa";
            t[i]= 'D';
        }
    }
        cout<<t;

        return 0;
    
}

Measured memory_bytes: 3756
#include<stdio.h>
 
#define N 100000
 
int A[N],n;
 
int partition(int p,int r){
  int x,i,j,tmp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      tmp=A[i]; A[i]=A[j]; A[j]=tmp;
    }
  }
  tmp=A[i+1]; A[i+1]=A[r]; A[r]=tmp;
  return i+1;
}
 
int main(void){
 
  int i,p;
   
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  p=partition(0,n-1);
 
  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==p) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
   
  return 0;
}

Measured memory_bytes: 2080
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

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

    UnionFind(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;
    }
};
int main() {
    ll n,m;
    cin >> n >> m;
    vl p(n);
    rep(i,n)cin>>p[i];
    UnionFind t(n);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        t.unite(x-1,y-1);
    }
    ll cnt=0;
    rep(i,n)if(t.same(i,p[i]-1))cnt++;
    cout<<cnt<<endl;
}

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

int main(void){
    int n,x,br=0,count=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x!=count){
            br++;
        }else{
            count++;
        }
    }
    
    if(n==br) br=-1;
    
    cout<<br<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByRune []rune

func (a ByRune) Len() int           { return len(a) }
func (a ByRune) Less(i, j int) bool { return a[i] < a[j] }
func (a ByRune) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	s, t := sc.nextRuneSlice(), sc.nextRuneSlice()
	sort.Sort(ByRune(s))
	sort.Sort(sort.Reverse(ByRune(t)))

	if string(s) < string(t) {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int A, B, C; cin >> A >> B >> C;
  auto ans = (B - A) == (C - B);
  cout << (ans ? "YES" : "NO") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

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

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

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    ll A, B, K;
    cin >> A >> B >> K;

    ll a = min(A, K);
    A -= a;
    B -= (K - a);
    B = max(B, 0LL);
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
arr = [int(x) for x in input().split()]
max_arr = max(arr)
mark = [0 for i in range(max_arr+1)]

for i in range(n):
    for j in range(arr[i], max_arr+1, arr[i]):
        mark[j] += 1
# print(mark)
count = 0
for i in range(n):
    if mark[arr[i]] == 1:
        count += 1
print(count)


Measured memory_bytes: 32200
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,a[100100],suf[100100];
int main()
{
    go;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=n-2;i>=0;i--)
    {
        if(a[i]>=a[i+1])
            suf[i]=1+suf[i+1];
        ans=max(ans,suf[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
N,M = map(int, input().split())
mod = 10 ** 9 + 7

import math
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    # Prime Factor Decomposition
    def pfd(n):
        rn = math.ceil(math.sqrt(n))
        primes = PrimeUtils.primes_sieve(rn)

        factors = []
        cur = n
        for p in primes:
            cnt = 0
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    cnt += 1
                    cur = div
                else:
                    break
            if cnt != 0:
                factors.append((p, cnt))
        if cur != 1 or n == 1:
            factors.append((cur, 1))
        return factors

import itertools, operator, math
class Combination:
    def __init__(self, fact=math.factorial, div=operator.itruediv):
        self.fact = fact
        self.div = div
    def C(self, n, m):
        if n < m: return 0
        if m == 0 or n == m: return 1
        return self.div(
                self.fact(n),
                self.fact(n - m) * self.fact(m)
            )
    def H(self, n, r):
        return self.C(n - 1 + r, r)

class GFp:
    def __init__(self, p):
        self.p = p
    def inv(self, v):
        return pow(v, self.p - 2, self.p)

class CachedFactorial:
    def __init__(self, n, mod):
        self.mod = mod
        self.fact_cache = list(
                itertools.accumulate(
                        itertools.chain(
                                [1],
                                range(1, n+1)
                        ),
                        lambda a,x: (a * x) % mod
                )
        )
    def factorial(self, n):
        return self.fact_cache[n]

class CachedComb(Combination):
    def __init__(self, n, mod):
        self.mod = mod
        self.gfp = GFp(mod)

        self.n = n
        self.fact = CachedFactorial(n, mod)
        super().__init__(
             self.fact.factorial,
             lambda x, y: (x * self.gfp.inv(y)) % self.mod
        )

ps = PrimeUtils.pfd(M)
cc = CachedComb(N + max(x[1] for x in ps), mod)
ans = 1
for p, c in ps:
    if p == 1: continue
    cmb = cc.H(N, c)
    ans = ans * cmb % mod
print(ans)

Measured memory_bytes: 7556
#include <stdio.h>

int main(void) {
    int i, h, w, max=0;
    scanf("%d %d", &h, &w);
    char data[h][w+1];
    for(i=0; i<h; i++) scanf("%s", data[i]);
    
    int yoko[h][w], tate[h][w];
    int x, y, flag, count, tmp;
    
    for(y=0; y<h; y++) {
        count=0; flag=0;
        for(x=0; x<w; x++){
            if(flag==0 && x+1==w && data[y][x]=='.') yoko[y][x]=1;
            else if(flag==0 && data[y][x]=='.'){ flag=1; count++; }
            else if(flag==1 && x+1==w){
                if(data[y][x]=='.'){ tmp=x; count+=1; }
                else { tmp=x-1; yoko[y][x]=0; }
                for(; tmp>=0; tmp--)
                    if(data[y][tmp]=='.') yoko[y][tmp]=count;
                    else { count=0; flag=0; break; }
            }
            else if(flag==1 && data[y][x]=='.') count++;
            else if(flag==1 && data[y][x]=='#'){
                yoko[y][x]=0;
                for(tmp=x-1; tmp>=0; tmp--) if(data[y][tmp]=='.') {
                    yoko[y][tmp]=count;
                    if(tmp==0) { count=0; flag=0;}}
                else { count=0; flag=0; break; } }
            else if(flag==0 && data[y][x]=='#') yoko[y][x]=0;
        }
    }
    
    for(x=0; x<w; x++){
        count=0;
        flag=0;
        for(y=0; y<h; y++) {
            if(flag==0 && y+1==h && data[y][x]=='.') tate[y][x]=1;
            else if(flag==0 && data[y][x]=='.'){ flag=1; count++; }
            else if(flag==1 && y+1==h){
                if(data[y][x]=='.'){ tmp=y; count+=1; }
                else { tmp=y-1; tate[y][x]=0; }
                for(; tmp>=0; tmp--)
                    if(data[tmp][x]=='.') tate[tmp][x]=count;
                    else { count=0; flag=0; break; }
            }
            else if(flag==1 && data[y][x]=='.') count++;
            else if(flag==1 && data[y][x]=='#'){
                tate[y][x]=0;
                for(tmp=y-1; tmp>=0; tmp--) if(data[tmp][x]=='.') {
                    tate[tmp][x]=count;
                    if(tmp==0) { count=0; flag=0;}}
                else { count=0; flag=0; break; } }
            else if(flag==0 && data[y][x]=='#') tate[y][x]=0;
        }
    }
    for(y=0; y<h; y++)
        for(x=0; x<w; x++)
            if(max<yoko[y][x]+tate[y][x]-1)max=yoko[y][x]+tate[y][x]-1;
    printf("%d\n", max);
    
    return 0;
}

Measured memory_bytes: 35328
/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL
 
Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  double a,b;
  cin>>a>>b;
  double ans=ceil(a/b);
  cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	string S;
	cin >> S;
    
    int ans = 0;
    for(int i=0;i<4;i++){
      if(S[i]=='+') ans++;
      else ans--;
    }

	cout << ans << "\n";

	return 0;
}


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

using namespace std;

int data[100005],dp[100005];

int main()
{
  int n,k;

  for(int c=1;c<100005;c++)
  dp[c]=2e9;
  scanf("%d%d",&n,&k);
  for(int c=0;c<n;c++)
  {
    scanf("%d",&data[c]);
    for(int c2=max(c-k,0);c2<c;c2++)
    dp[c]=min(dp[c],dp[c2]+abs(data[c]-data[c2]));
  }
  printf("%d\n",dp[n-1]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int a,b,c,k,sum=0;
	
	cin>>a>>b>>c>>k;
    sum+=min(a,k);
    k-=min(a,k);
    k-=min(k,b);
    sum-=min(c,k);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3184
#include<iostream>
using namespace std;
int a,b,c,d,n,dp[31];
int main(){
  dp[1]=1;
  dp[2]=2;
  dp[3]=4;
  for(int i=4;i<=30;i++){
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(1){
    cin>>n;
    if(n==0)break;
    a=dp[n]/10;
    b=dp[n]%10;
    if(b>0)a++;
    c=a/365;
    d=a%365;
    if(d>0)c++;
    cout<<c<<endl;
     
  }
 
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  cout << (islower(s[0]) ? 'a' : 'A') << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int s;
	int N;
	int *D;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	D = (int *)calloc(N, sizeof(int));
	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		D[2 * i] = atoi(ch);
		ch = strtok(NULL, " ");
		D[2 * i + 1] = atoi(ch);
	}

	s = 0;
	for(i = 0; i < N; i += 1) {
		if(s == 3) {
			break;
		}
		if(D[2 * i] == D[2 * i + 1]) {
			s += 1;
		} else {
			s = 0;
		}
	}
	if(s == 3) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	free(D);
	return 0;
}


Measured memory_bytes: 2028
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    ll A; string B;
    cin >> A >> B;
    string m = "...";
    m[0] = B[0];
    m[1] = B[2];
    m[2] = B[3];
    ll v = stoi(m);
    ll C = A*v;
    C -= C%100;
    C /= 100;
    prt(C);
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<long long, int> M;
    vector<long long> a(n+1, 0), L(n+1, 0), R(n+1, 0);

    long long ans = 0;
    for(int i = 1; i<n+1; i++){
        cin >> a[i];
        ans += M[i-a[i]];
        M[i+a[i]]++;
    }
    
    cout << ans << endl;
    return 0;
}

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

const int maxn = 110, maxv = 100010;
long long dp[maxv], w[maxn], v[maxn], n, W, totv = 0;

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	scanf("%lld%lld", &n, &W);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld %lld", &w[i], &v[i]);
		totv += v[i];
	}
	memset(dp, 0x7f, sizeof(dp));
	dp[0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = totv; j >= v[i]; j--)
		{
			dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
		}
	
	for (long long i = totv; i >= 0; i--)
		if (dp[i] <= W)
		{
			printf("%lld\n", i);
			break;
		}
					

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  if (n <= 1)
  {
    cout << 1 << endl;
    return 0;
  }
  vector<int> dp(n + 1, 1);
  for (int i = 2; i <= n; i++)
  {
    dp.at(i) = dp.at(i - 1) + dp.at(i - 2);
  }
  cout << dp.at(n) << endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=5e5+7;
typedef long long ll;
const int mod=1e9+7;
int read(){int c = getchar(),Nig = 1,x = 0;while(!isdigit(c))c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()

char s[maxn];
int main()
{
    scanf("%s",s);

    ll ans=0,cot=0;
    for(int i=0;s[i];i++)
        if(s[i]=='B')cot++;
        else ans+=cot;

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
import collections#モジュールをマスタしよう
N=int(input())
A= list(map(int,input().split()))#この入力は基本
cnt=collections.Counter(A)#インスタンスを作るイメージ
TTL=0
for key in cnt.keys():#辞書なのでkeysで持ってくる
  TTL+=cnt[key]*(cnt[key]-1)//2#事前に全体を計算しておく
for i in range(N):
  ans=TTL
  ans-=cnt[A[i]]*(cnt[A[i]]-1)//2#添え字の使い方がポイント
  ans+=(cnt[A[i]]-1)*(cnt[A[i]]-2)//2
  #その字を消した時、1個少ない数で組合せを作る
  print(ans)

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

int main() {
	int N;
	cin >> N;
	double ans = 0.0;
	for (int i = 0; i < N; ++i) {
		double x;
		cin >> x;
		string u;
		cin >> u;
		if (u == "JPY") ans += x;
		else ans += 380000.0 * x;
	}
	printf("%.6f", ans);
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
            self.size[xRoot] += self.size[yRoot]
            self.size[yRoot] = 0
        else:
            self.parents[xRoot] = yRoot
            self.size[yRoot] += self.size[xRoot]
            self.size[xRoot] = 0

N,M,K = map(int,input().split())
tree = UnionFind(N)
friends = [list(map(int,input().split())) for _ in range(M)]
blocks = [list(map(int,input().split())) for _ in range(K)]
for a,b in friends:
    tree.unite(a,b)
for a,b in friends:
    tree.unite(a,b)

ans = [tree.size[tree.parents[i]]-1 for i in range(N+1)]
for a,b in friends:
    ans[a] -= 1
    ans[b] -= 1

for a,b in blocks:
    if tree.parents[a] == tree.parents[b]:
        ans[a] -= 1
        ans[b] -= 1

ans = [str(ans[i]) for i in range(1,N+1)]
print(" ".join(ans))



Measured memory_bytes: 116980