akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX+1];

void m(int i)
{
  int l,r,largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i)
    {
      swap(A[i],A[largest]);
      m(largest);
    }
}

int main()
{
  cin >> H;

  for(int i = 1; i <= H; i++) cin >> A[i];

  for(int i = H / 2; i >= 1; i--)m(i);

  for(int i = 1; i <= H; i++)
    {
      cout << " "<< A[i];
    }
  cout << endl;

  return 0;
}
     



Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
const int INF=1000000007;
typedef long long LL;

LL type1(LL H, LL W){
    if(H<3)return W;
    else{
        LL s[3],res=INF;
        for(LL i=1;i<=H-2;i++){
            s[0]=i*W;
            s[1]=((H-i)/2)*W;
            s[2]=((H-i)-(H-i)/2)*W;
            sort(s,s+3);
            res=min(s[2]-s[0],res);
        }
        return res;
    }
    
}
LL type2(LL H, LL W){
    
        LL s[3],res=INF;
        for(LL i=1;i<=H-1;i++){
        s[0]=i*W;
        s[1]=(H-i)*(W/2);
        s[2]=(H-i)*(W-W/2);
            sort(s,s+3);
            res=min(s[2]-s[0],res);
        }

    return res;
}
int main(){
	LL H,W,ans;
    cin>>H>>W;
    ans=min(type1(H,W),type1(W,H));
    ans=min(type2(H,W),ans);
    ans=min(type2(W,H),ans);
    cout<<ans;
	
}

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

using namespace std;

using int64 = long long;

int main() {
  string s;
  int64 k;
  cin >> s >> k;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '1') {
      --k;
    } else {
      k = 0;
    }
    if(k <= 0) {
      cout << s[i] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

deque<char> stodeq(string s) {
  int n = s.size();
  deque<char> ret;
  rep(i, n) ret.push_back(s[i]);
  return ret;
}

void solve() {
  string sa, sb, sc; cin >> sa >> sb >> sc;
  deque<char> da = stodeq(sa);
  deque<char> db = stodeq(sb);
  deque<char> dc = stodeq(sc);
  int turn = 0;
  while (true) {
    char c = '*';
    if (turn == 0) {
      if (da.size() == 0) {
        outl('A');
        return;
      }
      c = da.front(); da.pop_front();
    } else if (turn == 1) {
      if (db.size() == 0) {
        outl('B');
        return;
      }
      c = db.front(); db.pop_front();
    } else if (turn == 2) {
      if (dc.size() == 0) {
        outl('C');
        return;
      }
      c = dc.front(); dc.pop_front();
    }
    turn = c - 'a';
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
using ll = long long;
using namespace std;

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a <= k)
        cout << "Yay!" << endl;
    else
        cout << ":( " << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N;

int main()
{
  char arare;
  
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%c", &arare);
    if (arare == 'Y') {
      puts("Four");
      return 0;
    }
  }

  puts("Three");
  return 0;
}


Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ; 
    cin >> n ;
    vector<int> A(n) , B(n) ;
    for(int i = 0; i < n; i++){
        cin >> A[i] >> B[i] ;
    }
    sort(A.begin(), A.end()) ;
    sort(B.begin(), B.end()) ;
    int ans = 0 ;
    if ( n & 1 ){
        ans = B[n / 2] - A[n / 2] + 1 ;
    }
    else{
        int first = A[n / 2 - 1] + A[n / 2] ;
        int second = B[n / 2 - 1] + B[n / 2] ;
        ans = second - first + 1 ;
    }
    cout << ans << endl ;
    return 0; 
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    int s=n/1000;
    n=n-s*1000;
    if(!n) cout << 0 << endl;
    else cout << 1000-n << endl;
    return 0;
}


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

int main(){
char a, b, c;
  cin >> a >> b >> c;
char A, B, C;
  cin >> A >> B >> C;
  
  if((a == C) && (b == B) && (c == A)) cout << "YES" << endl;
  else cout << "NO" << endl;

return 0;
  
}

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

