akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

int main(){
    string s;
    cin >> s;
    long long K;
    cin >> K;

    set<string> T;

    for(long long j = 1; j <= K; j++){
        long long i = 0;
        while(i < s.size()){
            string t;

            long long count = 0;
            long long k = i;
            while(k < s.size()){
                if(count == j){
                    break;
                }

                //t.push_back(s[k]);
                t = t + s[k];
                k++;
                count++;
            }

            if(t.size() == j){
                //printf("t %s\n", t.c_str());
                T.insert(t);
            }
            i++;

        }
    }

    set<string>::iterator it;

    long long count = 0;
    for(it = T.begin(); it != T.end(); it++){
        count++;
        
        if(count == K){
            cout << *it << endl;
            break;
        }
        //cout << *it << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4812
#include<stdio.h>
#define N 100000

typedef struct{
  int id;
  int parent;
  int child;
  int right;
  int depth;
}Node;

Node node[N];
int C[N];

int main(){

  int n,i,j,degree=0,id=0;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    node[i].parent=-1;
    node[i].child=-1;
    node[i].right=-1;
    node[i].depth=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&degree);

    node[id].id=id;
    for(j=0;j<degree;j++){
      scanf("%d",&C[j]);
      if(j==0){
	node[id].child=C[j];
      }else if(j!=0){
	node[C[j-1]].right=C[j];
      }
      node[C[j]].parent=id;
      node[C[j]].id=C[j];
    }
  }

  for(i=0;i<n;i++){
    j=node[i].parent;

    while(1){
      if(j==-1){
	break;  
      }
      j=node[j].parent;
      node[i].depth++;
    }
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d,",node[i].id,node[i].parent,node[i].depth);
    
    if(node[i].parent==-1){
      if(node[i].child!=-1){
	printf(" root, [%d",node[i].child);
	j=node[i].child;
	while(node[j].right!=-1){
	  printf(", %d",node[j].right);
	  j=node[j].right;
	}
	printf("]\n");
      }else{
	printf(" root, []\n");
      }
    }
    else if(node[i].parent!=-1){
      if(node[i].child!=-1){
	printf(" internal node, [%d",node[i].child);
	j=node[i].child;
	while(node[j].right!=-1){
	  printf(", %d",node[j].right);
	  j=node[j].right;
	}
	printf("]\n");
      }else{
	printf(" leaf, []\n");
      }
    }
  }
  return 0;
}

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

#define Max 100000
typedef long long llong;
int n,k;
llong T[Max];


int Check(llong P){
  int i=0;

  for(int j=0;j<k;j++){
    llong s=0;
    while(s+T[i]<=P){
      s+=T[i];
      i++;
      if(i==n)return n;
    }
  }
  return i;
}

int Solve(){
  llong left=0;
  llong right=100000*10000;
  llong mid;

  while(right-left>1){
    mid=(left+right)/2;
    int v=Check(mid);
    if(v>=n)right=mid;
    else left = mid;
  }
  return right;
}

main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>T[i];
  llong ans=Solve();
  cout<<ans<<endl;
}





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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, L1[MAXN], L2[MAXN], R1[MAXN], R2[MAXN], ans;
pll A[MAXN];
set<pll> st;

