akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y));

int main()
{
	int n,i,j;
	int* list;
	while(scanf("%d",&n),n)
	{
		list = mem(int,n);
		list[0] = 1;
		int k = 0;
		int topcolor;
		scanf("%d",&topcolor);
		for(i = 1;i < n;i++)
		{
			int color;
			scanf("%d",&color);
			if(topcolor == color)
			{
				list[k]++;
			}
			else if(i%2==0)
			{
				list[++k]=1;
				topcolor = color;
			}
			else
			{
				if(k != 0)
				{
					list[k-1]+=list[k]+1;
					k--;
				}
				else
				{
					list[0]++;
				}
				topcolor = color;
			}
		}
		int count = 0;
		for(i = (topcolor)?(k-1):k;i >= 0;i-=2)
		{
			count+=list[i];
		}
		printf("%d\n",count);
	}
	return 0;
}

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

int dist(int k, int p, int q)
{
    int a = abs(p-q);
    int b = k - a;
    return min(a, b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int m = dist(k, a[0], a[n-1]);
    for (int i = 1; i < n; ++i) {
        int tmp = dist(k, a[i-1], a[i]);
        if (tmp > m) {
            m = tmp;
        }
    }

    cout << k-m << endl;
}



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

int main(){

    int n,k;
    int i=0;
    int waru;
    cin>>n>>k;
   
    while(1){

        waru=pow(k,i);
        if(n<waru) break;
        i++;

    }
    cout<<i<<endl;





    return 0;
}

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

#define int long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pair<int,int> >
#define f first
#define s second
#define all(x) x.begin() , x.end()
#define mii map<int,int>
#define mod 1000000007
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define FOR(i,a,n) for(int i = a;i<n;i++)
#define FORD(i,a,n) for(int i = a;i<=n;i++)
#define FORR(i,n,a) for(int i = n;i>=a;i--)
#define endl "\n"

struct happiness {
    int a,b,c;
};

void solve(happiness *arr,int n) {
    
    int t1=arr[0].a,t2=arr[0].b,t3=arr[0].c;
    int x,y,z;
    FOR(i,1,n) {
        x = max(t2+arr[i].a,t3+arr[i].a);
        y = max(t1+arr[i].b,t3+arr[i].b);
        z = max(t1+arr[i].c,t2+arr[i].c);
        t1 = x,t2 = y,t3 = z;
    }
    cout<<max(t1,max(t2,t3))<<endl;
}



int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // w(x) {
        
        int n;
        cin >>n;
        happiness arr[n+10];
        FOR(i,0,n) {
            cin >>arr[i].a >>arr[i].b >>arr[i].c;
        }
        
        solve(arr,n);
        
    // }
}

Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
long long dp[60][200005];
int main(){
	long long n,k;
    cin>>n>>k;
	for(int i=0;i<n;i++) {
        cin>>dp[0][i];
        dp[0][i]--;
    }
	for(int i=0;i<59;i++) {
		for(int j=0;j<n;j++) {
			dp[i+1][j]=dp[i][dp[i][j]];
		}
	}
	long long ans=0;
	for(int i=59;i>=0;i--){
		long long l=1ll<<i;
		if(l<=k){
			k-=l;
			ans=dp[i][ans];
		}
	}
	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 97356
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in(),B=in();
	
	out(max({A*B,A+B,A-B}));
	return 0;
}


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

int main()
{
    ll t,n;
    cin>>n;
    ll a[n],j=0,k=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]%2!=0) j++;
    }
    if(j%2!=0)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007


int main(){
  ll c,n;
  char b;
  cin >>b;
  char ans;
  if(b=='A')ans='T';
  else if(b=='T')ans='A';
  else if(b=='C')ans='G';
  else if(b=='G')ans='C';
  cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    count = Counter(a_arr)
    cnt = 0
    for key in count.keys():
        _ = count[key]
        try:
            _ += count[key+1]
        except:
            pass
        try:
            _ += count[key-1]
        except:
            pass
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 56044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    string str;
    cin >> str;
    cout << (str.find("AC") != string::npos ? "Yes" : "No") << endl;
    return 0;
}

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

int main()
{
    int n, i, j, k=10000;
    bool res = false;

    cin>>n;

    for(i=1; i<10; i++){

        if(n/i == 111 && n%i == 0){
            res = true;
        }
    }
    if(res)
        cout<<n;
    else{

        while(k){
            n =n +1;
            for(i=1; i<10; i++){

                if(n/i == 111 && n%i == 0){
                    res = true;
                }
            }
            if(res){
                cout<<n;
                break;
            }

            k--;
        }

    }



}