int n, m, cnt, d[5], col[MAXN][MAXN][2];
bool vis[MAXN][MAXN][2];

void dfs(int x, int y, int a, int b)
{
	if(x<0 || x>m || y<0 || y>m || vis[x][y][a]) return;
	vis[x][y][a]=true; col[x][y][a]=b;
	for(int i=0; i*i<=d[a]; i++)
	{
		int j=sqrt(d[a]-i*i);
		if(i*i+j*j!=d[a]) continue;
		dfs(x+i, y+j, a, 3-b);
		dfs(x-i, y+j, a, 3-b);
		dfs(x+i, y-j, a, 3-b);
		dfs(x-i, y-j, a, 3-b);
	}
}

void debug()
{
	for(int i=0; i<=m; i++)
	{
		for(int j=0; j<=m; j++) printf("%d ", col[i][j][0]);
		printf("\n");
	}
	printf("\n\n");
	for(int i=0; i<=m; i++)
	{
		for(int j=0; j<=m; j++) printf("%d ", col[i][j][1]);
		printf("\n");
	}
}

int main()
{
	scanf("%d%d%d", &n, &d[0], &d[1]);
	m=n*2-1;
	for(int i=0; i<=m; i++)
	for(int j=0; j<=m; j++)
	{
		if(!vis[i][j][0]) dfs(i, j, 0, 1);
		if(!vis[i][j][1]) dfs(i, j, 1, 1);
	}
	for(int i=0; i<=m; i++)
	for(int j=0; j<=m; j++)
	{
		if(col[i][j][0]==1 && col[i][j][1]==1)
		{
			printf("%d %d \n", i, j);
			if(++cnt==n*n) return 0;
		}
	}
} 

Measured memory_bytes: 38272
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

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

  int i;
  for(i = 0; n/k >= 1; i++) {
    n /= k;
  }
  cout << i+1 << endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
const int N = 111111;
vector<int> a[N];
long long cnt[N];

long long dfs(int v, int p = -1) 
{
    if (a[v].size() == 1) 
    {
        return cnt[v];
    }
    long long mx = 0;
    long long sum = 0;
    for (int i=0;i<a[v].size();i++) 
    { 
        int cur = a[v][i];
        if (cur == p) continue; 
        long long mn = dfs(cur, v); 
        mx = max(mx, mn); sum += mn; 
    }
    long long x = sum - cnt[v];
    int num_sm = (sum - max(sum % 2, 2 * mx - sum)) / 2;

    if(cnt[v] >= x && x >= 0 && x <= sum - mx) 
        return 2 * cnt[v] - sum;
    else {
        puts("NO");
        exit(0);
    }
}
 
int main() 
{ 
    int n; cin >> n; 
    for (int i = 0; i < n; ++i) cin >> cnt[i];
    for (int i = 0; i < n - 1; ++i) 
    { 
        int u, v;  cin >> u >> v; --u, --v; 
        a[u].push_back(v); a[v].push_back(u); 
    }
    int root = 0;
    if (n == 2) 
    {
        if (cnt[0] == cnt[1]) puts("YES"); 
        else puts("NO"); return 0;
    }
    while (a[root].size() == 1) ++root;
    if (dfs(root)) puts("NO"); 
    else puts("YES");
}

Measured memory_bytes: 13440
import sys
input = sys.stdin.readline
r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.mod = mod
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
  def permi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod

f = Factorial(max(r1, c1, r2, c2) * 3, mod)

res = 0
for i in range(r1, r2 + 1):
  res += (f.combi(i + c2 + 1, c2 + 1) * (c2 + 1) - f.combi(i + c1, c1) * c1) % mod * pow(i + 1, mod - 2, mod) % mod
  res %= mod
print(res)

Measured memory_bytes: 211220
#include <bits/stdc++.h>
 
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007
 
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};
 
int n, m, a;
 