int main() {
    fast_io;

    cin >> n;
    for (ll i = 1; i <= n; i++) cin >> A[i].X, A[i].Y = i;

    sort(A + 1, A + n + 1, greater<pll>());
    st.insert({0, 0});
    st.insert({0, -1});
    st.insert({n + 1, n + 1});
    st.insert({n + 1, n + 2});
    for (ll i = 1; i <= n; i++) {
        auto it = st.upper_bound({A[i].Y, -INF});
        R1[i] = (*it).X;
        it++;
        R2[i] = (*it).X;
        it--;
        it--;
        L1[i] = (*it).X;
        it--;
        L2[i] = (*it).X;
        st.insert({A[i].Y, -INF});
    }

    for (ll i = 1; i <= n; i++) {
        ll x = A[i].Y;
        ans += A[i].X * ((R2[i] - R1[i]) * (x - L1[i]) + (L1[i] - L2[i]) * (R1[i] - x));
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 18304
import qualified Data.Map as Map



f::Int->Int->String->[(Int,String)]
f (-1) n str=[(n,str)]
f m n str=(f (m-2) (n+((-2)^m)) (str++"10"))++(f (m-2) n (str++"00"))

f2::Int->Int->String->Map.Map Int String->String
f2 34 _ _ _=""
f2 m n str ms
     |Map.member n ms=let t1=(Map.lookup n ms)
                          (Just t2)=t1
                      in t2++" "++str
     |otherwise = (f2 (m+2) n ("00"++str) ms)++(f2 (m+2) (n-(2^m)) ("01"++str) ms)

f3::String->String->String
f3 "" ys=ys
f3 xs ""=xs
f3 (_:xs) ('1':ys)='1':f3 xs ys
f3 ('1':xs) (_:ys)='1':f3 xs ys
f3 (_:xs) (_:ys)='0':f3 xs ys

main = do
       a<-getLine
       let b=read a::Int
           ms=(Map.fromList (f 33 0 ""))
           (c:d:_)=(map reverse) $ words $ f2 0 b "" ms
       if b==0 then putStrLn "0" 
       else let (_,ans)=span (=='0') (reverse (f3 c d)) in putStrLn ans

Measured memory_bytes: 29436
#include <iostream>
using namespace std;
#define Interest 0.01

int main(){
    long long int X,saving,i;
    saving = 100;
    i=0;
    cin >> X;
    //cout << Interest;
    for(;;){
        saving*=1.01;
        i++;
        if(saving >= X){
            cout << i;
            return 0;
        }
        
    }
    cout << i;
    
    return 0;
}
   

Measured memory_bytes: 3632
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
if p[-1] == n:
    cnt += 1
print(cnt)

Measured memory_bytes: 14008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

struct Combination{
    vector<long long> _fac,_finv,_inv;
    const int m = MOD;

    Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
        _fac[0] = _fac[1] = 1;
        _finv[0] = _finv[1] = 1;
        _inv[1] = 1;
        for(int i = 2; i <= sz; i++){
            _fac[i] = _fac[i-1]*i%m;
            _inv[i] = m-_inv[m%i]*(m/i)%m;
            _finv[i] = _finv[i-1]*_inv[i]%m;
        }
    }

    inline long long fac(int n){return _fac[n];}
    inline long long inv(int n){return _inv[n];}
    inline long long finv(int n){return _finv[n];}

    long long comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
    }
};

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

int main(){
    int n,m,k; cin >> n >> m >> k;
    Combination C(300000);
    ll ans = 0;
    rep(i,k+1){
        ans += m*C.comb(n-1,i)%MOD*modpow(m-1,n-i-1,MOD)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 10352
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))


using arr = array<ll, 3>;
int main() {
	auto proc = [](string str) {
		int bra = 0;
		int cket = 0;
		for (char c : str) {
			if (c == '(') {
				++bra;
			}
			else {
				if (bra > 0) --bra;
				else ++cket;
			}
		}
		return arr{cket, bra, bra - cket};
	};
	auto cmp = [](arr a, arr b) {
		if (a[0] == b[0])return a[1] > b[1];
		return a[0] < b[0];
	};
	auto cmp2 = [](arr a, arr b) {
		if (a[0] == b[0])return a[1] > b[1];
		return a[0] > b[0];
	};
	ll N;
	cin >> N;
	vector<arr> plus,minus;
	REP(i, 0, N) {
		string str;
		cin >> str;
		auto a = proc(str);
		if (a[2] >= 0) plus.push_back(a);
		else minus.push_back(a);
	}
	sort(plus.begin(), plus.end(), cmp);
	if (plus.size() == 0 || plus[0][0] > 0) {
		PRIN;
		return 0;
	}
	sort(minus.begin(), minus.end(), cmp2);
	int last = -1;
	REP(i, 0, minus.size()) {
		if (minus[i][1] == 0) {
			last = i;
			break;
		}
	}
	if (last == -1) {
		if (minus.size() != 0)PRIN;
		else {
			for (auto p : plus) {
				if (p[0] != 0 || p[1] != 0) {
					PRIN;
					return 0;
				}
			}
			PRIY;
		}
		return 0;
	}
	int cur = 0;
	for (auto p : plus) {
		cur -= p[0];
		if (cur < 0) {
			PRIN;
			return 0;
		}
		cur += p[1];
	}
	REP(i, 0, minus.size()) {
		if (i == last)continue;
		auto p = minus[i];
		cur -= p[0];
		if (cur < 0) {
			PRIN;
			return 0;
		}
		cur += p[1];
	}
	cur -= minus[last][0];
	if (cur == 0)PRIY;
	else PRIN;
	return 0;
}

