akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll w,h,x,y;
  cin >> w >> h >> x >> y;

  double c_x = w / 2.0;
  double c_y = h / 2.0;

  bool flg = false;
  if(c_x == (double)x && c_y == (double)y)
  {
    flg = true;
  }

  double ans = (w * h ) / 2.0;

  cout << fixed << setprecision(10) << ans << " " << (flg ? 1 : 0) << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a[1];
    double p,q;
    int origin;
    int ans;

    if(scanf("%d", &a[0])==1){}
    p = a[0]/1.08;
    q = (a[0]+1)/1.08;

    origin=(int)p;
    if(p <= (double)origin && (double)origin< q){
        ans = origin;
        printf("%d\n", ans);
    }else if(p <=(double)origin + 1.00 && (double)origin + 1.00 < q){
        ans = origin+1;
        printf("%d\n", ans);
    }else{
        printf(":(\n");
    }


    

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, d;
	cin >> n >> d;
	d = 2 * d + 1;
	cout << (n + d - 1) / d << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int K, S;
	cin >> K >> S;
	int ans = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			int k = S - i - j;
			if (k <= K && k >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;

    vector<int> list;

    for (int i = 0; i < n; i++)
    {
        int n;
        cin >> n;
        list.push_back(n);
    }

    for (int i = 0; i < n - 2; i++)
    {
        if (list[i] < list[i + 1])
        {
            if (list[i + 1] < list[i + 2])
            {
                ans++;
            }
        }
        else
        {
            if (list[i + 1] > list[i + 2])
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
int graph[50][50];
using namespace std;
int n, m;
int bfs();
int main() {

	//C
	cin >> n >> m;

	//queue<int> graph[50];
	//int graph[50][50];
	int i,j,a,b;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			graph[i][j] = 0;
		}
	}
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		graph[a - 1][b - 1] = 1;
		graph[b - 1][a - 1] = 1;
	}
	//cout << graph[1][6];
	int counter = 0;

	for (i = 0; i < n; i++) {
		for (j = i; j < n; j++) {
	//i = 1; j = 6;
			if (graph[i][j] == 1) {
				graph[i][j] = 0;
				graph[j][i] = 0;

				if (bfs() == 0) {
					counter++;
					//cout << i << ' ' << j << endl;
				}

				graph[i][j] = 1;
				graph[j][i] = 1;
			}
		}
	}
	cout << counter << endl;
	return 0;



	//D
	/*
	long long int x[50], xs[50], y[50], ys[50];
	int n, k;
	cin >> n >> k;
	int i1,i2,j1,j2,i,l;
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		xs[i] = x[i]; ys[i] = y[i];
	}
	sort(xs, xs + n);
	sort(ys, ys + n);
	int counter;
	long long int rectangle = 4000000000000000000;
	for (i1 = 0; i1 < n-1; i1++) {
		for (j1 = i1 + 1; j1 < n; j1++) {
			for (i2 = 0; i2 < n - 1; i2++) {
				for (j2 = i2 + 1; j2 < n; j2++) {
					if ((xs[j1] - xs[i1]) * (ys[j2] - ys[i2]) < rectangle) {


						counter = 0;
						for (i = 0; i < n; i++) {
							if ((x[i] >= xs[i1]) && (x[i] <= xs[j1]) && (y[i] >= ys[i2]) && (y[i] <= ys[j2])) {
								counter++;
							}
						}
						if (counter >= k) {
							rectangle = (xs[j1] - xs[i1]) * (ys[j2] - ys[i2]);
						}
					}
				}
			}
		}
	}
	cout << rectangle << endl;
	return 0;
	*/
}
int bfs() {
	int i, j;
	int edge[50];
	for (i = 0; i < n; i++) {
		edge[i] = 0;
	}
	queue<int> q;
	q.push(0);
	edge[0] = 1;
	int x;
	while (q.size()>0) {
		//cout << 'a';
		x = q.front(); q.pop();
		for (i = 0; i < n; i++) {
			//cout << 'a';
			//cout << x << ' ' << i << endl;
			if (i != x) {
				if (graph[x][i] == 1) {
					if (edge[i] == 0) {
						//cout << x << ' ' << i << endl;
						edge[i] = 1;
						q.push(i);
						//cout << i << endl;
					}
				}
			}
		}

	}
	for (i = 0; i < n; i++) {
		if (edge[i] == 0) {
			//cout << i << endl;
			return 0;
		}
	}
	return 1;
	
}

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

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=(a>b)?(a):(b);
#define chmin(a, b) (a)=(a<b)?(a):(b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