int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a;
		if(m == a - 1){
			m++;
		}
	}

	if(m){
		cout << n - m << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def sgined_area(v0, v1, v2):
    a1 = v1[0] - v0[0]
    a2 = v1[1] - v0[1]
    b1 = v2[0] - v0[0]
    b2 = v2[1] - v0[1]
    return a1*b2 - b1*a2

n = int(input())
vors = [[int(a) for a in input().split() ] for _ in range(n)]
vors.sort(key=lambda v: (v[1], v[0]))

over = [vors[0], vors[1]]

for v in vors[2:]:
    while len(over) > 1 and sgined_area(over[-2], over[-1], v) > 0:
        over.pop()
    over.append(v)
    
under = [vors[0], vors[1]]

for v in vors[2:]:
    while len(under) > 1 and sgined_area(under[-2], under[-1], v) < 0:
        under.pop()
    under.append(v)
    
print(len(over) + len(under) - 2)
for v in under[:-1]:
    print(v[0], v[1])

    
    
for v in reversed(over[1:]):
    print(v[0], v[1])


Measured memory_bytes: 30020
#include <cstdio>
#define MAX_N 100040
int input() {
	int a; scanf("%d", &a);
	return a;
}

int main() {
	int N = input(), M = input();
	int h[MAX_N] = { 0 };
	int notgood[MAX_N] = { 0 };
	for (int i = 1; i <= N; i++) h[i] = input();
	while (M--) {
		int a = input(), b = input();
		if (h[a] <= h[b]) notgood[a] = 1;
		if (h[a] >= h[b]) notgood[b] = 1;
	}
	int cnt = 0;
	for (int i = 1; i <= N; i++) cnt += !notgood[i];
	printf("%d", cnt);
  return 0;
}

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

int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }

  int ans=0;
  int total=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      total+=B.at(j)*A.at(i).at(j);
    }
    total+=C;
    if(total>0)ans++;
    total=0;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#define RG register
using namespace std;
const int N=5e5+10;
struct dabt{ int next,to; }e[N<<2];
int head[N],k,n,m,tree[N<<2],ru[N],pos[N],p[N],cnt,ans[N];
priority_queue<int, vector<int> ,greater<int> > pn;
inline void add(int from,int to){e[++k]=(dabt){head[from],to}; head[from]=k; ru[to]++;}
inline int read(){
    char ch=getchar(); int x=0, f=1;
    while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;}
