akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

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

    i64 m = 1;
    i64 sum = 0;

    while(h > 0)
    {
        h /= 2;
        sum += m;
        m *= 2;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  bool f=true;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<0){f=!f;a[i]*=-1;}
  }
  ll c=0;
  sort(a.begin(),a.end());
  for(int i=1;i<n;i++) c+=a[i];
  if(f) cout<<c+a[0];
  else cout<<c-a[0];
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    float ab = stof(a + b);
    if (!(sqrt(ab) - ceil(sqrt(ab))))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int N;
vector<tuple<string, int, int>> Guide;

int main() {
    scanf("%d", &N);
    Guide.resize(N);
    for (int i = 0; i < N; i++) {
        string a; int b;
        cin >> a >> b;
        Guide.at(i) = make_tuple(a, -b, i);
    }

    sort(Guide.begin(), Guide.end());

    for (int i = 0; i < N; i++) cout << get<2>(Guide.at(i))+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<numeric>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
vector<ll>solve(int n){
	vector<ll>res;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0)continue;
		else res.push_back(i);
	}
	return res;
}
int main(){
	
	int n;
	cin>>n;
	vector<ll>res=solve(n);
	// for(int i=0;i<res.size();i++){
	// 	cout<<res[i]<<" ";
	// }
	// cout<<endl;
	if(res.size()==0)cout<<0<<endl;
	else{
		ll ans=0;
		for(int i=0;i<res.size();i++){
			ans+=res[i];
		}

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

Measured memory_bytes: 11584
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int N, M, ans, d, p;
  while (cin >> N >> M, N) {
    vector< pair<int, int> > V;
    ans = 0;
    for (int i = 0; i < N; ++i) {
      cin >> d >> p;
      ans += d*p;
      V.push_back(make_pair(-p, d));
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < N; ++i) {
      p = V[i].first;
      d = V[i].second;
      M -= d;
      ans += p*d;
      if (M <= 0) {
	ans += M*p;
	break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  int N,K,Q;
  cin >> N >> K >>Q;
  vector<int>A(N); //N人目のtokuten
  rep(i,N){
    A[i] = K;
  }
  int x;
  rep(i,Q){
    cin >> x;
    A[x-1]++;
  }
  rep(i,N){
    A[i] -= Q;
    if(A[i] <= 0)cout << "No" << endl;
    else cout << "Yes" << endl;
  } 
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};


int main()
{
	fio;
	ll n,m;cin>>n>>m;
	char a[n+1][m+1];
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)cin>>a[i][j];
	}
	ll dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	dp[1][1]=1;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
			if(a[i][j]!='#')
			{
				if(a[i-1][j]!='#')dp[i][j]=add(dp[i][j],dp[i-1][j]);
				if(a[i][j-1]!='#')dp[i][j]=add(dp[i][j],dp[i][j-1]);
			}
		}
	}
	cout<<dp[n][m]<<"\n";
}

Measured memory_bytes: 9088
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():

    N = int(readline())
    num = []
    for i in range(5):
        num.append(int(readline()))

    q, r = divmod(N, min(num))
    ans = q + 4
    ans += 1 if r else 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