Measured memory_bytes: 256
t = 1
v, d, f = {}, {}, {}

def dfs(i):
  global t, v, d, f
  if i in d:
    return
  if i != 0:
    d[i] = t
    t += 1
  for j in v[i]:
    dfs(j)
  if i != 0:
    f[i] = t
    t += 1

n = int(input())
v[0] = list(range(1, n+1))
for i in range(n):
  tmp = list(map(int, input().split()))
  v[tmp[0]] = tmp[2:]
  v[tmp[0]].sort()
dfs(0)
for i in range(n):
  print("{} {} {}".format(i+1, d[i+1], f[i+1]))



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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("7");
            WillReturn.Add("3 1 4 1 5 9 2");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10");
            WillReturn.Add("0 1 2 3 4 5 6 7 8 9");
            //3
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1");
            WillReturn.Add("99999");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        var CntDict = new Dictionary<int, int>();
        foreach (int EachInt in AArr) {
            Action<int> AddAct = (pInt) =>
            {
                if (CntDict.ContainsKey(pInt))
                    CntDict[pInt]++;
                else CntDict[pInt] = 1;
            };

            AddAct(EachInt - 1);
            AddAct(EachInt);
            AddAct(EachInt + 1);
        }
        Console.WriteLine(CntDict.Values.Max());
    }
}


Measured memory_bytes: 31448
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

struct Vec2
{
	double x;
	double y;

	Vec2() = default;

	constexpr Vec2(double _x, double _y)
		: x(_x)
		, y(_y) {}

	double length() const
	{
		return std::sqrt(lengthSquare());
	}
	
	constexpr double lengthSquare() const
	{
		return dot(*this);
	}
	
	constexpr double dot(const Vec2& other) const
	{
		return x * other.x + y * other.y;
	}
	
	double distanceFrom(const Vec2& other) const
	{
		return (other - *this).length();
	}

	Vec2 normalized() const
	{
		return *this / length();
	}
	
	constexpr bool isZero() const
	{
		return x == 0.0 && y == 0.0;
	}

	constexpr Vec2 operator +() const
	{
		return *this;
	}

	constexpr Vec2 operator -() const
	{
		return{ -x, -y };
	}

	constexpr Vec2 operator +(const Vec2& other) const
	{
		return{ x + other.x, y + other.y };
	}

	constexpr Vec2 operator -(const Vec2& other) const
	{
		return{ x - other.x, y - other.y };
	}

	constexpr Vec2 operator *(double s) const
	{
		return{ x * s, y * s };
	}

	constexpr Vec2 operator /(double s) const
	{
		return{ x / s, y / s };
	}

	Vec2& operator +=(const Vec2& other)
	{
		x += other.x;
		y += other.y;
		return *this;
	}

	Vec2& operator -=(const Vec2& other)
	{
		x -= other.x;
		y -= other.y;
		return *this;
	}

	Vec2& operator *=(double s)
	{
		x *= s;
		y *= s;
		return *this;
	}

	Vec2& operator /=(double s)
	{
		x /= s;
		y /= s;
		return *this;
	}
};

constexpr Vec2 operator *(double s, const Vec2& v)
{
	return{ s*v.x, s*v.y };
}

template <class Char>
inline std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const Vec2& v)
{
	return os << Char('(') << v.x << Char(',') << v.y << Char(')');
}

template <class Char>
inline std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, Vec2& v)
{
	Char unused;
	return is >> unused >> v.x >> unused >> v.y >> unused;
}