inline int mi(int a,int b){return a<b ? a : b;}
inline int mx(int a,int b){return a>b ? a : b;}
int sum(int l,int r,int st,int ed,int o)
{
    if(st<=l && r<=ed) return tree[o];
    if(l==r) return 2e9;
    int mid=l+(r-l)/2, ans=2e9;
    if(mid>=st) ans=mi(ans,sum(l,mid,st,ed,o<<1));
    if(mid<ed) ans=mi(ans,sum(mid+1,r,st,ed,o<<1|1));
    return ans;
}
void upd(int l,int r,int pos,int kk,int o)
{
    if(l==r) 
    {
        tree[o]=kk;
        return ;
    }
    int mid=l+(r-l)/2;
    if(pos<=mid) upd(l,mid,pos,kk,o<<1);
    else upd(mid+1,r,pos,kk,o<<1|1);
    tree[o]=mi(tree[o<<1],tree[o<<1|1]);
}
inline void topo()
{
    for(RG int i=1;i<=n;i++) if(!ru[i]) pn.push(i);
    while(!pn.empty())
    {
        int x=pn.top(); pn.pop(); ans[x]=++cnt;
        for(RG int i=head[x];i;i=e[i].next) if(--ru[e[i].to]==0) pn.push(e[i].to);
    }
}
int main()
{
//	freopen("Wide Swap.in","r",stdin);
    n=read(); m=read();
    for(RG int i=1;i<=(n<<2);i++) tree[i]=2e9;
    for(RG int i=1;i<=n;i++) pos[p[i]=read()]=i;
    for(RG int i=n,x;i;i--)
    {
        x=sum(1,n,pos[i]+1,mi(pos[i]+m-1,n),1);
        if(x<2e9) add(pos[i],pos[x]);
        x=sum(1,n,mx(pos[i]-m+1,1),pos[i]-1,1);
        if(x<2e9) add(pos[i],pos[x]);
        upd(1,n,pos[i],i,1);
    }
    topo();
    for(RG int i=1;i<=n;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 30336
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210;

ll n;
int t[maxn],tp;
int q[maxn],head,tail;

int main()
{
	scanf("%lld",&n); ++n;
	while(n) t[++tp]=n&1,n>>=1;
	int k=1; q[head=tail=100]=k;
	for(int i=tp-1;i>=1;i--)
	{
		if(t[i]) q[--head]=++k;
		if(i>1) q[++tail]=++k;
	}
	printf("%d\n",(tail-head+1)*2);
	for(int i=head;i<=tail;i++) printf("%d ",q[i]);
	for(int i=1;i<=k;i++) printf("%d ",i);
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int bubbleSort(int *,int );

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

  atai= bubbleSort(ori,n);

  for(i=0;i<n-1;i++){
  printf("%d ",ori[i]);
  }
  printf("%d\n",ori[n-1]);
  printf("%d\n",atai);

  return 0;
}

int bubbleSort(int *ori,int n)
{
  int count=0,i,j;
  int kawari; 

  for(i=0;i<n-1;i++){  
    for(j=n-1;j>i;j--){
      if(ori[j]<ori[j-1]){
      kawari=ori[j];
      ori[j]=ori[j-1];
      ori[j-1]=kawari;
      count++;
      }
    }
  }
    
  return count;
}



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

int main () {
  int n ; 
  cin >> n ;
  string S ; 
  cin >> S;
  int64_t cnt = 0 ; 
  vector<int64_t> A(3) ; 
  
  for(int i = 0 ; i < n ; i++){
    if(S.at(i) == 'R') A.at(0)++ ; 
    if(S.at(i) == 'G') A.at(1)++ ; 
    if(S.at(i) == 'B') A.at(2)++ ;     
  }

  int64_t max_n ; 
  max_n = A.at(0)*A.at(1)*A.at(2) ; 
  
  for(int i = 0 ; i < n-2 ; i++){
    for(int j = i+1 ; j < n-1 ; j++){
      int k  = 2*j - i  ;
      if( k < n ) {
        if ( S.at(i) != S.at(j) && S.at(i) != S.at(k) && S.at(j) != S.at(k) ) cnt++ ; 
      }
    }
  }
  cout << max_n - cnt << endl ; 
}


Measured memory_bytes: 3584
def gcd(a, b):
    while a > 0:
        if a < b:
            a, b = b, a
        a = a % b
    return b

n, x = map(int, input().split())
town = map(int, input().split())

distance = (abs(x-y) for y in town)
res = next(distance)
for d in distance:
    res = gcd(res, d)

print(res)


Measured memory_bytes: 11096
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

const ll M = 1000000007ll;
inline ll func(ll n, ll k) {
    return ((k*(n-k+1)%M)+1) % M;
}

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

    int N, K; cin >> N >> K;
    ll rst = 0;
    for (int k = K; k <= N+1; k++) {
        rst = (rst + func(N, k)) % M;
    }
    cout << rst % M;
}

Measured memory_bytes: 3648
N = gets.to_i
X = gets.split.map(&:to_i).sort

#N = 100
#X = N.times.map{rand(1..100)}.sort

X_min = X.min
X_max = X.max


min = Float::INFINITY
X_min.upto(X_max) do |pp|
  sum = 0
  X.each do |xx|
    sum += (pp - xx) ** 2
  end
  min = min < sum ? min : sum
end

puts min

Measured memory_bytes: 1788
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
bool E[2005][2005];
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}
    