class Edge {
public:
  ll t, w;
  Edge() {}
  Edge(ll t, ll w): t(t), w(w) {}
};

ll N, M;
vector<Edge> g[2222];
ll d[2222][2222];

void dijkstra(ll s) {
  ll i, u;
  ll clr[2222]={};
  priority_queue<P> que;
    for(i=0; i<N; i++) {
        d[s][i]=INF;
        clr[i]=0;
    }
    d[s][s]=0;
    que.push(P(0, s));
    
    while(que.size()) {
        P f=que.top(); que.pop();
        u=f.second;
        clr[u]=1;
        if(d[s][u]<-f.first) continue;
        
        for(i=0; i<g[u].size(); i++) {
            Edge e=g[u][i];
            if(clr[e.t]!=1 && d[s][e.t]>d[s][u]+e.w) {
                d[s][e.t]=d[s][u]+e.w;
                que.push(P(-d[s][e.t], e.t));
            }
        }
    }
}
int main(void) {
  ll i, j, k;
  
  ll X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  
  for(i=0; i<N-1; i++) {
    g[i].push_back(Edge(i+1, 1));
    g[i+1].push_back(Edge(i, 1));
  }
  
  g[X].push_back(Edge(Y, 1));
  g[Y].push_back(Edge(X, 1));
  
  for(i=0; i<N; i++) dijkstra(i);
  
  ll cnt[2222]={};
  for(i=0; i<N; i++) {
    for(j=i+1; j<N; j++) {
      cnt[d[i][j]]++;
    }
  }
  
  
  for(i=1; i<N; i++) pt(cnt[i]);
  
  
  
}




Measured memory_bytes: 35200
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;

int n;
struct Point{
	int x,y,id;
	bool operator < (const Point &rhs) const{
		return x<rhs.x;
	}
}r[maxn];

int sy[maxn];

long long ans[maxn];
long long f[maxn][2];
vector<pair<int,int>>section;

int dist(int i,int j){
	return abs(r[i].x-r[j].x)+abs(r[i].y-r[j].y);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		r[i].id=i;scanf("%d%d",&r[i].x,&r[i].y);
		sy[i]=r[i].y;
	}
	sort(r+1,r+1+n);
	sort(sy+1,sy+1+n);sy[0]=0;sy[n+1]=1e9;
	
	for(int i=1;i<=n;++i)ans[i]=-1;
	for(int i=1;i<=n;++i){
		if(ans[r[i].id]!=-1)continue;
		int t=lower_bound(sy+1,sy+1+n,r[i].y)-sy;
		int t1=t-1,t2=t+1,L=i,R=i,predir=-1,dir;
		for(;;){
			int flag=0; 
			for(int i:{L-1,R+1}){
				if(i<=0||i>n)continue;
				if(r[i].y!=sy[t1]&&r[i].y!=sy[t2])continue;
				if(i==L-1){
					dir=r[i].y==sy[t1];
				}else{
					dir=r[i].y==sy[t2];
				}
				if(predir!=-1&&dir!=predir){
					section.push_back(pair<int,int>(L,R));
				}
				predir=dir;
				if(r[i].y==sy[t1])--t1;else ++t2;
				if(i==L-1)--L;else ++R;
				flag=1;
			}
			if(!flag)break;
		}
		section.push_back(pair<int,int>(L,R));
		
		int s=section.size();
		f[s-1][0]=f[s-1][1]=0;
		for(int i=s-1;i>=1;--i){
			int l1=section[i].first,r1=section[i].second;
			int l2=section[i-1].first,r2=section[i-1].second;
			f[i-1][0]=min(dist(l2,l1)+dist(l1,r1)+f[i][1],(r1==r2?dist(l1,l2):dist(l2,r1)+dist(r1,l1))+f[i][0]);
			f[i-1][1]=min(dist(r2,r1)+dist(r1,l1)+f[i][0],(l1==l2?dist(r1,r2):dist(r2,l1)+dist(l1,r1))+f[i][1]);
		}
		L=section[0].first;R=section[0].second;
		for(int i=L;i<=R;++i){
			int id=r[i].id;
			ans[id]=min(dist(i,R)+dist(R,L)+f[0][0],dist(i,L)+dist(L,R)+f[0][1])-(section[s-1].second-section[s-1].first);
		}
		section.clear();
	}
	
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);
	
	return 0;
}