int main(){
    Vec2 a,b;
    cin>>a.x>>a.y>>b.x>>b.y;
    Vec2 ab=b-a;

    int q;
    cin>>q;

    vector<double> ansx(q),ansy(q);

    REP(i,q){
        Vec2 p,as,s;
        cin>>p.x>>p.y;

        Vec2 ap=p-a;

        as=(ab.dot(ap)/ab.lengthSquare())*ab;

        s=as+a;
        ansx[i]=s.x;
        ansy[i]=s.y;
    }

    REP(i,q){
        cout<<fixed<<setprecision(10)<<ansx[i]<<" "<<ansy[i]<<endl;
    }
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

bool fun(pair<int,int> a, pair<int,int> b)
{
    // if(a.second==b.second)
    // {
    //     return a.first>b.first;
    // }
    // return a.second<b.second;

    if(a.first-a.second==b.first-b.second)
    {
        return a.first>b.first;
    }
    return (a.first-a.second > b.first-b.second);
}
int main()
{
    IOS;
    int n;
    cin>>n;
    vector<pair<int,int>> a;
    int clostart=0,opstart=0;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        stack<char> q;
        for (int j = 0; j < (int)s.size(); j++)
        {
            if(q.empty()==0)
            {
                if(q.top()=='(' && s[j]==')')
                {
                    q.pop();
                    continue;
                }
            }
            q.push(s[j]);
        }
        int close=0,open=0;
        while(!q.empty())
        {
            if(q.top()=='(')
            {
                close++;
            }
            else
            {
                open++;
            }
            q.pop();
        }
        if(open==0)
        {
            clostart+=close;
        }
        else if(close==0)
        {
            opstart+=open;
        }
        else
        {
            a.eb(mk(close,open));
        }
    }
    sort(a.begin(),a.end(),fun);
    int value=clostart;
    for (int i = 0; i < (int)a.size(); i++)
    {
        value-=a[i].second;
        if(value<0)
        {
            cout<<"No";
            return 0;
        }
        value+=a[i].first;
    }
    value-=opstart;
    if(value==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 5340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);


int main() {
    string str;
    cin >> str;
    int price = 700;
    REP(i, str.size()) {
        if (str.at(i) == 'o') price += 100;
    }

    cout << price << endl;

    return 0;
}

// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class Main implements Runnable {

    private void solve() throws IOException {


        long a = nextLong();
        long b = nextLong();
        long x = nextLong();
        if(b == 0) {
            writer.println(1);
        } else if(a == 0) {
            writer.println((b/x)+1);
        } else {
            if(x == 1) {
                writer.println((b-a+1));
            } else {
                if(a == 1) {
                    writer.println((b/x));
                } else {
                    writer.println((b/x) - ((a-1)/x));
                }
            }
        }
    }


    public static void main(String[] args) {

        new Main().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//             reader = new BufferedReader(new FileReader("input.txt"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while(tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 8276
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
  int N;
  cin >> N;

  UnionFind uf(N);

  vector<int> x(N), y(N);
  REP(i, N) cin >> x[i] >> y[i];

  vector<int> o(N);
  iota(ALL(o), 0);
  sort(ALL(o), [&](int const & l, int const & r){
      return x[l] < x[r];
      });


  stack<pair<int, int>> s;

  REP(I, N){
    int i = o[I];
    if(s.empty() || s.top().first > y[i]){
      s.emplace(y[i], i);
    }else{
      pair<int, int> p = s.top();
      while(!s.empty() && s.top().first < y[i]){
        uf.unite(s.top().second, i);
        s.pop();
      }
      s.emplace(p);
    }
  }

  REP(i, N){
    cout << uf.size(i) << "\n";
  }

  return 0;
}


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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100;
    B *= 100;

    double cardMax = 0;
    int waterMax = 0;
    int sugarMax = 0;

    int nA = F / A;
    for (int i=0; i<=nA; ++i) {
        int nB = (F - i *  A) / B;
        for (int j=0; j<=nB; ++j) {
            int water = i*A + j*B;
            if (water == 0) continue;

            int sMax100 = E * water; // E * (water / 100.0)
            sMax100 = min(sMax100, 100*(F-water));
            for (int sC=0; sC<=sMax100; sC+=100*C) {
                int sDMax100 = sMax100 - sC;
                for (int sD=0; sD<=sDMax100; sD+=100*D) {
                    //if ((water + sC + sD) > F) continue;
                    double card = double(sC + sD) / water;
                    if (card > cardMax) {
                        cardMax = card;
                        waterMax = water;
                        sugarMax = sC + sD;
                    }
                }
            }
        }
    }

    if (waterMax == 0) waterMax = A;
    cout << waterMax + sugarMax/100 << ' ' << sugarMax/100 << endl;;
    return 0;
}


Measured memory_bytes: 3556
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x=0,a=0,b=0,t=0;
  scanf("%d%d%d",&x,&a,&b);
  t=a-b;
  if (t>=0) {
    printf("delicious\n");
  }else if(-t<=x){
    printf("safe\n");
  }else{
    printf("dangerous\n");
  }
  return 0;
}


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