#print(a)
i = int(input())
#print(i)
print(a[i - 1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int main(){ 
    int n,l,t;
    scanf("%d %d %d",&n,&l,&t);
    pii p[100005];
    for(int i = 1;i<=n;i++){
        scanf("%d %d",&p[i].x,&p[i].y);
    }
    vector<pii> v;
    for(int i = 1;i<=n;i++){
        if(p[i].y==1){
            v.pb(mp((p[i].x+t)%l,i));
        }
        else{
            v.pb(mp(((p[i].x-t)%l+l)%l,i));
        }
    }
    sort(v.begin(),v.end());
    int cnt=0;
    for(int i = 2;i<=n;i++){
        if(p[i].y!=p[1].y){
            if(p[1].y==1){
                int dis=p[i].x-p[1].x;
                cnt+=2*t/l;
                cnt+=(2*t%l>dis);
            }
            else{
                int dis=l-(p[i].x-p[1].x);
                cnt-=2*t/l;
                cnt-=(2*t%l>=dis);
            }
        }
    }
    //printf("%d\n",cnt);
    int num=(cnt%n+n)%n+1;
    int ans[100005];
    int i;
    for(i=0;v[i].y!=1;i++){
        v.pb(v[i]);
    }
    for(;i!=v.size();i++){
        ans[num]=v[i].x;
        num=num%n+1;
    }
    for(int i = 1;i<=n;i++)
        printf("%d\n",ans[i]);
}
/*
1 2 2 3 3 3 4
2 2 1
3 2 3
4 2 4 4 7
 
*/

Measured memory_bytes: 4080
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

        int m,f,r;

        while(1){

                scanf("%d %d %d\n",&m,&f,&r);

                if(m == -1 && f == -1 && r==-1)
                        return 0;

                if(m == -1 || f == -1) {
                        puts("F");
                        continue;
                }

                if(80<=m+f)
                        puts("A");

                if(65<=m+f && m+f<80)
                        puts("B");

                if(50<=m+f && m+f<65)
                        puts("C");

                if(30<=m+f && m+f<50) {
                        if(50<=r)
                                puts("C");
                        else
                                puts("D");
                }

                if(m+f<30)
                        puts("F");

        }

}


Measured memory_bytes: 3128
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;

typedef long long ll ;
typedef long double ld ;


#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int n , sum = 0 ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	while ( n -- ) {
		int x ;
		cin >> x ;
		sum += x ; 
	}
	cout << ( sum & 1 ? "NO" : "YES" ) << '\n' ;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

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

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
int 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(10);
  int N, K;
  cin >> N >> K;
  vec< int > a(N);
  int index;
  REP(i, N) {
    cin >> a[i];
    if (a[i] == 1)
      index = i;
  }
  K--;
  // DEBUG(index);
  int ans = ceil((N - 1.0) / K);
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
N=int(input())
ans=0
for n in range(3,N+1)[::2]:
    count=0
    cor=int(n**0.5//1)
    for i in range(1,cor+1):
        if n/i==n//i:
            count+=2
    if cor==n/cor:
        count-=1
    if count==8:
        ans+=1
    #print(n,count)
print(ans)

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a, b, diff;
  LL A, B;
  Solver(LL n) : n(n), a(n), b(n), diff(n){};

  void solve() {
    A = B = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      A += a[i];
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
      B += b[i];
    }
    if (A < B) {
      cout << -1 << endl;
      return;
    }
    for (int i = 0; i < n; ++i) {
      diff[i] = a[i] - b[i];
    }
    sort(diff.begin(), diff.end());
    DBG(diff)
    auto it = lower_bound(diff.begin(), diff.end(), 0ll);
    LL nsum = accumulate(diff.begin(), it, 0ll);
    int ans = distance(diff.begin(), it);
    reverse(diff.begin(), diff.end());
    LL psum = 0;
    for (int i = 0; i < n; ++i) {
      DBG(i, psum, nsum)
      if (psum + nsum >= 0) {
        ans += i;
        break;
      }
      psum += diff[i];
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 2e5+5, M=2e4+5, oo=0x3f3f3f3f;

ll n, m, x, ans;
priority_queue<ll> pq;

int main()
{
    cin >> n >> m;
    for(int i=0; i<n; i++)
    {
        cin >> x;
        pq.push(x);
    }
    while(m--)
    {
        x = pq.top();
        pq.pop();
        pq.push(x/2);
    }
    while(pq.size())
    {
        x = pq.top();
        pq.pop();
        ans+=x;
    }
    cout << ans;

    return 0 ;
}


Measured memory_bytes: 1400
/**
 * ABC 150 C
 * 2020-04-25 19:13:10
 * unkounkounkounkounko
 * unko
 **/
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll N;
    cin >> N;
    ll min = 9999999999999;
    for(ll a = 1; a <= sqrt(N); a++){
        if(N % a == 0){
           if(a + N/a - 2 < min){
              min = a + N/a - 2;
           }
        }
    }
    cout << min << endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#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 per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; 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();
    string s; cin >> s;
    s = (s.size()%2 != 0) ? s.substr(0, s.size()-1) : s.substr(0, s.size()-2);
    string s1 = "", s2 = "";
    while(s.size()>1){
        s1 = s.substr(0, s.size()/2);
        s2 = s.substr(s.size()/2);
        s = s.substr(0, s.size()-2);
        if(s1 == s2) break;
    }
    cout << s1.size()*2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int n,q;
  int i,t;
  string name;
  queue<pair<string,int> > Q;
  cin >> n >>q;
  for(i=0;i<n;i++){
    cin >> name >> t;
    Q.push(make_pair(name,t));
  }
  pair<string,int> u;
  int elaps=0,a;
  while(!Q.empty()){
    u=Q.front();Q.pop();
    a=min(u.second,q);
    u.second-=a;elaps+=a;
    if(u.second > 0){
      Q.push(u);
    } else {
      cout << u.first << " " << elaps << endl;
    }
  }
  return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100015

//const int INF = 1e9 + 7;

ll solve(ll a, ll b) {

	if (a > b) {
		swap(a, b);
	}

	if (b % a == 0) {
		return 2 * a*(b / a) - a;
	}
	else {
		return solve(a, b%a) + 2 * a*(b / a);
	}
}


int main() {

	ll n, x;
	cin >> n >> x;
	cout << n + solve(x, n - x) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs= vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
  int N;
  cin >> N;
  
  vector<pair<pair<string,int>,int>> p(N);
  rep(i,N) {
    string S;
    int P;
    cin >> S >> P;
    p.at(i) = make_pair(make_pair(S,-P),i);
  }
  
  sort(p.begin(), p.end());
  
  rep(i,N) cout << p.at(i).second+1 << endl;
}

Measured memory_bytes: 256
def SUM(num_List):
    answer = 0
    for i, num in enumerate(num_List):
        answer += num*i
    return answer

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = list()
C = list()
start = True

num_List = [0 for x in range(100001)]

for a in A:
    num_List[a] = num_List[a] + 1

for x in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for x in range(Q):
    b = B[x]
    c = C[x]

    if start == True:
        num_List[c] = num_List[c] + num_List[b]
        num_List[b] = 0
        answer = SUM(num_List)
        start = False
        
    else:
        answer = answer + num_List[b]*(c-b)
        num_List[c] = num_List[c] + num_List[b]
        num_List[b] = 0

    print(answer)

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

int main(){
    ll x;
    cin>>x;
    ll n = x+100;

    bool isPrime[n];
    for(ll i=0;i<=x+100;i++)isPrime[i]=true;
    isPrime[0] = isPrime[1] = false;
    for(ll i = 2;i*i<=n;i++){
        for(ll j=i+i;j<=n;j+=i){
            isPrime[j]=false;
        }
    }

    ll ans;
    if(isPrime[x]){
        ans = x;
    }else{
        for(ll a=x;a<=n;a++){
            if(isPrime[a]){
                ans = a;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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 ll = long long;

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

bool pri(int x){ //素数判定
  bool ok = true;
  for(int i = 2; i*i<=x;i++){
    if(x%i==0) {
      ok = false;
      break;
    }
  }
  if(x==1)ok = false;
  return ok;
}

int main() {
  int N;
  cin>>N;
  vector<int> ans(N);
  ans[0]=11;
  for(int i = 1; i < N; i++){
    ans[i]=ans[i-1]+10;
    while(!pri(ans[i])){
      ans[i]+=10;
    }
  }
  for(auto x:ans) cout<<x<<" ";
  cout<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,p;
    cin>>a>>p;
    int s =3*a+p;
    cout<<s/2<<endl;
    
}

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

using namespace std;

#define DPRINTF(...) printf(__VA_ARGS__)
#define FOR0(i, n) for(int i=0;i<n;i++)
#define ALL(c) (begin(c)), (end(c))
#define fst(t) get<0>(t)
#define snd(t) get<1>(t)
#define thd(t) get<2>(t)

typedef tuple<int,int> P;
typedef long long ll;

std::vector<P> v;
std::vector<P> G[600300];
priority_queue<P, vector<P>, greater<P>> qu;
int dist[600300];
int p[200000], q[200000], c[200000];

int main(){
  //*
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  /*/
  /*/

  int N, M;
  cin >> N >> M;

  FOR0(i, M){
      cin >> p[i] >> q[i] >> c[i];
      --p[i];
      --q[i];

      v.emplace_back(p[i], c[i]);
      v.emplace_back(q[i], c[i]);
  }

  sort(ALL(v));
  v.erase(unique(ALL(v)), v.end());

  int _N = v.size(), id = _N;
  int s = -1, t = -1;
  for(int i=0,j=0;i<_N;){
      if(fst(v[i]) == 0){s = id;}
      if(fst(v[i]) == N-1){t = id;}
      
      while(j < _N && fst(v[j]) == fst(v[i])){
          G[j].emplace_back(id, 0);
          G[id].emplace_back(j, 1);
          ++j;
      }
      
      i = j;
      ++id;
  }

  if(s == -1 || t == -1){
      cout << -1 << endl;
      return 0;
  }

  for(int i=0;i<M;i++){
      int a = lower_bound(ALL(v), make_tuple(p[i], c[i]))-v.begin(),
          b = lower_bound(ALL(v), make_tuple(q[i], c[i]))-v.begin();
      G[a].emplace_back(b, 0);
      G[b].emplace_back(a, 0);
  }

  fill(dist, dist+id, 252521);
  dist[s] = 0;
  qu.emplace(s, 0);

  while(!qu.empty()){
      int u, c;
      tie(u, c) = qu.top();
      qu.pop();

      if(dist[u] < c){continue;}

      for(const auto& p : G[u]){
          int u2, c2;
          tie(u2, c2) = p;

          if(dist[u2] > c + c2){
              dist[u2] = c + c2;
              qu.emplace(u2, dist[u2]);
          }
      }
  }

  cout << (dist[t] < 252521 ? dist[t] : -1) << endl;
}


Measured memory_bytes: 45932
import java.util.*;
import java.io.*;
import java.math.*;

class Main {

    public static void main (String args[]) {
        
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = "";
			
			while ((line = br.readLine()) != null) {
				String[] str = line.split(" ");
				int a = Integer.parseInt(str[0]);
				int b = Integer.parseInt(str[1]);
				double sum = (double)(a+b);
				double digit = Math.floor(Math.abs(Math.log10(sum))) + 1;
				System.out.println((int)digit);
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
		finally {
			System.exit(0);
		}
	}
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}

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

    int N, K; cin >> N >> K;
    
    vector<int> A(N);
    cin >> A[0];
    int g = A[0];
    int a_max = A[0];
    rep1(i, N) {
        cin >> A[i];
        g = gcd(g, A[i]);
        chmax(a_max, A[i]);
    }

    cout << ((K <= a_max && K % g == 0) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<windows.h>
using namespace std;
 
#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

vector<edge> g[114514];
int x[114514];
int n,m;

void debug(int c){
    printf("\ncnt:%lld\n",c);
    puts("グラフ");
    REP(i,n){
        printf("%lld:\n",i);
        REP(j,SZ(g[i])) printf("%lld %lld, ",g[i][j].to,g[i][j].cost);
        puts("");
    }
    REP(i,n) printf("%lld ",x[i]);
    puts("");
}

signed main(){
    cin >> n >> m;
    REP(i,n) x[i] = -INF;
    REP(i,m){
        int l,r,d;
        scanf("%lld%lld%lld",&l,&r,&d);
        l--,r--;
        edge e;
        e.to = r,e.cost = d;
        g[l].PB(e);
        e.to = l,e.cost = -d;
        g[r].PB(e);
    }
    int cnt = 0;
    bool rullonz = false;

loop:

    queue<int> que;
    FOR(i,cnt,n){
        if(i==n-1) rullonz = true;
        if(SZ(g[i])&&x[i]==-INF){
            x[i] = 0;
            que.push(i);
            cnt = i+1;
            break;
        }
    }
    while(!que.empty()){
        int cur = que.front();que.pop();
        REP(i,SZ(g[cur])){
            if(x[g[cur][i].to]!=-INF){
                if(x[g[cur][i].to]-x[cur]!=g[cur][i].cost){
                    puts("No");
                    return 0;
                }
            } else{
                x[g[cur][i].to] = x[cur] + g[cur][i].cost;
                que.push(g[cur][i].to);
            }
        }
    }

    //debug(cnt);

    //Sleep(1*1000);

    if(!rullonz) goto loop;

    puts("Yes");
}



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

int main()
{
	int a[7],b[7],ans[7];
	for(int i=0; i<7; i++){
		cin>>a[i]>>b[i];
		ans[i] = a[i]+(-1*b[i]);
	}
	for(int i=0; i<7; i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<variant>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<climits>

using namespace std;

int main(void) {
	string s, t;
	cin >> s;
	cin >> t;
	int min = INT_MAX;
	int tot = 0;
	for (int i = 0; i < s.size() - t.size()+1; i++) {
		tot = 0;
		for (int k = 0; k < t.size(); k++) {
			if (s[i+k] != t[k])tot++;
		}
		if (min > tot)min = tot;
	}
	cout << min;
	return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader rd = new BufferedReader(new InputStreamReader(System.in), 1);
		HashSet<Integer> s = new HashSet<>();
		int n = Integer.parseInt(rd.readLine());
	    //String[] sl = s.split(" ");
		for(int i = 1; i <= n; i++)
		{
			int a = Integer.parseInt(rd.readLine());
			if(s.contains(a))
			{
				s.remove(a);
			}
			else
			{
				s.add(a);
			}
		}
		System.out.println(s.size());
		
  	}
}

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

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

	int sum = 0;

	for( int i = 0; i < N; ++i ) {
		int l, r;
		cin >> l >> r;

		sum += r - l + 1;
	}

	cout << sum;
}


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

using namespace std;

int a[100010], dp[100010];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <fstream>
#define input "vacation.inp"
#define output "vacation.out"
int n,k,a[100005][4],f[100005][4];
using namespace std;
int main()
{
 	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen(input,"r",stdin);
	//freopen(output,"w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
        for(int j=1;j<=3;j++) cin>>a[i][j];
    for (int i=1;i<=3;i++) f[1][i]=a[1][i];
    for (int i=2;i<=n;i++)
        for (int j=1;j<=3;j++)
        {
            if(j==1) f[i][j]=max(f[i-1][2]+a[i][j],f[i-1][3]+a[i][j]);
            if(j==2) f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][3]+a[i][j]);
            if(j==3) f[i][j]=max(f[i-1][2]+a[i][j],f[i-1][1]+a[i][j]);
        }
    int res;
    res=max(f[n][1],f[n][2]);
    res=max(res,f[n][3]);
    cout<<res;
}


Measured memory_bytes: 3328
from itertools import product

MAX_ITEM = 4
NUM = 7

ABCD = [i for i in list(input())]


def main():
    ops = ("+", "-")

    for p in product(ops, repeat=3):
        eq = ABCD[0]

        for o, abcd in zip(p, ABCD[1:]):
            eq += o
            eq += abcd

        if eval(eq) == NUM:
            print(eq + "=" + str(NUM))
            break

    return


main()


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

int main()
{
    int is = 1;
    char str[100];
    scanf("%[^\n]", str);

    int len = strlen(str), i = 0, j = len / 2 - 1, k = len / 2 + 1, l = len - 1;
    for(; i < l; i++, j--, k++, l--)
    {
        if((i < j && str[i] != str[j]) || str[i] != str[l] || (k < l && str[k] != str[l]))
        {
            is = 0;
            break;
        }
    }

    printf(is ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. aising-A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(12).
01 L          PIC 9(03).
01 R          PIC 9(03).
01 D          PIC 9(03).
01 I          PIC 9(03).
01 CNT        PIC 9(03).
01 OUT        PIC ZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO L R D.
*>
  IF (D = 1)
    COMPUTE CNT = R - D + 1
  ELSE 
    MOVE 0 TO CNT
    PERFORM VARYING I FROM 1 BY 1 UNTIL D * I > R
      IF (D * I >= L AND D * I <= R)
        ADD 1 TO CNT
      END-IF
    END-PERFORM
  END-IF.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3944
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
M,D = map(int,input().split())
ans = 0
for i in range(1,M+1):
    for j in range(2,1+D//10):
        for k in range(2,10):
            if j*10+k > D:
                break
            if i == j*k:
                ans += 1
print(ans)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;
  ll k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  int i;
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vector<ll> suma(n+1,0);
  vector<ll> sumb(m+1,0);
  rep(i,n) suma[i+1] = suma[i]+a[i];
  rep(i,m) sumb[i+1] = sumb[i]+b[i];
  int ans = 0;
  rep(i,n+1)
  {
    if(k-suma[i] < 0) break;
    int ind = upper_bound(all(sumb),k-suma[i])-sumb.begin();
    ans = max(ans,ind+i-1);
  }
  cout << ans << "\n";
}


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

int main() {
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  int n, m;
  n = c;
  m = d;
  /*cout << a << endl;
  cout << b << endl;
  cout << c << endl;
  cout << d << endl;
  cout << n << endl;
  cout << m << endl;*/
  while (n%m > 0 && m > 0){
    n = n%m;
    swap(n, m);
    //cout << n << " " << m << endl;
  }
  //cout << n << " " << m << endl;
  //cout << b/(c*d/n)-a/(c*d/n) << endl;
  long gcm, p1, pc, pd, pg;
  gcm = c*d/m;
  p1 = b-(a-1);
  pc = b/c-(a-1)/c;
  pd = b/d-(a-1)/d;
  pg = b/gcm-(a-1)/gcm;
  cout << p1-pc-pd+pg << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(r, c, k);
    VV<>  vec(r, V<>(c, 0));
    REP(i, k){
        LL(x, y, v); x--; y--;
        vec[x][y] = v;
    }
    VV<V<>> dp(r, VV<>(c, V<>(4, 0)));
    REP(i, r) REP(j, c){
        REP(l, 4){
            if(i + 1 < r)chmax(dp[i + 1][j][0], dp[i][j][l]);
            if(j + 1 < c)chmax(dp[i][j + 1][l], dp[i][j][l]);
        }
        if(vec[i][j]){
            if(i + 1 < r) REP(l, 3) chmax(dp[i + 1][j][0], dp[i][j][l] + vec[i][j]);
            if(j + 1 < c) REP(l, 3) chmax(dp[i][j + 1][l + 1], dp[i][j][l] + vec[i][j]);
        }
    }
    ll res = dp[r - 1][c - 1][3];
    REP(l, 3) chmax(res, dp[r - 1][c - 1][l] + vec[r - 1][c - 1]);
    print(res);
}

Measured memory_bytes: 706032
#include<stdio.h>
#include<assert.h>
#include<vector>
#include<string.h>
#include<algorithm>
#include<memory.h>
#include<cmath>
#include<string>
#include<iostream>
#include<set>
#include<unordered_set>
#include<map>
#include<queue>
#include<functional>
#include<list>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 100005;
const int MM = 1000000007;

int D[MX];
int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	ll tot = 0, cur = 0, ans = 0, ans2 = 0;
	for(int i = 1; i <= N; i++){
		cur += D[i];
		if( i%2 == 1 && cur >= 0 ) ans += cur+1, cur = -1;
		else if( i%2 == 0 && cur <= 0 ) ans += -cur+1, cur = 1;
	}
	tot = cur = 0;
	for(int i = 1; i <= N; i++){
		cur += D[i];
		if( i%2 == 0 && cur >= 0 ) ans2 += cur+1, cur = -1;
		else if( i%2 == 1 && cur <= 0 ) ans2 += -cur+1, cur = 1;
	}
	printf("%lld\n", min(ans, ans2));
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){

    int H,W,N,ans = 0;

    scanf("%d %d %d",&H,&W,&N);

    if(H > W){
        int tmp = H;
        H = W;
        W = tmp;
    }

    int i = 0;
    while(ans == 0){
        i++;
        if(H*i >= N){
            ans = i;
        }else if(W*i >= N){
            ans = i;
        }
    }

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

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(20000000)

n, q = map(int, input().split())
ab = [[] for _ in range(n+1)]
p_num = [0] * (n+1)
ans = [0] * (n+1)

for _ in range(n-1):
    a, b = map(int, input().split())
    ab[a].append(b)
for _ in range(q):
    p, x = map(int, input().split())
    p_num[p] += x

def dfs(num, cur_count):
    cur_count += p_num[num]
    ans[num] = cur_count
    if len(ab[num]) <= 0:
        return
    for v in ab[num]:
        dfs(v, cur_count)

dfs(1, 0)

out = []
for i in range(1, n+1):
    out.append(str(ans[i]))
print(" ".join(out))


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

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;

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

  char map[h+2][w+2];

  for(int i=1; i<=h; i++){
      for(int j=1; j<=w; j++){
          cin >> map[i][j];

      }
  }

  bool flag;

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){

            if(map[i][j] == '#'){

                flag = false;

                for(int k=0; k<4; k++){

                    if(map[i+dx[k]][j+dy[k]] == '#'){
                        flag = true;
                        break;
                    }
                }

                if(flag == false){
                    cout << "No" << endl;
                    return 0;
                }

            }

        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
<?php
while ($line = fgets(STDIN)) {
 $array[] = trim($line);
}
$a = $array[0];
$b = $array[1];
$num = explode(' ',$b);
  sort($num);
  $p = $num[0];
  $q = $num[1];

  if(($a >= 2 )&&($a <= 50 )){
    if($a == 2){
      $sum = $p + $q;
      $Ans = $sum / 2;
      echo $Ans;
    }else{
      $sum = $p + $q;
      $c = $sum / 2;
      for ($i=2; $i<$a; $i++) {
        $c = $c + $num[$i];
        $c = $c /2;
     }
      echo $c;
      
    }

    
  }
?>


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

#define N 100


signed main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<w*h/2<<" ";
	if(x==w/2&&y==h/2) cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    int d;
    cin >> d;
    /*
    int a[n];
    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */
 
    if(0 == d) cout << "1" << endl;
    else cout << "0" << endl;
    
    //cout << a << endl;
    //printf("%d\n", n);
    
    return 0;
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <limits.h>
using namespace std;

int m[101][101]; // m[i][j]: from i to j (columns)
int p[101]; // 
int main(){
	int n; scanf("%d", &n);
	for (int i = 0; i < n; ++i){
		int r, c; scanf("%d %d", &r, &c);
		p[i] = r; p[i + 1] = c;
	}
	// initialize m[][]
	for (int i = 0; i <= 100; ++i){
		for (int j = 0; j <= 100; ++j) m[i][j] = INT_MAX;
	}
	for (int i = 0; i <= 100; ++i) m[i][i] = 0;
	//
	for (int l = 2; l <= n; ++l){
		for (int i = 1; i <= n-l+1; ++i){
			int j = i + l - 1;
			for (int k = i; k < j; ++k){
				if (m[i][k] == INT_MAX || m[k + 1][j] == INT_MAX) continue;
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << '\n';
}

Measured memory_bytes: 1244
#include<iostream>

int main(){
	int e;
	while(1){
		std::cin >> e;
		if(!e)break;
		int m = 1000001;
		for(int i=0;i*i*i<=e;i++){
			for(int ii=0;i*i*i + ii*ii<=e;ii++){
				int x = e-i*i*i-ii*ii;
				int tmp = i+ii+x;
				if(tmp < m) m = tmp;
			}
		}
		std::cout << m << std::endl;
	}
	return 0;
}

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

#define ll long long
#define F first
#define S second
#define Pb push_back

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------

vector<string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
    string s;cin>>s;
    rep(i,7){
        if(day[i]==s) printf("%d\n",7-i);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

int main() {
    long long n, k, ret = 0;
    std::cin >> n >> k;
    std::vector<long long> a(n);
    std::multiset<long long, std::greater<>> ms;
    std::map<long long, bool> m;
    for (auto i = 0ll; i < n; i++) {
        std::cin >> a[i];
        if (a[i] < k) ms.insert(a[i]);
    }

    for (auto i = 0ll; i < n; i++) {
        if (a[i] >= k) continue;
        if (m.find(a[i]) != m.end()) {
            ret += (m[a[i]] ? 1 : 0);
            continue;
        }
        m[a[i]] = true;
        std::bitset<5000> bs;
        ret++;
        auto flg = true;
        for (auto num : ms) {
            if (num == a[i] && flg) {
                flg = false;
                continue;
            }
            bs = bs | (bs << num);
            bs[num] = 1;
            auto brk = false;
            for (auto l = k - a[i]; l < k; l++) {
                if (bs[l]) {
                    ret--;
                    m[a[i]] = false;
                    brk = true;
                    break;
                }
            }
            if (brk) break;
        }       
    }

    std::cout << ret << std::endl;

    return 0;
}

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

constexpr long long MOD = 1000000007;

int main() {
	int N, M;
	cin >> N >> M;
	static long long DP[301][301][301] = {};
	DP[0][1][N - 1] = 1;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= N - j; k++) {
				DP[i + 1][N - k][k] = (DP[i + 1][N - k][k] + DP[i][j][k] * j) % MOD;
				if (k != 0) DP[i + 1][j][k - 1] = (DP[i + 1][j][k - 1] + DP[i][j][k] * k) % MOD;
				DP[i + 1][j][k] = (DP[i + 1][j][k] + DP[i][j][k] * (N - j - k)) % MOD;
			}
		}
	}
	cout << DP[M][N][0] << endl;
}

Measured memory_bytes: 215888
let linear_search x lst =
  let rec doit = function
    | [] -> false
    | hd :: _ when x = hd -> true
    | _ :: tl -> doit tl
  in
  doit lst

let () =
  let read_seq () = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
  let _ = read_int () in
  let s = read_seq () in
  let _ = read_int () in
  let t = read_seq () in
  Printf.printf "%d\n" (List.fold_left (fun acc e -> if linear_search e s then acc + 1 else acc) 0 t)

Measured memory_bytes: 4104
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    N = I()

    ans = 0
    for i in range(1, N+1):
        ans += 0 if i % 3 == 0 or i % 5 == 0 else i
    print(ans)
    
main()


Measured memory_bytes: 9484
S = list(input())
count = 0
for i in range(len(S) - 1):
    if S[i+1] == S[i]:
        count += 1
        if S[i+1] == '1':
            S[i+1] = '0'
        else:
            S[i+1] = '1'
            
print(count)

Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>

#define MOD 1000000007
#define ll long long
#define ld long double

using namespace std;


int main(){
  ll N;
  vector<ll> A;
  ll inp;
  ll memo=0,l1=0,l2=0;
  ll i;
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  for(ll i =0;i<N;i++){
    cin >> inp;
    A.push_back(inp);
  }

  
  sort(A.begin(), A.end());
  
  for(i= A.size()-1;i>=0;i--){
    if(A[i]==memo) {
      l1=A[i];
      memo = 0;
      break;
    }
    else{
      memo = A[i];
    }
  }

  for(i-=1;i>=0;i--){
    if(A[i]==memo) {
      l2=A[i];
      memo = 0;
      break;
    }
    else{
      memo = A[i];
    }
  }
  
  cout << l1*l2<< endl;
  
  return 0;
  
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;

ll fastexpo(ll a,ll b)
{
    if(b==0)
    return 1;
    
    ll ans = (fastexpo(a,b/2))%mod;
    
    if(b%2==1)
    return (a%mod*ans%mod*ans%mod)%mod;
    else return (ans%mod*ans%mod)%mod;
}

int main()
{
    int n;
    cin >> n;
    
    if(n==1)
    cout << 0 << endl;
    else if(n==2)
    cout << 2 << endl;
    else
    {
        cout << (fastexpo(10,n)-2*fastexpo(9,n)+fastexpo(8,n)+2*mod)%mod << endl;
    }
    
    return 0;
}
 


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  if (n[0] == n[1] && n[1] == n[2]) {
    cout << "Yes" << endl;
  }
  else if (n[1] == n[2] && n[2] == n[3]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

  static final int N = 100000;
  static final int K = 50000;
  static int n, k;
  static int w[], t[];

  public static boolean check_load(int limit) {
    int i, j;

    for (i=0; i<n; i++)
      if (limit < w[i]) return false;

    Arrays.fill(t, 0);
    i = j = 0;
    while (i<n && j<k) {
      if (t[j] + w[i] < limit) 
        t[j] += w[i++];
      else if (t[j] + w[i] == limit)
        t[j++] += w[i++];
      else
        j++;
    }

    return (i<n && j==k) ? false : true;
  }

  public static void main(String[] args) {
    int i;
    Scanner sc = new Scanner(System.in); 
    n = Integer.parseInt(sc.next());
    w = new int[n];
    k = Integer.parseInt(sc.next());
    t = new int[k];
    for (i=0; i<n; i++)
      w[i] = Integer.parseInt(sc.next());

    int l = 0, u = 0;
    for (i=0; i<n; i++) u += w[i];
    while (u-l > 1) {
      int m = (l+u)/2;
      if (check_load(m))
        u = m;
      else
        l = m;
    }
    System.out.println(u);
  }
}

Measured memory_bytes: 68336