Measured memory_bytes: 12580
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> to[100];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   rep(i, 0, n) {
      int u, k;
      cin >> u >> k;
      u--;
      rep(i, 0, k) {
         int v;
         cin >> v;
         v--;
         to[u].push_back(v);
      }
   }
   queue<int> que;
   vector<int> d(n, -1);
   que.push(0);
   d[0] = 0;
   while (que.size()) {
      int u = que.front();
      que.pop();
      for (auto v : to[u]) {
         if (d[v] < 0) {
            d[v] = d[u] + 1;
            que.push(v);
         }
      }
   }
   rep(i, 0, n) printf("%d %d\n", i + 1, d[i]);
   return 0;
}


Measured memory_bytes: 3284
import math
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)

m = float('inf')
ans = 0
mea = A[0]/2
for i in range(n-1):
    if m > abs(mea-A[i+1]):
        ans = A[i+1]
        m=abs(mea-A[i+1])
print(A[0], ans)
        

Measured memory_bytes: 19936
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x,y;
while(cin >> a >> b >> c >> d >> e >> f){
  x = (double)((e*c-b*f) / (a*e-b*d));
  y = (double)((-(d*c)+a*f) / (a*e-b*d));
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
  printf("%.3f %.3f\n",x,y);
 }
}
 

Measured memory_bytes: 0
k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])


Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val (n, k) = readStrings().map(String::toInt)
    val pointList = arrayListOf<Point>()
    for (i in 1..n) {
        val (x, y) = readStrings().map(String::toInt)
        pointList.add(Point(x, y))
    }

    val verticalSorted = pointList.sortedBy { it.y }
    val horizontalSorted = pointList.sortedBy { it.x }

    var ans = Long.MAX_VALUE
    for (left in horizontalSorted) {
        for (right in horizontalSorted) {
            if (left.x >= right.x) {
                continue
            }

            for (top in verticalSorted) {
                if (!(top.x in left.x..right.x)) {
                    continue
                }

                for (bottom in verticalSorted) {
                    if (top.y >= bottom.y ||
                        !(bottom.x in left.x..right.x)) {
                        continue
                    }

                    val includedCount = pointList.count {
                        it.x in left.x..right.x
                        && it.y in top.y..bottom.y
                    }

                    if (includedCount < k) {
                        continue
                    }

                    ans = Math.min(ans, (right.x - left.x).toLong() * (bottom.y - top.y).toLong())
                }
            }
        }
    }

    println(ans)
}

fun readStrings() = readLine()!!.split(" ")


data class Point(val x: Int, val y: Int)


Measured memory_bytes: 43732
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll A, B;
	cin >> A >> B;

	if (A*B < 0) {
		cout << "Zero";
		return 0;
	}
	else if (A < 0) {
		
		if (abs(A - B + 1) % 2 == 0) {
			cout << "Positive";
			return 0;
		}
		else {
			cout << "Negative";
		}

	}
	else {
		cout << "Positive";
	}




}


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

using namespace std;


struct card {
    char suit;
    char val;
};


void swap(struct card *a, int i, int j)
{
    struct card tmp;
    tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
}


void bubble_sort(struct card *a, int n) {
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j > i; j--) {
            if (a[j - 1].val > a[j].val) {
                swap(a, j - 1, j);
            }
        }
    }
}


void selection_sort(struct card *a, int n) {
    for (int i = 0; i < n; i++) {
        int min_index = i;
        for (int j = i; j < n; j++) {
            if (a[min_index].val > a[j].val)
                min_index = j;
        }
        if(min_index != i)
            swap(a, min_index, i);
    }
}


void copy_deck(struct card *a, struct card *b, int n) {
    for (int i = 0; i < n; i++)
        b[i] = a[i];
}


void output(struct card *a, int n) {
    for (int i = 0; i < n - 1; i++)
        printf("%c%c ", a[i].suit, a[i].val);
    printf("%c%c\n", a[n - 1].suit, a[n - 1].val);
}


