akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T>
T gcd(T a, T b)
{
    if (a < b)
        return gcd(b, a);
    else if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b)
{
    return abs(a)/gcd(a,b)*abs(b);;
}

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

    vector<long> t(n); for (int i = 0; i < n; i++) cin >> t[i];
    cout << accumulate(t.begin(), t.end(), 1L, lcm<long>);
    cout << endl;
    return 0;
}

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

int main(){ 
  ll n;
  cin >> n;
  vector<ll> vec;  
  
  while(n > 0){
    n--;
    vec.push_back(n%26);
    n /= 26;
  }

  for(ll l = vec.size()-1; l >= 0; l--) cout << string(1, 'a'+vec.at(l));
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=1e5+5;
int n,m,w[maxn],d[maxn],a[maxn];
ll ss=0,des,tt;

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	#ifndef ONLINE_JUDGE
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	#endif
	n=rd();
	go(i,n+1,1) w[i]=rd(),ss=ss+w[i]; w[n+1]=w[1];
	go(i,n+1,1) d[i]=w[i+1]-w[i]; d[n+1]=d[1];
	ll ons=1ll*n*(1+n)/2;
	if(ss%ons != 0){ puts("NO"); return 0; }
	ll dep=ss/ons; int fl=0;
	go(i,n+2,1){
		a[i]=(dep-d[i])/n;
		if(a[i] < 0) a[i]=0;
		if((dep-d[i])%n != 0) fl=1;
		if(i >= 2) des=des+tt,des=des+a[i-1],tt=tt+a[i-1];
	}
	if(fl){ puts("NO"); return 0; }
	go(i,n+1,1){
		des-=1ll*n*a[i]; tt-=a[i];
		if(i > 1) des=des+a[i-1],tt=tt+a[i-1];
		if(des+1ll*a[i]*n != w[i]){ fl=1; break; }
		des=des+tt;
	}
	if(fl) puts("NO");
	else puts("YES");
	return 0;
}//Faze


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;



void solve(void){

  llint n;
  std::cin >> n;
  std::vector<llint> a(n);
  for(int i=0; i<n; i++){
    std::cin >> a[i];
  }

  llint allxor = 0;
  for(int i=0; i<n; i++){
    allxor = (allxor ^ a[i]);
  }

  for(int i=0; i<n; i++){
    std::cout << (allxor ^ a[i]) << " ";
  }
  std::cout << std::endl;

}

int main(void){

  solve();
  
  return 0;
}


Measured memory_bytes: 4708
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n,a,b=map(int,input().split())
    val=0
    for i in range(1,n+1):
        #print([int(j) for j in str(i)])
        if a<=sum([int(j) for j in str(i)])<=b:
            val+=i
    print(val)

resolve()

Measured memory_bytes: 2940
n = int(raw_input())

R = [0 for i in range(n)]

ans = 1 - 10**9
min_R = int(raw_input())
for i in range(n-1):
    R[i] = int(raw_input())
    if R[i] - min_R > ans:
        ans = R[i] - min_R
    if R[i] < min_R:
        min_R = R[i]
        
print ans
    
    
    

Measured memory_bytes: 18808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
    int N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]*=2;
    }
    ll offset=0;
    for(int i=0;i<N;i++) offset=A[i]-offset;
    ll x=offset/2;
    
    ll cur=x;
    for(int i=0;i<N;i++){
        cout<<cur<<" ";
        cur=A[i]-cur;
    }
    cout<<endl;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int n, r;
	cin >> n >> r;
	cout << r + 100 * max(0, 10 - n) << endl;
	return 0;
}



Measured memory_bytes: 256
from fractions import gcd
a,b,c,d=map(int,input().split(' '))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a
lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
if c>a and c>b and d>a and d>b:
	print(0)
else:
	print(out-divi)




Measured memory_bytes: 5076
#include "iostream"
#include "iomanip"
using namespace std;

long double X;
long double rad;
long double ans;

int main() {
	cin >> X >> rad;
	if ((long long int)X % 2 == 0) {
		for (int i = 0; i < 10000000; i++) {
			ans = (ans + X - rad / 100 * ans + (100.0 - rad) / 100 * ans) / 2;
		}
	}
	else {
		for (int i = 0; i < 10000000; i++) {
			ans = (ans+1 + X - rad / 100 * ans + (100.0 - rad) / 100 * ans) / 2;
		}
	}
	cout << setprecision(15) << ans;
	return 0;
}

Measured memory_bytes: 384
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
  
   int isValid(int mid,int k,int a[],int n){
       int i,j;
       if(mid == 0) return 0;
       for(i = 0;i<n;i++){
           if(a[i]  <= mid) continue;
           int tt = a[i] / mid;
           k -= tt;
       }
       if(k>=0) return 1;
       else return 0;
   }
