akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
		cout << 0 << endl;
		PAU;
		return 0;
	}
	if (A == B && B == C) {
		cout << -1 << endl;
		PAU;
		return 0;
	}
	int ans = 0;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		int a = (B + C) / 2;
		int b = (A + C) / 2;
		int c = (A + B) / 2;
		A = a;
		B = b;
		C = c;
		ans++;
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include<stdio.h>

#define LENn 100000

int binarySeach(int a[],int n,int key){
  int left = 0;
  int right = n;
  int mid;
  while(left<right){
    mid = (left+right)/2;
    if(a[mid]==key){
      return 1;
    }else if(key<a[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }
  return 0;
}

int main(){
  int a[LENn],n;
  scanf("%d",&n);
  for(int i=0;i<n; i++){
    scanf("%d",&a[i]);
  }
  int q,key;
  int sum=0;
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySeach(a,n,key)) sum++;
  }
  printf("%d\n",sum);
}



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

int main(){
  int a,b; cin >> a >> b;
  int count=0;
  for(int i=a; i<=b; i++){
    if(i/10000==i%10&&(i%10000)/1000==(i%100)/10){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,t,tt = 0;
	cin >> n >> k;
	t = n / k;
	if(k % 2 == 0 && n >= k / 2) tt = (n - k / 2) / k + 1;
	cout << t * t * t + tt * tt * tt << endl;
	return 0;
}

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

n, k, q = map(int, input().split())
aq = [int(input()) for _ in range(q)]

point = [0 for _ in range(n+1)]

for i in aq:
    point[i] += 1

for j in range(1, n+1):
    if k - q + point[j] > 0:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 8644
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, x, m;
	cin >> n >> x >> m;
	vector <pair<ll, ll> > vis(m, {0, 0});
	vis[x].ff = x;
	vis[x].ss = 1;
	ll sum = x;
	ll c = 2;
	while (true) {
		if (c > n)
			break;
		ll cur = (x * x) % m;
		if (vis[cur].ss == 0) {
			vis[cur].ss = c;
			c++;
			sum += cur;
			vis[cur].ff = sum;
			x = cur;
			continue;
		}
		ll cyc = c - vis[cur].ss;
		ll csum = sum - vis[cur].ff + cur;
		ll lef = n - c + 1;
		sum += (lef / cyc) * csum;
		lef = lef - (lef / cyc) * cyc;
		//cout << lef << "\n";
		while (lef--) {
			cur = (x * x) % m;
			sum += cur;
			x = cur;
		}
		break;
	}
	cout << sum << "\n";
}


Measured memory_bytes: 4780
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
    var color =  ReadLine().Split(' ');
    var num = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var take = ReadLine();
    
    if(take.Equals(color[0])){
      Write(num[0] - 1 + " " + num[1]);
    }else{
      Write(num[0] + " " + (num[1] - 1));
    }
  }
}

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

using namespace std;

int main()
{
    int n;
    while (scanf("%d", &n) && n){
        int s = 0;
        for (int i = 1; i * i <= n; i++){
            if (n % i == 0){
                if (i != n / i) s += n / i;
                s += i;
            }
        }
        
        if (2 * n > s) printf("deficient number\n");
        if (2 * n < s) printf("abundant number\n");
        if (2 * n == s) printf("perfect number\n");
    }
    
    return (0);
}

