akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int x, y, pa, pb, pc;
int a[100010];
int b[100010];
int c[100010];

//定义比较结构
struct cmp1{
    bool operator ()(int &a,int &b){
        return a>b;//最小值优先
    }
};

bool compare(const int &a, const int &b) {
	return a > b;
}

int main()
{
	scanf("%d%d%d%d%d", &x, &y, &pa, &pb, &pc);
	for (int i = 0 ; i < pa ; i++)
		scanf("%d", &(a[i]));
	for (int i = 0 ; i < pb ; i++)
		scanf("%d", &(b[i]));
	for (int i = 0 ; i < pc ; i++)
		scanf("%d", &(c[i]));
		
	sort(a, a + pa, compare);
	sort(b, b + pb, compare);
	sort(c, c + pc, compare);
	
	long long curSum = 0;
	std::priority_queue<int, vector<int>, cmp1> qa;
	std::priority_queue<int, vector<int>, cmp1> qb;
	for (int i = 0 ; i < x ; i++) {
		qa.push(a[i]);
		curSum = curSum + a[i];
	}
		
	for (int i = 0 ; i < y ; i++) {
		qb.push(b[i]);
		curSum = curSum + b[i];
	}
		
		
	int numA, numB;
	int num;
	for (int i = 0 ; i < pc ; i++) {
		numA = qa.top();
		numB = qb.top();
		
		long long diff = 0;
		if (numA > numB) {
			if (c[i] > numB) {
				diff = c[i] - numB;
				qb.pop();
				qb.push(c[i]);
			} else {
				break;
			}
		} else {
			if (c[i] > numA) {
				diff = c[i] - numA;
				qa.pop();
				qa.push(c[i]);
			} else {
				break;
			}	
		}
		
		curSum = curSum + diff;
	}
	
	printf("%lld\n", curSum);
	
	
	
	return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n;
  ll ans = 0;
  string s;
  cin >> n >> s;
  int R[n], G[n], B[n];
  if (s[0] == 'R') R[0]++;
  if (s[0] == 'G') G[0]++;
  if (s[0] == 'B') B[0]++;
  repi(i, 1, n) {
    if (s[i] == 'R') {
      R[i] = R[i - 1] + 1;
      G[i] = G[i - 1];
      B[i] = B[i - 1];
    }
    if (s[i] == 'G') {
      R[i] = R[i - 1];
      G[i] = G[i - 1] + 1;
      B[i] = B[i - 1];
    }
    if (s[i] == 'B') {
      R[i] = R[i - 1];
      G[i] = G[i - 1];
      B[i] = B[i - 1] + 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (219 - s[i] - s[j] == 82) {
        if (2 * j - i < n) {
          if (s[2 * j - i] != 'R') {
            ans += R[n - 1] - R[j];
          } else {
            ans += R[n - 1] - R[j] - 1;
          }
        } else {
          ans += R[n - 1] - R[j];
        }
      } else if (219 - s[i] - s[j] == 71) {
        if (2 * j - i < n) {
          if (s[2 * j - i] != 'G') {
            ans += G[n - 1] - G[j];
          } else {
            ans += G[n - 1] - G[j] - 1;
          }
        } else {
          ans += G[n - 1] - G[j];
        }
      } else if (219 - s[i] - s[j] == 66) {
        if (2 * j - i < n) {
          if (s[2 * j - i] != 'B') {
            ans += B[n - 1] - B[j];
          } else {
            ans += B[n - 1] - B[j] - 1;
          }
        } else {
          ans += B[n - 1] - B[j];
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using LL = long long;

int n;

char s[50];

string s1, s2;

unordered_map<string, LL> st;

int main() {
	cin >> n >> s;
	
	LL full = 1 << n;
	
	for (LL S = 0; S < full; ++S) {
		s1.clear();
		s2.clear();
		
		for (int i = 0; i < n; ++i)
			if (S & (1 << i)) s1.push_back(s[i]);
			else s2.push_back(s[i]);
		
		reverse(s2.begin(), s2.end());
		++st[s1 + "$" + s2];
		
		// cerr << "cnbb1: " << s1 + "$" + s2 << endl;
	}
	
	LL ans = 0;
	
	for (LL S = 0; S < full; ++S) {
		s1.clear();
		s2.clear();
		
		for (int i = 0; i < n; ++i)
			if (S & (1 << i)) s1.push_back(s[i + n]);
			else s2.push_back(s[i + n]);
		
		reverse(s1.begin(), s1.end());
		ans += st[s1 + "$" + s2];
		
		// cerr << "cnbb2: " << s1 + "$" + s2 << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 70900
import math

a,b,h,m = (int(x) for x in input().split())
dh = 30*h+0.5*m
dm = 6*m
if dh==dm:
  print(abs(a-b))
elif dh<dm:
  print(math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(dm-dh))))
else:
  print(math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(dh-dm))))

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

typedef long long LL;

const int maxn=200020;
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;

vector<int>vec;

int main()
{
    for(int i=2;i<=1000;i++){
        int res=i;
        for(int j=2;j<=10;j++){
            res*=i;
            if(res>1000) break;
            else vec.push_back(res);
        }
    }
    vec.push_back(1);

    sort(vec.begin(),vec.end());
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<vec.size();i++){
        if(vec[i]>n) break;
        ans=vec[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n, m = [int(v) for v in input().split()]
cities = []
for i in range(m):
        py = tuple(int(v) for v in input().split())
        cities.append((py[1], py[0], i))
cities.sort()
nums = [None] * m
city_nums = {}
for city in cities:
        if not city[1] in city_nums:
                city_nums[city[1]] = 1
        else:
                city_nums[city[1]] += 1
        nums[city[2]] = str(city[1]).zfill(6) + str(city_nums[city[1]]).zfill(6)
for num in nums:
        print(num)

Measured memory_bytes: 36248
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var D = Number.parseInt(inputStr[1]);
  var X_arr = [];
  var count = 0;
  //引数の配列を数値変換してX_arrに溜め込む。配列は擬似的な二次元配列
  for (var i = 0; i < N ; i++){  
    var tmp = input[i+1].split(" ");
    X_arr.push(tmp.map( tmp => parseInt(tmp)));
  }
  //ループで回しながら計算する
  for(var i1 = 0; i1 < N-1 ; i1++ ){
	//中間変数tmpを定義
    var tmp1 = X_arr[i1].map(tmp => parseInt(tmp));
    
    for(var i2=i1+1; i2 < N ; i2++){
      var cul = 0;
      var tmp2 = X_arr[i2].map(tmp => parseInt(tmp));
      
      //D=配列の横分ループを回して各要素の計算結果を足しこむ。
      for(var i3 = 0 ; i3 < D ; i3++){
        cul = cul + Math.pow(tmp1[i3]-tmp2[i3],2)
      }
      if (Number.isInteger(Math.sqrt(cul))){
        count += 1;
      }
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main()
{
	static int dp[2][5][1 + (1 << 15)];
	dp[0][0][0] = 1;
	for (int i = 1; i * i <= (1 << 15); i++){
		memset(dp[i & 1], 0, sizeof(dp[i & 1]));
		for (int j = 0; j <= 4; j++){
			for (int k = 4; k - j >= 0; k--){
				for (int l = (1 << 15); l - i * i * j >= 0; l--){
					dp[i & 1][k][l] += dp[1 - (i & 1)][k - j][l - i * i * j];
				}
			}
		}
	}
	
	for (int T; scanf("%d", &T) && T;){
		printf("%d\n", dp[1][1][T] + dp[1][2][T] + dp[1][3][T] + dp[1][4][T]);
	}
	
	return (0);
}

Measured memory_bytes: 2476
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int h = Integer.parseInt(strs[0]);
		int w = Integer.parseInt(strs[1]);
		boolean[][] map = new boolean[h][w];
		for(int i = 0 ; i < h ; i++){
			strs = br.readLine().split(" ");
			for(int j = 0 ; j < w ; j++){
				map[i][j] = Integer.parseInt(strs[j]) % 2  == 1;
			}
		}
		
		ArrayList<String> result = new ArrayList<String>();
		
		int j1 = 0;
		L1:for(int i = 0 ; i < h ; i++){
			while(!map[i][j1]){
				j1++;
				if(j1 >= w){
					j1 = 0;
					continue L1;
				}
			}
			int j2 = j1 +1;
			if(j2 >= w){
				if(i+1 < h){
					map[i][j1] = false;
					map[i+1][j1] = !map[i+1][j1];
					result.add((i+1)  + " " + (j1+1) + " " + (i+1+1) + " " + (j1+1));
				}
				j1 = 0;
				continue L1;
			}
			while(!map[i][j2]){
				j2++;
				if(j2 >= w){
					if(i+1 < h){
						map[i][j1] = false;
						map[i+1][j1] = !map[i+1][j1];
						result.add((i+1)  + " " + (j1+1) + " " + (i+1+1) + " " + (j1+1));
					}
					j1 = 0;
					continue L1;
				}
			}
			
			for(int m = j1 ; m < j2 ; m++){
				result.add((i+1)  + " " + (m+1) + " " + (i+1) + " " + (m+1+1));
			}
			
			map[i][j1] = false;
			map[i][j2] = false;
			j1 = j2;
			i--;
			continue L1;
		}
		/*
		for(int i = 0 ; i < h ; i++){
			for(int j = 0 ; j < w ; j++){
				System.out.print(map[i][j]?"x":"o");
			}
			System.out.println();
		}*/
		
		System.out.println(result.size());
		for(String s:result){
			System.out.println(s);
		}
	}
}


Measured memory_bytes: 60080
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(a, b);
    if(a == 1)a += 13;
    if(b == 1)b += 13;
    if(a < b)puts("Bob");
    if(a > b)puts("Alice");
    if(a == b)puts("Draw");

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	cout << min(p + q, min(q + r, r + p)) << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int n,t,x,y;
	bool f=true;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d %d %d",&t,&x,&y);
		if(t%(x+y)!=0&&(t-x-y)%2!=0||t<(x+y))
			f=false;
	}
	if(f) 
		printf("Yes");
	else
		printf("No");
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s0;
	int n, a, b;
	string str[3] = {"replace", "reverse", "print"};
	cin >> s0 >> n;
	rep(i,n) {
		string s1;
		cin >> s1 >> a >> b;	
		if(s1 == str[0]) {
			string q;
			cin >> q;
			s0.replace(a, b - a + 1, q);
		} else if(s1 == str[1]) {
			string s2 = s0.substr(0, a);
			string s3 = s0.substr(a, b - a + 1);
			string s4 = s0.substr(b + 1);
			string s5;
			for(int j = 0; j < b - a + 1; ++j) {
				s5 += s3[b - a - j];
			}
			s0 = s2 + s5 + s4;
		} else if(s1 == str[2]){
			rep2(j, a, b + 1) {
				cout << s0[j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int k = n / 2;
	if (n % 2 == 0 && s.substr(0, k) == s.substr(k, k))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
        cin>>N;
        A.resize(N);
        for(auto &x:A) cin>>x;
        
        Int ans=0;Int best=0;
        for(int i=1;i<N;++i){
            if(A[i]>A[i-1]){
                best=max(best,ans);
                ans=0;
            }
            else ++ans;
        }
        best=max(best,ans);
        cout<<best<<"\n";
        
}


Measured memory_bytes: 27468
#include<bits/stdc++.h>
using namespace std;
long long n,x[100005],i,j,y[100005],z[100005],top,top2,top3,book1[100005],book2[100005];
int main(){	
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x[i];
		if(x[i]<0){
			top++;
			y[top]=x[i];
		}
		else{
			top2++;
			z[top2]=x[i];
		}
	}
	if(top==0){
		sort(z+1,z+top2+1);
		for(j=3;j<=top2;j++){
			top3++;
			book1[top3]=z[1];
			book2[top3]=z[j];
			z[1]-=z[j];
		}
		top3++;
		book1[top3]=z[2];
		book2[top3]=z[1];
		z[2]-=z[1];
		cout<<z[2]<<endl;
		for(i=1;i<=top3;i++)
			cout<<book1[i]<<" "<<book2[i]<<endl;
	}
	else if(top2==0){
		sort(y+1,y+top+1);
		for(j=top-1;j>=1;j--){
			top3++;
			book1[top3]=y[top];
			book2[top3]=y[j];
			y[top]-=y[j];
		}
		cout<<y[top]<<endl;
		for(i=1;i<=top3;i++)
			cout<<book1[i]<<" "<<book2[i]<<endl;
	}
	else{
		sort(y+1,y+top+1);
		sort(z+1,z+top2+1);
		if(top==1){
			for(i=1;i<=top2-1;i++){
				top3++;
				book1[top3]=y[top];
				book2[top3]=z[i];
				y[top]-=z[i];
			}
			top3++;
			book1[top3]=z[top2];
			book2[top3]=y[top];
			z[top2]-=y[top];
			cout<<z[top2]<<endl;
			for(i=1;i<=top3;i++)
				cout<<book1[i]<<" "<<book2[i]<<endl;
		}
		else{
			for(i=1;i<=top2-1;i++){
				top3++;
				book1[top3]=y[top];
				book2[top3]=z[i];
				y[top]-=z[i];
			}
			for(i=1;i<=top;i++){
				top3++;
				book1[top3]=z[top2];
				book2[top3]=y[i];
				z[top2]-=y[i];
			}
			cout<<z[top2]<<endl;
			for(i=1;i<=top3;i++)
				cout<<book1[i]<<" "<<book2[i]<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 4992
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
string s;
int k;
vector<string> v;
int main()
{
	cin>>s;
	cin>>k;
	for(int i=0;i<s.length();i++)
	{
		string cur;
		for(int j=i;j<s.length()&&j<i+k;j++)
		{
			cur+=s[j];
			v.push_back(cur);
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	cout<<v[k-1]<<endl;
	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n+1];memset(arr,0,sizeof(arr));
	for(int i=0;i<k;i++){
	    int d;cin>>d;
	    for(int j=0;j<d;j++){
	        int c;cin>>c;
	        arr[c]++;
	    }
	}
	int res=0;
	for(int i=1;i<n+1;i++){
	    if(arr[i]==0){res++;}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> H >> W >> D;
	vector<pair<int, int>>N(H*W + 1);
	vector<int>sum(H*W + 1, 0);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A;
			N[A] = { i,j };
		}
	}
	for (int a = 1+D; a < H*W + 1; a++) {
		sum[a] = sum[a - D] + abs(N[a].first - N[a - D].first) + abs(N[a].second - N[a - D].second);
	}
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> L >> R;
		cout << sum[R] - sum[L] << endl;
	}
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,aa[110000],cnt=0;
string s,ss;
signed main()
{
	cin>>a;
	rep(i,a){
		if((i+1)/10==0||((i+1)/100>=1&&(i+1)/1000==0)||((i+1)/10000>=1&&(i+1)/100000==0)){
			cnt++;
		}
	}
	cout<<cnt;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

char x,y;

main() {
    cin >> x >> y;
    if (x>y) ct(">")
    else if (x<y) ct("<")
    else ct("=")
}








Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const in MOD = 998244353;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
using T=tuple<int,int,int>;

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

    int n,q;
    cin>>n>>q;
    vector<P> cng(q);
    vector<int> num(q);
    rep(i,q){
        cin>>cng[i].first>>cng[i].second>>num[i];
        cng[i].first--;
        cng[i].second--;
    }

    set<T> a;
    a.emplace(n-1,0,1);
    int x=0,y,z;

    using mint=modint998244353;
    vector<mint> mo(n,0);
    mint ten=1;
    mo[n-1]=1;
    for(int i=n-2;i>=0;i--){
        ten *= 10;
        mo[i]=mo[i+1]+ten;
    }
    mo.emplace_back(0);

    mint sum=mo[0];
    int s,t,u;
    auto v=a.lower_bound(T(x,0,0));

    rep(i,q){
        tie(x,y)=cng[i];
        z=num[i];

        v=a.lower_bound(T(x,0,0));
        if(v==a.end()) goto jump;
        else tie(s,t,u)=*v;

        while(y>=t){
            v=a.erase(v);
            if(y>=s){
                if(t>=x) sum -= u*(mo[t]-mo[s+1]);
                else{
                    a.emplace(x-1,t,u);
                    sum -= u*(mo[x]-mo[s+1]);
                }
            }
            else{
                a.emplace(s,y+1,u);
                if(t>=x) sum -= u*(mo[t]-mo[y+1]);
                else{
                    sum -= u*(mo[x]-mo[y+1]);
                    a.emplace(x-1,t,u);
                }
            }
            if(v==a.end()) break;
            else tie(s,t,u)=*v;
        }
        jump:
        a.emplace(y,x,z);
        sum += z*(mo[x]-mo[y+1]);
        cout<<sum.val()<<'\n';
    }
}/*
./problem.exe
*/


Measured memory_bytes: 18992
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    int j = i;
    while(j > 0){
      j /= 10;
      cnt++;
    }
    if(cnt%2 == 1) ans++;
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ALL(x) begin(x), end(x)
using namespace std;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> s(n), t(m);
    for(auto& x : s)
        cin >> x;
    for(auto& x : t)
        cin >> x;

    auto sign = [] (int x)-> int {
        return (x >= 0) - (x < 0);
    };

    auto answer = [&] (int x)->int {
        vector<int> ss, tt;
        auto it = lower_bound(ALL(s), x);
        if(it != end(s)) ss.push_back(*it);
        if(it != begin(s)) {
            --it;
            ss.push_back(*it);
        }
        it = lower_bound(ALL(t), x);
        if(it != end(t)) tt.push_back(*it);
        if(it != begin(t)) {
            --it;
            tt.push_back(*it);
        }

        int ans = numeric_limits<int>::max();
        for(int uu : ss) {
            for(int vv : tt) {
                int u = uu;
                int v = vv;
                if(sign(x - u) * sign(x - v) == 1) {
                    u = abs(x - u);
                    v = abs(x - v);
                    ans = min(ans, max(u, v));
                } else {
                    u = abs(x - u);
                    v = abs(x - v);
                    if(u > v) swap(u, v);
                    ans = min(ans, 2 * u + v);
                }
            }
        }

        return ans;
    };

    while(q--) {
        int x;
        cin >> x;
        cout << answer(x) << '\n';
    }
}

Measured memory_bytes: 2944
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)

constexpr double EPS = 1e-9;

struct point {
	double x, y, z;
	explicit point(double x_ = 0, double y_ = 0, double z_ = 0):x(x_), y(y_), z(z_) {}

	point operator-(const point &p) const {
		return point(x - p.x, y - p.y, z - p.z);
	}
};

struct sphere {
	point c;
	double r;
	sphere(const point &c_, double r_):c(c_), r(r_) {}
};

double norm(const point &p) {
  return p.x * p.x + p.y * p.y + p.z * p.z;
}

double dot(const point &a, const point &b) {
  return a.x * b.x + a.y * b.y + a.z * b.z;
}

vector<double> solve_quadratic_equation(double a, double b, double c) {
	const double d = b * b - 4 * a * c;
	if(d < -EPS) return {};
	return {(-b - sqrt(d)) / (2 * a), (-b + sqrt(d)) / (2 * a)};
}

double get_time(const sphere &a, const sphere &va, const sphere &b, const sphere &vb) {
	const point d = a.c - b.c;
	const point dv = va.c - vb.c;
	const double sum_r = a.r + b.r;
	const double sum_vr = va.r + vb.r;

	const double x = norm(dv) - sum_vr * sum_vr;
	const double y = 2.0 * (dot(d, dv) + sum_r * sum_vr);
	const double z = norm(d) - sum_r * sum_r;

	if(abs(x) < EPS) return INT_MAX;

	double res = INT_MAX;
	vector<double> ans = solve_quadratic_equation(x, y, z);
	for(const auto &e : ans) {
		if(e > 0) res = min(res, e);
	}
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int n; cin >> n && n;) {
		vector<sphere> stars;
		vector<sphere> vec;
		stars.reserve(n);
		vec.reserve(n);

		rep(i, n) {
			double px, py, pz, vx, vy, vz, r, vr;
			cin >> px >> py >> pz >> vx >> vy >> vz >> r >> vr;
			stars.emplace_back(point(px, py, pz), r);
			vec.emplace_back(point(vx, vy, vz), vr);
		}

		typedef tuple<double, int, int> event;
		vector<event> event_list;
		event_list.reserve(n * n);

		rep(i, n) {
			event_list.emplace_back(stars[i].r / vec[i].r, i, i);
		}

		rep(i, n) {
			rep(j, i) {
				event_list.emplace_back(get_time(stars[i], vec[i], stars[j], vec[j]), i, j);
			}
		}

		sort(ALL(event_list));
		vector<double> ans(n);
		vector<bool> used(n, false);

		for(const auto &e : event_list) {
			double t;
			int a, b;
			tie(t, a, b) = e;

			if(used[a] || used[b]) continue;

			ans[a] = ans[b] = t;
			used[a] = used[b] = true;
		}

		for(const auto &e : ans) {
			cout << e << endl;
		}
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1676
#include <stdio.h>

int main(void){

        int a, b, c;

        scanf("%d %d %d", &a, &b, &c);

        if(0<=a && a<=100 && 0<=b && b<=100 && 0<=c && c<=100){

                if(a < b && b < c){
                        printf("Yes\n");
                }else{
                        printf("No\n");
                }
        }

        return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  string s; int k;
  cin>>s>>k;
  vector<string> v;
  rep(i,0,s.size()){
    for(int j=1 ; j<=k&& i+j-1<s.size() ; j++){
      v.pb(s.substr(i,j));
    }
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  cout << v[k-1] << endl;
  return 0;
}


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

int main() {

	ll n, k, q; cin >> n >> k >> q;
	vector<ll> c(n, k - q);
	for (int i = 0; i < q; i++) {
		ll a; cin >> a;
		c[--a]++;
	}
	for (int i = 0; i < n; i++) {
		if (0 < c[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
long long int sum[200000+200];
int main()
{
	long long int i,k,n,cnt=0,cnt1=0,ans=1000000000000000000;
	cin>>k>>n;
	long long int ara[n];
	for(i=0;i<n;i++){
		cin>>ara[i];
	}
	sort(ara,ara+n);
	for(i=0;i<n-1;i++){
		cnt+=ara[i+1]-ara[i];
		sum[i+1]=cnt;
	}
	
	for(i=1;i<n;i++){
		cnt1=ara[0]+(k-ara[n-1]);
		cnt1+=sum[i]+(sum[n-1]-sum[i+1]);
		ans=min(ans,cnt1);		
	}

	cout<<min(ans,cnt)<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    int n,a=0,b=0,ab=0,ans=0,tmp=0;
    cin>>n;
    vector<string> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        int len=v[i].length();
        if(v[i][0]=='B' && v[i][len-1]=='A') ab++;
        else if(v[i][0]=='B') b++;
        else if(v[i][len-1]=='A') a++;
        for(int j=0;j<len-1;j++){
            if(v[i].substr(j,2)=="AB") ans++;
        }
    }
    if(ab==0) tmp=min(a,b);
    else if(a+b>0) tmp=ab+min(a,b);
    else if(a+b==0) tmp=ab-1;
    ans+=tmp;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		if (s.length() > k) {
			System.out.println(s.substring(0, k) + "...");
		} else {
			System.out.println(s);
		}
	}

}


Measured memory_bytes: 38628
#include <bits/stdc++.h>
using namespace std;
#define                MXX 1000006
#define                FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define                exit() return 0
#define                mpii map<int, int>
#define                mpit map<int, int>::iterator it
#define                si set<int>
#define                sit set<int>::iterator it;
#define                ll long long int
#define                endl "\n";
const                  ll INF = 2000000000000000000LL;
const                  int MOD = 10000007;

int a[MXX], N;
int dp[MXX];
ll solve(int curr)
{
    if(curr>=N)
    {
        return INF;
    }
    if(curr == N - 1)
    {
        return 0;
    }
    if(dp[curr]!=-1)
    {
        return dp[curr];
    }
    ll x = solve(curr + 1) + abs(a[curr] - a[curr+1]);
    ll y = solve(curr + 2) + abs(a[curr] - a[curr+2]);
    ll ans = min(x, y);
    dp[curr] = ans;
    return ans;
}
int main()
{
    FAST_IO;
    cin>>N;
    for(int i = 0; i<N; i++)cin>>a[i];
    memset(dp, -1, sizeof(dp));
    cout<<solve(0)<<endl;
    return 0;
}


Measured memory_bytes: 9472
#include<stdio.h>


int main(void){

  int n;
  int a, b, c, d;
  int count;

  while(scanf("%d", &n)!=EOF){
    count=0;
    if(n<=36){
      for(a=0; a<10; ++a){
	for(b=0; b<10; ++b){
	  for(c=0; c<10; ++c){
	    for(d=0; d<10; ++d){
	      if(n==a+b+c+d) count++;
	    }
	  }
	}
      }
    }
    printf("%d\n", count);
    
  }

  return(0);
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int n, a, b;
	cin >> n >> a >> b;
	if(a > b){
		swap(a, b);
	}
	if((b - a) % 2 == 0){
		cout << (b - a) / 2;
	}else{
		int d = b - a - 1;
		cout << min(a + d / 2, n - b + 1 + d / 2);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[110][110];
char S[MAXN];
bool sq[MAXN];

int main()
{
    int n,m,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>m;

    for(int i=1;i<=130;i++)
        sq[i*i] = true;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>A[i][j];

    for(int i=1;i<=n;i++)
        for(int j=1;j<i;j++){
            sum = 0;
            for(int k=1;k<=m;k++)
                sum+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
            if(sq[sum])cnt++;
    }

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,a,b,c,x=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            x++;
        }
    }
    printf("%d\n",x);
    return 0;
    
}

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

#define digit(A,B) (B<strlen(A)?A[strlen(A)-B-1]-'0':0)
#define max(A,B) (A>B?A:B)

#define SIZE 80

int main(void){
//	char a[SIZE+1], b[SIZE+1], c[SIZE]; int i, carry, n;	/* EOFª ÓêÈ¢æ¤1oCg]vÉmÛ */
	char a[1000], b[1000], c[SIZE]; int i, carry, n;	/* Èñ©80ÈãÌàinput³êéçµ¢ */
	
	scanf("%d",&n);

	for(;n--;){	
		carry=0, i=0, scanf("%s%s",a,b);
		
		while(i<max(strlen(a),strlen(b)) || carry!=0){
			if(i==SIZE){ printf("overflow\n"); goto end; }
			
			carry+=digit(a,i)+digit(b,i);
			c[i]=carry%10, carry/=10;
			
			i++;
		}
		
		for(--i; i>=0; i--) printf("%d",c[i]);
		printf("\n");
		
		end:;
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll a, b;

int main()
{
    cin >> a >> b;
    if(a <= 0 && b >= 0) { printf("Zero\n"); }
    else if(a < 0 && b < 0) {
        if(abs(b - a) % 2 == 0) { printf("Negative\n"); }
        else { printf("Positive\n"); }
    } else {
        printf("Positive\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
int x,y,z;
int main()
{
	cin>>x>>y>>z;
	cout<<z<<' '<<x<<' '<<y<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int H,W,h,w; cin >>H >>W >>h >>w;
  if(H%h==0 && W%w==0){
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  int a,b,q,r,p,m,d;
  if(W%w){b=W,a=w;} else{b=H,a=h;}
  q=b/a,r=b%a; // 1<=r<a
  d=a-r;
  m=r*(2*q+1),p=2*d*q;
  if(df)printf("a%d b%d q%d r%d p%d m%d d%d\n",a,b,q,r,p,m,d);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(W%w){
	printf("%d",j%a<r?p:-m);
      }else{
	printf("%d",i%a<r?p:-m);
      }
      printf("%c",j==W-1?'\n':' ');
    }
  }
}

/// confirm df==0 ///


Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
using namespace std;


int main() {
	int M;
	cin >> M;
	int time = 48 - M;
	cout << time << endl;
	return 0;
}

Measured memory_bytes: 256
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int n;
	cin >> n;
	
	int counter = 0;
	for (int i = 1; i <= n; i += 2)
	{
		int subcounter = 0;
		for (int j = 1; j <=i; j++)
		{
			if ((i % j) == 0)
			{
				subcounter++;
			}
		}
		
		if (subcounter == 8)
		{
			counter++;
		}
	}
	
	cout << counter << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


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

typedef long long ll;
const int N = 55;
const int M = 1000000007;

int n, m;
int a[N];
ll dp[N][N * N];

int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]); a[i] -= m;
    }
    int mid = N * N / 2;
    dp[0][mid] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = N * N - 1; j >= 0; j--) {
        dp[i][j] += dp[i - 1][j];
        if (j >= a[i]) { dp[i][j] += dp[i - 1][j - a[i]]; }
      }
    }
    printf("%lld\n", dp[n][mid] - 1);
  }
}


Measured memory_bytes: 1536
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1:
    chk = S.replace('A', '').replace('C', '')
    l = len(chk)
    cnt = 0
    for s in chk:
        if s.islower():
            cnt += 1
    if cnt == l:
        print('AC')
        exit()
print('WA')

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

using namespace std;

int main()
{
  int n,m,l;
  cin>>n>>m>>l;
  long long a[100][100],b[100][100];
  long long c[100][100]={};

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

  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin>>b[i][j];
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
        c[i][k] += a[i][j] * b[j][k];
      }
    }
  }

     for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << (j == 0 ? "": " ") << c[i][j];
    }
    cout << endl;
     }
  return 0;
  }



Measured memory_bytes: 3276
from collections import defaultdict
import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    f = "<v>^".index
    N = int(readline())
    Y = defaultdict(list)
    for i in range(N):
        x, y, d = readline().split()
        x = int(x); y = int(y)
        Y[y].append((x, f(d)))
    *S, = Y.items()
    S.sort()
    L = [0]*N
    V = [[-1]*4 for i in range(N)]
    cur = 0
    X = {}
    for y, es in S:
        es.sort()
        prv = -1
        for x, d in es:
            v = V[cur]
            L[cur] = d
            if x in X:
                k = X[x]
                v[3] = k
                V[k][1] = cur
            X[x] = cur
            if prv != -1:
                v[0] = prv
                V[prv][2] = cur
            prv = cur
            cur += 1
    ans = 0
    for i in range(N):
        res = 0
        R = [e[:] for e in V]
        v = i
        while v != -1:
            d = L[v]
            w0, w1, w2, w3 = r = R[v]
            if w0 != -1:
                R[w0][2] = w2
            if w1 != -1:
                R[w1][3] = w3
            if w2 != -1:
                R[w2][0] = w0
            if w3 != -1:
                R[w3][1] = w1
            res += 1
            v = r[d]
        ans = max(ans, res)
    write("%d\n" % ans)
solve()


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

int main() {
	int n; cin >> n;
	int l[2005];
	int ans = 0;
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	sort(l,l+n);
	int ng, ok, mid;
	for(int i=n-1;i>=2;i--){
		for(int j=i-1;j>=1;j--){
			if((l[i]-l[j])>=l[j-1]){
				continue;
			}else{
				ng = -1;
				ok = j-1;
				while(ok-ng>1){
					mid = (ok+ng)/2;
					//cout << ng << mid << ok << endl;
					if((l[i]-l[j])<l[mid]){
						ok = mid;
					}else{
						ng = mid;
					}
				}
				ans += j-ok;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
int H,W;
  cin>>H>>W;
  
  char C[220][110];
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
    cin>>C[i][j]; }}
  
  int i=0,j=0;
  for(i=0; i<H; i++){
   for(j=0; j<W; j++){ 
    cout<<C[i][j];
   }
  cout<<endl;
    cout<<C[i];
  cout<<endl;  
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2 
int queue[100],len[100],color[100],M[100][100],n;

int main(void){
    int u,k,v,j,o;
    scanf("%d",&n);
    for(j=0;j<n;j++){
        scanf("%d %d",&u,&k);
        u--;
        for(o=0;o<k;o++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    color[0]=BLACK;
     int sign,top,end,i;
    memset(len,-1,sizeof(len));
    len[0]=0;
    for(top=0,end=1;end != top;){
        sign=queue[top];
        top++;
        for(i=0;i<n;i++){
            if(M[sign][i]!=0 && color[i]==WHITE){
                queue[end++]=i;
                len[i]=len[sign]+1;
                color[i]=GRAY;
            }
        }
        color[sign]=BLACK;
    }
    for(i=0;i<n;i++)
        printf("%d %d\n",i+1,len[i]);


    
    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
};

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

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

typedef long long ll;
ll n;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	cin >> n;
	ll mx = 0;
	for(ll i = 1; i * i <= n; i++)
		if(n % i == 0) mx = i;
	cout << mx - 1 + n / mx - 1 << "\n";	    
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int C[26];
  bool flagA = false;
  bool flagB = false;
  
  for (int i = 0; i < 26; i++) C[i] = 0;
  
  for (int i = 0; i < S.size(); i++)
  {
    C[(int)S.at(i) - (int)'A']++;
  }
  
  for (int i = 0; i < 26; i++)
  {
    if (C[i] > 2)
    {
      flagA = false;
      flagB = false;
      break;
    }
    if (C[i] == 2)
    {
      if(!flagA)
      {
        flagA = true;
      }
      else if(flagA)
	  {
      	flagB = true;
      	break;
      }
    }
  }
  
  if (flagA && flagB) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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


int main(){
    ll n,m;cin>>n>>m;
    pair<ll,ll> vd[100010];
    rep(i,0,n){
        ll a,b;
        cin>>a>>b;
        vd[i]=make_pair(a,b);
    }
    sort(vd,vd+n);
    vd[n]=make_pair(1e11,1e11);
    ll mon=0;
    priority_queue<ll> pq;
    ll I=0;
    rep(i,1,m+1){
        while(vd[I].first<=i){
            pq.push(vd[I].second);
            I++;
        }
        if(!pq.empty()){
            mon+=pq.top();
            pq.pop();
        }
    }
    cout<<mon<<endl;

}
    









Measured memory_bytes: 2936
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %.5lf\n",d,r,f);
		return 0;
}


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

int main(void){
    int n,b,i,j,v=0,d[100010],saisyou=10000,ans=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> d[i];
    }
    sort(d,d+n,greater<int>());
    for(i=0;i<n;i++)
    {
        if(d[i]<saisyou)
        {
            saisyou=d[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;

}


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


int main()
{
  string s;
  cin >> s;
  vector<int> ans(s.size(), 0);
  vector<int> c(2, 0);
  c[0] = 1;
  int lastr = 0;
  for (int i=1; i<s.size(); i++)
  {
    if (s[i] == 'R')
    {
      c[i%2]++;
      lastr = i;
    }
    else if (s[i-1] == 'R')
    {
      c[i%2]++;
      ans[i] += c[i%2];
      c[i%2] = 0;
      ans[i-1] += c[i%2^1];
      c[i%2^1] = 0;
    }
    else if (lastr % 2 == i % 2)
      ans[lastr]++;
    else
      ans[lastr+1]++;
  }
  rep(i, s.size())
    if (i < s.size() - 1)
      printf("%d ", ans[i]);
    else
      printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 55;
int arr[N];

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,maxi=-1,maxm=-1; cin>>n;
    FOR(i, 0, n) {
    	cin>>arr[i];
    	if(abs(arr[i]) > maxm) {
    		maxm = abs(arr[i]);
    		maxi = i;
    	}
    }
    cout<<2*n-2<<endl;
    FOR(i, 0, n) {
    	if(i != maxi) {
    		cout<<maxi+1<<" "<<i+1<<endl;
    		arr[i] += arr[maxi];
    	}
    }
    if(arr[maxi] < 0) {
    	RFOR(i, n-2, 0) {
    		cout<<i+2<<" "<<i+1<<endl;
    		arr[i] += arr[i+1];
    	}
    } else {
    	FOR(i, 1, n) {
    		cout<<i<<" "<<i+1<<endl;
    		arr[i] += arr[i-1];
    	}
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define SIZE 100100

int gcd(int* x, int n) {
	int i, g;

	int calc(int a, int b) {
		return a % b == 0 ? b : calc(b, a % b);
	}

	g = x[0];
	for (i = 1; i < n; i++) g = calc(g, x[i]);
	return g;
}

int comp(const void* a, const void* b) {
	return *(int *)a - *(int *)b;
}

int main() {
	int n, x[SIZE], i;
	scanf("%d%d", &n, &x[0]);
	for (i = 1; i <= n; i++) scanf("%d", &x[i]);
	qsort(x, n + 1, sizeof(int), comp);
	for (i = 0; i < n; i++) x[i] = x[i + 1] - x[i];
	printf("%d", gcd(x, n));
	return 0;
}

Measured memory_bytes: 892
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

const string YES = "YES";
const string NO = "NO";
void yn(bool ok){
  cout << (ok ? YES : NO) << endl;
}

void solve(long long N, std::vector<long long> A){
  sort(ALL(A));
  A.erase(unique(ALL(A)), A.end());
  yn(int(A.size()) == N);
} 

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 1792