int main() {
    string S;
    queue<char> A;
    queue<char> B;
    queue<char> C;
    cin >> S;
    for(int j = 0;j<S.size();j++)A.push(S.at(j));
    cin >> S;
    for(int j = 0;j<S.size();j++)B.push(S.at(j));
    cin >> S;
    for(int j = 0;j<S.size();j++)C.push(S.at(j));
    
    bool ok = true;
    char now = A.front();
    A.pop();
    while(ok){
        if(A.empty() && now == 'a'){
            cout << "A" << endl;
            ok = false;
        }
        else if(B.empty() && now == 'b'){
            cout << "B" << endl;
            ok = false;
        }
        else if(C.empty() && now == 'c'){
            cout << "C" << endl;
            ok = false;
        }
        //cout << now << endl;
        if(now == 'a'){
            now = A.front();
            A.pop();
            continue;
        }
        else if(now == 'b'){
            now = B.front();
            B.pop();
            continue;
        }
        else if(now == 'c'){
            now = C.front();
            C.pop();
            continue;
        }
        
    }

    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int N;
  cin>>N;
  string A,B,C;
  cin>>A>>B>>C;
  int sum=0;
  for(int i=0;i<N;i++){
    if(A.at(i)==B.at(i)&&B.at(i)==C.at(i)){

    }else if(A.at(i)!=B.at(i)&&A.at(i)!=C.at(i)&&B.at(i)!=C.at(i)){
      sum+=2;
    }else{
      sum++;
    }
  }
  cout<<sum<<endl;
  




  


}


  
  

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>

int main(void){
  int i, n, judge, taro = 0, hanako = 0;
  char taroC[101], hanakoC[101];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf(" %s %s", taroC, hanakoC);
    judge = strcmp(taroC, hanakoC);
    if(judge > 0){
      taro += 3;
    }else if(judge < 0){
      hanako += 3;
    }else{
      taro++;
      hanako++;
    }
  }
  printf("%d %d\n", taro, hanako);
  return 0;
}

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

int a, b;

void input() {
    cin >> a >> b;
}

void solve() {
    int add = a + b;
    int sub = a - b;
    int mul = a * b;
    if ( add > sub ) {
        if ( add > mul) {
            cout << add << endl;
        } else {
            cout << mul << endl;
        }
    } else {
        if (sub > mul) {
            cout << sub << endl;
        } else {
            cout << mul << endl;
        }
    }

}


int main() {
    input();
    solve();

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int a, b;
	char op;
	while (cin >> a >> op >> b) {
		switch (op) {
			case '+':
				cout << a + b << endl;
				break;
			case '-':
				cout << a - b << endl;
				break;
			case '*':
				cout << a * b << endl;
				break;
			case '/':
				cout << a / b << endl;
				break;
			default:
				break;
		}
	}
}

Measured memory_bytes: 1160
import sys

def solve():
      input = sys.stdin.readline
      A, B, C = map(int, input().split())
      K = int(input())
      count = 0
      while B <= A:
            B *= 2
            count += 1
      while C <= B:
            C *= 2
            count += 1
      if count <= K: print("Yes")
      else: print("No")

      return 0

if __name__ == "__main__":
      solve()

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<double> v;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    v.push_back(x);
  }
  while(v.size() > 1){
    sort(v.begin(), v.end());
    double a = v[0], b = v[1];
    v.erase(v.begin(), v.begin() + 2);
    v.push_back((a + b) / 2.0);
  }
  cout << fixed << setprecision(6) << v[0] << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