class Program
{
	static void Main()
	{
		var t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var x1 = t[0];
		var y1 = t[1];
		var x2 = t[2];
		var y2 = t[3];

		var diffX = Math.Abs(x2 - x1);
		var diffY = Math.Abs(y2 - y1);

		if (x1 == x2) {
			if (y1 < y2) {
				Console.WriteLine($"{x1 - diffY} {y2} {x1 - diffY} {y1}");
			} else {
				Console.WriteLine($"{x1 + diffY} {y2} {x1 + diffY} {y1}");
			}
		} else if (y1 == y2) {
			if (x1 < x2) {
				Console.WriteLine($"{x2} {y2 + diffX} {x1} {y1 + diffX}");
			} else {
				Console.WriteLine($"{x2} {y2 - diffX} {x1} {y1 - diffX}");
			}
		} else if (x1 < x2) {
			if (y1 < y2) {
				Console.WriteLine($"{x2 - diffY} {y2 + diffX} {x1 - diffY} {y1 + diffX}");
			} else {
				Console.WriteLine($"{x2 + diffY} {y2 + diffX} {x1 + diffY} {y1 + diffX}");
			}
		} else {
			if (y1 < y2) {
				Console.WriteLine($"{x2 - diffY} {y2 - diffX} {x1 - diffY} {y1 - diffX}");
			} else {
				Console.WriteLine($"{x2 + diffY} {y2 - diffX} {x1 + diffY} {y1 - diffX}");
			}
		}

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

ll lcm(ll a, ll b){
  return a * b / gcd(a,b);
}

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

    ll cd = lcm(c,d);

    ll ans = (b/c - (a-1)/c) + (b/d - (a-1)/d) - (b/cd - (a-1)/cd);

    cout << b - a + 1 - ans << endl;

}

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

int main() {
    ll H;
    cin >> H;
    ll ans = 0;
    ll enemy = 1;
    while (H)
    {
        if(H!=1){
            H /= 2;
            ans+=enemy;
            enemy*=2;
        }else{
            H = 0;
            ans += enemy;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int inf=(int)2e9;
const long long mod=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,mod-2); }

signed main(){
	IOS
	int n;cin>>n;
	vi h(n),d(n);
	forn(i,n) cin>>h[i];
	d[n-1]=0;d[n-2]=abs(h[n-1]-h[n-2]);
	for(int i=n-3;i>=0;i--){
		d[i]=min(d[i+1]+abs(h[i]-h[i+1]),d[i+2]+abs(h[i]-h[i+2]));
	}
	cout<<d[0];
}


Measured memory_bytes: 1792
#include<cstdio>
using namespace std;
int a[10],k,m;
int main()
{
  scanf("%d%d%d",&a[1],&a[2],&a[5]);k=a[5]*3;
  a[3]=k-a[1]-a[2];a[7]=k-a[3]-a[5];a[4]=k-a[1]-a[7];
  a[6]=k-a[4]-a[5];a[8]=k-a[2]-a[5];a[9]=k-a[7]-a[8];
  for(int i=1;i<=9;i++)
  {
  	printf("%d ",a[i]);m++;
  	if(m%3==0)  printf("\n");
  }
  return 0;
}

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

class Magatro
{
    static int W,H,N;
    static int[] x, y, a;
    static void Main()
    {
        Read();
        int ans;
        int ue = H, sita = 0, migi = W, hidari = 0;
       for(int i = 0; i < N; i++)
        {
            switch (a[i])
            {
                case 1:
                    hidari = Math.Max(hidari, x[i]);
                    break;
                case 2:
                    migi = Math.Min(migi, x[i]);
                    break;
                case 3:
                    sita = Math.Max(sita, y[i]);
                    break;
                case 4:
                    ue = Math.Min(ue, y[i]);
                    break;
            }
        }
        if (sita >= ue||migi<=hidari)
        {
            Console.WriteLine(0);
            return;
        }
        ans = (ue - sita) * (migi - hidari);
        Console.WriteLine(ans);
    }
    static void Read()
    {
        int[] q = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        W = q[0];
        H = q[1];
        N = q[2];
        x = new int[N];
        y = new int[N];
        a = new int[N];
        for(int i = 0; i < N; i++)
        {
            q = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            x[i] = q[0];
            y[i] = q[1];
            a[i] = q[2];
        }
    }
}

Measured memory_bytes: 3032
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  long long nn=1,n;
  cin>>n;
  for(long long i=1;i<=n;i++){
    nn=nn*i;
    if(nn>1000000007) nn=nn%1000000007;
  }
  cout<<nn<<endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n),b(n+1);
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	b[0]=0;
	for(int i=1;i<n+1;i++)
		b[i]=b[i-1]+a[i-1];
	long long ans=0;

	sort(b.begin(),b.end());

	long long tmp=0;
	for(int i=1;i<n+1;i++)
	{
		if(b[i]==b[i-1])tmp++;
		else
		{
			ans+=(tmp)*(tmp+1)/2;
			tmp=0;
		}
	}
	ans+=(tmp)*(tmp+1)/2;

	cout << ans << endl;



}

Measured memory_bytes: 3328
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])

#print(a,b,c)

cnt=1

while cnt<= 100:
    
    if (c + b * cnt) % a ==0:
        
        print("YES")
        break
        
    cnt+=1
    