int main(void)
{
    int n;
    char c[2];
    struct card cards[36];
    struct card bubble_deck[36];
    struct card selection_deck[36];


    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c;
        cards[i].suit = c[0];
        cards[i].val = c[1];
    }

    copy_deck(cards, bubble_deck, n);
    copy_deck(cards, selection_deck, n);

    bubble_sort(bubble_deck, n);
    output(bubble_deck, n);
    cout << "Stable" << endl;

    selection_sort(selection_deck, n);
    output(selection_deck, n);

    bool stable = true;
    for (int i = 0; i < n; i++) {
        if (bubble_deck[i].suit != selection_deck[i].suit) {
            stable = false;
            break;
        }
    }

    if (stable)
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
int main() {
	int a, b, c, d, l, r;
	cin >> a >> b >> c >> d;
	l = a + b;
	r = c + d;
	if (l > r) 	cout << "Left";
	else if (l == r) cout << "Balanced";
	else cout << "Right";
}

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

bool cmp(int a, int b) {
	return a > b;
}

int main() {
	int N;
	cin >> N;
	int p[20];
	for (int i = 0; i < N; i++)
		cin >> p[i];
	sort(p, p + N, cmp);
	int ans = 0;
	ans += p[0] / 2;
	for (int i = 1; i < N; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define DEV_VAL 1000000007

template <typename T>
void inputList(vector<T>* list, int n, int sortType = 0)
{
  repl(i, n)
  {
    T tmp;
    cin >> tmp;
    list->push_back(tmp);
  }
  if(sortType == 1)
  {
    sort(list->begin(), list->end());
  }
  else if(sortType == 2)
  {
    sort(list->begin(), list->end(), greater<T>());
  }
}

int main()
{
  ll n;
  cin >> n;
  vector<ll> ilist;
  inputList(&ilist, n);

  bool isBuy = true;
  ll preMoney = 9999;
  ll stock = 0;
  ll money = 1000;

  repl(i, n)
  {
    if(isBuy)
    {
      if(preMoney >= ilist[i])
      {
        // より安いので買う
        money += preMoney * stock; // いったん買った金額で売る
        stock = money / ilist[i];
        money -= stock * ilist[i];
        preMoney = ilist[i];
      }
      else
      {
        // 高くなったので売る
        isBuy = false;
        money += stock * ilist[i];
        preMoney = ilist[i];
      }
    }
    else
    {
      if(preMoney <= ilist[i])
      {
        // より高いので売る
        money += stock * (ilist[i] - preMoney);
        preMoney = ilist[i];
      }
      else
      {
        // 安くなったので買う
        isBuy = true;
        stock = money / ilist[i];
        money -= stock * ilist[i];
        preMoney = ilist[i];
      }
      
    }
    
  }

  if(isBuy)
  {
    // 最後まで売れなかったものを買わなかったことにする
    money += stock * preMoney;
  }
  cout << fixed << money << endl;
  return 0;
}

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

int main(){
    std::string a;
    cin >> a;
    std::string b = "hi";
    if(a==b){cout << "Yes" << endl; return 0;}
    b="hihi";
    if(a==b){cout << "Yes" << endl; return 0;}
    b="hihihi";   
    if(a==b){cout << "Yes" << endl; return 0;}
    b="hihihihi";      
    if(a==b){cout << "Yes" << endl; return 0;}
    b="hihihihihi";     
    if(a==b){cout << "Yes" << endl; return 0;}
    b="hihihihihihi";    
    if(a==b){cout << "Yes" << endl; return 0;}

    cout << "No" << endl; 

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    int n; cin>>n;
    vector<int> array(n);
    for(int i=0; i<n; ++i) cin>>array[i];
    int prev = 0;
    ll ans = 0;
    for(int i=0; i<n; ++i){
        ans = ans + max(0, prev-array[i]);
        prev = max(prev, array[i]);
    }
    cout<<ans<<endl;
}



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

int main() {
  vector<int>A(3);
  for (int i = 0; i < 3; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  if (A.at(0) == A.at(1) && A.at(1) != A.at(2)) {
    cout << "Yes";
  }
  else if (A.at(0) != A.at(1) && A.at(1) == A.at(2)) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int C = scan.nextInt();

    double S = a * b * Math.sin(Math.toRadians(C)) / 2;
    System.out.println(S);
    double c = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(C)));
    System.out.println(a + b + c);
    System.out.println(2 * S / a);

  }

}



Measured memory_bytes: 26352
import java.lang.Math.*

const val MOD = 1000000007L

fun main(args: Array<String>) {
    val (n, k) = readIntList()
    val s = readList().first()

    s.forEachIndexed { index, c ->
        if (index == k - 1) {
            print(c.toLowerCase())
        } else {
            print(c)
        }
    }

}


