akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll H, ll W) {
  ll result;
  if (H == 1 || W == 1) {
    result = 1;
  } else {

    ll hw = H * W;
    result = hw / 2 + hw % 2;
  }
  cout << result << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll H;
  scanf("%lld", &H);
  ll W;
  scanf("%lld", &W);
  solve(H, W);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m)-((m)>(n));i!=(n)-((m)>(n));i+=2*((m)<(n))-1)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
int ans[100000];
vector <int> point[100000];

int find(int k) {
	if (ans[k]!=-1) return ans[k];
	int anss=0;
	fop (i,0,point[k].size()) {
		anss=max(anss,find(point[k][i])+1);
	}
	ans[k]=anss;
	return ans[k];
}

int main () {
	int n,m,u,v;
	cin >> n >> m;
	fop (i,0,m) {
		cin >> u >> v;
		point[u-1].pb(v-1);
	}
	fop (i,0,n) ans[i]=-1;
	int maxx=0;
	fop (i,0,n) {
		maxx=max(maxx,find(i));
	}
	cout << maxx << endl;
}

Measured memory_bytes: 8192
import sys

INF = 10 ** 15

n, m = map(int, sys.stdin.readline().split())
abc = map(int, sys.stdin.read().split())
abc = list(zip(*[abc] * 3))

def main():
    dist = [INF] * n
    dist[0] = 0
    for _ in range(n - 1):
        for a, b, c in abc:
            a -= 1; b -= 1; c = -c
            if dist[a] == INF:
                continue
            dist[b] = min(dist[b], dist[a] + c)

    res = dist[n-1]

    for _ in range(n - 1):
        for a, b, c in abc:
            a -= 1; b -= 1; c = -c
            if dist[a] == INF:
                continue
            dist[b] = min(dist[b], dist[a] + c)

    if dist[n-1] == res:
        return -res
    else:
        return 'inf'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define M 2010
#define MOD 924844033
#define rep(i, x, y) for(int i = (x); i <= (y); i ++)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	} while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	} return x * f;
}
bool vis[2010][2];
int f[4010][2010][2];
bool a[4010];
int fac[4010];
int sum;
int main() {
	int n = read(), k = read();
	fac[0] = 1; rep(i, 1, n) fac[i] = 1ll * i * fac[i - 1] % MOD;
	rep(i, 1, n) rep(j, 0, 1) if(!vis[i][j]) {
		int u = i, v = j;
		int now = 0;
		while(u <= n) {
			vis[u][v] = 1;
			u += k; v ^= 1;
			now ++;
		} a[sum += now] = 1;
	} f[1][0][0] = 1;
	rep(i, 2, sum) rep(j, 0, n) {
		(f[i][j][0] += f[i - 1][j][0]) %= MOD;
		(f[i][j][0] += f[i - 1][j][1]) %= MOD;
		if(!a[i - 1]) {
			(f[i][j][1] += f[i - 1][j - 1][0]) %= MOD;
		}
	} int ans = 0;
	rep(i, 0, n) {
		ans = (ans + 1ll * (i & 1 ? -1 : 1) * fac[n - i] * (f[sum][i][0] + f[sum][i][1]) % MOD + MOD) % MOD;
	} cout << ans;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int price = 700;
    if (s[0] == 'o') price += 100;
    if (s[1] == 'o') price += 100;
    if (s[2] == 'o') price += 100;
    cout << price << endl;
}

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

int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int lmonth[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};