int main(){
    
    int i,j,n,k;
    cin >> n >> k;
    int a[n];
    
    for(i = 0;i<n;i++) cin >> a[i];
    
    int low,high,mid,temp;
    
    low = -1;
    high = 1e9 + 10;
    while(high - low > 1){
        mid = (low + high)/2;
        if(isValid(mid,k,a,n)) high = mid;
        else low = mid;
    }
      cout << high << endl;
    return 0;
}




Measured memory_bytes: 4384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a, b, c;
  int sum=0;
  cin>>a>>b>>c;

  for(int i=0; i<b; ++i){
    sum = a*i;
    if(sum%b==c){
      cout<<"YES"<<endl;
      break;
    }
  }if(sum%b!=c){
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;

ll enc(ll a, ll b) {
	if (a >= b)swap(a, b);
	return N * (N - 1) / 2 - (N - a) * (N - a - 1) / 2 + b - a - 1;
}

vector<vector<ll>> edges, edgesinv;

void topologicalVisit(ll n, vector<ll>& check, stack<ll>& q, bool& flag) {
	if (check.at(n) == 1) {
		flag = true;
		return;
	}
	if (check.at(n) == 0) {
		check.at(n) = 1;
		for (auto itr = edges[n].begin(); itr != edges[n].end(); itr++) {
			topologicalVisit(*itr, check, q, flag);
			if (flag)return;
		}
		check[n] = 2;
		q.push(n);
	}
}

int main() {
	cin >> N;
	edges.resize(N * (N - 1) / 2);
	edgesinv.resize(N * (N - 1) / 2);
	for (ll n = 0; n < N; n++) {
		vector<ll> temp(N - 1);
		for (ll e = 0; e < N - 1; e++)cin >> temp[e];
		for (ll e = N - 3; e >= 0; e--) {
			edges[enc(n, temp[e + 1]-1)].push_back(enc(n, temp[e]-1));
			edgesinv[enc(n, temp[e]-1)].push_back(enc(n, temp[e+1]-1));
		}
	}
	vector<ll> check(N * (N - 1),0);   //0初期・1一時的・2恒常的
	vector<ll> topans;   //結果保存用 i -> j  => topans[i] < topans[j]
	stack<ll> qans;
	bool cflag = false;
	for (int i = 0; i < N*(N-1)/2; i++) {
		if (check[i] != 0)continue;
		topologicalVisit(i, check, qans, cflag);
	}
	//cflag == trueだったら木じゃない
	while (!qans.empty()) {
		topans.push_back(qans.top());
		qans.pop();
	}
	if (cflag) {
		cout << -1 << endl;
		return 0;
	}
	vector<ll> DP(N * (N - 1) / 2,0);
	for (ll n : topans) {
		if (edgesinv[n].size() == 0)continue;
		for (ll prev : edgesinv[n]) {
			DP[n] = max(DP[n], DP[prev]);
		}
		DP[n]++;
	}
	ll ans = 0;
	for (ll n = 0; n < DP.size(); n++)ans = max(ans, DP[n]);
	cout << ans+1 << endl;
	return 0;
}

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

int op(int a, int b){
    return max(a, b);
}

int e(){
    return 0;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    segtree<int, op, e> seg(300005);
    for(int i = n - 1; i >= 0; i--){
        int l = max(0, a[i] - k);
        int r = min(a[i] + k, 300003);
        int res = seg.prod(l, r + 1) + 1;
        seg.set(a[i], res);
    }
    cout << seg.all_prod() << endl;
}


Measured memory_bytes: 9628
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int main(){
  string s;
  cin>>s;
  bool f =true;
  rep(i,s.length()){
    if(s[i]!=s[s.length()-1-i])f=false;
  }
  int n =s.length();
  rep(i,(n-1)/2){
    if(s[i]!=s[(n-1)/2-1-i])f=false;
  }
  for(int i=(n+3)/2-1;i<n;i++){
    if(s[i]!=s[n-1-i])f=false;
  }
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


int main(){
  int n,x;cin>>n>>x;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int i=0;
  while(i!=n){
    x-=a[i];
    i++;
    if(x<0){
      i--;
      break;
    }
  }
  if(i==n&&x!=0){i--;}

  cout<<i<<endl;
    
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
struct Data{
    string s;
    int t;
    Data(string _s,int _t){
        s =_s,t =_t;
    }
};
int main(){
    string str;
    while(cin>>str,str!="0"){
        queue<Data> Q;
        map<string,bool> M;
        Q.push(Data(str,0));
        while(!Q.empty()){
            Data E = Q.front();
            //cout<<E.s<<endl;
            Q.pop();
            if(M[E.s])continue;
            M[E.s] = true;
            bool flg = true;
            for(int i = 1;i < E.s.length();i++){
                if(E.s[i] != E.s[0])flg = false;
            }
            if(flg){
                cout<<E.t<<endl;
                goto e;
            }
            for(int i = 0;i < E.s.length()-1;i++){
                Data D = E;
                if(D.s[i]!=D.s[i+1]){
                    bool flg[3]={};
                    string w = "rgb";
                    if(D.s[i]=='r'||D.s[i+1]=='r')flg[0] = true;
                    if(D.s[i]=='g'||D.s[i+1]=='g')flg[1] = true;
                    if(D.s[i]=='b'||D.s[i+1]=='b')flg[2] = true;
                    for(int j = 0;j < 3;j++){
                        if(!flg[j])D.s[i] = D.s[i+1] = w[j];
                    }
                    D.t++;
                    //cout<<D.s<<endl;
                    Q.push(D);
                }
            }
        }
        cout<<"NA"<<endl;
        e:;
    }
}

Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

cnt = 0
for i in range(len(S)) :
  if S[i] == "1" :
    cnt += 1

print (cnt)

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct LazySegmentTree{
    int n;
    vector<ll> lazy,node;
    LazySegmentTree(int sz,ll init=0){
        n=1;
        while(n<sz)n*=2;
        lazy.assign(2*n,-1);
        node.assign(2*n,init);
    }

    void eval(int k){
        if(lazy[k]==-1)return;
        node[k]=lazy[k];
        if(k<n){
            lazy[2*k+1]=lazy[k];
            lazy[2*k+2]=lazy[k];
        }
        lazy[k]=-1;
    }

    void update(int a,int b,ll x,int k=0,int l=0,int r=-1){
        eval(k);
        if(r<0)r=n;
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            lazy[k]=x;
            eval(k);
            return;
        }
        update(a,b,x,2*k+1,l,(l+r)/2);
        update(a,b,x,2*k+2,(l+r)/2,r);
        node[k]=min(node[2*k+1],node[2*k+2]);
    }

    ll get(int a,int b,int k=0,int l=0,int r=-1){
        eval(k);
        if(r<0)r=n;
        if(r<=a||b<=l)return longinf;
        if(a<=l&&r<=b){
            return node[k];
        }
        ll xl=get(a,b,2*k+1,l,(l+r)/2);
        ll xr=get(a,b,2*k+2,(l+r)/2,r);
        return min(xl,xr);
    }
};
int main(){
    int n,q;
    cin>>n>>q;
    LazySegmentTree sg(n,(1LL<<31)-1);
    while(q--){
        int c;
        cin>>c;
        if(c){
            int a,b;
            cin>>a>>b;
            cout<<sg.get(a,b+1)<<endl;
        }
        else{
            int a,b,x;
            cin>>a>>b>>x;
            sg.update(a,b+1,x);     
        }
    }
    return 0;
}


Measured memory_bytes: 7048
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

int n;
int s[1<<18];


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, 1<<n) cin >> s[i];

  sort(s, s+(1<<n), greater<int>());
  PQ<int> pq;
  pq.emplace(1<<n);
  int i = 0;
  while(i != 1<<n) {
    int j = i;
    while(j != 1<<n and s[j] == s[i]) j++;
    j -= i;
    if(pq.size() < j) {
      cout << "No" << endl;
      return 0;
    }
    vi hg(j);
    rep(ss, j) {
      hg[ss] = pq.top();
      pq.pop();
    }
    rep(ss, j) {
      while(hg[ss] != 1) {
        pq.emplace(hg[ss] >>= 1);
      }
    }
    i += j;
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 5180
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),k=in();
    vector<double>p(n);for(int i=0;i<n;++i)p[i]=(in()+1)/2.0;
    double sum=accumulate(p.begin(),p.begin()+k,.0);
    double ans=sum;
    for(int i=1;i<=n-k;++i){
        sum+=p[i+k-1]-p[i-1];
        ans=max(ans,sum);
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


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

int main(){
    char s;
    string t;
    int n;
    cin>>n;
    cin>>t;
    
    for(int i=0;i<t.size();i++){
    	s=t[i];
        for(int j=0;j<n;j++){
        	if(s=='Z'){
        		s='A';
        	}
        	else{
        		s++;
        	}
        }
        t[i]=s;
    }
    cout<<t<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 60
string s[N], t[N];

int main(){
	int n, m;
  cin>>n>>m;
  rep(i, n) cin>>s[i];
  rep(i, m) cin>>t[i];
  rep(i, n-m+1) rep(j, n-m+1){
    bool ok = true;
    rep(i2, m) rep(j2, m) if(t[i2][j2]!=s[i2+i][j2+j]) ok = false;
    if(ok){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int solve(int ,int);
int A[1000],B[1000], i, j,k,d,n;
int main() {
	scanf("%d", &n);
	for ( i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}
	scanf("%d", &d);
	for ( i = 0; i < d; i++)
	{
		scanf("%d", &B[i]);
	}
	for ( i = 0; i < d; i++)
	{
		if (solve(0,B[i]))
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
	return 0;
}
int solve(int i, int m ) {
	int res;
	if (m == 0) {
		return 1;
	}
	if (i >= n) {
		return 0;
	}
	res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}


Measured memory_bytes: 2052
#include <cstdio>
#include <queue>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	
	int a[200000];
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	int b[200000];
	priority_queue<pair<int, int> > pq;
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (a[i] > b[i]) {
			puts("-1");
			return 0;
		}
		if (a[i] == b[i]) continue;	
		pq.push(make_pair(b[i], i));
	}
	
	long long cnt = 0;
	while (!pq.empty()) {
		int id = pq.top().second;
		pq.pop();
		int s = (id == 0) ? n-1 : id-1;
		int t = (id == n-1) ? 0 : id+1;
		if ((b[id]-a[id])%(b[s]+b[t]) == 0) {
			cnt += (b[id]-a[id])/(b[s]+b[t]);
			b[id] = a[id];
			continue;
		} else if (b[id]-a[id] < b[s]+b[t]) {
			puts("-1");
			return 0;
		} else {
			cnt += b[id]/(b[s]+b[t]);
			b[id] %= b[s]+b[t];
			pq.push(make_pair(b[id], id));
		}
	}
	
	printf("%lld\n", cnt);
	
	return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int H,W,N,a,b;
set< pair<int,int> > brd;
int dem[15];
signed main(){

	cin>>H>>W>>N;
	dem[0]=(H-2)*(W-2);
	while(N--)
	{
		cin>>a>>b;
		a--;b--;
		brd.insert({a,b});
		for(int x=max((int)0,a-2);x<=min(H-3,a);x++)
		{
			for(int y=max((int)0,b-2);y<=min(W-3,b);y++)
			{
				int cnt=0;
				for(int i=x;i<=x+2;i++)
				{
					for(int j=y;j<=y+2;j++)
					{
						if(brd.count({i,j})) cnt++;
					}
				}
				dem[cnt]++;
				dem[cnt-1]--;
			}
		}
	}
	for(int i=0;i<=9;i++)
	{
		cout<<dem[i]<<endl;
	}
	
	
}

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


int main(){

    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> x_step;
    vector<int> y_step;
    bool odd_even = true;
    int pointer = 0;
    int temp_count = 0;
    while(pointer < s.length()){
        if(s[pointer] == 'T'){
            if(odd_even){
                x_step.push_back(temp_count);
                odd_even = !odd_even;
                temp_count = 0;
                pointer ++;
            }else{
                y_step.push_back(temp_count);
                odd_even = !odd_even;
                temp_count = 0;
                pointer ++;
            }
        }else{
            temp_count ++;
            pointer ++;
        }
    }

    if(odd_even){
        x_step.push_back(temp_count);
    }else{
        y_step.push_back(temp_count);
    }

    bool x_position[x_step.size() + 1][16000+1] = {};
    x_position[0][8000] = 1;
    x_position[1][8000 + x_step[0]] = 1;
    for(int i=2; i<x_step.size()+1; i++){
        for(int j=0; j<=16000; j++){
            if(j - x_step[i-1] < 0){
                x_position[i][j] = x_position[i-1][j+x_step[i-1]];
            }else if(j + x_step[i-1] > 16000){
                x_position[i][j] = x_position[i-1][j-x_step[i-1]];
            }else if(j - x_step[i-1] < 0 && j + x_step[i-1] > 16000){
                x_position[i][j] = 0;
            }else{
                x_position[i][j] = x_position[i-1][j+x_step[i-1]] | x_position[i-1][j-x_step[i-1]];
            }
        }
    }


    if (!x_position[x_step.size()][x + 8000]){
        cout << "No" << endl;
        return 0;
    }

    bool y_position[y_step.size() + 1][16000+1] = {};
    y_position[0][8000] = 1;
    for(int i=1; i<y_step.size()+1; i++){
        for(int j=0; j<=16000; j++){
            if(j - y_step[i-1] < 0){
                y_position[i][j] = y_position[i-1][j+y_step[i-1]];
            }else if(j + y_step[i-1] > 16000){
                y_position[i][j] = y_position[i-1][j-y_step[i-1]];
            }else{
                y_position[i][j] = y_position[i-1][j+y_step[i-1]] | y_position[i-1][j-y_step[i-1]];
            }
        }
    }

    if(!y_position[y_step.size()][y + 8000]){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 121600
import sys
N,M = map(int, input().strip().split(' '))
broken = set(int(line.strip()) for line in sys.stdin)
p = [0]*(N+2)
p[0] = 1
for i in range(N):
  # 今i段目にいる
  if i in broken:
    continue
  p[i+1] += p[i]
  p[i+2] += p[i]
print(p[N]%1000000007)


Measured memory_bytes: 462708
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;



int main(){
		
		string a;
		cin>>a;
		if(a[2]==a[3]&&a[4]==a[5])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;		
		return 0;
}

Measured memory_bytes: 256
input()

numbers = tuple(map(int, input().split(' ')))

n_4_multiples = 0
n_2_multiples = 0
n_other = 0

for n in numbers:
    if n % 4 == 0:
        n_4_multiples += 1
    elif n % 2 == 0:
        n_2_multiples += 1
    else:
        n_other += 1

if n_2_multiples > 0:
    n_other += 1

if n_other - n_4_multiples <= 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20032
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    ll A,B;
    cin >> A >> B;
    cout << A * B / __gcd(A, B) << endl;
}

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

int Pow(int a){
	int ret = 1;
	for(int i = 0; i < a; i++) ret *= 10;
	return ret;
}

int main(){
	int n;
	cin >> n;
	for(int v = 0; v < n; v++){
		string s[2];
		int t[2] = {0,0};
		int x;
		cin >> s[0] >> s[1];
		for(int u = 0; u < 2; u++){
			for(int i = 0; i < s[u].size(); i++){
				if(s[u][i] == 'm'){
					if(i == 0) t[u] += 1000;
					else if(0<=s[u][i-1]-'0'&&s[u][i-1]-'0'<=9){
						t[u] += 1000*(s[u][i-1]-'0');
					} else{
						t[u] += 1000;
					}
				} else if(s[u][i] == 'c'){
					if(i == 0) t[u] += 100;
					else if(0<=s[u][i-1]-'0'&&s[u][i-1]-'0'<=9){
						t[u] += 100*(s[u][i-1]-'0');
					} else{
						t[u] += 100;
					}
				} else if(s[u][i] == 'x'){
					if(i == 0) t[u] += 10;
					else if(0<=s[u][i-1]-'0'&&s[u][i-1]-'0'<=9){
						t[u] += 10*(s[u][i-1]-'0');
					} else{
						t[u] += 10;
					}
				} else if(s[u][i] == 'i'){
					if(i == 0) t[u] += 1;
					else if(0<=s[u][i-1]-'0'&&s[u][i-1]-'0'<=9){
						t[u] += 1*(s[u][i-1]-'0');
					} else{
						t[u] += 1;
					}
				}
			}
		}
		x = t[0]+t[1];
		char ch[4] = {'i','x','c','m'};
		for(int i = 3; i >= 0; i--){
			int y;
			y = (x%Pow(i+1))/Pow(i);
			if(y == 1){
				cout << ch[i];
			} else if(y >= 2){
				cout << y << ch[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1204
import sys
input = lambda: sys.stdin.readline().rstrip()

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

def gcd(a,b):
    if b == 0:return a
    return gcd(b,a%b)

A = list(map(int, input().split()))

g = gcd(A[0], A[1])
for i in range(2, len(A)):
    g = gcd(g, A[i])

print(g)

Measured memory_bytes: 62704
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: u64 = read();

  for i in 0.. {
    if (i+1) * (i+1) > n {
      println!("{}", i*i);
      break;
    }
  }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x = n/500;
        int ans = x*1000;
        n-=x*500;
        int y = n/5;
        ans+=y*5;
        cout<<ans;
    }
    return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int c[6], d[6]={1,5,10,50,100,500};
  int sum_money=0;
  for(int i=0;i<6;i++){
    cin>> c[i];
    sum_money+=c[i]*d[i];
  }

  if(sum_money>=1000) cout<< '1'<< endl;
  else cout<< '0'<< endl;

}

Measured memory_bytes: 1152
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1==x2:
        x,y=-xq+2*x1,yq
    elif y1==y2:
        x,y=xq,-yq+2*y1
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        x=(2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1)
        y=(xq-x)/m+yq
    print "{:.6f} {:.6f}".format(x+0,y+0)

Measured memory_bytes: 4252
import math
from decimal import Decimal

a,b=map(str,input().split())

#パソコンは数値は2進数で表現しますが、2進数では小数点を正確に表現することができないため
#10進数表記に変える
#小数点を文字列型で定義する
a=Decimal(a)
b=Decimal(b)

print(math.floor(a*b))



Measured memory_bytes: 9676
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <utility>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    cin>>a>>b;
    if (max(a,b)<=8) cout<<"Yay!\n";
    else cout<<":(\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define F 1000000000
#define M 500000
int total=0,A[M];
int L[M/2+2],R[M/2+2];
void merge(int,int,int);
void mergeSort(int,int);
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
}
  mergeSort(0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
}
  printf("%d\n",A[n-1]);
  printf("%d\n",total);

  return 0;
}
void merge(int left,int mid,int right){
  int i,j,k,n1,n2;
n1=mid-left;
n2=right-mid;
 for(i=0;i<n1;i++){
   L[i]=A[left+i];
      }
 for(i=0;i<n2;i++){
   R[i]=A[mid+i];
      }
 L[n1]=F;
 R[n2]=F;
    i=0;
    j=0;
    for(k=left;k<right;k++){
      total++;
      if(L[i]<=R[j]){
	A[k]=L[i];
	i=i+1;
      }
      else{ 
	A[k]=R[j];
	j=j+1;
	}
    }
}
void mergeSort(int left,int right){
  int mid;
  if(left+1<right){
  mid=(left+right)/2;
  mergeSort(left,mid);
  mergeSort(mid,right);
  merge(left,mid,right);
    }
      }



Measured memory_bytes: 5612
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	sx, sy := 0, 0
	prevTime := 0
	for i := 0; i < n;i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		diffDis := abs(x-sx) +abs(y -sy)
		diffTime := t - prevTime
		if diffTime >= diffDis {
			if diffTime % 2 == 0 && (abs(x-sx) +abs(y -sy)) %2 ==0 {
				sx = x
				sy = y
				prevTime = t
				continue
			} else if diffTime % 2 == 1 && diffDis%2 == 1 {
				sx = x
				sy = y
				prevTime = t
				continue
			}
		}
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


Measured memory_bytes: 6320
'use strict'

function main(inp) {
  inp = Number(inp.trim())

  let ans = 1
  let enemy = 1
  let num = inp
  while(1) {
    if (num > 1) {
      num = Math.floor(num / 2)
      enemy *= 2
      ans += enemy
    } else {
      break
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int sign(int a) {
  if (a < 0) return -1;
  if (a == 0) return 0;
  return 1;
}

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }

    int arr = 1;
    int dir = 0;

    for (int i = 1; i < n; i++) {
      if (dir == 0) {
        dir = sign(a[i] - a[i - 1]);
      } else if ((a[i] - a[i - 1]) * dir < 0) {
        arr++;
        dir = 0;
      }
    }

    printf("%d\n", arr);
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll a,b,x;
    ll ans=0;
    cin>>a>>b>>x;
    ans=b/x-max(a-1,0ll)/x;
    if(a==0) ++ans;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int n;

  cin >> n;

  if (n % 2 == 1) {
    cout << (n / 2 + 1);
  } else {
    cout << (n / 2);
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, M;

struct Node{
    int begin, end;
    Node *prev, *next;
};

// 0, 1, 2, 3, 4, 5, 6, 7, 8
// 1, 2, 3, 4, 5, 6, 7, 8, 9
// [6, 7, 8, 9], [4, 5], [1, 2, 3]
Node* update(Node* n, int index){
    int size = n->end - n->begin;
    if(index == 0){
        return n;
    }else if(0 < index && index < size){
        Node* new_node = new Node{n->begin + index, n->end, n, n->next};
        n->end = new_node->begin;
        n->next = new_node;
        if(new_node->next != nullptr){new_node->next->prev = new_node;}
        return new_node;
    }
    return update(n->next, index-size);
}

Node* tail(Node* n){
    if(n->next == nullptr){return n;}
    return tail(n->next);
}

void test(Node* n){
    while(n != nullptr){
        printf("[%d, %d)\n", n->begin, n->end);
        n = n->next;
    }
    puts("---------------------------");
}

P intersect(int al, int ar, int bl, int br){
    if(al <= bl && br <= ar){return mp(bl, br);}
    if(bl <= al && ar <= br){return mp(al, ar);}
    if(al <= bl && bl < ar){return mp(bl, ar);}
    if(bl <= al && al < br){return mp(al, br);}
    return mp(-1, -1);
}

int count(Node* root, int begin, int end, int v){
    int pos = 0, res = 0;
    while(root != nullptr){
        int size = root->end - root->begin;
        
        if(v - root->begin >= 0){
            P is = intersect(begin, end, pos, pos+std::min(v-root->begin+1, size));
            if(is.first != -1){
                res += is.second - is.first;
            }
        }

        pos += size;
        root = root->next;
    }

    return res;
}

int main(){
    while(std::cin >> N >> M, N){
        int p, q, r;
        std::cin >> p >> q >> r;

        Node *root = new Node{1, N+1, nullptr, nullptr};
        REP(i, M){
            int a, b;
            std::cin >> a >> b;

            // シャッフル前 [a1, ..., a2], [b1, ..., b2], [c1, ..., c2]
            // シャッフル後 [c1, ..., c2], [b1, ..., b2], [a1, ..., a2] (a2後ろの接続を断つ)
            Node *a1 = root, *b1 = update(root, a), *c1 = update(root, b),
                *a2 = b1->prev, *b2 = c1->prev, *c2 = tail(root);

            // printf("a1: [%d, %d), a2: [%d, %d)\n", a1->begin, a1->end, a2->begin, a2->end);        
            // printf("b1: [%d, %d), b2: [%d, %d)\n", b1->begin, b1->end, b2->begin, b2->end);
            // printf("c1: [%d, %d), c2: [%d, %d)\n", c1->begin, c1->end, c2->begin, c2->end);

            c2->next = b1;
            b1->prev = c2;
            b2->next = a1;
            a1->prev = b2;
            a2->next = nullptr;

            root = c1;
        }
        printf("%d\n", count(root, p-1, q, r));
    }
}

Measured memory_bytes: 1728
import math

n, h = map(int, input().split(" "))
abL = [list(map(int, input().split(" "))) for _ in range(n)]

aL = []
bL = []
for a, b in abL:
    aL.append(a)
    bL.append(b)
aL = sorted(aL)
bL = sorted(bL)

aMax = max(aL)
ans = 0
while h != 0:
    if h <= 0:
        break
    if len(bL) == 0 or bL[-1] < aMax:
        ans += math.ceil(h / aMax)
        break
    ans += 1
    h -= bL.pop()

print(ans)

Measured memory_bytes: 29732
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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



Measured memory_bytes: 3728
#include <string>
#include <stdio.h>
#include <vector>

int A = 0;
int d[300000] = {};
bool ok = false;

int main(){
	scanf("%d", &A);
	for(int i = 0; i < A; i++){
		scanf("%d", &(d[i]));
	}

	int ck = 0;
	int get = 0;
	for(int i = 0; i <= ck; i++){
		if(i == A){
			ok = true;
			break;
		}
		get = i + d[i]/10;
		if( ck < get ){
			ck = get;
		}

	}
	if ( ok ){
	ok = false;
	ck = A-1;
	for(int i = A-1; i >= ck; i--){
		if(i == -1){
			ok = true;
			break;
		}
		get = i - d[i]/10;
		if( ck > get ){
			ck = get;
		}

	}
	}
	if(ok){
		printf("yes\n");
	}else{
		printf("no\n");
	}

	return 0;
}


Measured memory_bytes: 3864
N = 0
V = []
C = []
 
i = 0
ans = 0

str = input()
N = int(str)
 
str = input().split()
while i < N:
  V.append(int(str[i]))
  i = i+1
  
i=0
str = 0
str = input().split()
while i < N:
  C.append(int(str[i]))
  i = i+1

i=0
while i<N:
  if V[i] > C[i]:
    ans = ans + V[i] - C[i]
  i = i+1
    
    
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N],sum[N];

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

    string s1,s2;
    cin >>s1>>s2;
    reverse(s1.begin(),s1.end());
    if(s1==s2)  cout <<"YES"<<endl;
    else cout <<"NO"<<endl;

    return 0;
}


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

def main():
	s = input().strip()
	ans = 100000000
	for i in range(len(s)-2):
		ans = min(ans, abs(753 - int(s[i]+s[i+1]+s[i+2])))
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 38256
import java.util.*;



class Main {

	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] b = new int[n-1];
		
		for(int i=0;i<n-1;i++){
			b[i] = sc.nextInt();
		}

		int ans = b[0] + b[n-2];
		for(int i=0;i<n-2;i++){
			ans += Math.min(b[i],b[i+1]);
		}
		
		System.out.println(ans);
		}
	}

Measured memory_bytes: 35832
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string a,b; cin>>a>>b;
  int c=stoi(a),d=stoi(b);
  string s1,s2;
  for(int i=0; i<c; ++i) s1+=b;
  for(int i=0; i<d; ++i) s2+=a;
  if(s1<s2) cout<<s1; else cout<<s2;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string S;
	int k,l;
	cin>>k>>S;
	l=S.length();
	if(l>k)
	{
		for(int i=0;i<k;i++)cout<<S[i];
		cout<<"...";
	}
	else cout<<S;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string S,T;
	cin >> S >> T;
	char tmp;
	int flag = 0;
	for (int i = 0;i < S.size();i++){
		if(S == T){
			flag  = 1;
			break;
		}
		tmp = S[S.size() - 1];
		S.pop_back();
		S = tmp + S;
	}
	if (flag == 1){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll n,i,c=0,d=0;
	cin>>n;
	string s,p;
	cin>>s;p=s;

	sort(p.begin(),p.end());
		fr(i,0,n)
	{
		if(s[i]!=p[i] && s[i]=='W')
		{
			c++;
		}
		if(s[i]!=p[i] && s[i]=='R')
		{
			d++;
		}
		
	}
	ll z=min(c,d);
	d-=z;
	c-=z;
	ll k=max(c,d);
	cout<<z+k;	return 0;
}



Measured memory_bytes: 3920
N = int(input())
bfr = [[[0]*10 for i in range(3)] for j in range(4)]
for i in range(N):
    b, f, r, v = [int(n) for n in input().split()]
    bfr[b-1][f-1][r-1] += v
c = 0
for B in bfr:
    for F in B:
        print('{:>20}'.format(' '.join([str(c) for c in F])))
    c += 1
    if c < 4:
        print('####################')



Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;cin >> n;
  vector<ll> a(n);rep(i,n) cin >> a[i];
  vector<ll> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];
  map<ll,ll> mp;
  rep(i,n+1) mp[sum[i]]++;
  ll res = 0;
  rep(i,n+1){
    mp[sum[i]]--;
    res += mp[sum[i]];
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std ; 
int main(){
    ll h ; 
    cin>> h ; 
    ll x = h , mul = 1 , ans = 0 ; 
    while(x > 0 ){
		ans+=mul ; 
		x = x/2 ; 
		mul*=2 ; 
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

int H, W = 5;
int maps[10][5];

int solera() {
	int res = 0;
	REP(i, H) {
		int eq[5] = {};
		REP(j, W) {
			if (!maps[i][j]) eq[j] = 0;
			else if (j && maps[i][j] == maps[i][j - 1]) eq[j] = eq[j - 1] + 1;
			else eq[j] = 1;
		}
		for (int j = W - 2; j >= 0; j--) {
			if (maps[i][j] == maps[i][j + 1]) eq[j] = eq[j + 1];
		}
		REP(j, W) if (eq[j] >= 3) {
			res += maps[i][j];
			maps[i][j] = 0;
		}
	}
	return res;
}

bool soldro() {
	bool res = false;
	
	REP(j, W) {
		for (int i = H - 2; i >= 0; i--) {
			if (maps[i + 1][j] == 0 && maps[i][j]) {
				maps[i + 1][j] = maps[i][j];
				maps[i][j] = 0;
				res = true;
			}
		}
	}
	return res;
}

int main() {
	while (cin >> H, H) {
		REP(i, H) REP(j, W) scanf("%d", &maps[i][j]);
		
		int ans = 0;
		while (true) {
			int cur = solera();
			ans += cur;
			if (cur == 0) break;
			while (soldro());
		}
		
		if (debug) printf("@ ");
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int r,c,k;
char arr[7][7];
char b[7][7];
bool check(){
	int count =0;
	for(int i=0; i<r; i++){
		for(int j=0; j<c; j++){
			if(b[i][j] == '#')
			count++;
		}
	}
	if(count == k){
		return true;
	}
	else
	return false;
}
void colour(int c1,int c2){
	for(int i=0; i<r; i++){
		if(c1 &(1 << i)){
			for(int j=0; j<c; j++){
				b[i][j]='$';
			}
			
		}
		
	}
	
	for(int j=0; j<c; j++){
		if(c2 &(1 << j)){
			for(int i=0; i<r; i++)
			b[i][j]='$';
		}
	}
	
}
void copy(){
	for(int i=0; i<r; i++){
		for(int j=0; j<c; j++){
			b[i][j] = arr[i][j];
		}
	}
}
void solve(){
   
    cin >> r >> c >>k;
   
   for(int i=0; i<r; i++){
   	for(int j=0; j<c; j++){
   		cin >> arr[i][j];
   	}
   }
   int count =0;
   for(int i=0; i<(1 << r); i++){
   	for(int j=0; j<(1 << c); j++){
   		copy();
   		colour(i,j);
   		if(check())
   		count++;
   		
   	}
   }
   
  
  cout << count <<'\n';
    
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1; //cin >> t;
    
    while(t--){
        solve();
    }
}

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

int main() {
  int n;cin>>n;
  vector<int> b(n-1);
  rep(i,n-1)cin>>b[i];
  int cnt=b[0];
  rep(i,n-2){
    if(b[i]<b[i+1])cnt+=b[i];
    else cnt+=b[i+1];
  }
  cnt+=b[n-2];
  cout<<cnt<<endl;
}

Measured memory_bytes: 3624
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs1 = ReadInts();
        var inputs2 = ReadInts();
        var inputs3 = ReadInts();

        var points = inputs1.Concat(inputs2).Concat(inputs3)
            .GroupBy(_ => _);

        if (points.Count() < 4 || points.Any(_ => _.Count() >= 3))
        {
            Console.WriteLine("NO");
        }
        else
        {
            Console.WriteLine("YES");
        }

    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

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

int main()
{
    int x1;
    
    for(int i=0; i<5; i++){
        cin>>x1;
        if(x1 == 0) {
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int m;

int main(){
    readi(m);
    lp(h,1,3500) lp(n,1,3500){
        if(abs(4.0 / m - 1.0 / h - 1.0 / n) < eps) continue;
        double w = 1 / (4.0 / m - 1.0 / h - 1.0 / n);
        if(abs(w - round(w)) < eps and (int)round(w) <= 3500 and (int)round(w) >= 1)
            return cout <<h <<" " <<n <<" " <<(int)round(w), 0;
    }
    assert(false);
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 256