fun readList() = readLine()!!.split(' ')
fun readInt() = readLine()!!.split(' ').map(String::toInt).first()
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
inline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    val former = mutableListOf<Long>()
    val latter = mutableListOf<Long>()
    (1..max).filter { value % it == 0L }
        .forEach {
            former.add(it)
            latter.add(value / it)
        }
    former.addAll(latter.reversed())
    return former
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

// 二分探索
fun Array<Long>.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {
    var start = (_start - 1).toLong()
    var end = _end.toLong()
    while (end - start > 1) {
        val mid = (start + end) / 2
        if (this[mid.toInt()] < target) {
            start = mid
        } else {
            end = mid
        }
    }
    return end.toInt()
}

// bit全探索
inline fun Int.bitAllSearch(body: (Array<Int>) -> Unit) {
    for (bit in 0 until (1 shl this)) {
        val s = mutableListOf<Int>()
        for (i in 0 until this) {
            if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか
                s.add(i)
            }
        }
        body(s.toTypedArray())
    }
}

Measured memory_bytes: 36208
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
right = 0
left = 0
for i in range(x+1,n+1):
    if i in a:
        right+=1
for j in range(x):
    if j in a:
        left+=1
if right < left:
    print(right)
else:
    print(left)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  long long n, d, x, y, cnt = 0;
  cin >> n >> d;
  d *= d;
  rep(i,n)
  {
    cin >> x >> y;
    if (x * x + y * y <= d)
      cnt++;
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define MOD 998244353

using namespace std;

int main()
{
    IOS;
    ll l,r;
    cin>>l>>r;
    ll ans=2019;
    if(l/2019==r/2019)
    {
        repf(i,l%2019,r%2019+1)
        {
            repf(j,i+1,r%2019+1) ans=min(ans,(i*j)%2019);
        }
    }
    else{
        vector<ll> v;
        repf(i,l%2019,2019) v.pb(i);
        repf(i,0,r%2019+1) v.pb(i);
        for(int i=0;i<v.size();i++)
        {
            for(int j=i+1;j<v.size();j++) ans=min(ans,(v[i]*v[j])%2019);
        }
    }
    cout<<ans<<endl;
}
 

Measured memory_bytes: 384
#include <stdio.h>
int min(int a, int b) { return a < b ? a : b; }
int a[40];
void solve(int n, int k, int c)
{
    int i;
    if (n == 0) {
        for (i=0; i<c-1; ++i) printf("%d ", a[i]);
        printf("%d\n", a[c-1]);
        return;
    }
    for (i=min(n, k); i>=1; --i) {
        a[c] = i;
        solve(n-i, i, c+1);
    }
}

int main(void)
{
    int n;
    while (scanf("%d", &n), n) solve(n, n, 0);
    return 0;
}

Measured memory_bytes: 0
import sys
S = input()
T = input()
Slen = len(S)
Tlen = len(T)
if Tlen > Slen:
    print('UNRESTORABLE')
    sys.exit()
start = Slen + 1
for i in range(Slen - Tlen + 1):
    flg = True
    for j in range(Tlen):
        #print("i:j:S[i+j]:T[j]",i,j,S[i+j],T[j])
        if flg == True:
            if (S[i+j] == T[j]) or (S[i+j] == '?'):
                if j == (Tlen -1) and flg == True:
                    start = i
            else:
                flg = False
if start == (Slen + 1):
    print('UNRESTORABLE')
else:
    S2 = S[:start] + T + S[start+Tlen:]
    S3 = S2.replace("?","a")
    print(S3)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
#define ll long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/*******source code below********/
#define MAX_S 100010
ll L;
string S;
ll dp[MAX_S][4];
void solve() {
	for (int i = 0; i < 4; i++)
	{
		dp[L][i] = (i == 3) ? 1 : 0;
	}
	for (ll i = L - 1; i >= 0; i--) {
		for (int j = 3; j >= 0; j--) {
			if (j == 3) { 
				dp[i][j] = (S[i] == '?') ? 3 * dp[i + 1][j] : 1 * dp[i + 1][j]; 
				dp[i][j] %= mod;
			}else {
				int m1, m2;
				m1 = (S[i] == '?') ? 3 : 1;
				m2 = (S[i] == '?' || S[i] - 'A' == j) ? 1 : 0;
				dp[i][j] = m1 * dp[i + 1][j] + m2 * dp[i + 1][j + 1];
				dp[i][j] %= mod;
			}
		}
	}
}

int main(void) {

	cin >> S;
	L = S.length();
	solve();
	ll ans = dp[0][0];
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 3584
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
sum = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = 500*i + 100*j + 50*k 
            if X == sum:
                count+=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll min(ll a,ll b){
if(a>b){
  return b;
}
  else{
    return a;
  }
}
ll max(ll a,ll b){
if(a>b){
  return a;
}
  else{
return b;
  }
}
 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	
}



int main(){
 ll N,X;
  cin>>N>>X;
  
  vector<ll>x(N);
  vector<ll>date(N);
  
  for(ll i=0;i<N;i++){
cin>>x[i];
  }
  sort(x.begin(),x.end());
  
  for(ll i=0;i<N;i++){
    date[i]=abs(x[i]-X);
  }
  if(N==1){
cout<<abs(x[0]-X);
  }
  else{
  ll ans=gcd(date[1],date[0]);
  for(ll i=1;i<N;i++){
    
      ans=gcd(date[i],ans);
    }
  

  cout<<ans<<endl;
}

}

  
  
  

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace cswork {

    class Program {
        public Program () { }

        Scanner cin;

        void Omame () {
            cin = new Scanner ();
            long a = cin.nextLong ();
            long b = cin.nextLong ();
            long c = cin.nextLong ();
            long x = cin.nextLong ();

            long ans = 0;
            for (int i = 0; i <= a; i++) {
                for (int j = 0; j <= b; j++) {
                    for (int k = 0; k <= c; k++) {
                        long n = i * 500 + j * 100 + k * 50;
                        if (x == n) {
                            ans++;
                        }
                    }
                }
            }
            Console.WriteLine (ans);
        }
        static void Main (string[] args) {
            new Program ().Omame ();
        }
    }

    class Scanner {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner () {
            s = new string[0];
            i = 0;
        }

        public string next () {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();

            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next ();
        }

        public int nextInt () {
            return int.Parse (next ());
        }

        public long nextLong () {
            return long.Parse (next ());
        }

        public double nextDouble () {
            return double.Parse (next ());
        }
    }
}

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

int main(){
  int n; cin>>n;
  if(n <= 111){
    cout<<111<<endl;
  }else if(n <= 222){
    cout<<222<<endl;
  }else if(n <= 333){
    cout<<333<<endl;
  }else if(n <= 444){
    cout<<444<<endl;
  }else if(n <= 555){
    cout<<555<<endl;
  }else if(n <= 666){
    cout<<666<<endl;
  }else if(n <= 777){
    cout<<777<<endl;
  }else if(n <=888){
    cout<<888<<endl;
  }else{
    cout<<999<<endl;
  }
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var A = int.Parse(ss[0]);
            var B = int.Parse(ss[2]);

            Console.WriteLine(ss[1] == "+" ? A + B : A - B);
        }
    }
}