else:
        
    print("NO")

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=5e2+5;
const int M=5e5+5;
int n,cnt,prime[M],vis[M];
ll a[N][N];

ll gcd(ll x,ll y) {return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y) {if(!x||!y) return x+y;return 1ll*x/gcd(x,y)*y;}
template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

int main() {
	IN(n);
    if(n==2) return printf("4 7\n23 10\n"),0;
	for(int i=2;i<M;++i) {
		if(!vis[i]) prime[++cnt]=i;
		for(int j=1;i*prime[j]<M&&j<=cnt;++j) {
			vis[i*prime[j]]=1;
			if(!(i%prime[j])) break;
		}
	}
    for(int i=1;i<=n;++i)
        for(int j=(i+1&1)+1;j<=n;j+=2)
            a[i][j]=prime[(i+j)/2]*prime[n+(i-j)/2+(n+1)/2];
    for(int i=1;i<=n;++i)
        for(int j=(i&1)+1;j<=n;j+=2)
            a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	for(int i=1;i<=n;++i) {
        for(int j=1;j<=n;++j) printf("%lld ",a[i][j]);
        puts("");
    }
	return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> adj[1000*999/2];
vector<pair<int,int>> P;
int node_cnt, num[1000*999/2], chk[1000*999/2];
queue<int> Q[1001];

void dfs(int c)
{
	num[c]=++node_cnt;
	chk[c]=true;
	for(auto n: adj[c]) {
		if(chk[n]) {
			cout<<"-1\n";
			exit(0);
		}
		else if(num[n]==0) dfs(n);
	}
	chk[c]=false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, cnt, ans=0;
	vector<int> t1, t2, n1, n2;
	cin>>N; cnt=N*(N-1)/2;
	for(int i=1;i<=N;i++) for(int j=i+1;j<=N;j++) P.emplace_back(i,j);
	for(int i=1;i<=N;i++) {
		int p, a;
		cin>>p; Q[i].push(p);
		p=lower_bound(P.begin(),P.end(),make_pair(min(p,i),max(p,i)))-P.begin();
		for(int j=2;j<N;j++) {
			cin>>a; Q[i].push(a);
			a=lower_bound(P.begin(),P.end(),make_pair(min(a,i),max(a,i)))-P.begin();
			adj[p].push_back(a);
			p=a;
		}
	}
	for(int i=0;i<P.size();i++) if(num[i]==0) dfs(i);
	for(int i=1;i<=N;i++) if(i<Q[i].front() && Q[Q[i].front()].front()==i) {
		t1.push_back(i);
		t2.push_back(Q[i].front());
	}
	for(memset(chk,-1,sizeof(chk));cnt;ans++) {
		for(int i=0;i<t1.size();i++) {
			Q[t1[i]].pop();
			Q[t2[i]].pop();
			cnt--;
		}
		n1.clear(); n2.clear();
		for(auto t: t1) {
			if(Q[t].size() && Q[Q[t].front()].front()==t && chk[t]!=ans) {
				n1.push_back(t);
				n2.push_back(Q[t].front());
				chk[t]=chk[Q[t].front()]=ans;
			}
		}
		for(auto t: t2) {
			if(Q[t].size() && Q[Q[t].front()].front()==t && chk[t]!=ans) {
				n1.push_back(t);
				n2.push_back(Q[t].front());
				chk[t]=chk[Q[t].front()]=ans;
			}
		}
		t1=n1; t2=n2;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 39920
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int N;
  int *A;
  int i, j, k;
  int v;

  scanf("%d", &N);
  A = (int *)malloc(sizeof(int) * N);

  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  for (i = 0; i < N; i++) {
    if (i != N - 1) printf("%d ", A[i]);
    else printf("%d\n", A[i]);
  }

  for (i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for (k = 0; k < N; k++) {
      if (k != N - 1) printf("%d ", A[k]);
      else printf("%d\n", A[k]);
    }
  }

  free(A);

  return 0;
}

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

using Pi = pair < int, int >;
using IPi = pair < int , Pi >;

constexpr int INF = (1 << 30) - 1;

void chmin(int &a, int b) { a = min(a, b); }

int main()
{
        int N;
        int dp[1005][20];
        string S[1005];
        priority_queue < IPi, vector < IPi > , greater < IPi > > pq;

        fill_n(*dp, 1005 * 20, INF);
        cin >> N;
        for ( int i = 0; i < N; i++ ) {
                cin >> S[i];
                dp[i][0] = 0;
                pq.emplace(0, Pi(i, 0));
        }
        
        while ( !pq.empty() ) {
                IPi dat = pq.top(); pq.pop();
                int cost = dat.first, node = dat.second.first, pos = dat.second.second;
                int nodesize = S[node].size();
                int remainsize = nodesize - pos;
                for ( int i = 0; i < N; i++ ) {
                        if ( i == node && pos == 0 ) continue;
                        int len = S[i].size();
                        if ( len > remainsize ) {
                                if ( S[node].substr(pos, remainsize) == S[i].substr(0, remainsize) ) {
                                        int ncost = cost + remainsize;
                                        if ( dp[i][remainsize] > ncost ) {
                                                chmin(dp[i][remainsize], ncost);
                                                pq.emplace(ncost, Pi(i, remainsize));
                                        }
                                }
                        } else if ( S[node].substr(pos, len) == S[i]) {
                                int ncost = cost + len;
                                if ( dp[node][pos + len] > ncost ) {
                                        chmin(dp[node][pos + len], ncost);
                                        if ( len < remainsize ) pq.emplace(ncost, Pi(node, pos + len));
                                }
                        }
                }
        }

        int minv = INF;

        for ( int i = 0; i < N; i++ ) {
                minv = min(minv, dp[i][S[i].size()]);
        }

        if ( minv == INF ) cout << 0 << endl;
        else cout << minv << endl;

        return ( 0 );
}



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

int n, k, a[200001];
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
	for(int i = k; i < n; ++i)
		if(a[i] > a[i-k]) puts("Yes");
		else puts("No");
	return 0;
}


Measured memory_bytes: 4540
N = int(input())
H = list(map(int, input().split()))


flag = True
for i in range(1, N):
    if H[i-1] > H[i]:
        H[i] += 1
    if H[i-1] > H[i]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14396
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
from itertools import permutations
import bisect
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    ci = defaultdict(list)
    for i, c in enumerate(S):
        ci[c].append(i)

    ans = 0
    for c1, c2 , c3 in permutations('RGB', r=3):
        for i in ci[c1]:
            for j in range(bisect.bisect_left(ci[c2], i), len(ci[c2])):
                j = ci[c2][j]
                ans += len(ci[c3]) - bisect.bisect_left(ci[c3], j)
                d = (j-i)+j
                k = bisect.bisect_left(ci[c3], d)
                if k < len(ci[c3]) and ci[c3][k] == d:
                    ans -= 1
    return ans


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 70168
#include<stdio.h>

int main()

{

    int p,q,r;
    scanf("%d %d %d",&p,&q,&r);

    int x1,x2,x3;
    x1=p+q;
    x2=q+r;
    x3=r+p;

    if (x1<x2 && x1<x3)
        printf("%d",x1);
    else if (x2<x3 && x2<x3)
        printf("%d",x2);
    else if (x3<x1 && x3<x1)
        printf("%d",x3);
    else if (x1==x2)
    {
        if(x1>x3)
         printf("%d",x3);
        else
            printf("%d",x1);
    }
    else if (x2==x3)
    {
        if (x1>x3)
            printf("%d",x3);
        else
            printf("%d",x1);
    }
    else if (x1==x3)
    {
        if (x1>x2)
            printf("%d",x2);
        else
            printf("%d",x1);
    }
    else
        printf("%d",x1);

    return 0;

}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int max_p, max_d;
        int p, d1, d2;

        max_p = max_d = -100;
        while (n--) {
            cin >> p >> d1 >> d2;
            
            if (d1 + d2 > max_d) {
                max_d = d1 + d2;
                max_p = p;
            }
        }
        cout << max_p << " " << max_d << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
string S, T;

//解法
void solve() {

	vector<int> alt(26);
	fill(alt.begin(), alt.end(), -1);

	rep(i, S.size()) {
		if (alt[S[i] - 'a'] == -1) {
			alt[S[i] - 'a'] = T[i];
		}
		else {
			if (alt[S[i] - 'a'] != T[i]) {
				cout << "No";
				return;
			}
		}
	}

	fill(alt.begin(), alt.end(), -1);

	rep(i, T.size()) {
		if (alt[T[i] - 'a'] == -1) {
			alt[T[i] - 'a'] = S[i];
		}
		else {
			if (alt[T[i] - 'a'] != S[i]) {
				cout << "No";
				return;
			}
		}
	}
	cout << "Yes";

	return;
}

int main() {
	//入力
	cin >> S >> T;
	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
    long long a[200005],b[200005];
    int n;
    int main()
		{
        scanf("%d",&n);
        for(int i = 1;i <= n;i++){
            scanf("%lld",&a[i]);
        }
        int l = 1, r = n,flag = 0;
        for(int i = n;i >= 1;i--){
            if(flag == 0) b[l++] = a[i],flag = 1;
            else b[r--] = a[i],flag = 0;
        }
        for(int i = 1;i <= n;i++){
            printf("%lld ",b[i]);
        }
    }


Measured memory_bytes: 5248
import std.stdio;
import std.string;
import std.conv;
 
void main()
{
	auto input = split( readln() );
	long N = to!long(input[0]), M = to!long(input[1]);
	
	if (N >= 2 && M >= 2) { writeln( (N-2) * (M-2) ); }
	else if ( N == 1 && M >= 2 ) { writeln( M-2 ); }
	else if ( M == 1 && N >= 2 ) { writeln( N-2 ); }
	else if ( N == 1 && M == 1 ) { writeln(1); }
	
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))

s = 10**9

for i in range(n-k+1):
    if x[i] * x[i+k-1] >= 0:
        t = max(abs(x[i]), abs(x[i+k-1]))
    else:
        t = abs(x[i]) + abs(x[i+k-1]) + min(abs(x[i]), abs(x[i+k-1]))

    s = min(s, t)

print(s)

Measured memory_bytes: 20060
N = int(input())
station = [list(map(int, input().split())) for _ in range(N - 1)]

lst = []

for i in range(N - 1):
    c, s, f = station[i]

    for j in range(len(lst)):
        a = lst[j]

        if a >= s:
            if a % f == 0:
                a += c
            else:
                a += (f - a % f) + c
        else:
            a = s + c

        lst[j] = a

    lst.append(s + c)


lst.append(0)
for a in lst:
    print(a)


Measured memory_bytes: 9168
sx,sy,tx,ty = map(int,input().split())
ans=''
dy=ty-sy
dx=tx-sx

ans += 'U'*dy + 'R'*dx
ans += 'D'*dy + 'L'*dx
ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

#define rep(i,n) for(int i = 0; i < n; ++i)

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int s,w;
    cin >> s >> w;
    cout << ( s > w ? "safe" : "unsafe" ) << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  while (N > 0)
  {
    N /= K;
    ans++;
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for(int a = 0; a < N; a++)
    cin >> V.at(a);
  
  vector<int> W(1000000,0);
  for (int i = 0; i < N; i++) {
    if (W.at(V.at(i) - 1) >= 1) 
      W.at(V.at(i) - 1)++;
    
    else {  
      for (int i2 = 1; i2*V.at(i) <= 1000000; i2++) 
        W.at(i2*V.at(i) - 1)++;
    }
  } 
  int ans = 0;
  for (int j = 0; j < N; j++) {
    if (W.at(V.at(j) - 1) == 1)
      ans++;
  }
  
  cout << ans << endl;
        
}


Measured memory_bytes: 8000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=0;
	int alice[110]; for(int i=0;i<110;i++)alice[i]=0;
	int bob[110]; for(int i=0;i<110;i++)bob[i]=0;

	for(int i=a+1;i<=b;i++)alice[i]=1;
	for(int i=c+1;i<=d;i++)bob[i]=1;

	for(int i=0;i<110;i++){
		if((alice[i]==1) && (bob[i]==1))ans++;
	}

	cout<< ans <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void breakisland(int,int,char[12][13]);

int main(void) {
	char island[12][13];
	int i;
	int x,y;
	int count;
	while(scanf("%s",island[0])==1) {
		for(i=1;i<12;i++)scanf("%s",island[i]);
		count=0;
		for(y=0;y<12;y++) {
			for(x=0;x<12;x++) {
				if(island[y][x]=='1') {
					count++;
					breakisland(x,y,island);
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

void breakisland(int x,int y,char island[12][13]) {
	if(island[y][x]!='1')return;
	island[y][x]='0';
	if(x>0)breakisland(x-1,y,island);
	if(y>0)breakisland(x,y-1,island);
	if(x<11)breakisland(x+1,y,island);
	if(y<11)breakisland(x,y+1,island);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    try {
      int observatoryNum = stdIn.nextInt();
      if (observatoryNum < 2 || observatoryNum > (int)Math.pow(10, 5)) return;
      //int[][] roadList = new int[observatoryNum][observatoryNum];
      int[][] resultList = new int[observatoryNum][2];
      int roadNum = stdIn.nextInt();
      if (roadNum < 1 || roadNum > Math.pow(10, 5)) return;
      int[] hight = new int[observatoryNum];
      for (int hightCnt = 0; hightCnt < observatoryNum; hightCnt++) {
        hight[hightCnt] = stdIn.nextInt();
        if (hight[hightCnt] < 1 || hight[hightCnt] > Math.pow(10, 9)) return;
      }
      for (int roadCnt = 0; roadCnt < roadNum; roadCnt++) {
        int startPosition = stdIn.nextInt() - 1;
        int endPosition = stdIn.nextInt() - 1;
        if (startPosition == endPosition) return;
        resultList[startPosition][0]++;
        resultList[endPosition][0]++;
        if (hight[startPosition] > hight[endPosition]) resultList[startPosition][1]++;
        if (hight[endPosition] > hight[startPosition]) resultList[endPosition][1]++;
      }
      int highestNum = 0;
      for (int result[] : resultList) {
        if (result[0] == result[1]) highestNum++;
      }
      System.out.println(highestNum);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      stdIn.close();
    }
  }
}

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

using namespace std;

#define vll vector<long long>
#define ll long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vld vector<long double>
#define vs vector<string>
#define MOD 1000000007
#define endl "\n"
#define vc vector<char>
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define RFOR(i,b,a) for (ll i = (b) - 1; i >= (a); i--)
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define SZ(a) int((a).size())
#define pi acos(-1.0)
#define F first
#define S second
#define RESET(a, b) memset(a, b, sizeof(a))
#define INF 1000000000000000000
#define PLL pair<long,long>
#define PI pair<int,int>
/*

,--.  ,--. ,--. ,--.                                            ,---.       ,--. ,--.
|  ,'.|  | `--' |  |,-.  ,--.,--.  ,---.  ,--. ,--.  ,--,--.   |  o ,-.     |  .'   /  ,--,--.  ,---.   ,---.   ,--,--.
|  |' '  | ,--. |     /  |  ||  | (  .-'   \  '  /  ' ,-.  |   .'     /_    |  .   '  ' ,-.  | | .-. | | .-. | ' ,-.  |
|  | `   | |  | |  \  \  '  ''  ' .-'  `)   \   '   \ '-'  |   |  o  .__)   |  |\   \ \ '-'  | | '-' ' | '-' ' \ '-'  |
`--'  `--' `--' `--'`--'  `----'  `----'  .-'  /     `--`--'    `---'       `--' '--'  `--`--' |  |-'  |  |-'   `--`--'
                                          `---'                                                `--'    `--'
*/





using namespace std;

int main() {
/*
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
*/
//    ifstream in("ladder.in");
//    cin.rdbuf(in.rdbuf());
//    ofstream out("ladder.out");
//    cout.rdbuf(out.rdbuf());

     ll n,l;
     cin>>n>>l;
     vs num(n);
     FOR(i,0,n){
         cin>>num[i];
     }
     sort(num.begin(),num.end());
     FOR(i,0,num.size()){
         cout<<num[i];
     }




    return 0;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/
void check(vector<int>& ans, vector<vector<int>>& road, int now, queue<int>& que){
    que.pop();
    for(int i = 0;i < road[now].size();i++){
        if(ans[road[now][i]] == -1){
            ans[road[now][i]] = now;
            que.push(road[now][i]);
        }
    }
    if(que.size() != 0)check(ans, road, que.front(), que);
}

void solve(){
    LL N, M;
    cin >> N >> M;
    vector<vector<int>> road (N);
    for(LL i = 0;i < M;i++){
        LL l, r;
        cin >> l >> r;
        road[l-1].push_back(r-1);
        road[r-1].push_back(l-1);
    }

    vector<int> ans (N,-1);
    ans[0] = 0;
    queue<int> que;
    que.push(0);
    check(ans,road,0,que);

    cout << "Yes" << endl;
    for(int i = 1;i < N;i++){
        cout << ans[i]+1 << endl;
    }
}



Measured memory_bytes: 10136
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

int main()
{
	int a[3];
	scanf("%d%d%d", a, a + 1, a + 2);
	std::sort(a, a + 3);
	if ((a[0] == a[1] && a[1] != a[2]) || (a[0] != a[1] && a[1] == a[2]))
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 128
program main;
var 
	i : integer;
    h : boolean;
	s : string;
begin 
	readln(s);
    h := false;
    for i := 1 to length(s) do begin
    	if(s[i]='7')then h := true;
    end;
    if (h=true)
    	then writeln('Yes')
       	else writeln('No');
end.

Measured memory_bytes: 1376
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=[0]
for i in a:
    c.append((c[-1]+i)%m)
cc=Counter(c)
ans=0
for i in cc.values():
    ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 63256
N, Y = map(int, input().split())
x = Y // 10000
Y -= x * 10000
y = Y // 5000
Y -= y * 5000
z = Y // 1000
Y -= z * 1000
for i in range(x+1):
    yy = y + i * 2
    for j in range(yy+1):
        zz = z + j * 5
        if x-i+yy-j+zz==N:
            print(x-i,yy-j,zz)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3064