Measured memory_bytes: 1168
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i;
  int A[N];
  int B[N-1];
  
  for(i=0; i<N-1; i++)
    cin >> B[i];

  A[0] = B[0];
  //  A[1] = B[0];
  
  for(i=0; i<N-1; i++){
    if(A[i]>B[i])
      A[i] = B[i];
    A[i+1] = B[i];
  }

  int sum = 0;

  for(i=0; i<N; i++){
    // cout << A[i] << endl;
    sum += A[i];
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, i, j, k, l, m, n, ans, tmp, hoge;

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

    cin >> a >> b;

    if (a == 1 || b == 1)
        cout << 1 << endl;
    else
        cout << (a * b + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

int main()
{
    int c[4][4];
    for (int i = 1; i <= 3; ++i)
    {
        for (int j = 1; j <= 3; ++j)
        {
            cin >> c[i][j];
        }
    }

    for (int a1 = 0; a1 <= 100; ++a1)
    {
        int b1 = c[1][1] - a1;
        int b2 = c[1][2] - a1;
        int b3 = c[1][3] - a1;
        if ((c[2][1] - b1 == c[2][2] - b2) && (c[2][2] - b2 == c[2][3] - b3))
        {
            if ((c[3][1] - b1 == c[3][2] - b2) && (c[3][2] - b2 == c[3][3] - b3))
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = [str(input()) for _ in range(N)]
check = []
ans = 0

for s in S:
  s = sorted(s)
  check.append(''.join(s))

L = Counter(check)
for l,n in L.items():
  ans += n*(n-1)//2
print(ans)

Measured memory_bytes: 26860
//
// Created by yamunaku on 2019/12/01.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CYESA cout<<"Yay!"<<endl
#define CNOA cout<<":("<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi c(n, 0);
    c[0] = 3;
    ll ans = 1;
    rep(i, n){
        ans = ans * c[a[i]] % MOD;
        c[a[i]]--;
        c[a[i] + 1]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,n;
    cin>>n;
    vector<long long int> h(n);
    for(i=0;i<n;i++)
        cin>>h[i];
    vector<long long int> lcost(n,0); 
    lcost[0]=0;
    lcost[1]=abs(h[0]-h[1]);
    for(i=2;i<n;i++)
    {
        lcost[i]=min(abs(h[i]-h[i-1])+lcost[i-1],lcost[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<lcost[n-1]<<endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    vector<string> word = {{"maerd"}, {"remaerd"}, {"resare"}, {"esare"}};
    string s;
    cin >> s;
    int len = s.size();
    reverse(s.begin(), s.end());
    int ans = 0;
    bool can = true;
    for (int i = 0; i < s.size();i++){
        string tmp="";
        rep(j,5)tmp += s[i+j];
        i += 4;
        if(tmp==word[0]||tmp==word[3]){
            continue;
        }
        i++;
        tmp += s[i];
        if(tmp==word[2])
            continue;
        i++;
        tmp += s[i];
        if(tmp==word[1])
            continue;
        can = false;
        break;
    }
    if(can){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
x, k, d = map(int, input().split())

if x < 0:
    if k <= abs(x) // d:
        ans = abs(x + d * k)
    else:
        k -= abs(x) // d
        x += d * (abs(x) // d)
        if k % 2 == 0:
            ans = abs(x)
        else:
            if x >= 0:
                ans = abs(x - d)
            else:
                ans = abs(x + d)
elif x > 0:
    if k <= x // d:
        ans = abs(x - d * k)
    else:
        k -= x // d
        x -= d * (x // d)
        if k % 2 == 0:
            ans = abs(x)
        else:
            if x >= 0:
                ans = abs(x - d)
            else:
                ans = abs(x + d)
elif x == 0:
    ans = d

print(ans)


Measured memory_bytes: 9132
#include <stdio.h>

const long long sup = (long long)1 << 60;

typedef struct {
	int t, h, cost;
} edge;

int main()
{
	int i, u, w, c, N, M;
	edge e[2001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d %d", &u, &w, &c);
		e[i].t = u;
		e[i].h = w;
		e[i].cost = -c;
	}

	int k;
	long long min[1001], ans;
	for (i = 2, min[1] = 0; i <= N; i++) min[i] = sup;
	for (k = 1; k < N; k++) {
		for (i = 0; i < M; i++) {
			u = e[i].t;
			w = e[i].h;
			c = e[i].cost;
			if (min[u] < sup && min[w] > min[u] + c) min[w] = min[u] + c;
		}
	}
	ans = min[N];
	for (k = 1; k <= N; k++) {
		for (i = 0; i < M; i++) {
			u = e[i].t;
			w = e[i].h;
			c = e[i].cost;
			if (min[u] < sup && min[w] > min[u] + c) min[w] = min[u] + c;
		}
	}
	
	if (min[N] == ans) printf("%lld\n", -ans);
	else printf("inf\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)

/////////////////////////////////////////////////////////

int DFS(vector<vector<int>> V, vector<int> &visited, int cur, int key, int ini){
  int res = 0;
  visited[cur] = 1;
  rep(i, 0, V[cur].size()){
    if(ini == 0 && V[cur][i] == key){
      res = 1;
      break;
    }
    if(visited[V[cur][i]]) continue;
    if(DFS(V, visited, V[cur][i], key, 0)){
      res = 1;
      break;
    }
  }
  return res;
}

void Main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> V(N);
  vector<pair<int, int>> E(M);
  rep(i, 0, M){
    int a, b; cin >> a >> b;
    a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
    E[i] = make_pair(a, b);
  }
  int res = M;
  rep(i, 0, M){
    vector<int> visited(N, 0);
    visited[E[i].second] = 1;
    if(DFS(V, visited, E[i].first, E[i].second, 1)){
      res--;
    }
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
string gen[100010];
int main(void){
    // Your code here!
    cin >> n;
    ll lb = 0, ub = n;
    cout << 0 << endl << flush;
    cin >> gen[0];
    if (gen[0] == "Vacant") return 0;
    while(true){
        ll mid = (lb + ub) / 2;
        cout << mid << endl << flush;
        cin >> gen[mid];
        if (gen[mid] == "Vacant"){
            return 0;
        } else if ((gen[mid] == gen[lb]) ^ ((mid - lb) % 2)){
            lb = mid;
        } else {
            ub = mid;
        }
    }
}


Measured memory_bytes: 1620
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main(){
	ll N;
	int x;
	cin>>N;
	x=sqrt(N*1.0);
	cout<<x*x;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i<s.size(); i++){
    for(int j=i; j<s.size(); j++){
      bool a = true;
      for(int k = i ; k<=j; k++){
        if(s.at(k)!='A'&&s.at(k)!='C'&&s.at(k)!='G'&&s.at(k)!='T'){
          a = false;
        }
      }
      if(a) ans = max(ans,j-i+1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const int tx[] = {+0,+1,+0,-1};
const int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-8;

int init_dic(int x,int y,
	    map<P,int>& dic){
  if(dic.find(P(x,y)) == dic.end()){
    int idx = dic.size();
    dic[P(x,y)] = idx;
  }
  return dic[P(x,y)];
}

void fill_dic(int W,int H,map<P,int>& dic){
  for(int x=0;x<=W;x++){
    for(int y=0;y<=H;y++){
      if(dic.find(P(x,y)) == dic.end()){
	dic[P(x,y)] = -1;
      }
    }
  }
}

class State{
public:
  int x;
  int y;
  int dir;
  int remaining;
  int cost;
  vector<char> route;
  State(int _x,int _y,int _dir,int _remaining,int _cost,const vector<char>& _r)
    : x(_x),y(_y),dir(_dir),remaining(_remaining),cost(_cost),route(_r) {}
  State(int _x,int _y,int _dir,int _remaining,int _cost)
    : x(_x),y(_y),dir(_dir),remaining(_remaining),cost(_cost) {}
  bool operator<(const State& s) const{
    return cost < s.cost;
  }
  bool operator>(const State& s) const{
    return cost > s.cost;
  }
};

int main(){
  int H,W;
  while(~scanf("%d %d",&H,&W)){
    char stage[101][101];
    int sx,sy;
    int dir;
    int init_state=0;
    map<P,int> dic;

    for(int y=0;y<H;y++){
      char buf[101];
      scanf("%s",buf);
      for(int x=0;x<W;x++){
	stage[y][x] = buf[x];
	if(buf[x] == 'U' || buf[x] == 'R'
	   || buf[x] == 'D' || buf[x] == 'L'){
	  sx = x;
	  sy = y;
	  init_state |= (1<<init_dic(x,y,dic));

	  const char dirs[4] = {'U','R','D','L'};
	  for(int i=0;i<4;i++){
	    if(dirs[i] == buf[x]){
	      dir = i;
	      break;
	    }
	  }
	}
	if(buf[x] == 'o'){
	  init_state |= (1<<init_dic(x,y,dic));
	}
      }
    }
    
    fill_dic(W,H,dic);
    priority_queue<State,vector<State>,greater<State> > que;
    que.push(State(sx,sy,dir,init_state,0));

    set<int> visited[101][101][4];
    bool flag = false;
    while(!que.empty()){
      State s = que.top();
      que.pop();

      if(visited[s.x][s.y][s.dir].count(s.remaining) > 0) continue;
      visited[s.x][s.y][s.dir].insert(s.remaining);

      if(__builtin_popcount(s.remaining) == 1){
	const char dirs[4] = {'U','R','D','L'};
	string ans = "";
	for(int i=0; i<s.route.size(); i++){
	  ans += dirs[s.route[i]];
	}
	cout << ans << endl;
      }

      for(int i=0;i<4;i++){
	if(i == (s.dir + 2) % 4) continue;

	int dx,dy;
	for(int j=1;j<=max(H,W);j++){
	  dx = s.x + tx[i] * j;
	  dy = s.y + ty[i] * j;
	  if(dx < 0 || dy < 0 || dx >= W || dy >= H ) continue;
	  if(dic[P(dx,dy)] == -1) continue;
	  
	  if(s.remaining & (1<<dic[P(dx,dy)])){
	    int next = s.remaining & ~(1<<dic[P(s.x,s.y)]);
	    vector<char> next_route = s.route;
	    next_route.push_back(i);
	    que.push(State(dx,dy,i,next,s.cost+1,next_route));
	    break;
	  }
	}
      }
    }
  }
}

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

class B
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		Console.WriteLine(new string('#', a[1] + 2));
		for (var i = 0; i < a[0]; i++) Console.WriteLine($"#{Console.ReadLine()}#");
		Console.WriteLine(new string('#', a[1] + 2));
	}
}


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

using namespace std;

const int MAX = 1e5 + 10;
int N;
vector<int> G[MAX];
int dist[MAX], step[MAX];

int dfs1(int now, int prev) {
    for (auto &&e : G[now]) {
        if (e != prev) {
            dist[now] = max(dist[now], dfs1(e, now) + 1);
        }
    }
    return dist[now];
}

void dfs2(int now, int par, int d_par) {
    vector<pair<int, int>> children;
    children.emplace_back(0, -1);
    for (auto &&e : G[now]) {
        if (e == par) {
            children.emplace_back(d_par + 1, e);
        } else {
            children.emplace_back(dist[e] + 1, e);
        }
    }
    sort(rbegin(children), rend(children));
    step[now] = ((N - 1) << 1) - children[0].first;
    for (auto &&e : G[now]) {
        if (e != par) {
            dfs2(e, now, children[children[0].second == e].first);
        }
    }
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N - 1; i++) {
        int a, b, c;
        scanf("%d%d", &a, &b);
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    dfs1(0, -1);
    dfs2(0, -1, 0);
    for (int i = 0; i < N; i++) {
        printf("%d\n", step[i]);
    }
}



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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim() {
	int u,minv;
	int d[MAX],p[MAX],color[MAX];
	
	for(int i=0;i<n;i++){
		d[i] = INFTY;
		p[i] = -1;
		color[i]=WHITE;
	}
	
	d[0]=0;
	
	while(1){
		minv=INFTY;
		u=-1;
		for(int i=0;i<n;i++){
			if(minv>d[i] && color[i]!=BLACK){
				u=i;
				minv=d[i];
			}
		}
		
		if(u==-1) break;
		color[u]=BLACK;
		for(int v=0;v<n;v++){
			if(color[v]!=BLACK && M[u][v]!=INFTY){
				if(d[v]>M[u][v]){
					d[v]=M[u][v];
					p[v]=u;
					color[v]=GRAY;
				}
			}
		}
	}
	
	int sum=0;
	for(int i=0;i<n;i++){
		if(p[i]!=-1){
			sum+=M[i][p[i]];
		}
	}
		
	return sum;
}

int main(){
	cin>>n;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int e;cin>>e;
			M[i][j]=(e==-1)?INFTY:e;
		}
	}
	
	cout<<prim()<<endl;
	
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int h,w;
    char a[55][55];
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	    for(int j=1;j<=w;j++)
	        cin>>a[i][j];
	    //scanf("%s",&a[i][1]);
	for(int i=1;i<=h;i++,puts(""))
	    for(int j=1;j<=w;j++) 
	    {
    		if(a[i][j]=='#'){printf("#");continue;}
    		int cnt=0;
    		for(int x=i-1;x<=i+1;x++)
    		    for(int y=j-1;y<=j+1;y++)if(a[x][y]=='#')cnt++;
    		cout<<cnt;
	    }
}

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


int main() {
    long long mod = 1e9+7;
    long long n,m;
    cin>>n>>m;
    if(abs(n - m) > 1) {
        cout<<0;
        return 0;
    }
    long long ans=0,nfact=1,mfact=1;
    for(int i=2;i<=n;i++) {
        nfact=(nfact*i)%mod;
    }
    for(int i=2;i<=m;i++) {
        mfact=(mfact*i)%mod;
    }
    if(abs(n - m) == 0) {
        ans = (2*mfact*nfact)%mod;
    }
    else {
        ans = (mfact*nfact)%mod;
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  int ans=a.at(2)-a.at(0);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,d;
    cin>>n>>d;

    vector<vector<int>>x(n,vector<int>(d));

    for (int i=0;i<n;i++) {
        for (int j=0;j<d;j++) {
            cin>>x[i][j];
        }
    }

    int answer=0;

    for (int i=0;i<n-1;i++) {
        for (int j=i+1;j<n;j++) {
            int sum=0;
            for(int k=0;k<d;k++){
                //sub=差
                int sub=abs(x[i][k]-x[j][k]);
                sum+=sub*sub;
            }
            for (int k=1;k<=sum;k++) {
                if(k*k==sum){
                    answer++;
                }
            }
        }
    }

    cout<<answer<<endl;
}


Measured memory_bytes: 764
#include <iostream>

using namespace std;
typedef long long ll;

ll nd(ll x){
    ll ret = 0;
    for(; x > 0; x /= 10, ret++){
    }
    return ret;
}

ll f(ll a, ll b){
    return max(nd(a), nd(b));
}

int main(){
    ll n;
    cin >> n;
    ll ans = 10;
    for(ll a = 1; a * a <= n; ++a){
        if(n % a != 0){ continue; }
        ll b = n / a;
        ans = min(ans, f(a, b));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string t;
  cin >> t;

  F0R(i, t.size()) {
    if (t[i] == '?') {
      if (i > 0 && t[i - 1] == 'P') {
        t[i] = 'D';
      }
      else if (i < t.size() - 1 && (t[i + 1] == '?' || t[i + 1] == 'D')) {
        t[i] = 'P';
      }
      else t[i] = 'D';
    }
  }
  cout << t;
}
#endif


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

int main(){
    int n;
    cin>>n;
    vector<long long int> a(n-1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int j=1;j<n;j++){
        if(a[j]>1000000000&&a[j-1]>=1000000000){
            cout<<-1<<endl;
            return 0;
        }
        else if(a[j]>=1000000000&&a[j-1]>1000000000){
            cout<<-1<<endl;
            return 0;
        }
        if(a[j]*a[j-1]>1000000000000000000){
            cout<<-1<<endl;
            return 0;
        }
        a[j]*=a[j-1];
    }
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        for (int i = 0; i < n; i++) cin >> v[i];

        ll ans[n];
        ans[0] = 0;
        for (int i = 0; i < n; i++) {
            ans[0] += v[i];
            if (i & 1) ans[0] -= 2 * v[i];
        }
        ans[0] = ans[0] / 2;
        for (int i = 1; i < n; i++) {
            ans[i] = v[i - 1] - ans[i - 1];
        }

        for (int i = 0; i < n; i++) cout << ans[i] * 2 << " ";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 2944
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if a[i] < b[i]:
        b[i] = b[i] - a[i] 
        cnt += a[i]
        a[i] = 0
        
        if a[i+1] < b[i]:
            b[i] = b[i] - a[i+1] 
            cnt += a[i+1]
            a[i+1] = 0
        
        elif a[i+1] >= b[i]:
            a[i+1] = a[i+1] - b[i]
            cnt += b[i]
    elif a[i] >= b[i]:
        a[i] = a[i] - b[i]
        cnt += b[i]
print(cnt)

Measured memory_bytes: 82020
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
    int i,len,count=0;
    char str[15];
    scanf("%s",str);
    len=strlen(str);
    if(str[0]=='A' && str[len-1]>='a' && str[len-1]<='z' && str[1]>='a' && str[1]<='z'){
            for(i=2;i<=len-2;i++){
                if(str[i]=='C') count++;
            }
        if(count==1) printf("AC\n");
        else printf("WA\n");
    }
    else printf("WA\n");
    return 0;
}


Measured memory_bytes: 128
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
#ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=inf


n=I()

for h in range(1,3501):
    for w in range(h,3501):
        if (4*h*w-h*n-w*n)>0 and (n*h*w)%(4*h*w-h*n-w*n)==0:
            x=n*h*w//(4*h*w-h*n-w*n)
            print(x,h,w)
            exit()




Measured memory_bytes: 41064
#include<iostream>
#include<cmath>

#define MAX (100000)

using namespace std;

int table[MAX+10];
int Count[MAX+10];

int main(void) {
    int Q;
    cin>>Q;

    table[2] = 1;
    for(int i = 3;i <= MAX;i += 2) {
        bool flag = true;
        for(int j = 3;j <= sqrt(i);j += 2) {
            if(i % j == 0)
            {
                flag = false;
                break;
            }
        }
        if(flag)
            table[i] = 1;
    }

    for(int i = 2;i <= MAX;i++) {
        if(table[i] && table[(i+1)/2])
            Count[i] = Count[i-1]+1;
        else
            Count[i] = Count[i-1];
    }

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

        cout<<Count[r]-Count[l-1]<<endl;
    }

    return 0;
}


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

#define mp make_pair
#define x first
#define y second
#define pb push_back
using namespace std;

int main()
{

    string s; cin >> s;
    if (s[0] == 'S') cout << "Cloudy"; else
    if (s[0] == 'C') cout << "Rainy"; else
    cout << "Sunny";
}


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

using ll=int64_t;
//#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	#ifdef int
	scanf("%" SCNd64,&i);
	#else
	scanf("%d",&i);
	#endif
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	#ifdef int
	printf("%" PRId64,x);
	#else
	printf("%d",x);
	#endif
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

#ifdef int
const int inf=LLONG_MAX/3;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=1010;
char ans[Nmax][Nmax];
void Answer(int n){
	Yes(0);
	REP(i,n)printf("%s\n",ans[i]);
	exit(0);
}

signed main(){
	int n=read(),m=read(),a=read(),b=read();
	if(n*m<(a+b)*2)No();
	{
		int x=(n+1)/2*m,y=n/2*m;
		x-=b;
		y-=b;
		if(x<0||y<0)No();
		if(x/2+y/2<a)No();
	}
	{
		int x=(m+1)/2*n,y=m/2*n;
		x-=a;
		y-=a;
		if(x<0||y<0)No();
		if(x/2+y/2<b)No();
	}
	REP(i,n)REP(j,m)ans[i][j]='.';
	if(m%2==1)
		for(int i=0;i+1<n;i+=2)
			if(b){
				ans[i][m-1]='^';
				ans[i+1][m-1]='v';
				b--;
			}
	if(n%2==1)
		for(int i=0;i+1<m;i+=2)
			if(a){
				ans[n-1][i]='<';
				ans[n-1][i+1]='>';
				a--;
			}
	if(n%2==1&&m%2==1)
		if(a%2==1&&b%2==1){
			ans[n-3][m-3]='<';ans[n-3][m-2]='>';ans[n-3][m-1]='^';
			ans[n-2][m-3]='^';ans[n-2][m-2]='.';ans[n-2][m-1]='v';
			ans[n-1][m-3]='v';ans[n-1][m-2]='<';ans[n-1][m-1]='>';
			a--;
			b--;
		}
	for(int i=0;i+1<n;i+=2){
		for(int j=0;j+1<m;j+=2){
			if(a){
				ans[i][j]='<';
				ans[i][j+1]='>';
				a--;
				if(a){
					ans[i+1][j]='<';
					ans[i+1][j+1]='>';
					a--;
				}
			}else if(b){
				ans[i][j]='^';
				ans[i+1][j]='v';
				b--;
				if(b){
					ans[i][j+1]='^';
					ans[i+1][j+1]='v';
					b--;
				}
			}
		}
	}
	assert(a==0&&b==0);
	Answer(n);
}


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

const int N = 200005;

int n, m, it[4 * N], lazy[4 * N];
vector<int> go[N];

void build(int i, int l, int r) {
    if (l == r) {
        it[i] = l - m; return;
    }
    int mid = (l + r) >> 1;
    build(i << 1, l, mid);
    build(i << 1 | 1, mid + 1, r);
    it[i] = max(it[i << 1], it[i << 1 | 1]);
}

void push(int i, int l, int r) {
    if (!lazy[i]) return;
    it[i] += lazy[i];
    if (l != r) {
        lazy[i << 1] += lazy[i], lazy[i << 1 | 1] += lazy[i];
    }
    lazy[i] = 0;
}

void update(int i, int l, int r, int u, int v) {
    push(i, l, r);
    if (l > v || u > r) return;
    if (u <= l && r <= v) {
        lazy[i] = 1, push(i, l, r); return;
    }
    int mid = (l + r) >> 1;
    update(i << 1, l, mid, u, v);
    update(i << 1 | 1, mid + 1, r, u, v);
    it[i] = max(it[i << 1], it[i << 1 | 1]);
}

int get(int i, int l, int r, int u, int v) {
    push(i, l, r);
    if (l > v || u > r) return 0;
    if (u <= l && r <= v) return it[i];
    int mid = (l + r) >> 1;
    return max(get(i << 1, l, mid, u, v), get(i << 1 | 1, mid + 1, r, u, v));
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    m++, build(1, 1, m);
    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        go[l].push_back(r);
    }
    int res = max(0, n - m + 1);
    for (int i = 0; i < m; ++i) {
        for (auto j : go[i]) update(1, 1, m, i + 1, j);
        res = max(res, get(1, 1, m, i + 1, m) - i);
    }
    cout << res;
}


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

const int MOD = 1000000007;

ll pw(ll n) { return n * n % MOD; }
ll pw(ll n, ll k) {
	ll r = 1; for(n %= MOD; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

const int MAXN = 5005;

vector<int> G[MAXN];

int cnt[MAXN];

ll Ans;
int N, Rt;

void dfs(int i) {
	cnt[i] = 1;
	for(int v : G[i]) if(!cnt[v]) {
		dfs(v);
		cnt[i] += cnt[v];
	}
}

void cent(int &rt) {
	const int N = cnt[rt];
	for(int hi, hc;;) {
		hi = hc = -1;
		for(int v : G[rt]) if(cnt[v] < N) {
			if(cnt[v] <= hc) continue;
			hc = cnt[v]; hi = v;
		}
		if(hc*2 <= N) break;
		cnt[rt] = N - hc;
		cnt[hi] = N;
		rt = hi;
	}
}

ll D[2][MAXN];
ll F[MAXN], RF[MAXN];

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1, a, b; i < N; i++) {
		cin >> a >> b;
		G[a].eb(b);
		G[b].eb(a);
	}

	dfs(1);
	Rt = 1; cent(Rt);

	F[0] = 1;
	for(int i = 1; i <= N; i++) F[i] = F[i-1] * i % MOD;
	RF[N] = inv(F[N]);
	for(int i = N; i--;) RF[i] = RF[i+1] * (i+1) % MOD;

	memset(D[0], 0, MAXN<<3);
	D[0][0] = 1;
	int sum = 0;
	for(int v : G[Rt]) {
		memset(D[1], 0, MAXN<<3);
		int c = cnt[v];
		for(int j = 0; j <= sum; j++) {
			for(int l = 0; l <= c; l++) {
				D[1][j+l] += D[0][j] * pw(F[c]) % MOD * RF[l] % MOD * pw(RF[c-l]);
				D[1][j+l] %= MOD;
			}
		}
		memcpy(D[0], D[1], MAXN<<3);
		sum += c;
	}

	for(int k = 0; k < N; k++)
		Ans += D[0][k] * F[N-k] * ((k&1) ? -1 : 1) % MOD;
	
	cout << ((Ans % MOD + MOD) % MOD) << endl;
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int comb(int n)
{
    if (n < 2 ) return 0;
    return n*(n-1)/2;
}

int main()
{
    int x,y;
    cin>>x>>y;
    cout<<comb(x)+comb(y)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int main(){
  ll a, b, c; cin >> a >> b >> c;

  if(a%2 || b%2 || c%2){
    cout << 0 << endl;
    return 0;
  }

  if(a == b && b == c && c == a){
    cout << -1 << endl;
    return 0;
  }

  ll aa = a, bb = b, cc = c, cnt = 0;
  while(aa%2 == 0 && bb%2 == 0 && cc%2 == 0){
    aa = (b+c) / 2;
    bb = (c+a) / 2;
    cc = (a+b) / 2;

    a = aa; b = bb; c = cc;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scn=new Scanner(System.in);
        String wrongDate=scn.next();
        for(int i=0;i<wrongDate.length();i++){
            if(i==3) {
                System.out.print(8);
            }else{
                System.out.print(wrongDate.charAt(i));
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 20948
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <bitset>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <cfloat>
#include <initializer_list>
#include <iomanip>
#include <functional>
#include <unordered_map>
#include <regex>

using namespace std;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; ++i)
    {
      int a;
      cin >> a;
      sum += a;
    }
  if (sum & 1) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define N 10000000
#define mod_32(n) (n&((1<<5)-1))
int prime[(N>>5)+1];

void init(){
	memset(prime,-1,sizeof(prime));
	prime[0] = prime[0] - (1<<0) - (1<<1);
	for(int i=2;i*i <= N;i++){
		if( prime[i>>5] & (1 << mod_32(i)) ){
			for(int j=i*i;j<=N;j+=i){
				prime[j>>5] -= (prime[j>>5] & (1<<mod_32(j)));
			}
		}
	}
}
inline bool isprime(int n){
	return !!(prime[n>>5] & (1<<mod_32(n)));
}
int main(){
	int n;
	init();
	while(~scanf("%d",&n)){
		while(n){
			if( isprime(n) & isprime(n-2) & isprime(n-6) & isprime(n-8) ){printf("%d\n",n);break;}
			n--;
		}
	}
}

Measured memory_bytes: 1980
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    a = ii()
    print(a+a**2+a**3)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(x) ((int)(x).size())
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define M 1000000007
#define MM 998244353
#define SZ(a) int((a).size())
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define mod 1000000007
using ll = long long;

//a and b are assumed to be taken modulo p
inline ll add(ll a, ll b, ll p = mod){ ll c = a + b; if(c >= p) c -= p; return c; }
inline ll sub(ll a, ll b, ll p = mod){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll mul(ll a, ll b, ll p = mod){ return (a * 1ll * b) % p; }
 
using VI = vector<int>;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using VLL = vector<ll>;
using ld = long double;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*1ll*x) % p;
    }
    return res;
}
const int MX = 2e5+10;
const int MX2 = 1e6+5;

ll INF= 4 * (ll)1e18;
int mx = 2 * (ll)1e9 + 10;
ll A[MX];
int main(int argc, const char * argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); // insert code here...
    int N;
    ll T;
    cin >> N;
    cin >> T;
    ll ans = 0;
    REP(i,N) {
        cin >> A[i];
    }
    ll start = A[0];
    ll end = A[0]+T;
    FOR(i,1,N-1) {
        if (A[i] > end) {
            ans += end - start;
            start = A[i];
            end = A[i] + T;
        }
        else {
            end = A[i] + T;
        }
    }
    ans = ans + end - start;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int n = 0;
  int i;
  int x = 0;
  
  scanf("%d", &n);
  
  for(i = 1; i <= n; i++){
    x = i;
    
    if(x % 3 == 0)
      printf(" %d", i);
    else
      do{
	if(x % 10 == 3){
	  printf(" %d", i);  
	  break;
	}
      }while(x /= 10);
  }
  putchar('\n');
  
  return 0;
}

Measured memory_bytes: 600
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,ans,frag,s;
    vector<pair<int,int> > v;
    cin>>a;
    for(i=0;i<a;i++){
        cin>>b;
        v.push_back(make_pair(b,i+1));
    }
    sort(v.begin(),v.end());
    for(i=0;i<a;i++){
        cout<<v[i].second;
        if(i!=a-1)
        cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1780
#include<stdio.h>
int main(){
    int a,b,W;
    int tmp;
    scanf("%d %d %d",&W,&a,&b);
    if(a>b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    if((a+W)<b)printf("%d\n",b-(a+W));
    else printf("0\n");
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
int main(){
        ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin>>h>>w;
    char input[h][w];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
           cin>>input[i][j];
        }
    }
    ll output[h][w] = {0};
    memset(output,0,sizeof(output));
    ll i=0;
    for(i=0;i<w;i++){
        if(input[0][i] == '.'){
            output[0][i] = 1;
        }
        else{
            break;
        }
    }
    for(;i<w;i++){
        output[0][i] = 0;
    }
    

    ll j = 0;
    for(j = 0;j<h;j++){
        if(input[j][0] == '.'){
            output[j][0] = 1;
        }
        else{
            break;
        }
    }
    for(;j<h;j++){
        output[j][0] = 0;
    }
    for(ll i=1;i<h;i++){
        for(ll j=1;j<w;j++){
            if(input[i][j] == '#'){
                output[i][j] = 0;
                continue;
            }
            else{
                output[i][j] = (output[i][j-1] + output[i-1][j]) % MOD;
            }
        }
    }
    cout<<output[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 12384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-I/usr/local/include
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<1000, std::int64_t>> fl;
typedef mp::cpp_dec_float_100 fl_100;
/*
  fl a, b, c;std::cin >> a >> b >> c;
  mp::sqrt(x)
  x.str()    num - > str
  x(str)     str - > num
*/
#include "boost/multiprecision/cpp_int.hpp"
typedef mp::cpp_int lll;
//int128_t

/*
  lll x(str) str -> num
*/
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vector<fl> a(n);
  fl s = 0;
  re(i, n) {
    std::cin >> a[i];
    s += a[i];
  }
  s /= (fl)(4*m);
  ll ans = 0;
  re(i, n) if(a[i]>=s) ans++;
  std::cout << (ans>=m?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 512
n = int(input())
l = list(map(int, input().split()))

count = 0
flag = True
while flag:
    flag = False
    for j in range(n-1, 0, -1):
        if l[j] < l[j-1]:
            l[j], l[j-1] = l[j-1], l[j]
            count += 1
            flag = True

print(' '.join(map(str, l)))
print(count)



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll m,n;
    cin>>m>>n;
    ll a[m][3];
    rep(i, m){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll sum = 0;
    for(auto i = -1;i<2;i+=2){
        for(auto j = -1;j<2;j+=2){
            for(auto k = -1;k<2;k+=2){
                vector<ll> scores;
                rep(ii, m){
                    ll score = 0;
                    score += a[ii][0]*i;
                    score += a[ii][1]*j;
                    score += a[ii][2]*k;
                    scores.push_back(score);
                }
                sort(alll(scores));
                reverse(alll(scores));
                while(scores.size()>=4){
                    scores.pop_back();
                }
                ll uu = 0;
                rep(jj, n)uu+=scores[jj];
                sum= max(sum,uu);
            }
        }
    }
    pr(sum);
}



Measured memory_bytes: 256