Measured memory_bytes: 11092
x,y=map(int,input().split())
n=x+y
if x/y>2 or y/x>2 or n%3!=0:
    print(0)
    exit()
n//=3
r=min(x-n,y-n)
m=10**9+7
a=b=1
for i in range(r):
    a=a*(n-i)%m
    b=b*(i+1)%m
print(a*pow(b,m-2,m)%m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    if (N >= 30) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{     
      char a,b;
      cin>>a>>b;
      if(a=='H') 
      {
          cout<<b;
      }
      else
      {
            if(b=='H')
            {  cout<< a; }
             else
            {cout<<'H';} 
 
       }
      return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    if (N % 2 == 0) {
        cout << 0.5 << endl;
    } else {
        cout << (N + 1) / 2 / float(N) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = input()
dictInProb = set()
for i in range(int(n)):
    cmdAndStr = list(input().split())
    if cmdAndStr[0] == "insert":
        dictInProb.add(cmdAndStr[1])
    elif cmdAndStr[0] == "find":
        if cmdAndStr[1] in dictInProb:
            print("yes")
        else:
            print("no")
    else: pass

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

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> iP;
typedef pair< LL, LL > LP;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

int grid[105][105];

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

        int h, w;
        cin >> h >> w;
        for( int i = 1; i <= h; ++i ) {
                string s;
                cin >> s;
                for( int j = 1; j <= w; ++j ) {
                        if( s[j - 1] == '#' ) grid[i][j] = 1;

                }
        }

        for( int i = 1; i <= h; ++i ) {
                for( int j = 1; j <= w; ++j ) {
                        if( grid[i][j] == 1 ) {
                                cout << '#';

                        } else {
                                int sum = grid[i - 1][j - 1] + grid[i - 1][j] + grid[i - 1][j + 1] + grid[i][j - 1] + grid[i][j + 1] + grid[i + 1][j - 1] + grid[i + 1][j] + grid[i + 1][j + 1];

                                cout << sum;
                        }
                }
                cout << endl;

        }

    return 0;
}



Measured memory_bytes: 256
import numpy as np
N, T = map(int,input().split())
c_t = np.array([input().split() for _ in range(0, N)])
c_t = c_t.astype(int)

if np.min(c_t[:,1]) <= T:
    print(np.sort(c_t[np.where(c_t[:,1] <= T)][:,0])[0])
else:
    print('TLE')

Measured memory_bytes: 18632
#include "bits/stdc++.h"
using namespace std;
int s[10000];/*??????¨?*/
char kk[100];
int main(){
	int W,H;
	cin >> H>>W;
	for(int i = 0;i <= H-1;i++){
			string n;
			cin >>n;
			int cloud = -1;
			for(int m = 0;m < W;m++){

			int loc = 100*i+m;

			if(n.substr(m,1) =="c"){
				s[loc] = 0;
				cloud = 0;
			}else{
									if(cloud >= 0)cloud++;
					s[loc] = cloud;

			}
		}
	}

	for(int i = 0;i <H;i++){
		for(int k = 0;k<W;k++){
			cout << s[100*i+k];
			if(k != W-1)cout <<" ";
		}
		cout <<endl;
	}

		return 0;
}

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

#define a 1000000007LL

using namespace std;

int main() {
  int N;
  uint64_t A[200000];
  uint64_t c[200000] = {};
  uint64_t result = 1;
  int count = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      count++;
      if (count >= 4) {
        cout << 0 << endl;
        return 0;
      }
      c[A[i]]++;
      continue;
    }
    int tmp = c[A[i] - 1LL] - c[A[i]];
    result = (result * tmp) % a;
    c[A[i]]++;
  }
  result = ((count == 1 ? 3LL : 6LL) * result) % a;

  cout << result << endl;
}