int main(){
  int h,w,n;
  cin >>h >>w >>n;
  int X=0, Y=0;
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a == 1 && X < x) X = x;
    else if(a == 2 && x < h) h = x;
    else if(a == 3 && Y < y) Y = y;
    else if(a == 4 && y < w) w = y;
  }
  int ans = (h-X)*(w-Y);
  if(h-X<0 || w-Y<0) cout << 0 << endl;
  else cout << (h-X)*(w-Y) << endl;
  return 0;
}

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

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

    a = a % 10;

    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9){
        cout << "hon" << endl;
    }else if(a == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const ll inf = 2e15;
const int mod = 1e9 + 7;
const int N = 1e5 + 15;
int n, a[N], c[N];
vector <int> g[N];

inline void no() {
	cout << "NO" << endl;
	exit(0);
}

void dfs(int v, int p = -1) {
	int sum = 0;
	for(int to : g[v])
		if(to != p) {
			dfs(to, v);
			sum += c[to];
		}
	if(p != -1) {
		c[v] = (g[v].size() == 1 ? a[v] : 2 * a[v]) - sum;
	}
	else {

		if(g[v].size() == 1) {
			if(sum != a[v])
				no();
		}
		else if(sum != 2 * a[v])
			no();
	}
	if(c[v] < 0)
		no();
	for(int to : g[v])
		if(g[v].size() != 1 && ((to != p && c[to] > a[v]) || c[v] > a[v]))
			no();
}

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	for(int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1);
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 13952
// AOJ 0299: Railroad II
// 2017.10.27 bal4u@uu

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

int d[10003];
int n;

char buf[65], *pp;
int getint()
{
	int n = 0;
	while (*pp >= '0') n = (n<<3) + (n<<1) + (*pp++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }
int dis(int s, int d) {	d -= s; if (d < 0) d += n; return d; }

int main()
{
	int m, p, i, x, ans;

	fgets(pp=buf, 64, stdin), n = getint(), pp++, m = getint(), pp++, p = getint();
	for (i = 0; i < m; i++) {
		fgets(pp=buf, 64, stdin), d[i] = getint();
	}
	qsort(d, m, sizeof(int), cmp);
	if (m == 1) {
		ans = dis(d[0], p), x= dis(p, d[0]);
		if (x < ans) ans = x;
	}
	else {
		ans = 2 * n;
		for (i = 0; i < m; i++) {
			int a = d[i], b = d[(i+1)%m], y;
			x = dis(p, a); y = dis(a, p); if (y < x) x = y;
			y = dis(p, b); if (y < x) x = y;
			y = dis(b, p); if (y < x) x = y;
			y = x + n - dis(a, b);
			if ( y < ans) ans = y;
		}
	}
	printf("%d\n", 100*ans);
	return 0;
}

Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 3e6 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll a ,b;
    cin >> a >> b;
    ld x = 0.08, y = 0.1;
    ll ans = 0;
    for (int i = 1; i <= N; i ++) {
    	ld k = i;
    	if (ll(k * x) == a && ll(k * y) == b) {
    		return cout << i, 0;
		}
	}
	cout << -1;
    return (0);
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++) {
			a[i] = scan.nextInt();
		}
		boolean first = true;
		int i;
		for(i=n-1; i>1; i-=2) {
			if(first) {
				first = false;
			}else{
				System.out.print(" ");
			}
			System.out.print(a[i]);
		}
		if(first) {
			first = false;
		}else{
			System.out.print(" ");
		}
		System.out.print(a[i]);
		
		for(i=((i==1)?0:1) ; i<n; i+=2) {
			System.out.print(" ");
			System.out.print(a[i]);
		}
		
	}

}


Measured memory_bytes: 92500
N, K = map(int, input().split())
okashi_map = {}

for num in range(N):
    okashi_map[num+1] = 0

for _ in range(K):
    okashi = input()
    sunuke_list = list(map(int, input().split()))
    for sunuke in sunuke_list:
        okashi_map[sunuke] += 1

find_keys = [k for k, v in okashi_map.items() if v == 0]

print(len(find_keys))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000009
#define N 1000005  //check the limits, man
int main()
{
    int a,b,c,x;
    in2(a,b);
    x=1,c=0;
    while(x<b)
    {
        x+=(a-1);
        c++;
    }
    out(c);
}



Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define inf 105000000000000000

using namespace std;