Measured memory_bytes: 26812
while True:
    H,W=map(int,input().split())
    if H==0 and W==0: break
    for y in range(1,H+1):
        for x in range(1,W+1):
            if x==1 or y ==1 or x == W or y == H:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
h,w,K=map(int,input().split())
c=[]
black=0
hb=[0]*(h)
wb=[0]*(w)
for i in range(h):
    c.append(input())
    for j in range(w):
        if c[i][j]=="#":
            black+=1
            hb[i]+=1

for i in range(0,w):
    for j in range(h):
        if c[j][i]=="#":
            wb[i]+=1

ans=0
for i in range(2**h):
    for j in range(2**w):
        ansb=black
        for k in range(h):
            if ((i>>k)&1):
                ansb-=hb[k]
        for l in range(w):
            if((j>>l)&1):
                ansb-=wb[l]
        for k in range(h):
            for l in range(w):
                if((i>>k)&1 and (j>>l)&1 and c[k][l]=="#"):
                    ansb+=1
        if ansb==K:
            ans+=1
print(ans)

Measured memory_bytes: 68400
#include <stdio.h>

int main(void) {
  int n, k, i, now = 1;
  scanf("%d%d", &n, &k);
  for(i = 0; i < n; ++i) now = (now + k < now * 2 ? now + k : now * 2);
  printf("%d", now);
  return 0;
}

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

using namespace std;
int dp[200000];
int main() {
	int n;
	cin>>n;
	int a[n+1];

	a[0]=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[2] =abs(a[2] - a[1]);
	if(n==2){cout<<dp[2];exit(0);}
	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-2] - a[i]));
	}
	
	cout<<dp[n];
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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() {
    int n; cin >> n;
    vector<int> a(n); rep(i, n) { int x; cin >> x; x--; a[i] = x;}
    int cnt = 0, pos = 0;
    vector<bool> seen(n, false); 
    seen[0] = true;
    while(true){
        cnt++;
        int next = a[pos];
        if(next == 1)break;
        if(seen[next]){ cnt = -1; break;}
        pos = next; seen[next] = true;
    }
    cout << cnt << ln;

}


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

//プロトタイプ宣言
bool result(vector<int> &dataiV);	

int main(){
  string data;
  cin >> data;
  
  char data1;
  char data2;
  char data3;
  char data4;
  
  int data1i;
  int data2i;
  int data3i;
  int data4i;
  
  data1 = data.at(0);
  data1i = stoi(&data1);
  data2 = data.at(1);
  data2i = stoi(&data2);  
  data3 = data.at(2);
  data3i = stoi(&data3);
  data4 = data.at(3);
  data4i = stoi(&data4);
  
  vector<int> datai(7);
  
  datai.at(0)=data1i;
  datai.at(1)=0;
  datai.at(2)=data2i;
  datai.at(3)=0;
  datai.at(4)=data3i;
  datai.at(5)=0;
  datai.at(6)=data4i;
  
  int flg=0; 
  
  for(int i1=0;i1<2;i1++){
 
    datai.at(1)=i1;
    if(result(datai) == true){
      flg = 1;
      break;
    }
        
  	for(int i2=0;i2<2;i2++){
      datai.at(3)=i2;
      if(result(datai) == true){
        flg = 1;
        break;
      }
      
      for(int i3=0;i3<2;i3++){
        datai.at(5)=i3;
        if(result(datai) == true){
          flg = 1;
          break;
        }      
      }
      if(flg==1){
        break;
      } 
    }
    if(flg==1){
      break;
    }
  }

  string dataC = "0000000=7";
  int tmp;
  
  for(int i=0;i<7;i++){
    if(i % 2 == 0){
      tmp = datai.at(i);
      dataC.at(i) = '0'+ tmp;
    }else{
      if(datai.at(i)==0){
        dataC.at(i) = '-';
      }else{
        dataC.at(i) = '+';
      }        
    }
  }
  cout << dataC << endl;
}

bool result(vector<int> &dataiV){

    int clm=dataiV.at(0);
    for(int i=0;i<6;i++){
      if(i % 2 == 0){
      }else{
        if(dataiV.at(i)==0){
          clm-=dataiV.at(i+1);
        }else{
          clm+=dataiV.at(i+1);
        }
      }
    }
  
  if(clm==7){    
    return true;
  }else{
    return false;
  }

}

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