int main() {
  int y1,m1,d1,y2,m2,d2;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
    if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;
    int day1 = 0,day2 = 0;

    //day    
    day1 += d1;
    day2 += d2;

    //month
    if(y1 % 4 == 0) {
      if(y1 % 100 == 0 && y1 % 400 != 0){
	for(int i=1;i<m1;i++)
	  day1 += month[i];
      }
      else {
	for(int i=1;i<m1;i++)
	  day1 += lmonth[i];
      }
    }
    else {
      for(int i=1;i<m1;i++)
	day1 += month[i];
    } 

    if(y2 % 4 == 0) {
      if(y2 % 100 == 0 && y2 % 400 != 0){
	for(int i=1;i<m2;i++)
	  day2 += month[i];
      }
      else {
	for(int i=1;i<m2;i++)
	  day2 += lmonth[i];
      }
    }
    else {
      for(int i=1;i<m2;i++)
	day2 += month[i];
    } 
    


    //year
    for(int i=1;i<y1;i++) {
      if(i % 4 == 0) {
	if(i % 100 == 0 && i % 400 != 0){
	  day1 += 365;
	}
	else {
	  day1 += 366;
	}
      }
      else {
	day1 += 365;
      }
    }

    for(int i=1;i<y2;i++) {
      if(i % 4 == 0) {
	if(i % 100 == 0 && i % 400 != 0){
	  day2 += 365;
	}
	else {
	  day2 += 366;
	}
      }
      else {
	day2 += 365;
      }
    }
    
    cout << day2-day1 << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int qp[1005][1005];
int main()
{
	int h,w,a,b;
	cin >> h >> w >> a >> b;

	for(int i=1;i<=b;i++){
		for(int j=1;j<=a;j++){
			qp[i][j]=1;
		}
	}

	for(int i=b+1;i<=h;i++){
		for(int j=a+1;j<=w;j++){
			qp[i][j]=1;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			printf("%d",qp[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    string s;
    std::cin >> s;

    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) {
        cout << YES << endl;
    } else
        cout << NO << endl;
}


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

int H, W;
vector<string> P, R, B;

void init_data(void) {
	string x(W - 1, '#');
	string y(W - 1, '.');
	R.resize(H);
	B.resize(H);
	string r0 = x + ".";
	string r1 = "#" + y;
	for (int j = 0; j < H; ++j) {
		if (j % 2 == 0)
			R[j] = r0;
		else
			R[j] = r1;
	}
	string b0 = y + "#";
	string b1 = "." + x;
	for (int j = 0; j < H; ++j) {
		if (j % 2 == 0)
			B[j] = b0;
		else
			B[j] = b1;
	}
}

void solve(void) {
	for (int j = 1; j < H - 1; j += 2) {
		for (int i = 1; i < W - 1; ++i) {
			if (P[j][i] == '#')
				R[j][i] = '#';
		}
	}
	for (int j = 2; j < H - 1; j += 2) {
		for (int i = 1; i < W - 1; ++i) {
			if (P[j][i] == '#')
				B[j][i] = '#';
		}
	}
}

int main(void) {
	cin >> H >> W;
	P.resize(H);
	for (int j = 0; j < H; ++j)
		cin >> P[j];

	init_data();
	solve();

	for (int j = 0; j < H; ++j)
		cout << R[j] << '\n';
	cout << '\n';
	for (int j = 0; j < H; ++j)
		cout << B[j] << '\n';

	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    FasterIO
    ll n, k, a, b, x, y;
    cin >> n >> k;
    a=n%k;
    b=k-a;
    x=min(a, b);
    cout << x << endl;
    return 0;

}


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

int main()
{
    int value = 0;
    int count = 0;

    do
    {
        if (count > 0)
            cout << "Case " << count << ": " << value << endl;

        ++count;
        cin >> value;
        
    } while(value != 0);
    
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main()
{
	while(1){
      int m, n;
      scanf("%d %d", &m, &n);
      if(m==0 && n==0) return 0;
      bool used[7368792]={};
      int ans=m;
      int mx=7368791;
      for(int i=1; i<=n; i++){
        while(used[ans]==1) ans++;
        for(int j=1; j*ans<=mx; j++){
          used[j*ans]=1;
        }
      }
      while(used[ans]==1) ans++;
      printf("%d\n", ans);
    }
	
	return 0;
}



Measured memory_bytes: 10380
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])
bc.reverse()

flg = 0
cnt = 0

for i in range(n):
  if flg < m and bc[flg][1] >a[i]:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
  else:
      break

print(sum(a))

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

int main(){

    int n;

    cin >> n;

    int x[n];

    priority_queue<int> q;

    for(int i =0; i<n; i++){
        cin >> x[i];
        q.push(x[i]);
    }

    for(int i=0; i<n/2-1; i++){
        q.pop();
    }

    int rmedi = q.top();
    q.pop();
    int lmedi = q.top();

    if(rmedi == lmedi){
        for(int i=0; i<n; i++){
            cout << rmedi << endl;
        }
    }
    else {
        for (int i = 0; i < n; i++) {
            if (x[i] <= lmedi) {
                cout << rmedi << endl;
            } else {
                cout << lmedi << endl;
            }
        }
    }

    return 0;

}


Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int H, W;
const int MAX_H = 2000;
string S[MAX_H];

int main(){
  cin >> H >> W;
  REP(i, H) cin >> S[i];

  vpll vh[H], vw[W];
  REP(i, H) {
    ll ct = 0, x = 0;
    REP(j, W) {
      if(S[i][j] == '#') {
        vh[i].pb(pll(x, ct));
        ct = 0;
        x = j + 1;
      } else {
        ct++;
      }
      if(j == W - 1) vh[i].pb(pll(x, ct));
    }
  }

  REP(j, W) {
    ll ct = 0, x = 0;
    REP(i, H) {
      if(S[i][j] == '#') {
        vw[j].pb(pll(x, ct));
        ct = 0;
        x = i + 1;
      } else {
        ct++;
      }
      if(i == H - 1) vw[j].pb(pll(x, ct));
    }
  }

  ll ans = 0;
  
  REP(i, H) {
    REP(j, W) {
      if(S[i][j] == '#') continue;
      ans = max(ans, (upper_bound(ALL(vh[i]), pll(j + 1, -1)) - 1)->S + (upper_bound(ALL(vw[j]), pll(i + 1, -1)) - 1)->S - 1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 132480
#include <iostream>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 1; i <= m; i++){
	int days;
    cin >> days;
    sum += days;
  }
  cout << ((sum <= n) ? (n - sum) : -1) << endl;
  return 0;
}


Measured memory_bytes: 3624
n = int(input())
arr = list(map(int,input().split()))
ans = 0

def half(n):
    return n / 2

def check_odd(n):
    if n % 2 != 0:
        return False
    else:
        return True
flg = list(map(check_odd,arr))

while False not in flg:
    arr = list(map(half,arr))
    flg = list(map(check_odd,arr))
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

long long k,x,y;
int main()
{
  scanf ("%lld %lld %lld",&k,&x,&y);
  long long d = abs(x) + abs(y);
  
  vector<pair<long long, long long> > ans;
  
  if (k % 2 == 0 && d % 2){
puts("-1");
    return 0;
  }
  
  if (d == k) ans.emplace_back(x,y);
  else{
	long long t = (d + k - 1) / k;
    if (t <= 1) t++;
    if (t % 2 * k % 2 != d % 2) t++;
    
    while (t > 2){
    ans.emplace_back(x,y);
      if (abs(x) >= k){
		if (x > 0) x -= k;
        else x += k;
      }
      else if (abs(y) >= k){
		if (y > 0) y -= k;
        else y += k;
      }
      else if (abs(x) >= abs(y)){
        long long r = k - abs(x);
        x = 0;
        if (y > 0) y -= r;
        else y += r;
      }
      else{
        long long r = k - abs(y);
        y = 0;
        if (x > 0) x -= r;
        else x += r;
      }
      t--;
    }
    
    ans.emplace_back(x,y);
    if (x + y >= 0){
		if (y - x >= 0){
			y = (y - x) / 2;
          	x = k - y;
        }
        else{
			x = (x - y) / 2;
          y = k - x;
        }
    }
    else{
x = -x; y = -y;
		if (y - x >= 0){
			y = (y - x) / 2;
          	x = k - y;
        }
        else{
			x = (x - y) / 2;
          y = k - x;
        }
x = -x; y = -y;
    }
    ans.emplace_back(x,y);
    
    reverse(ans.begin(),ans.end());
  }
   
  printf ("%d\n",ans.size());
  for (auto &p : ans) printf ("%lld %lld\n",p.first,p.second);
return 0;
}

Measured memory_bytes: 6764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <tuple>
#include <set>

typedef long long ll;

using namespace std;
int main() {
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for(ll& ac : a){ cin >> ac;}
    for(ll& ac : b){ cin >> ac;}
    for(ll& ac : c){ cin >> ac;}
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    reverse(a.begin(),a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    
    map<vector<ll> ,ll> nx;
    map<vector<ll> , int> sol;
    vector<ll> pres{0,0,0};
    vector<ll> mx_ind{x,y,z};
    sol[pres] +=1;
    int ct = 1;
    cout << a[pres[0]] + b[pres[1]] + c[pres[2]] << endl;
    while(ct < k){
        for(int i=0; i<3; ++i){
            auto nxv = pres;
            nxv[i] +=1;
            if (nxv[i]<mx_ind[i] & nx.count(nxv)==0){
                nx[nxv] = a[nxv[0]] + b[nxv[1]] + c[nxv[2]];
            }
        }
        auto mx_it = max_element(nx.begin(), nx.end(),
                                 [](auto v1, auto v2){return v1.second < v2.second;}
                                 );
        pres = mx_it->first;
        cout << mx_it->second << endl;
        nx.erase(mx_it);
        ++ct;
    }
    
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;

    if (S == U) {
        A -= 1;
    } else {
        B -= 1;
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int D(int x)
{
  int ret = 0;
  for(int i = 1; i <= x; i++) {
    if(x % i == 0) ret++;
  }
  return(ret);
}

int main()
{
  int data[14];
  fill_n(data, 14, INF);
  for(int i = 1; i < 10000; i++) {
    data[min(13, D(i))] = min(data[min(13, D(i))], i);
  }
  int N;
  cin >> N;
  cout << data[N] << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
   ll n; cin>>n;
   ll res=1e18;
   for(ll i=2; i*i<=n; i++){
        if(n%i==0){
          res = min(res,i+n/i - 2);
        }
   }
   cout<<min(res,n-1);
}


Measured memory_bytes: 256
{-
問題文
N個の品物があります。品物には 1,2,…,N と番号が振られています。
各 i (1≤i≤N) について、品物 i の重さは wi で、価値は viです。

太郎君は、N個の品物のうちいくつかを選び、ナップサックに入れて持ち帰ることにしました。
ナップサックの容量は W であり、持ち帰る品物の重さの総和は W以下でなければなりません。

太郎君が持ち帰る品物の価値の総和の最大値を求めてください。

制約
入力はすべて整数である。
    1≤N≤100
    1≤W≤10^5
    1≤wi≤W
    1≤vi≤10^9

入力
入力は以下の形式で標準入力から与えられる。
    N W
    w1 v1
    w2 v2
    :
    wN vN

出力
太郎君が持ち帰る品物の価値の総和の最大値を出力せよ。
-}

import Control.Monad
import Control.Monad.ST
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Array
import Data.Array.ST

main = do
    [n,w]<-map read.words<$>getLine::IO [Int]
    wvs<-replicateM n $ unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[[Int]]
    print $ f n w wvs

f n w wvs = runST $ do
    dp <- newArray ((0,0),(n,w)) 0 :: ST s (STUArray s (Int,Int) Int)
    forM_ [(i,wi,vi,j)|(i,[wi,vi])<-zip [1..] wvs,j<-[0..w]] $ \(i,wi,vi,j) ->
        if j<wi then
            writeArray dp (i,j) =<< readArray dp (i-1,j)
        else 
            writeArray dp (i,j) =<< maximum <$> sequence [readArray dp (i-1,j), (+vi)<$>readArray dp (i-1,j-wi)]
    readArray dp (n,w)


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

using namespace std;

long long gcd(long long A, long long B){
    if(B == 0) return A;
    else return gcd(B, A%B);
}

int main(){
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i=0; i<N; ++i){
        cin >> a[i]; 
    }

    long long ans = 0;
    for(int i=0; i<N; ++i){
        ans = gcd(ans, a[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
defmodule Main do
 def step(heights), do: step(heights, 0)
 defp step([], acc), do: acc
 defp step([head|tail], acc) do
   cond do
     head <= Enum.at(tail,0) -> step(tail,acc)
     head > Enum.at(tail,0) -> step(func(head,tail), acc+ head - Enum.at(tail,0))
   end
 end
 defp func(fst, list), do: [fst | tl list]
 

 def main do
    _num = IO.read(:line) |> String.trim() |> String.to_integer
    heights = IO.read(:line) |> String.trim() |> String.split(" ") |>  Enum.map(&String.to_integer/1)
    IO.inspect step(heights)
 end
end

Measured memory_bytes: 80196
from collections import deque
 
N = int(input())
edges = [[] for _ in range(N + 1)]
ends = []
 
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    ends.append(b)
 
nodes = deque([1])
count = [0] * (N + 1)
 
while nodes:
    node = nodes.popleft()
    nodes.extend(edges[node])
 
    c = 0
    for n in edges[node]:
        c += 1 + (c + 1 == count[node])
        count[n] = c
 
print(max(count))
for i in ends:
    print(count[i])

Measured memory_bytes: 70176
# クリスマスもあと半年となり、トナカイのAtCoDeer君はプレゼントを配る計画を立てることにしました。
# TopCoDeer通りにはN個の家が並んでいます。i個目の家は座標aiにあります。彼はこのすべての家にプレゼントを配ることにしました。
# 好きな場所から開始し好きな場所で終了することができる時、最小の移動距離を求めなさい。

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

print(max(a) - min(a))

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

int main() {
    string w;
    cin >> w;

    vector<int> ab(26);
    char cbuff;
    rep(i,w.size()) {
        ab.at(w.at(i)-'a')++;
    }

    bool beautiful=true;
    rep(i,ab.size()) {
        if (ab.at(i)%2) {
            beautiful=false;
            break;
        }
    }

    if (beautiful) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  string s;
  cin >> s;
  if (s.substr(0, 4) == "YAKI") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

class ALDS1
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        string[] x = new string[a];
        string[] y = new string[a];
        string str = Console.ReadLine();
        for (int i = 0; i < a; i++)
        {
            x[i] = str.Split(' ')[i];
            y[i] = x[i];
        }
        string c;
        for (int i = 0; i < a - 1; i++)
        {
            for (int j = a - 1; j > i; j--)
            {
                if (x[j][1] < x[j - 1][1])
                {
                    c = x[j - 1]; x[j - 1] = x[j]; x[j] = c;
                }
            }
        }
        for (int i = 0; i < a; i++)
        {
            if (i == a - 1) Console.WriteLine("{0}{1}", x[i][0], x[i][1]);
            else Console.Write("{0}{1} ", x[i][0], x[i][1]);
        }
        Console.WriteLine("Stable");
        int b;
        for (int i = 0; i < a; i++)
        {
            b = i;
            for (int j = i; j < a; j++)
            {
                if (y[j][1] < y[b][1])
                {
                    b = j;
                }
            }
            if (i != b)
            {
                c = y[i]; y[i] = y[b]; y[b] = c;
            }
        }
        for (int i = 0; i < a; i++)
        {
            if (i == a - 1) Console.WriteLine("{0}{1}", y[i][0], y[i][1]);
            else Console.Write("{0}{1} ", y[i][0], y[i][1]);
        }
        int d = 0;
        for (int i = 0; i < a; i++)
        {
            if (x[i][0] == y[i][0]) d++;
        }
        if (a == d) Console.WriteLine("Stable");
        else Console.WriteLine("Not stable");
    }
}

Measured memory_bytes: 5388
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    q=4*q
    h=2*h
    sp1=min(q,h,s)
    dp2=min(2*q,2*h,2*s,d)
    c=n//2
    if n%2==0:
        print(c*dp2)
    else:
        print(c*dp2+sp1)
    

if __name__=="__main__":
    main()

Measured memory_bytes: 9160
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
lli MOD = 1000000;
int main()
{
    lli a[100005];
    lli n;
    cin >> n;
    lli b[100005];
    lli sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }
    lli sumn = n * (n + 1) / 2;
    if (sum % sumn) {
        cout << "NO" << endl;
        return 0;
    }
    lli l = sum / sumn;
    rep(i, n) b[i] = a[(i + 1) % n] - a[i];
    rep(i, n)
    {
        if (b[i] - l > 0 || ((-b[i] + l) % n)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1920
s = input()
if s[0] == 'W':
    ans = s.count('WB')
elif s[0] == 'B':
    ans = s.count('BW')
if s[0] == s[len(s) - 1]:
    a = 1
else:
    a = 0
print(0 if ans==0 else ans * 2 - 1 + a)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 300;
double ans[N][N][N];
bool done[N][N][N];

double solve(int f1, int f2, int f3, int tot) {
  if (done[f1][f2][f3]) return ans[f1][f2][f3];
  const int n = f1 + f2 + f3;
  double res = 0;
  if (f1 > 0) {
    res += f1 * solve(f1 - 1, f2, f3, tot);
  }
  if (f2 > 0) {
    res += f2 * solve(f1 + 1, f2 - 1, f3, tot);
  }
  if (f3 > 0) {
    res += f3 * solve(f1, f2 + 1, f3 - 1, tot);
  }
  res = (res + tot)/n;

  done[f1][f2][f3] = true;
  ans[f1][f2][f3] = res;
  return res;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  VI f(4);
  for (int a; cin >> a; f[a]++);
  done[0][0][0] = true;
  cout << fixed << setprecision(10) << solve(f[1], f[2], f[3], n) << endl;

  return 0;
}


Measured memory_bytes: 125168
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
        A[i] -= B[i]
    else:
        ans += A[i]
        yoryoku = B[i] - A[i]
        A[i] = 0
        if A[i + 1] >= yoryoku:
            ans += yoryoku
            A[i+1] -= yoryoku
        else:
            ans += A[i+1]
            A[i + 1] = 0
print(ans)


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

ll mod = 1e9+7;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}



int N;
vector<vector<int>> edge;
vector<vector<int>> child;
vector<int> ts;
vector<int> rs;

int calcrs(int now, int par){
    ts.push_back(now);
    rs[now] = 1;
    for (int c : edge[now]) {
        if (c == par) continue;
        child[now].push_back(c);
        rs[now] += calcrs(c, now);
    }
    return rs[now];
}

int main(){
    cin >> N;
    edge.resize(N+1);
    child.resize(N+1);
    rs.resize(N+1);
    for (int i = 0; i < N-1; i++) {
        int A, B;
        cin >> A >> B;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    calcrs(1, 0);
    
    for (int i = N-1; i >= 0; i--) {
        rs[ts[i]] = 1;
        for (int t : child[ts[i]]) {
            rs[ts[i]] += rs[t];
        }
    }
    
    vector<ll> pow(N+1, 1);
    for (int i = 1; i <= N; i++) pow[i] = pow[i-1]*2%mod;
    
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ll t = pow[N-1]-1;
        t += mod-(pow[N-rs[i]]-1);
        for (int c : child[i]) {
            t += mod-(pow[rs[c]]-1);
        }
        ans += t;
        ans %= mod;
    }
    cout << ans*modinv(pow[N])%mod << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int d, t, s;
  cin >> d >> t >> s;
  d = (d+s-1) / s;
  if (d <= t) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3608
/*
 *  ॐॐॐॐ
 *  मनुष्य के साहस से बड़ा कोई लक्ष्य नहीं, हारा वही जो लड़ा नहीं ।। 
 *          ---- स्वामी विवेकानंद जी
 */
/*
 * Author: @SumitRaut
 */


#include <bits/stdc++.h>
#define debug1(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 sbc __builtin_popcount
#define pb push_back
#define em emplace
#define emb emplace_back
#define ll long long
int mod = 1e9+7;

template<typename T> void smax(T& a, T b) { if(a<b) a=b; }
template<typename T> void smin(T& a, T b) { if(a<b) a=b; }
template<typename T> T pw(T a,T b) { T p=1,one=1; while(b) { if(b&one) p=p*a; a=a*a; b >>=1; } return p; }
template<typename T> T gcd(T x,T y) { /* if(y==0) return x; return gcd (y,x%y); */ T t; while(y!=0) { t=y; y=x%y; x=t; } return x; }
template<typename T> T pwm(T a,T b) { T p=1,one=1,md=1e9+7; while(b) { if(b&one) p=p*a%md; a=a*a%md; b >>=1; } return p; }

using namespace std;
struct Timer { chrono::high_resolution_clock::time_point start_t, end_t; Timer() { start_t=chrono::high_resolution_clock::now(); } ~Timer() { end_t = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t); cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n'; } };

inline void solve() {
    // Timer timer;
 int n;
 cin>>n;
 n*=2;
 int arr[n],i=-1,ans=0;
 while(++i<n) cin>>arr[i];
 sort(arr,arr+n);
 i=0;
 while(i<n) ans+=arr[i],i+=2;
 cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t; cin>>t; while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 256
from sys import stdin

def main():
    A, B, K = map(int, input().split())

    ans = 0
    for i in range(100, 0, -1):
        if not A % i and not B % i:
            ans += 1
            if ans == K:
                print(i)
                break

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3064
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<string, ll> ma;
    rep(i, N)
    {
        string S;
        cin >> S;
        ++ma[S];
    }
    ll maxCount = 0;
    for (auto& p : ma)
    {
        chmax(maxCount, p.second);
    }
    for (auto& p : ma)
    {
        if (maxCount == p.second)
        {
            cout << p.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 18728
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int main(){
  lint a,b,c;cin>>a>>b>>c;
  lint res=min({
    c%2*a*b,
    b%2*a*c,
    a%2*b*c
  });
  cout<<res<<endl;
  return 0;
}





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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;

string s;
lli n;
lli cnt[e5];
lli l;
lli ans = 0;
lli g_ans = INT_MAX;

int main(){
	cin >> s;
	n = s.size();
	for(char c = 'a';c <= 'z';c++){
		l = 0;
		ans = 0;
		for(lli i = 0;i < n;i++){
			if(s[i] != c){
				l++;
			}else{
				ans = max(ans,l);
				l=0;
			}
		}
		ans = max(ans,l);
		g_ans = min(g_ans,ans);
	}

	cout << g_ans << endl;

}


Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate

h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [["" for i in range(w)]for j in range(h)]

for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]

lin = [["#" for i in range(w+2)]for j in range(h+2)]

for i in range(h):
    for j in range(w):
        lin[i+1][j+1] = li[i][j]

for i in lin:
    print("".join(i))

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

ll N;
ll K, A, B;
ll ret = 1;

void input () {
    cin >> K >> A >> B;
}

void solve() {
    if(B-A<=2){
        ret += K;
        return;
    }
    while(ret < A){
        K--;
        ret++;
        if(K==0){
            return;
        }
    }
    if(K%2==1){
        K--;
        ret++;
    }
    ret += (K/2)*(B-A);
}

int main(void){
    // Your code here!
    input();
    solve();
    cout << ret << endl;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	double ans = 0;
	int tmp;
	double a, b;
	int h, m;
	cin >> a >> b >> h >> m;
	double th, tm;
	tm = (double) m * 6.0;
	th = (double) h * 30.0 + 30.0 * m / 60;
	cout << setprecision(20) << sqrt(a * a + b*b - 2*a*b*cos((tm - th)* 2 *M_PI / 360))  << endl;
}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 2510;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    b += c;
    cout << max(b - a, 0);
    return 0;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int l, r, d;

    cin >> l >> r >> d;
    cout << r/d-(l-1)/d << '\n';

    return 0;
}


Measured memory_bytes: 3636
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

#define INF 93193111451418101
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define FOR(a, s, n) for(int a = s; a < n; ++a)

#define IN std::cin
#define OUT std::cout
using std::endl;

#define LL long long int
#define ll long long int

#define itn int
#define fro for

int main()
{

	ll A, B, C, D, ans = 0, buf;

	IN >> A >> B >> C >> D;

	if (A + B < C + D) puts("Right");
	if (A + B == C + D) puts("Balanced");
	if (A + B > C + D) puts("Left");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 100002



int32_t main()
{   
    io
    
    string s;

    cin>>s;

    if(s=="Sunny")
        cout<<"Cloudy";
    else if(s=="Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";

 
return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }
inline void Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int k;
	cin>>k;
	queue<int> task[2];
	for(int i=1;i<=9;i++)task[0].push(i);
	vector<int> s;
	for(int i=1;i<=9;i++)s.push_back(i);
	int now=0;
	while((int)s.size()<k){
		while(!task[now].empty()){
			int a=task[now].front();
			task[now].pop();
			int b=a%10;
			for(int i=b-1;i<b+2;i++){
				if(0<=i&&i<=9){
					s.push_back(a*10+i);
					task[(now+1)%2].push(a*10+i);
				}
			}
		}
		if(now==0)now=1;
		else now=0;
	}
	sort(all(s));
	//for(int i=0;i<(int)s.size();i++)cout<<s[i]<<" ";
	//cout<<endl;
	cout<<s[k-1]<<endl;
}

Measured memory_bytes: 3024
S = input()
T = input()
s = len(S)
t = len(T)

if t > s:
	print("UNRESTORABLE")
else:
	ans = []
	for i in range(s - t + 1):
		ju = "YES"
		for j in range(t):
			if S[i + j] != "?" and S[i + j] != T[j]:
				ju = "NO"
				break
		if ju == "YES":
			x = S[:i] + T + S[i + t:]
			ans.append(x.replace("?", "a"))
	if ans == []:
		print("UNRESTORABLE")
	else:
		ans = sorted(ans)
		print(ans[0])




Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

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

	if(a>=3200){
		cout << s << endl;
	}else{
		cout << "red" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	a := strings.Split(sc.Text(), " ")
	sort.Strings(a)
	if strings.Join(a, "") == "557" {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640