Measured memory_bytes: 3456
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let c = get!(usize);
    let mut d = vec![vec![0; c+1]; c+1];
    for i in 1..c+1 {
    	for j in 1..c+1 {
        	d[i][j] = get!();
        }
    }
    let mut g = vec![vec![0i64; c+1]; 3];
    for i in 1..n+1 {
    	for j in 1..n+1 {
        	let p = (i + j) % 3;
            let c = get!(usize);
        	g[p][c] += 1;
        }
    }
    let mut ans = std::i64::MAX;
    for c0 in 1..c+1 {
    	let mut d0 = 0;
        for i in 0..g[0].len() {
        	d0 += g[0][i] * d[i][c0];
        }
    	for c1 in 1..c+1 {
        	if c0 == c1 {
            	continue;
            }
	    	let mut d1 = 0;
    	    for i in 0..g[1].len() {
        		d1 += g[1][i] * d[i][c1];
        	}
            for c2 in 1..c+1 {
            	if c0 == c2 || c1 == c2 {
                	continue;
                }
	    		let mut d2 = 0;
    	    	for i in 0..g[2].len() {
        			d2 += g[2][i] * d[i][c2];
        		}
                let d = d0+d1+d2;
                ans = std::cmp::min(ans, d);
            }
        }
    }
    println!("{}", ans);
}

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

