akhauriyash/Code-Regression huggingface dataset:
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> K, A, B;
  int bk = B % K;


  return (B -  bk >= A ? "OK" : "NG");
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
import java.util.Arrays;
public class Main {

	public static void main (String [] args) throws IOException

	{
		Scanner s=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);

		int a=s.nextInt(),b=s.nextInt(),c=s.nextInt(),d=s.nextInt();
		long max=Long.MIN_VALUE;
		int x=Math.max(a,b);
		long y=Math.max(c,d);
		max=Math.max(max,x*y);

		x=Math.min(a,b);
		y=Math.min(c,d);
		max=Math.max(max,x*y);

		x=Math.min(a,b);
		y=Math.max(c,d);
		max=Math.max(max,x*y);


		x=Math.max(a,b);
		y=Math.min(c,d);
		max=Math.max(max,x*y);
		pw.println(max);


		pw.flush();

}


















	public static void shuffle(int[] a)
	{
		int n = a.length;
		for(int i = 0; i < n; i++)
		{
			int r = i + (int)(Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

	/*

	 try {
		    Thread.sleep(2000);
		} catch(InterruptedException ex) {
		    Thread.currentThread().interrupt();
		}

	 */



	static class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

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

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

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}


}
}

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



int main(int argc, char* argv[])
{
	using std::cin;
	using std::cout;
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, L;
	cin >> N >> L;

	const int original = (N * (N + 2*L - 1)) / 2;

	int best_diff = 2e9;
	for (int i = 1; i <= N; ++i)
	{
		const int diff = - (L + i - 1);
		if (std::abs(diff) < std::abs(best_diff))
		{
			best_diff = diff;
		}
	}

	cout << original + best_diff << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
#include <stdio.h>
#include<cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};


int main() {
  string S;
  cin >> S;
  if( S == "BBB" || S == "AAA") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int x,y,z,n,m;
    scanf("%d%d",&x,&y);
    if(x>=y){
        z=(x%y);
        n=y;
    }
    else if(x<y){
        z=(y%x);
        n=x;
    }
    while(1){
        if(z==0)break;
        m=n%z;
        n=z;
        z=m;
    }
    printf("%d\n",n);
    return 0;
}



Measured memory_bytes: 2732
def insertionSort(A, N) :
    for i in range(N) :
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v :
            A[j+1]  = A[j]
            j -= 1
        A[j+1]  = v
        for j in range(N-1) :
            print(A[j],  end=" ")
        print(A[N-1])
    


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

insertionSort(A, N)



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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;

    ll N;
    cin >> N;
    vll A, B;
    for(i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    ll c = 0;
    for(i = 0; i < N; i++) {
        if(A[i] == B[i]) {
            c++;
        } else {
            c = 0;
        }
        if(c >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


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

using namespace std;
int main() {
  int N, D; cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      cin >> X[i][j];
    }
  }
  int ans=0;
  for (int i2=1; i2<N; i2++){
    for (int i1=0; i1<i2; i1++){
      double dist=0;
      for(int k=0; k<D; k++){
        dist+=pow(X[i1][k]-X[i2][k],2);
      }
      double x,y;
      x=pow(dist,0.5);
      y=int(x);
      if (x-y<0.00001){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by AMK on 8/27/2019.
 * Life is nice :)
 * Enjoy coding :D
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int items[] = new int[n + 1];
        int weights[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            weights[i] = scanner.nextInt();
            items[i] = scanner.nextInt();
        }
        long memo[][] = new long[n + 1][w + 1];
        for (int i = 1; i < n + 1; i++) {
            for (int j = 0; j <= w; j++) {
                if (j >= weights[i]){
                    memo[i][j] = Math.max(memo[i - 1][j], memo[i - 1][j - weights[i]] + items[i]);
                }else{
                    memo[i][j] = memo[i - 1][j];
                }
            }
//            System.out.println(memo[i][w]);
        }
        System.out.println(memo[n][w]);
    }
}


Measured memory_bytes: 128596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector<int> G[10001];
int c[10001];

void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin>>a>>b;
        add_edge(a,b);
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(c,c+n);
    ll ans=0;
    int ansr[n];
    bool used[n];
    for(int i=0;i<n;i++){
        used[i]=false;
    }
    for(int i=0;i<n;i++){
        int maxed;
        int msize=100000;
        int minj;
        for(int j=1;j<=n;j++){
            if(G[j].size()<msize&&G[j].size()!=0){
                minj=j;
                msize=G[j].size();
            }
        }
        if(msize!=100000){
        used[minj-1]=true;
        ansr[minj-1]=c[i];
        ans+=msize*c[i];
        int gs=G[minj].size();
        for(int k=0;k<gs;k++){
            int l=G[minj][k];
            if(G[l].size()==0) {}
            else{
            for(int h=0;h<G[l].size();h++){
            if(G[l][h]==minj){
            G[l].erase(G[l].begin()+h);
            h=G[l].size()+2;
            }
            }
            }
            
        }    
        G[minj].erase(G[minj].begin(),G[minj].begin()+gs);
        }
        else{
            bool ca=false;
            int d=0;
            while(ca==false&&d!=n){
                if(used[d]==false){
                    used[d]=true;
                    ansr[d]=c[i];
                    ca=true;
                }
                d++;
            }
        }
    }
    cout << ans << "\n";
    for(int i=0;i<n;i++){
        cout<<ansr[i]<<" ";
    }
    cout<<"\n";
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(H)]

ans = []
for i,al in enumerate(A):
    for j in range(W-1):
        if al[j] & 1:
            A[i][j    ] -= 1
            A[i][j + 1] += 1
            ans.append((i + 1, j + 1, i + 1, j + 2))

for i,al in enumerate(A[:-1]):
    if al[-1] & 1:
        A[i  ][-1] -= 1
        A[i+1][-1] += 1
        ans.append((i + 1, W, i + 2, W))

print(len(ans))
for a in ans:
    print(*a)

Measured memory_bytes: 26544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b;cin>>a>>b;
    if(a<=b){
        cout<<a<<endl;
    }else{
        cout<<a-1<<endl;
    }
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s;
    while(cin >> s){
        char c;
        int count = 1;
        s+='A';
        rep(i,s.size() - 1){
            if(s[i] == s[i + 1]){
                count++;
            }else{
                if(s[i] == '1'){
                    if(count % 5 == 1) c = '\'';
                    else if(count % 5 == 2) c = ',';
                    else if(count % 5 == 3) c = '.';
                    else if(count % 5 == 4) c = '!';
                    else if(count % 5 == 0) c = '?';
                }else if(s[i] == '2'){
                    if( (count - 1) % 6 < 3 ) c = 'a' + (count - 1) % 3;
                    else c = 'A' + (count - 1) % 3;
                }else if(s[i] == '3'){
                    if( (count - 1) % 6 < 3 ) c = 'd' + (count - 1) % 3;
                    else c = 'D' + (count - 1) % 3;
                }else if(s[i] == '4'){
                    if( (count - 1) % 6 < 3 ) c = 'g' + (count - 1) % 3;
                    else c = 'G' + (count - 1) % 3;
                }else if(s[i] == '5'){
                    if( (count - 1) % 6 < 3 ) c = 'j' + (count - 1) % 3;
                    else c = 'J' + (count - 1) % 3;
                }else if(s[i] == '6'){
                    if( (count - 1) % 6 < 3 ) c = 'm' + (count - 1) % 3;
                    else c = 'M' + (count - 1) % 3;
                }else if(s[i] == '7'){
                    if( (count - 1) % 8 < 4 ) c = 'p' + (count - 1) % 4;
                    else c = 'P' + (count - 1) % 4;
                }else if(s[i] == '8'){
                    if( (count - 1) % 6 < 3 ) c = 't' + (count - 1) % 3;
                    else c = 'T' + (count - 1) % 3;
                }else if(s[i] == '9'){
                    if( (count - 1) % 8 < 4 ) c = 'w' + (count - 1) % 4;
                    else c = 'W' + (count - 1) % 4;
                }
                if(s[i] == '0') rep(i,count - 1) cout << ' ';
                else cout << c;
                count = 1;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <assert.h>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;
#define P (31LL)
#define MOD1 (1000000009LL)
#define INV1 (838709685LL)
#define MOD2 (1000000007LL)
#define INV2 (129032259LL)

int n, m, a[400000];
Int B1[400000], B2[400000];
char s[400000], op[10];

int main() {
    scanf("%d%d", &n, &m);
    scanf("%s", s);
    rep (i, n) a[i] = s[i]-'a'+1;
    B1[0] = 1;
    rep (i, n) B1[i+1] = B1[i]*P % MOD1;
    B2[0] = 1;
    rep (i, n) B2[i+1] = B2[i]*P % MOD2;
    set<pair<Int, Int> > st;
    int L = 0, R = 0;
    Int cur1 = a[0], cur2 = a[0];
    rep (_, m) {
        scanf("%s", op);
        if (op[0] == 'L') {
            if (op[1] == '+') {
                cur1 = (cur1 - a[L]*B1[R-L]%MOD1 + MOD1) % MOD1;
                cur2 = (cur2 - a[L]*B2[R-L]%MOD2 + MOD2) % MOD2;
                L++;
            }
            else {
                cur1 = (cur1 + a[L-1]*B1[R-L+1]%MOD1) % MOD1;
                cur2 = (cur2 + a[L-1]*B2[R-L+1]%MOD2) % MOD2;
                L--;
            }
        }
        else {
            if (op[1] == '+') {
                cur1 = (cur1 * P + a[R+1]) % MOD1;
                cur2 = (cur2 * P + a[R+1]) % MOD2;
                R++;
            }
            else {
                cur1 = ((cur1 - a[R] + MOD1) % MOD1 * INV1) % MOD1;
                cur2 = ((cur2 - a[R] + MOD2) % MOD2 * INV2) % MOD2;
                R--;
            }
        }
        //Int x = 0;
        //for (int k = L; k <= R; k++) x = (x * P + a[k]) % MOD;
        //assert(x == cur);
        st.insert(make_pair(cur1, cur2));
    }
    printf("%d\n", (int)st.size());
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
    p.at(i)--;
  }
  int s=0;
  for(int i=0;i<n;i++){
    if(p.at(i)!=i){
      s++;
    }
  }
  if(s<=2){
    cout<<"YES"<<endl;
    
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debugg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e7+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,sum;
void solve()
{
    ll n;cin>>n;
    ll nn=n;
    while(nn)
        {sum+=nn%10;nn/=10;}
    if(n%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = str(input())
x = '000'
ans = 0
while int(x) < 1000:
  st = 0
  cnt = 0
  if x[0] in S:
    for i in range(N):
      if x[0] == S[i]:
        st = i+1
        cnt += 1
        break
  if x[1] in S[st:]:
    for j in range(st, N):
      if x[1] == S[j]:
        st = j+1
        cnt += 1
        break
  if x[2] in S[st:]:
    for k in range(st, N):
      if x[2] == S[k]:
        st = k+1
        cnt += 1
        break
                
  if cnt == 3:
    ans += 1
  x = '{:03d}'.format(int(x)+1)
print(ans)

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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

char vratiKarakter(char c)
{
    if(c == 'r')
    {
        return 's';
    }

    else if(c == 'p')
    {
        return 'r';
    }

    else if(c == 's')
    {
        return 'p';
    }
}

vector <pair<int, char>> redosledObradivanja(int r, int s, int p)
{
    vector <pair<int, char>> v(3);

    v[0] = mp(r, 'r');
    v[1] = mp(s, 's');
    v[2] = mp(p, 'p');

    sort(rall(v));

    for(int i = 0; i < 3; i++)
    {
        v[i].se = vratiKarakter(v[i].se);
    }

    return v;
}

int main()
{
    int n, k;

    cin >> n >> k;

    int r, s, p;

    cin >> r >> s >> p;

    string t;

    cin >> t;

    vector <bool> visited(n, false);

    vector<pair<int, char>> redosled = redosledObradivanja(r, s, p);

    int suma = 0;

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(t[j] == redosled[i].se)
            {
                if(j - k >= 0)
                {
                    if(t[j] == t[j - k])
                    {
                        if(!visited[j - k])
                        {
                            visited[j] = true;
                            suma += redosled[i].fi;
                        }
                    }

                    else
                    {
                        visited[j] = true;
                        suma += redosled[i].fi;
                    }
                }

                else
                {
                    visited[j] = true;
                    suma += redosled[i].fi;
                }
            }
        }
    }

    cout << suma << '\n';

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
void fast(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int32_t main()
{
    fast();
    double n;
    cin >> n;
    cout << 6.28318530717958623200*n << "\n";
    return 0;
}


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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int ctr = 0;
    int rep = B-A+1;
    int val = 0;
    for(int i = 0; i < rep;i++){
        val = A+i;
        if(val % K == 0){
        cout << "OK" << endl;
        ctr = 1;
        break;
        }
    }
    if (ctr == 0){
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<long> as(n);
    if (n >= 3200){
        cout << s << endl; 
    }else{
        cout << "red" << endl;
    }
}

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

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


Measured memory_bytes: 3496
#include <stdio.h>
 
using namespace std;
 
int main(){
    int C[10001];
    for(int i = 0; i < 10001; i++) C[i] = 0;
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }
 
    for(int i = 0,j=0; i < 10001; i++){
        if(C[i] != 0){
            for(int k = 0; k < C[i]; k++){
                B[j++] = i;
            }
        }
    }
 
    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
    delete[] A;
    delete[] B;
    return 0;
}
 



Measured memory_bytes: 17928
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N, x int
	fmt.Scan(&N, &x)
	a := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		a[i] = nextInt(sc)
	}
	ans := 0
	for i := 0; i+1 < N; i++ {
		d := a[i+1] + a[i] - x
		if d > 0 { // a[i]とa[i+1]の合計がxより大きい
			ans += d // 少なくともd個食べないといけない
			// 今後のためになるべく多くa[i+1]から引いた方が良い。
			if a[i+1] > 0 {
				a[i+1] -= min(a[i+1], d)
			}
			// まだxより大きければa[i]から引く
			d = a[i+1] + a[i] - x
			if d > 0 {
				a[i] -= min(a[i], d)
			}
		}
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

int main(int argc, char const *argv[])
{
    int n, ans=0;
    cin >> n;

    for(int i=0; i<n; i++){
        ans += (i+1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int n, v[112345];

	scanf("%d", &n);
	rep(i, n) scanf("%d", &v[i]);

	map<int, int> odd, even;
	rep(i, n) {
		if (i % 2) ++odd[v[i]];
		else ++even[v[i]];
	}


	int best = -1;

	int odd_max = 0, even_max = 0, o_m = -1;

	for (auto o : odd) {
		odd_max = max(o.second, odd_max);
		if (o.second == odd_max) o_m = o.first;
	}
	for (auto e : even) {
		if (e.first != o_m) even_max = max(e.second, even_max);
	}

	best = max(best, odd_max + even_max);

	odd_max = 0, even_max = 0;
	int e_m = -1;

	for (auto e : even) {
		even_max = max(e.second, even_max);
		if (e.second == even_max) e_m = e.first;

	}
	for (auto o : odd) {
		if (o.first != e_m) odd_max = max(o.second, odd_max);
	}
	best = max(best, odd_max + even_max);

	printf("%d\n", n - best);

	return 0;
}


Measured memory_bytes: 5376
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>

using namespace std;

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

int main(){
	
	int point[111]={0};
	
	int n;
	cin>>n;
	
	for(int i=0; i<(n)*(n-1)/2;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;b--;
		
		if(c>d)point[a]+=3;
		if(d>c)point[b]+=3;
		if(c==d){ point[a]++; point[b]++; }
	}
	
	
	for(int i=0;i<n;i++){
		int rank=1;
		for(int j=0;j<n;j++){
			if(point[i]<point[j])rank++;
		}
		printf("%d\n",rank);
	}
}

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

int main() {
int A,B,C,D;
  cin >>A>>B>>C>>D;
  if(A+B>C+D){
    cout <<"Left";
  }
  else if(A+B==C+D){
    cout <<"Balanced";
  }
  else{
    cout <<"Right";
  }

}


Measured memory_bytes: 256
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
const long long MOD=1e9+7;
long long n,m,x,y,num[100010],a[100010];
vector<pair<long long,long long> > v;
vector <long long> ans;
long long find(long long pos){
	if(a[pos]!=pos) a[pos]=find(a[pos]);
	return a[pos];
}
void UNION(long long pos1,long long pos2){
	num[find(pos2)]+=num[find(pos1)];
	a[find(pos1)]=find(pos2);
}
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		cin>>x>>y;
		v.push_back(pair<long long,long long>(x,y));
	}
	reverse(v.begin(),v.end());
	for (int i=0;i<100005;i++) a[i]=i,num[i]=1;
	ans.push_back(n*(n-1)/2);
	long long sum=ans[0];
	for (int i=0;i<m-1;i++){
		if(find(v[i].first)!=find(v[i].second)){
			sum-=num[find(v[i].first)]*num[find(v[i].second)];
			UNION(v[i].first,v[i].second);
		}
		ans.push_back(sum);
	}
	reverse(ans.begin(),ans.end());
	for (int i=0;i<ans.size();i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
int x;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> x;
	if (x % 1000 == 0){
		cout << 0 << endl;
	} else {
		cout << 1000 - (x % 1000) << endl;
	}
}

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

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

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

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

int n;
ll k, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    if (k == 0) {
        ll res = 0;
        FOR(i,1,n) res += a[i];
        cout << res;
        return 0;
    }
    int x = 64 - __builtin_clzll(k);
    ll chosen = 0;
    ll p = k;
    FORE(j,x-1,0) {
        if ((p & (1LL << j)) == 0) continue;
        int num1 = 0, num0 = 0;
        FOR(i,1,n)
            if (a[i] & (1LL << j)) num1++; else num0++;
        if (num0 > num1) chosen |= (1LL<<j);
        else p = (1LL << j) - 1;
    }
    ll res = 0;
    FOR(i,1,n) res += (a[i] ^ chosen);
    cout << res;
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def func():
    S = input()
    for idx in range(len(S)):
        if idx > 0:
            if S[idx] == S[idx-1]:
                print("{} {}".format(idx, idx+1))
                return
        if idx > 1:
            if S[idx] == S[idx-2]:
                print("{} {}".format(idx-1, idx+1))
                return
    print("-1 -1")

func()    



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
S = int(readline())
f = [0]*(2000+1)
f[3] = 1
f[4] = 1
f[5] = 1

for i in range(6,S+1):
    tmp = 1
    for k in range(3,S+1):
        if i-k < k:
            break
        a = k
        b = i-k
        if a!=b:
            tmp+=f[a]
            tmp+=f[b]
        else:
            tmp+=f[a]
        tmp%=MOD
    f[i] = tmp
    
print(f[S])

Measured memory_bytes: 66432
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AGC
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long count(string s)
        {
            long cnt = 0;
            long num = 0;
            for (var i = 0; i < s.Length - 1; ++i)
            {
                if (s[i] == s[i + 1])
                { ++cnt; }
                else
                {
                    num += (cnt + 1) / 2;
                    cnt = 0;
                }
            }
            num += (cnt + 1) / 2;
            return num;

        }
        static void Main(string[] args)
        {
            var s = ReadLine();
            var k = Sarray()[0];
            if (s.First() != s.Last())
            {
                long num = count(s);
                WriteLine(num * k);
            }
            else
            {
                if (s.Length == s.Count(c => c == s[0]))
                    WriteLine((k * (long)s.Length) / 2L);
                else
                {
                    var idx = 0;
                    for (var i = 0; i < s.Length; ++i)
                        if (s[0] != s[i])
                        {
                            idx = i;
                            break;
                        }
                    string news = string.Empty;
                    for (var i = 0; i < s.Length; ++i)
                        news += s[(idx + i) % s.Length].ToString();
                    long num = count(news);
                    long ans = num * (k - 1);
                    string pres = string.Empty;
                    for (var i = 0; i < idx; ++i)
                        pres += s[i].ToString();
                    num = count(pres);
                    ans += num;
                    string afts = string.Empty;
                    for (var i = idx; i < s.Length; ++i)
                        afts += s[i].ToString();
                    num = count(afts);
                    ans += num;
                    WriteLine(ans);
                }
            }
        }
    }
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  //
  string s;
  cin >> s;

  ll sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    sum += s[i] - '0';
  }

  cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3728
import java.io.*;
import java.util.*;

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long M;
        M = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(N, M);
    }
}

class Solver {
    public void solve(long N, long M) {
        if (N == M) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;

  if(d1<d2) cout << 0 << endl;
  else cout << 1 << endl;
  
  //cout << fixed << setprecision(10);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string s[3];

  for (int i = 0; i < 3; i ++) {
    std::cin >> s[i];

    std::reverse(ALL(s[i]));
  }

  int x = 0;

  while (1) {
    if (s[x].empty()) {
      std::cout << static_cast<char>(x + 'A') << std::endl;

      return 0;
    }

    char c = s[x].back();

    s[x].pop_back();

    x = c - 'a';
  }

  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
まず大きい順にk個とる。このときの種類数をxとする。種類数がxより小さくて答えがこれより大きくなることはない。なるべく和を減らさずに種類数を増やすことを考える。
*/

ll n,k,num[100010]={},ans=0,f=0,g=0,l,r;
mp p[100010];

int main(void){
	cin>>n>>k;
	reg(i,1,n){
		ll t,d;
		cin>>t>>d;
		p[i] = {d,t};
	}
	//まず大きい順にk個とった時の種類数を見る。
	sort(p+1,p+n+1,greater<mp>());
	reg(i,1,k){
		f+=p[i].first;
		num[p[i].second]++;
	}
	reg(i,1,n)if(num[i]!=0)g++;
	ans=max(ans,f+g*g);
	l=k;
	r=k+1;
	while(l>=1 && r<=n){
		//種類数を1ずつ増やしていく
		//種類の変わらないものの中で一番小さいものを取り除き
		//種類の増えるものの中で一番大きいものを追加する
		while(l>=1 && num[p[l].second]<=1)l--;
		if(l==0 || num[p[l].second]<=1)break;
		while(r<=n && num[p[r].second]>=1)r++;
		if(r==n+1 || num[p[r].second]>=1)break;
		f=f-p[l].first+p[r].first;
		g++;
		ans=max(ans,f+g*g);
		num[p[l].second]--;
		num[p[r].second]++;
		l--;
		r++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
// 2020-07-26 06:47:00
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n, m, d;
  cin >> n >> m >> d;
  ld ans = d ? ld(n-d)*2 : n;
  ans *= ld(m-1) / n / n;
  cout << fixed << setprecision(10) << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3748
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[20];
int main(){
	int a;scanf("%d",&a);
	set<string>S;
	for(int i=0;i<a;i++){
		scanf("%s",in);
		string str=in;
		S.insert(str);
	}
	printf("%d\n",(int)(S.size()));
}


Measured memory_bytes: 18908
#include<stdio.h>

int main(void)
{
  int n,array[100],i,temp,frag=1,counter=1;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&array[i]);
    }
  while(frag == 1)
    {
      frag = 0;
      for(i=0;i<n-1;i++)
	{
	  if(array[i] > array[i+1])
	    {
	      temp = array[i];
	      array[i] = array[i+1];
	      array[i+1] = temp;
	      frag = 1;
	    }
	}
    }
  for(i=0;i<n-1;i++)
    {
      if(array[i] != array[i+1])
	{
	  counter++;
	}
    }
  printf("%d\n",counter);
  return 0;
}


Measured memory_bytes: 128
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    int n,arr[100001],cnt=0,ans=0;
    cin >> n;
    for(int i=0;i<n;i++) cin >> arr[i];

    for(int i=0;i<n-1;i++){
        if(arr[i]>=arr[i+1]) cnt++;
        else cnt=0;
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


bool solve(){
    int n;
    cin >> n;
    vector<int> arr{1, 2, 1};
    if(n < 3)
        cout << arr[n] << endl;
    else
        cout << 0 << endl;
    return false;
}

signed main(){
    while(solve());
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=300010;

int main(){
	string s;
	int Q;
	cin>>s;
	cin>>Q;
	int t[Q];
	int reverse_time=0;
	vector<string> head, tail;
	REP(i,Q){
		double f;
		string c;
		cin>>t[Q];
		if(t[Q]==2){
			cin>>f>>c;
			if(reverse_time%2==0){
				if(f==1)head.push_back(c);
				else if(f==2)tail.push_back(c);
			}else{
				if(f==1)tail.push_back(c);
				else if(f==2)head.push_back(c);
			}
		}else{
			reverse_time++;
		}
	}
	string head_str="";
	string tail_str="";
	string ans="";

	while(!head.empty()){
		head_str+=head.back();
		head.pop_back();
	}
	while(!tail.empty()){
		tail_str+=tail.back();
		tail.pop_back();
	}
	if(reverse_time%2==0){
		reverse(tail_str.begin(), tail_str.end());
		ans=head_str+s+tail_str;
	}else{
		reverse(s.begin(),s.end());
		reverse(head_str.begin(),head_str.end());
		ans=tail_str+s+head_str;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12016
import java.util.Scanner;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        char c = S.charAt(0);
        int l = 1;
        for(int i = 1; i < N; i++) {
           if(S.charAt(i) != c) {
               l += 1;
               c = S.charAt(i);
           }
        }

        System.out.println(l);

    }
}

Measured memory_bytes: 24660
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i=0,n;
	char o[100],e[100];
	char s;
	
	scanf("%s %s",o,e);
	
	n=strlen(e);
	
	for(i=0;i<n;i++)
	{
		s=o[i];
		printf("%c",s);
		s=e[i];
		printf("%c",s);
		
	}
	
	if(strlen(o)>strlen(e))
	{
		printf("%c\n",o[i]);
	}
	else
	{
		printf("\n");
	}
	
	return 0;
}

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

int main() {
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int rui[N+1] = {0};
  for (int i = 1; i < N+1; i++) {
    rui[i] = rui[i-1];
    if (S[i - 1] == 'A' && S[i] == 'C') {
      rui[i - 1]++;
      rui[i]++;
    }
  }
   int l[Q],r[Q];
  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
    cout << rui[r[i]-2] - rui[l[i]-2] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2176
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	ll res = 0; int nx = 1;
	for (int i = 0; i < N; ++i) {
		if (A[i] % nx) {
			res += A[i] / nx;
			A[i] -= A[i] / nx * nx;
		}
		else if (A[i] > nx) {
			res += A[i] / nx - 1LL;
			A[i] = 1;
		}
		if (A[i] >= nx) ++nx;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
# ARC093D

a,b = map(int, input().split())

if a<=b:
    m = "."
    M = "#"
    mc = a
    Mc = b
else:
    m = "#"
    M = "."
    mc = b
    Mc = a
    
s = [[m]*100 for _ in range(100)]
tmp = [[M,M,M,m],
        [M,m,M,m],
      [M,M,M,m],
      [m,m,m,m]]
tmp2 = [[M,m,m,m],
        [m,m,m,m],
      [m,m,m,m],
      [m,m,m,m]]
i = 0
for i in range(mc-1):
    u,v = (i*4)//100, (i*4)%100
    u *= 4
    for x in range(4):
        for y in range(4):
            s[u+x][v+y] = tmp[x][y]

for j in range(i+1, i+1+(Mc-(mc-1))):
    u,v = (j*4)//100, (j*4)%100
    u *= 4
    for x in range(4):
        for y in range(4):
            s[u+x][v+y] = tmp2[x][y]
print(100,100)
print("\n".join(["".join(item) for item in s]))

Measured memory_bytes: 40688
import Control.Applicative
import Data.Bool (bool)

main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve [a, b] = bool "Impossible" "Possible" $ any (== 0) $ map (flip mod 3) [a, b, a + b]


Measured memory_bytes: 508