llint N, W;
llint w[105], v[105];
llint dp[105][105][405];

int main(void)
{
	cin >> N >> W;
	for(llint i = 1; i <= N; i++) cin >> w[i] >> v[i];
	
	llint w1 = w[1];
	for(llint i = 1; i <= N; i++) w[i] -= w1;
	
	llint ans = 0;
	for(llint x = 1; x <= N; x++){
		
		for(llint i = 0; i <= x*4; i++) dp[0][0][i] = -inf;
		dp[0][0][0] = 0;
		
		for(llint i = 1; i <= N; i++){
			for(llint j = 0; j <= x; j++){
				for(llint k = 0; k <= x*4; k++){
					dp[i][j][k] = dp[i-1][j][k];
					if(j > 0 && k >= w[i]) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-w[i]] + v[i]);
				}
			}
		}
		for(llint i = 0; i <= min(x*4, W - x*w1); i++) ans = max(ans, dp[N][x][i]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34688
#include <iostream>
#include <algorithm>

int main(){
    std::string s1, s2;
    std::cin >> s1 >> s2;
    std::sort(s1.begin(), s1.end());
    std::sort(s2.begin(), s2.end(), std::greater<int>());
    if(s1 < s2){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

const int limit = 50;

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

	if (k == 0) {
		cout << (ll)n * n << endl;
		return 0;
	}

	ll ans = 0LL;
	for (int b = 1; b <= n; b++) {
		int x = n / b;
		int r = n % b;
		ans += x * max(0, b - k);
		ans += max(0, r - k + 1);
	}

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

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

string shuffle (string cards, int h) {
  string tmp;
  tmp = cards.substr(0,h);
  cards.erase(0,h);
  cards = cards + tmp;
  
  return cards;
}

int main() {
  string cards;
  int m;
  
  for (;;) {
    cin >> cards;
    if (cards == "-") break;
    
    cin >> m;
    
    int h = 0;
    for (int i = 0; i < m; i++) {
      cin >> h;
      cards = shuffle(cards,h);
    }

    cout << cards << endl;
    
  }
  
  return 0;
}


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

#include <bits/stdc++.h>
// use library with "../library/***.hpp"
#include <vector>
#include <cassert>

class unionfind {
public:
    int _n;
    std::vector<int> d;

    unionfind(int n) :_n(n) {
        d.resize(n, -1);
    }

    int find(int x) {
        assert(0 <= x && x < _n);
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    void unite(int x, int y) {
        assert(0 <= x && x < _n);
        assert(0 <= y && y < _n);
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (d[x] > d[y]) std::swap(x, y);
        d[x] += d[y];
        d[y] = x;
    }

    bool same(int x, int y) {
        assert(0 <= x && x < _n);
        assert(0 <= y && y < _n);
        return find(x) == find(y);
    }

    int size(int x) {
        assert(0 <= x && x < _n);
        return -d[x];
    }
};

using namespace std;

void CConnectCities(std::istream& in, std::ostream& out) {
    int n, m;
    in >> n >> m;
    int ans = n - 1;
    unionfind uf(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        in >> a >> b;
        --a; --b;
        if (!uf.same(a, b)) {
            uf.unite(a, b);
            --ans;
        }
    }
    out << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    CConnectCities(in, out);
    return 0;
}

Measured memory_bytes: 3692
n, m  = gets.chomp.split(" ").map(&:to_i)
a  = gets.chomp.split(" ").map(&:to_i).sort.reverse
afterDivide = [ a[0]/2 ]
a.shift
(m-1).times do
  if !a.empty?
    if afterDivide[0] < a[0]
      afterDivide.push(a[0]/2)
      a.shift
    else
      afterDivide.push(afterDivide[0]/2)
      afterDivide.shift
    end
  else
    afterDivide.push(afterDivide[0]/2)
    afterDivide.shift
  end
end
ans = 0
a.each do |x|
  ans += x
end
afterDivide.each do |x|
  ans += x
end
puts ans

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

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; }

const long long INF = 1LL << 60;

int main(){
  int a, b; cin >> a >> b;
  string s; cin >> s;

  bool ok = true;
  rep(i, s.size()){
    if(s.size() != a+b+1) ok = false;
    if(i < a) if(s[i] < '0' || '9' < s[i]) ok = false;
    if(i == a) if(s[i] != '-') ok = false;
    if(i > a) if(s[i] < '0' || '9' < s[i]) ok = false;
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void)
{
	float t,x;
	scanf("%f %f",&t,&x);
	printf("%f",t/x);
	return 0;
}

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

void findAC(char*,int*,int);

int main(void)
{
    int n,q=0,l,r,i;
    scanf("%d %d",&n,&q);
    char *s=(char*)malloc(sizeof(char)*n);
    int *loc=(int*)malloc(sizeof(int)*n);
    scanf("%s",s);
    findAC(s,loc,n);
    while(q>0)
    {
        scanf("%d %d",&l,&r);
        l--;r--;
        printf("%d\n",loc[r]-loc[l]);
        q--;
    }
    free(s);free(loc);
    return 0;
}

void findAC(char *s,int *loc,int n)
{
    int i=0,same=0,isAC=0;
    while(i<n)
    {
        if(*(s+i)=='A') isAC=1;
        else if(*(s+i)=='C' && isAC==1) same++, isAC = 0;
        else isAC=0;
        loc[i]=same;
        i++;
    }
    return;
}





Measured memory_bytes: 1280
// atcoder/abc163/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  double r;
  while (cin >> r) {
    cout << 2 * 3.14159 * r << endl;
  }

  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }
 
int main(){
    int N, M;
    cin >> N >> M;
    Yes(N == M);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x[5000000], day[13][32], day2[13][32], cnt, a, b, c, d, e, f, daya1, daya2;
int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int days2[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
int main() {
	for (int i = 1; i < 5000000; i++) {
		if ((i % 4 == 0 && i % 100>0) || i % 400 == 0) {
			x[i] = x[i - 1] + 366;
		}
		else {
			x[i] = x[i - 1] + 365;
		}
	}
	for (int i = 1; i <= 12; i++) {
		for (int j = 1; j <= days[i]; j++) {
			day[i][j] = cnt;
			cnt++;
		}
	}
	cnt = 0;
	for (int i = 1; i <= 12; i++) {
		for (int j = 1; j <= days2[i]; j++) {
			day2[i][j] = cnt;
			cnt++;
		}
	}
	while (true) {
		cin >> a >> b >> c >> d >> e >> f;
		if (a < 0) { break; }
		if (b < 0) { break; }
		if (c < 0) { break; }
		if (d < 0) { break; }
		if (e < 0) { break; }
		if (f < 0) { break; }
		daya1 = 0; daya2 = 0;
		daya1 += x[a - 1];
		daya2 += x[d - 1];
		if ((a % 4 == 0 && a % 100>0) || a % 400 == 0) {
			daya1 += day2[b][c];
		}
		else {
			daya1 += day[b][c];
		}
		if ((d % 4 == 0 && d % 100>0) || d % 400 == 0) {
			daya2 += day2[e][f];
		}
		else {
			daya2 += day[e][f];
		}
		cout << daya2 - daya1 << endl;
	}
}

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

int N, Q;
int const INF = INT_MAX;

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    int getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];

        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    SegmentTree seg( vector<int>(3e5+1,0) );
    int ans = 0;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0; i<n; i++) {
        int l = max(0,a[i] - k);
        int r = min(300000,a[i] + k);
        int x = seg.getmin(l,r+1);
        seg.update(a[i],x-1);
    }
    cout << -1*seg.getmin(0,300001) << endl;
}

Measured memory_bytes: 9516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (i == 3)
		{
			cout << '8';
		}
		else
		{
			cout << s.at(i);
		}
	}
	cout << endl;
}


Measured memory_bytes: 256