int main() {
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans = 0;
    for(int i=0;i<=n;i++) {
        for(int j=0; j<=n; j++) {
            int x = r*i+j*g;
            if(x>n) break;
            if((n-x)%b==0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int s=0,n,t;
int main()
{
   cin>>n;
   v.clear();
   for (int i=1;i<=n;i++)
   {
   	  cin>>t;
   	  v.push_back(t);
	  s+=t;	
   }
   sort(v.begin(),v.end());
   if(s%10==0) 
     	for(int i=0;i<=v.size()-1;i++)   			
   			if ((s-v[i])%10!=0) {s=s-v[i];break;}
   if (s%10==0)
   		cout<<0<<endl;
   else
   		cout<<s<<endl;   
   return 0;
} 

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 2e5 + 10;
vector<int> a[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  queue<int> Q;
  vector<int> visit(n, -1);
  visit[0] = 0;
  Q.push(0);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto& v : a[u]) {
      if (visit[v] >= 0) continue;
      visit[v] = u;
      Q.push(v);
    }
  }
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if (visit[i] < 0) found = true;
  }
  if (found) {
    puts("No");
  } else {
    puts("Yes");
    for (int i = 1; i < n; ++i) {
      printf("%d\n", visit[i] + 1);
    }
  }
  return 0;
}


Measured memory_bytes: 12152
#include <stdio.h>

main(void)
{
	int a,b,c,i;
	i=0;
	
	scanf("%d%d%d",&a,&b,&c);
	
	for(a=a;a<=b;a++){
		if(c%a==0){
			i++;
		}
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int H, W, M; std::cin >> H >> W >> M;
    std::set<std::pair<int, int>> p;
    int mh(0), mw(0);
    std::vector<int> t, y;
    std::map<int, int> hh, ww;
    {
        int h, w;
        for(int i(0); i < M; ++i){
            std::cin >> h >> w;
            p.emplace(h, w);
            ++hh[h]; ++ww[w];
            chmax(mh, hh[h]); chmax(mw, ww[w]);
        }
    }
    for(auto [a, b]: hh){
        if(b == mh) t.push_back(a);
    }
    for(auto [a, b]: ww){
        if(b == mw) y.push_back(a);
    }
    int ans(mh + mw - 1);
    for(int i(0), i_len(t.size()); i < i_len; ++i){
        for(int j(0), j_len(y.size()); j < j_len; ++j){
            if(p.find({t[i], y[j]}) == std::end(p)){
                std::cout << ans + 1 << std::endl;
                return 0;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 49588
//
//  main.cpp
//  JOI
//
//  Created by Kate Tada on 2016/06/08.
//  Copyright ?? 2016??´ aaa. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    for (int a = 1; a < 10; a++)
    {
        for (int b = 1; b < 10; b++)
        {
            cout << a <<"x"<< b << "=" << a*b <<endl;
        }
    }
}


Measured memory_bytes: 1112
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

bool inside( const int y, const int x )
{
	return 0 <= y && y < 8 && 0 <= x && x < 8;
}

int flip( VS &board, int y, int x, char c )
{
	int res = 0;
	REP( dy, -1, 2 )
	{
		REP( dx, -1, 2 )
		{
			if ( !( dy | dx ) )
			{
				continue;
			}
			bool ok = false;
			for ( int cy = y + dy, cx = x + dx; inside( cy, cx );  cy += dy, cx += dx )
			{
				if ( board[ cy ][ cx ] == '.' )
				{
					break;
				}
				else if ( board[ cy ][ cx ] == c )
				{
					ok = true;
					break;
				}
			}
			if ( ok )
			{	
				for ( int cy = y + dy, cx = x + dx; inside( cy, cx ) && board[ cy ][ cx ] != c;  cy += dy, cx += dx )
				{
					board[ cy ][ cx ] = c;
					res++;
				}
			}
		}
	}
	if ( res )
	{
		board[y][x] = c;
	}
	return res;
}

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

	VS board( 8 );
	FOR( line, board )
	{
		cin >> line;
	}

	for ( int t = 0; ; t++ )
	{
		bool pass1 = false, pass2 = false;

		{ // mami
			int maxflip = 0, y = -1, x;
			REP( i, 0, 8 )
			{
				REP( j, 0, 8 )
				{
					if ( board[i][j] != '.' )
					{
						continue;
					}
					VS tmp_board( board );
					const int tmp = flip( tmp_board, i, j, 'o' );
					if ( maxflip < tmp )
					{
						y = i;
						x = j;
						maxflip = tmp;
					}
				}
			}
			if ( maxflip == 0 )
			{
				pass1 = true;
			}
			else
			{
				flip( board, y, x, 'o' );
			}
		}
		{ // charlotte
			int maxflip = 0, y = -1, x;
			for ( int i = 7; 0 <= i; i-- )
			{
				for ( int j = 7; 0 <= j; j-- )
				{
					if ( board[i][j] != '.' )
					{
						continue;
					}
					VS tmp_board( board );
					const int tmp = flip( tmp_board, i, j, 'x' );
					if ( maxflip < tmp )
					{
						y = i;
						x = j;
						maxflip = tmp;
					}
				}
			}
			if ( maxflip == 0 )
			{
				pass2 = true;
			}
			else
			{
				flip( board, y, x, 'x' );
			}
		}

		if ( pass1 && pass2 )
		{
			break;
		}
	}

	FOR( line, board )
	{
		cout << line << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2100