int main(){
	int a,b;
	cin >> a >> b;
	int ans = -1;
	
	for(int i = 0;i < 1000000000;i++){
		if(abs(a-i) == abs(b-i)){
			ans = i;
			break;
		}
	}
	if(ans != -1){
		cout << ans << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
		
}
		




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

int main() {
  int count = 0;
  string str;
  cin >> str;
  for(int i = 0; i < str.size(); i++) {
    if(str[i] == '1') count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

bool ss(string x){
  i64 N = x.size();
  rep(i,N/2){
    if(x[i] != x[N/2+i]){
      return false;
    }
  }
  return true;
}

void Main()
{
  string S;
  cin >> S;
  rrep(i,S.size()-1,0){
    if(ss(S.substr(0,i))){
      cout << i - 1 << "\n";
      return;
    }
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
int i, x, y, tmp;


for(i=1;;i++){
scanf("%d %d", &x, &y);
  if (x==0&&y==0){
  break;
  }
if (x<=y) {
printf("%d %d\n", x, y);
}
if(x>y){
tmp = x;
x = y;
y = tmp;
printf("%d %d\n", x, y);
}


}
return 0;
}


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

#define INF 114514810

int main(){
    int n;
    string s;
    int num[50][26];
    int total[26] = {0};
    for(int i=0; i<50; i++){
        for(int j=0; j<26; j++){
            num[i][j] = 0;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        for(auto c : s){
            num[i][c-'a']++;
        }
    }
    for(int i=0; i<26; i++){
        int num_min = INF;
        for(int j=0; j<n; j++){
            if(num[j][i] <= num_min){
                num_min = num[j][i];
            }
        }
        total[i] = num_min;
    }
    string ans = "";
    for(int i=0; i<26; i++){
        string str(total[i], 'a'+i);
        ans += str;
    }
    cout << ans;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int count = scan.nextInt();
    double sum = 0;
    for (int i=0; i<count&&scan.hasNextInt(); i++) {
      sum += (1/(double)scan.nextInt());
    }
    System.out.println(1/sum);
  }
}

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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int n;
    std::cin >> n;

    if (n % 2 == 0) {
        auto dp = vec(2, vec(n + 2, -INF));
        dp[0][0] = 0;
        for (int i = 0; i <= n; ++i) {
            lint x;
            if (i >= n) {
                x = 0;
            } else {
                std::cin >> x;
            }

            dp[1][i + 1] = std::max(dp[1][i + 1], dp[0][i]);
            if (i == n) break;

            for (int k = 0; k < 2; ++k) {
                dp[k][i + 2] = std::max(dp[k][i + 2], dp[k][i] + x);
            }
        }

        std::cout << dp[1][n + 1] << std::endl;

    } else {
        auto dp = vec(3, vec(n + 2, -INF));
        dp[0][0] = 0;
        for (int i = 0; i <= n; ++i) {
            lint x;
            if (i >= n) {
                x = 0;
            } else {
                std::cin >> x;
            }

            for (int k = 0; k < 2; ++k) {
                dp[k + 1][i + 1] = std::max(dp[k + 1][i + 1], dp[k][i]);
            }
            if (i == n) break;

            for (int k = 0; k < 3; ++k) {
                dp[k][i + 2] = std::max(dp[k][i + 2], dp[k][i] + x);
            }
        }

        std::cout << dp[2][n + 1] << std::endl;
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,p;
    cin>>a>>p;
    a=a*3;
    int sum=a+p;
    cout<<sum/2<<endl;

    
    return 0;
    
}



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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    REP (i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];
    REP (i, 0, N - 1) {
        lli ans = S[i];
        REP (j, i, N - 1) {
            ans = max(ans, (lli)S[j]);
            if (ans % F[j] != 0) {
                ans = ans / F[j] * F[j] + F[j];
            }
            ans += C[j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);


    int a, b,sum=0;
    cin >> a >> b;
    for(int i = 1; i < 1000; ++i) {
        sum += i;
        if(sum - b == sum - i - a) {
            cout << sum - b << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2 == 0 && y >= x * 2 && y <= x * 4) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e9 + 9;
const ll SIZE = 5e5 + 5;
const ll MOD  = 1e9 + 7;


ll N, M, res, bads, step = 1, fac[SIZE], inv[SIZE];


ll binpow (ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1LL)
			res = mod (res * a, MOD);
		a = mod (a * a, MOD);
		n >>= 1LL;
	}
	return res;
}


ll c (ll n, ll k) {

	if (k < 0 || k > n) 
		return 0;

	ll res = fac[n];

	res = mod (res * inv[n - k], MOD);
	res = mod (res * inv[k], MOD);

	return res;
}

ll a (ll n, ll k) {
	if (k < 0 || k > n) 
		return 0;
	else 
		return mod (fac[n] * inv[n - k], MOD);
}

void prec () {
	
	fac[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i <= M; i++) {
		fac[i] = i;
		inv[i] = binpow (i, MOD - 2);
	}

	for (ll i = 1; i <= M; i++) {
		fac[i] = mod (fac[i] * fac[i - 1], MOD);
		inv[i] = mod (inv[i] * inv[i - 1], MOD);
	}

}


int main() { speedhack()

	cin >> N >> M;

	prec ();

	for (ll i = 0; i <= N; i++) {
		ll bad = mod (step * c (N, i) * a (M - i, N - i), MOD);
		bads = mod (bads + bad, MOD);
		step = -step;
	}

	res = mod (a (M, N) * bads, MOD);
	cout << res;

	return 0;
}

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


int main()
{
  int n;
  cin>>n;
  
  int arr[n+1];
  arr[0]=0;arr[1]=0;
  
  for(int i=2;i<=n;i++)
  	cin>>arr[i];
  int ans[n+1];
  
  for(int i=0;i<=n;i++)
  	ans[i]=0;
  
  for(int i=2;i<=n;i++)
  {
    ans[arr[i]]++;
  }
  
  for(int i=1;i<=n;i++)
  	cout<<ans[i]<<endl;
  
  
}

Measured memory_bytes: 5188
#include <stdio.h>

int main(void){
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	int tmp;
	tmp=x;
	x=y;
	y=tmp;
	tmp=x;
	x=z;
	z=tmp;

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

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define ll long long
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    for(int i=0;i<s.size();i+=2){
        if(s[i]!=s[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
ABs = [list(map(int,input().split())) for i in range(N)]
li = []
for A,B in ABs:
  li.append([A+B,A,B])
  
li.sort(reverse=True)
flag = True
ans1 = ans2 = 0
for S,A,B in li:
  if flag:
    ans1 += A
  else:
    ans2 += B
  flag = not flag
  
print(ans1-ans2)


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

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

int main() {
	map <int, int> m;
	int N,ans = 0;
	cin >> N;
	REP(i,N){
		int x;
		cin >> x;
		m[x]++;
	}
	
	for(map<int,int>::iterator it = m.begin(); it!=m.end(); it++) {
		int x = it->first, y = it->second;
		if(y < x) ans += y;
		else ans += y-x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = {-1 , 1 , 0 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 0 , 1 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int mxN=3e5+5,oo=0x3f3f3f3f,mod=1e9+7;
vi adj[mxN];
int n,m;
bool vis[mxN];
int dp[mxN];
int go(int node){
    vis[node]=1;
    int &ret=dp[node];
    if(~ret)
        return ret;
    for(auto &x:adj[node]){
        ret=max(ret,go(x)+1);
    }
    return ~ret?ret:0;
}
void solve(){
    cin>>n>>m;
    loop(m,i,0){
        int u,v;cin>>u>>v;
        adj[u].pb(v);
    }
    mem(dp,-1);
    int res=0;
    loop(n+1,i,1){
        res=max(res,go(i));
    }
    cout<<res<<endl;
}
int main() {
    fast();
    solve();
}


Measured memory_bytes: 13056
# Date [ 2020-08-15 21:00:28 ]
# Problem [ a.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    s = read_str()
    if 'RRR' == s:
        print(3)
    elif 'RRS' == s or 'SRR' == s:
        print(2)
    elif 'RSS' == s or 'SRS' == s or 'SSR' == s or 'RSR' == s:
        print(1)
    else:
        print(0)

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 9872
import sys
n,m=map(int,input().split())
s=list(input())
s.reverse()
ans=[]
x=0
while x<n:
  f=0
  for i in range(x+1,min(x+1+m,n+1)):
    if s[i]=='0':
      y=i-x
      f=1
  if f==0:
    print(-1)
    sys.exit()
  ans.append(str(y))
  x+=y
ans.reverse()
print(' '.join(ans))

Measured memory_bytes: 10832
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 200000

struct edge{
	int to;
	long long int cost;
};

vector<edge> G[MAX_V];
long long int cost[10][MAX_V];

void shortest_path(int s, int V, long long int d[]){
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
    int N, M, R, Q;
    cin >> N >> M >> R >> Q;
    for(int i = 0; i < M; i++){
		int u, v, cost;
		cin >> u >> v >> cost;
        edge e;
        e.cost = cost;
        e.to = u;
        G[v].push_back(e);
    }
    for(int i = 0; i < R; i++){
        G[0].clear();
        edge e;
        e.cost = 0;
        for(int j = 1; j <= N; j++){
            if(j % R == i){
                e.to = j;
                G[0].push_back(e);
            }
        }
        shortest_path(0, N + 1, cost[i]);
    }
    long long int ans = 0;
    for(int loop = 0; loop < Q; loop++){
        long long int x, y, z;
        cin >> x >> y >> z;
        long long int S = 0;
        for(int i = 0; i < R; i++){
            S = max(S, z - cost[i][x] - cost[i][y]);
        }
        ans += S;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19252
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> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: usize = read();
  let hs: Vec<u32> = read_vec();

  let mut max = 0;

  for i in 0..n as usize {
    let mut j = i;
    let mut cnt = 0;

    if max > n - j { break; };

    loop {
      if j == n - 1 { break; };
      if hs[j as usize] >= hs[j + 1 as usize] {
        cnt += 1;
        j += 1;
      } else {
        break;
      }
    }

    if max < cnt { max = cnt; };
  }

  println!("{}", max);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll t;
    t=1;
    while(t--) /// get diameter nothing else
    {
        ll k,n;
        cin>>k>>n;
        ll arr[n];
        for(int i=0;i<n;i++)cin>>arr[i];
        ll ans=1e18;
        ll pre[n];
        for(int i=1;i<n;i++)
            pre[i]=arr[i]-arr[i-1];
        pre[0]=arr[0]+(k-arr[n-1]);
        ll nxt[n];
        for(int i=0;i<n-1;i++)
            nxt[i]=arr[i+1]-arr[i];
        nxt[n-1]=(k-arr[n-1])+arr[0];
        for(int i=0;i<n;i++)
        {
            ll d1=k-pre[i],d2=k-nxt[i];
            ans=min(ans,min(d1,d2));
        }
        cout<<ans;
    }
}


Measured memory_bytes: 4992
//A§ûö®
//ax + by = c
//dx + ey = f
//ÌððoÍ¹æ@È¨AðÍêÓÉèÜéàÌÆ·é

//üÍÍÀa`fªóÅæØçêÄ^¦çêéiIíèÍHj
//oÍÍxAyðóÅæØÁÄA¬_æ4ðlÌÜüµ½lðoÍ¹æ



#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;


void Round(double &refX)
{
	//ë·@¡ñÍ¬_Èºæ4ÅlÌÜüÆ
	const double eps = 0.001;
	if( abs(refX) < eps)
		refX = 0;
}

int main(void)
{
	double a, b, c, d, e, f;
	double x, y;
	while(cin >> a >> b >> c >> d >> e >> f)
	{

		
		//ax+by=c
		//dx+ey=f

		//d(ax+by=c)
		//a(dx+ey=f)
		//ãÓ[ºÓÅ
		//(bd-ae)y=dc-af
		//æÁÄy = (cd-af) / (bd-ae)

		//¯¶­
		//e(ax+by=c)
		//b(dx+ef=f)
		//ãÓ[ºÓÅ
		//(ae-bd)x=ce-bf
		//æÁÄx = (ce-bf) / (ae-bd)

		if(a*e == b*d)
		{
			cout << "ðªêÓÉèÜèÜ¹ñ" << endl;
			continue;
		}

		x = (c*e-b*f) / (a*e-b*d);
		y = (c*d-a*f) / (b*d-a*e);

		//-0Æ©oé±Æª Á½©çÛßé
		Round(x);
		Round(y);

		//¬_Èºà\¦·éæ¤ÉµA¬_æ4ðlÌÜü·é
		cout << setprecision(3);
		cout << setiosflags(ios::fixed);

		cout << x << ' ';
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
const int N = 100010;
int n;
int num=0;
int color[N];
int s[N],t[N];
map<pair<int,int>,int > m;
struct edge{
	int v;
	int next;
}e[2*N];
int p[N],eid;
void init(){
	memset(p,-1,sizeof(p));
	eid=0;
}
void insert(int u,int v){
	e[eid].v=v;
	e[eid].next=p[u];
	p[u]=eid++;
}
void dfs(int u,int fa,int last){
	int cur=1;
	for(int i=p[u];i!=-1;i=e[i].next){
		int v=e[i].v;
		if(v!=fa){
			if(cur==last){
				cur++;
			}
			dfs(v,u,cur);
			color[m[make_pair(u,v)]]=cur;
			cur++;
		}
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	init();
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		insert(u,v);
		insert(v,u);
		s[i]=u,t[i]=v;
		m[make_pair(u,v)]=i;
	}
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=p[i];j!=-1;j=e[j].next){
			cnt++;
		}
		num=max(num,cnt);
	}
	cout<<num<<endl;
	dfs(1,0,0);
	for(int i=1;i<n;i++){
		cout<<color[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13312
N = int(input())
B6 = [6**i for i in range(1,8)]
B9 = [9**i for i in range(1,7)]
L = sorted(list(set(B6+B9)))
dp = [i for i in range(N+1)]
for i in L :
    for j in range(i,N+1) :
        dp[j] = min(dp[j], dp[j-i]+1)
print(dp[-1])


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

typedef long long ll;

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

    int n;cin>>n;
    ll x;cin>>x;
    vector<ll> a(n);
    vector<vector<ll>> cost(n,vector<ll>(n,1e18));
    for(int i=0;i<n;i++){
        cin>>a[i];
        cost[i][0]=a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            int idx=i-j;
            if(idx<0) idx+=n;
            cost[i][j]=min(cost[i][j-1],a[idx]);//+j*x);
            // cost[i][j] := j 回以内で i を買う最小コスト
        }
    }
    ll res=1e18;
    for(int i=0;i<n;i++){
        ll tmp=i*x;
        for(int j=0;j<n;j++){
            tmp+=cost[j][i];
           // cout<<i<<" "<<j<<" "<<cost[i][j]<<endl;
        }
        res=min(res,tmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <queue>

using namespace std;

int N;
int MS[101];
vector<vector<char> > howToGet;
map<vector<char>,char> dp;
void dfs(int kind,int wgt,const vector<char> &v){
  if(kind==0){
    vector<char> nv=v;
    nv.push_back(0);
    dfs(kind+1,wgt,nv);
  }
  else if(wgt==0)howToGet.push_back(v);
  else if(kind==10)return;
  else{
    for(int i=0;i*kind<=10;i++){
      if(wgt-i*kind>=0){
	vector<char> nv=v;
	nv.push_back(i);
	dfs(kind+1,wgt-i*kind,nv);
      }
    }
  }
}

int dfs2(const vector<char> &v){
  if(dp.count(v)!=0)return dp[v];
  int res=0;
  for(int pos=0;pos<(int)howToGet.size();pos++){
    // 1セット分取れるか
    vector<char> nv=v;
    bool ok=true;
    for(int j=1;j<(int)howToGet[pos].size();j++){
      nv[j]-=howToGet[pos][j];
      if(nv[j]<0){
	ok=false;
	break;
      }
    }
    // iセット取れるならとる
    if(ok)res=max(res,dfs2(nv)+1);
  }
  return dp[v]=res;
}

int main(){
  dfs(0,10,vector<char>());
  while(cin>>N&&N){
    vector<char> cnts;
    for(int i=0;i<N;i++)cin>>MS[i];
    for(int i=0;i<=10;i++)cnts.push_back(0);
    for(int i=0;i<N;i++)cnts[MS[i]]++;
    int sum=0;
    for(int i=1;i<=4;i++){
      int a=min(cnts[i],cnts[10-i]);
      cnts[i]-=a;cnts[10-i]-=a;
      sum+=a;
    }
    int a=cnts[5]/2;
    cnts[5]-=2*a;
    sum+=a;
    int res=dfs2(cnts)+sum;
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 9420
import sys, collections

def solve():
    file_input = sys.stdin
    H, W = map(int, file_input.readline().split())
    max_area = 0
    prev = [0] * W
    rect_stack = collections.deque()
    for line in file_input:
        tile_line = map(int, line.split())
        for i, tpl in enumerate(zip(tile_line, prev)):
            t, p = tpl
            if t:
                h = 0
                prev[i] = 0
            else:
                h = p + 1
                prev[i] = h
            if (not rect_stack) or (h > rect_stack[-1][0]):
                rect_stack.append((h, i))
            elif h < rect_stack[-1][0]:
                while rect_stack:
                    if rect_stack[-1][0] >= h:
                        rect_h, rect_i = rect_stack.pop()
                        max_area = max(max_area, rect_h * (i - rect_i))
                    else:
                        break
                rect_stack.append((h, rect_i))
        while rect_stack:
            rect_h, rect_i = rect_stack.pop()
            max_area = max(max_area, rect_h * (W - rect_i))
    print(max_area)

solve()

Measured memory_bytes: 8116
s = gets()
begin
	Time.new(2000 + s[0 .. 1].to_i, s[2 .. 3].to_i, 1)
	yymm = true
rescue
	yymm = false
end

begin
	Time.new(2000 + s[2 .. 3].to_i, s[0 .. 1].to_i, 1)
	mmyy = true
rescue
	mmyy = false
end

puts (yymm ? (mmyy ? "AMBIGUOUS" : "YYMM") : (mmyy ? "MMYY" : "NA"))


Measured memory_bytes: 1788
#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;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
using V = vector<ll>;

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll hcnt[300005],wcnt[300005];

int main() {
  ll Q;
  cin>>Q;
  rep(i,Q){
    ll A,B;
    cin>>A>>B;
    ll l = 0,r=1000000000LL;
    while(r-l>1){
      ll mid = (l+r)/2;
      if(A*B-1>mid*(mid+1LL)) l = mid;
      else r = mid;
    }
    if(A!=B) cout<<l+(A*B-1)/r-1<<endl;
    else cout<<l+(A*B-1)/r<<endl;
  }
}

Measured memory_bytes: 3592
s = list(input())
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in odd:
            print('No')
            break
    else:
        if s[i] not in even:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int a,b,k; cin >> a >> b >> k;

  vector<int> ans;

  for(int i = 0; i < k; i++){
    if(a+i > b) break;
    ans.push_back(a+i);
    ans.push_back(b-i);
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()),ans.end());
  for(int v: ans) cout << v << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

const int MAX = 100000000;

int main(){
  const int n = getInt();
  const int m = getInt();
  const int r = getInt();
  vector<int> p(r);
  vector<vector<int> > d(n, vector<int>(n, MAX));

  REP(i,r) p[i] = getInt() - 1;
  REP(i,n) d[i][i] = 0;
  REP(i,m){
    const int a = getInt() - 1;
    const int b = getInt() - 1 ;
    const int c = getInt();
    d[a][b] = d[b][a] = c;
  }
  REP(k,n) REP(i,n) REP(j,n)
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  int ans = MAX;
  sort(p.begin(), p.end());
  do{
    int tot = 0;
    REP(i,r-1){
      tot += d[p[i]][p[i + 1]];
    }
    ans = min(ans, tot);
  }while(next_permutation(p.begin(), p.end()));

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n;
    while( true ) {
        int a[SIZE];
        cin >> n;
        if( n == 0 ) break;
        ++n;
        for( int i = 0; i < n; ++i ) cin >> a[i];

        for( int i = 0; i < n; ++i ) {
            int dif;
            int nx;
            bool flg = true;
            if( i == 0 ) {
                dif = a[2] - a[1];
                nx = a[2];
                for( int j = 3; j < n; ++j ) {
                    if( j != i ) {
                        if( dif != a[j] - nx ) {
                            flg = false;
                            break;

                        }
                        nx = a[j];

                    }
                }

            } else if( i == 1 ) {
                dif = a[2] - a[0];
                nx = a[2];
                for( int j = 3; j < n; ++j ) {
                    if( j != i ) {
                        if( dif != a[j] - nx ) {
                            flg = false;
                            break;

                        }
                        nx = a[j];
                    }
                }

            } else {
                dif = a[1] - a[0];
                nx = a[1];
                for( int j = 2; j < n; ++j ) {
                    if( j != i ) {
                        if( dif != a[j] - nx ) {
                            flg = false;
                            break;

                        }
                        nx = a[j];

                    }
                }
            }
            if( flg ) {
                cout << a[i] << endl;
                break;

            }
        }
    }
    return 0;
}



Measured memory_bytes: 3192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(a: i64, b: i64) -> i64 {
    (a + b) % 24
}



fn main() {
    input! {
        a: i64,
        b: i64,
    }
   println!("{}", solve(a, b));
}


Measured memory_bytes: 4352
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
//-----------------------------------------
int main(void){
    ll N,M;cin>>N>>M;
    UnionFind uf(N);
    typedef pair<ll,ll> P;
    P p[M];
    REP(i,M){
        cin>>p[i].first>>p[i].second;
        p[i].first--;p[i].second--;
    }
    ll cnt=0;
    REP(i,M){
        uf.init(N);
        REP(j,M){
            if(j==i)continue;
            uf.merge(p[j].first,p[j].second);
        }
        if(uf.size(0)!=N)cnt++;
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 3652