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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int a[1000010];
int main()
{
    string s, a = "", b = "";
    int ca = 0, cb = 0;
    cin >> s;
    for (int i = 0; i < sz(s); ++i)
        a += char(((i + 1) % 2) + '0');
    for (int i = 0; i < sz(s); ++i)
    {
        b += char((i & 1) + '0');
    }

    for (int i = 0; i < sz(s); ++i)
    {
        if (a[i] != s[i])
            ca += 1;
        if (b[i] != s[i])
            cb += 1;
    }
    cout << min(ca, cb) << endl;
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void foo(int n, int id, char c, string& s) {
	if (id == n)
		cout << s << endl;
	else {
		for (char f = 'a'; f <= c; f++) {
			s = s + f;
			foo(n, id + 1, c, s);
			s.pop_back();
		}
		c = (char)(c + 1);
		s += c;
		foo(n, id + 1, c, s);
		s.pop_back();
	}
}

void solve() {
	int n; cin >> n;
	string s = "a";
	foo(n, 1, 'a', s);
	return;
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewMe)
{
  StNode*  poParnt = nullptr;
  StNode** ppoNode = &rpoRoot;

  while (*ppoNode)
  {
    poParnt = *ppoNode;
    if (poNewMe->m_nKey < poParnt->m_nKey)
      ppoNode = &poParnt->m_poLeft;
    else
      ppoNode = &poParnt->m_poRigt;
  }
  poNewMe->m_poParnt = poParnt;
  *ppoNode = poNewMe;
}

StNode* fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode)
    if (nNo == poNode->m_nKey)
      return poNode;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return nullptr;
}

void fnDelete(StNode*& rpoRoot, StNode* poDelMe)
{
  StNode** ppoPrToMe;
  if (poDelMe == rpoRoot)
    ppoPrToMe = &rpoRoot;
  else
    if (poDelMe->m_nKey < poDelMe->m_poParnt->m_nKey)
      ppoPrToMe = &poDelMe->m_poParnt->m_poLeft;
    else
      ppoPrToMe = &poDelMe->m_poParnt->m_poRigt;

  int nDegr = 0;
  StNode* poMeToCd;
  if (poDelMe->m_poLeft)
  {
    ++nDegr;
    poMeToCd = poDelMe->m_poLeft;
  }
  if (poDelMe->m_poRigt)
  {
    ++nDegr;
    poMeToCd = poDelMe->m_poRigt;
  }

  if (!nDegr)
  {
    *ppoPrToMe = nullptr;
    delete poDelMe;
  }
  else if (nDegr == 1)
  {
    *ppoPrToMe = poMeToCd;
    poMeToCd->m_poParnt = poDelMe->m_poParnt; 
    delete poDelMe;
  }
  else if (nDegr == 2)
  {
    StNode* poNext = poDelMe->m_poRigt;
    while (poNext->m_poLeft)
      poNext = poNext->m_poLeft;

    poDelMe->m_nKey = poNext->m_nKey;
    fnDelete(rpoRoot, poNext);
  }
}

void fnInOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (!poNode)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewMe = new StNode(nNo);
      fnInsert(rpoRoot, poNewMe);
    }
    else if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    else if (sCmd[0] == 'd')
    {
      int nNo;
      cin >> nNo;
      StNode* poDelMe;
      if (poDelMe = fnFind(rpoRoot, nNo))
        fnDelete(rpoRoot, poDelMe);
      else;
    }
    else if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
    else;
  }
}

void fnPstOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
  return 0;
}

Measured memory_bytes: 21956
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;

int main(){
    fastio
int x;
cin>>x;
if(x==5 || x==7 || x==3)
cout<<"YES"<<endl;
else
{
    cout<<"NO"<<endl;
}

    return 0 ;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a[1000560];
int main(){
	int n,j,i;
	while(~scanf("%d",&n)){
		int t;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		if(n%2==0){
			for(i=n;i>0;i-=2){
				printf("%d ",a[i]);
			}
			for(i=1;i<=n-1;i+=2){
				if(i==n-1){
					printf("%d",a[i]);
				}
				else{
					printf("%d ",a[i]);
				}	 
			}
		}
		if(n%2==1){
			for(i=n;i>=1;i-=2){
				
				printf("%d ",a[i]);
				
			}for(i=2;i<=n-1;i+=2){
				
				if(i==n-1){
					printf("%d",a[i]);
				}
				else{
					printf("%d ",a[i]);
				}
			}
		}
		printf("\n");
	}
	return 0;
} 

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

int main(int argc, char const *argv[])
{
	int N;
	int ai, a1, a2, a4;

	a1 = a2 = a4 = 0;
	cin >> N;

	while(N--)
	{
		cin >> ai;
		if(ai % 4 == 0)
			a4++;
		else if(ai % 2 == 0)
			a2++;
		else
			a1++;
	}

	if(a2 > 0 && a1 <= a4)
		cout << "Yes";
	else if(a2 == 0 && a1 <= a4+1)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n; cin >> n; ll total = 0;
	for (int i = 0; i < n; i++) {
		ll temp; cin >> temp; total += temp;
	}
	cout << total - n;
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, x;
    cin >> n >> x;

    int r = 1, t = 0;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        t += l;
        if (t <= x) r++;
    }

    cout << r << endl;

    return 0;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	int n;cin>>n;
	ll s=0;
	unordered_map<int, int> cnt;
	for(int i=0;i<n;i++) {
		int x;cin>>x;
		cnt[x]++;
		s+=(ll)x;
	}
	int q;cin>>q;
	while(q--) {
		int b,c;cin>>b>>c;
		if(cnt.count(b)) {
			cnt[c]+=cnt[b];
			s-=(ll)cnt[b]*b;
			s+=(ll)cnt[b]*c;
			cnt[b]=0;
		}
		cout << s << "\n";
	}
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

ll dp[3001][3001][2];

int main(){	
	long long T;
	long long N;
	scanf("%lld",&N);
	vector<long long> B(N-1+1);
	vector<long long> A(N-1+1);
	scanf("%lld",&T);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
	repn(i, N) {
		rep(j, T+1) {
			if (j-A[i-1] >= 0) dp[i][j][0] = max(dp[i-1][j][0], dp[i-1][j-A[i-1]][0]+B[i-1]); else dp[i][j][0] = dp[i-1][j][0];
			if (j-A[i-1] >= 0) dp[i][j][1] = max(max(dp[i-1][j][1], dp[i-1][j-A[i-1]][1]+B[i-1]), dp[i-1][j][0]+B[i-1]); else dp[i][j][1] = max(dp[i-1][j][1], dp[i-1][j][0]+B[i-1]);
		}
	}

	ll res = 0;
	rep(i, T) {
		res = max(res, max(dp[N][i][0], dp[N][i][1]));
		// cout << i << " " << dp[N][i][0] << " " << dp[N][i][1] << endl;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 140928
#include<iostream>
#include<queue>
using namespace std;
int m[105][105],n,v[105],d[105];
void bfs(int s)
{
    v[s]=true;
    d[s]=0;
    queue<int>q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();q.pop();
        for(int i=0;i<n;i++)
        {
             if(m[u][i]&&!v[i])
            {
                d[i]=d[u]+1;
                v[i]=true;
                q.push(i);
            }
        }
    }
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)d[i]=-1;
    for(int i=0;i<n;i++)
    {
        int u,v,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            cin>>v;
            m[u-1][v-1]=true;
        }
    }
    bfs(0);
    for(int i=0;i<n;i++)cout<<i+1<<' '<<d[i]<<endl;
    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int cnt[100009];

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

	string S; cin >> S;
	int N = S.size();
	vector<int> V; // R,Lとなっている個所
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == 'R' && S[i + 1] == 'L') V.push_back(i + 1);
	}

	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') {
			auto it = upper_bound(V.begin(), V.end(), i);
			int pos = *it; // iよりも右にある一番近いRL

			if ((pos - i) % 2 == 0) cnt[pos]++;
			else cnt[pos - 1]++;
		}
		else {
			auto it = upper_bound(V.begin(), V.end(), i);
			it--;
			int pos = *it; // iよりも右にある一番近いRL

			if ((i - pos) % 2 == 0) cnt[pos]++;
			else cnt[pos - 1]++;
		}
	}

	for (int i = 0; i < N; i++) cout << cnt[i] << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exawizards2019B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            //string[] input = Console.ReadLine().Split(' ');
            //int b = int.Parse(input[0]);
            //int c = int.Parse(input[1]);
            // 文字列の入力
            string s = Console.ReadLine();

            int r = 0;
            int b = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s.Substring(i, 1) == "R")
                {
                    r++;
                }
                else
                {
                    b++;
                }
            }
            if (r > b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main(){

	long x,happiness=0;
	cin>>x;
	
	while(x>4){
		if(x>=500){
			x-=500;
			happiness+=1000;
			continue;
		}else if(x>=5){
			x-=5;
			happiness+=5;			
			continue;
		}
	}
			
			
	cout<<happiness;
	
	return 0;
}
	
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 SZ(x) ((int)(x).size())
typedef long long ll;

typedef long double ld;
using namespace std;


int main() {
    ll N;
    cin>>N;
    ll A,B;
    cin>>A>>B;
    ll costa,costb;
    costa=N*A;
    costb=B;
    if(costa>costb){
        cout<<costb<<endl;
    }else{
        cout<<costa<<endl;
    }
}
 

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

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << A + B + C + max({ A, B, C }) * 9 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		String S = sc.next();
		String T = sc.next();
		int len = S.length();
		String res = "No";
		for(int i=1;i<=len;i++){
			if(T.contains(S.substring(0, i)) && T.contains(S.substring(i))){
				res = "Yes";
				break;
			}
		}
		out.println(res);
		out.flush();
	}
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
// https://atcoder.jp/contests/abc075/tasks/abc075_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

struct UnionFind {
    vector<int> par, rank;

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

    int root(int x) {
        if (par[x] == -1)
            return x;
        else
            return par[x] = root(par[x]);
    }

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

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

void solve() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(M);
    for (auto &x : v) {
        cin >> x.first >> x.second;
        x.first--, x.second--;
    }
    int ans = 0;
    REP(i, M) {
        UnionFind uf(N);
        REP(j, M) {
            if (i != j) {
                uf.merge(v[j].first, v[j].second);
            }
        }
        // 連結でなければ橋
        if (!uf.issame(v[i].first, v[i].second)) {
            ans++;
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3628
a,b,c = input().split()

if a == b == c:
  print('No')
elif a != b and b != c and a != c:
  print('No')
elif a == b and a != c:
  print('Yes')
elif a == c and a != b:
  print('Yes')
elif b == c and a != b:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int maxn = 1e3;
char A[maxn],B[maxn];
int main()
{
	while( scanf(" %s",A) != EOF ){
		scanf(" %s",B);
		int lenA = strlen(A);
		int lenB = strlen(B);
		int check = 0,flag = 0;
		if( lenA > lenB )
			printf("GREATER\n");
		else if( lenA < lenB )
			printf("LESS\n");
		else{
			for( int i = 0 ; i < lenA ; i++ ){
				if( A[i] > B[i] ){
					flag = 1;
					break;
				}
				else if( A[i] < B[i] ){
					flag = 2;
					break;
				}
				else
					check += 1;
			}
			if( flag == 1 )
				printf("GREATER\n");
			else if( flag == 2 )
				printf("LESS\n");
			else
				printf("EQUAL\n");
		}
		memset( A , ' ' , sizeof(A) );
		memset( B , ' ' , sizeof(B) );
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r = 0; r <= N; r++)
    {
        for (int g = 0; g <= N; g++)
        {
            double b = (double)(N - R * r - G * g) / B;
            if (b - (int)b == 0 && b <= N && b >= 0)
            {
                // cout << r << ' ' << g << ' ' << (int)b << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  vector<pair<int,int>> ab(n);
  for(int i=0;i<n;i++){
    ab[i]=make_pair(a[i],b[i]);
  }
  sort(ab.begin(),ab.end());
  long long ans = 0;
  for(int i=0;i<n;i++){
    int kaukazu = min(m,ab[i].second);
    ans += (long long)kaukazu*ab[i].first;
    m-=kaukazu;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int max(int a, int b, int c, int d){
	return max(a, max(b, max(c,d)));
}
int32_t main() {
	int w, h, x, y; cin>>w>>h>>x>>y;
	cout<<double(w) * double(h) / 2<<" "<<(x + x == w && y + y == h)<<endl;
}


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


// vector
#define MAX_ELE(vec) *max_element(vec.begin(), vec.end())

// ---------------------------------------

// string
#define TO_UP(str) transform(str.cbegin(), str.cend(), str.begin(), ::toupper)

// ---------------------------------------



using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------

    int A, B;
    vector<int> gjgj;

    cin >> A >> B;

    gjgj.push_back(A+B);
    gjgj.push_back(A-B);
    gjgj.push_back(A*B);

    cout << MAX_ELE(gjgj) << "\n";

}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
 ll N;cin>>N;
 
 if(N!=0){
   vi A;
  while(N!=0){
    
     A.pb(max(N%(-2),(N%(-2)+2) %2));
    if(A.back()==1)N--;
    N/=(-2);

 
 
  }
  reverse(all(A));
  rep(i,A.size()){
    cout<<A[i];
  }
  cout<<endl;
      
 }
  else cout<<0<<endl;

  
}






Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 20000001;
#define ff(i,n) for(i=0;i<n;i++) 
void dfs(ll i,ll vis[],ll p[],vector<vector<ll> > &adj,ll par)
{
	vis[i] = 1;
	p[i] = par;
	ll j;
	for(j=0;j<adj[i].size();j++)
	{
		if(vis[adj[i][j]]==0)
		{
			dfs(adj[i][j],vis,p,adj,i);
		}
	}
}
ll dp[140000][26];
string s;
ll fun(ll l,ll r,ll alpha)
{
	ll mid = (l+r)/2;
	if(l==r)
	{
		if((s[l-1]-'a')!=alpha)
		   return 1;
		else
		   return 0;   
	}
	ll l1 = ((r-mid)-(dp[r][alpha]-dp[mid][alpha])) + fun(l,mid,alpha+1);
	ll l2 = ((mid-l+1)-(dp[mid][alpha]-dp[l-1][alpha])) + fun(mid+1,r,alpha+1);
	ll l3 = min(l1,l2);
	return l3;
}
int main()
{
	ll test,t;
	t=1;
	for(test=1;test<=t;test++)
	{
		ll l,r,d,i,a=0;
		cin>>l>>r>>d;
		for(i=l;i<=r;i++)
		   if(i%d==0)
		      a++;
		cout<<a;      
	}
	return 0;
} 

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b and b == c and c == a){
    cout << "No" << endl;
  }
  else if (a != b and b!= c and c != a){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int Q, H, S, D; cin >> Q >> H >> S >> D;
    int N; cin >> N;
    N *= 4;

    int d = N / 8;
    int s = (N - 8 * d) / 4;
    int h = (N - 8 * d - 4 * s) / 2;
    int q = N - 8 * d - 4 * s - 2 * h;

    int Pd = min(min(D, 2 * S), min(4 * H, 8 * Q));
    int Ps = min(min(S, 2 * H), 4 * Q);
    int Ph = min(H, 2 * Q);
    int Pq = Q;

    int ans = d * Pd + s * Ps + h * Ph + q * Pq;
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 110
using namespace std;
long long a[maxn],b[maxn];
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n;
    long long mx=0;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<=n;i++)a[i]+=a[i-1];
    for(int i=n;i>=1;i--)b[i]+=b[i+1];
    for(int i=1;i<=n;i++)mx=max(mx,a[i]+b[i]);
    cout<<mx<<endl;
return 0;
}


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

    long long sum = 0,result;

    long long l;
    for (int i = 0; i< M ;i++){
        cin >> l;
        sum+=l;
    }

    result = (N-sum >= 0) ? N-sum : -1;
 
    cout << result  << endl;

    return 0;
}
 


Measured memory_bytes: 3632
n = int(input())
S = []
for _ in range(n):
    S.append(sorted(input()))

count = 1
ans = 0
pre = ""
for s in sorted(S):
    if s == pre:
        count += 1
    else:
        ans += (count*(count-1))//2
        count = 1
    pre = s
ans += (count*(count-1))//2
print (ans)

Measured memory_bytes: 100312
import Data.List
main = do
  getLine
  xs <- map read . words <$> getLine
  print $ solve3 xs
solve3 xs = case filter ((2 <=) . length) . group $ sortBy (flip compare) xs of
  ((x : _ : _ : _ : _) : _) -> x * x
  ((x : _ : _) : (y : _ : _) : _) -> x *y
  _ -> 0

Measured memory_bytes: 39932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, dp[MAX_N];
    cin >> n;
    fill(dp, dp+n+1, IINF);
    dp[0] = 0;
    REP(i,n){
        dp[i+1] = min(dp[i]+1,dp[i+1]);
        int n6=6, n9=9;
        while(i+n6<=n){
            dp[i+n6] = min(dp[i+n6],dp[i]+1);
            n6 *= 6;
        }
        while(i+n9<=n){
            dp[i+n9] = min(dp[i+n9],dp[i]+1);
            n9 *= 9;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

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

    int N, L;

    cin >> N >> L;

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

    int min_abs = 0;
    if (L > 0) {
        min_abs = L;
    } else if (L + N - 1 < 0) {
        min_abs = L + N - 1;
    }

    cout << all_taste - min_abs << '\n';

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
b = 27
mod = 67280421310721
m = n // 2
x = [1] * (m + 1)
for i in range(1, m + 1):
    x[i] = (x[i - 1] * b) % mod
h0 = [0] * m
h0[0] = ord(s[0]) - 96
d = [{} for _ in range(m + 1)]
for i in range(1, m):
    h0[i] = (h0[i - 1] * b + (ord(s[i]) - 96)) % mod
for i in range(m, 0, -1):
    h = h0[i - 1]
    d[i][h] = 0
    for j in range(i, n):
        h *= b
        h %= mod
        h -= (x[i] * (ord(s[j - i]) - 96) % mod)
        h += (ord(s[j]) - 96)
        h %= mod
        if h in d[i]:
            if (j - i + 1 - d[i][h]) >= i:
                print(i)
                exit()
        else:
            d[i][h] = j - i + 1
print(0)

Measured memory_bytes: 451992
#include<iostream>
using namespace std;
class Dice{
    int x[7] = {};
    public:
    void input(int I, int num){
        x[I] = num;
    }
   
    void move(char order){
        int oldx[7];
        for(int i = 1; i <= 7; i ++){
            oldx[i] = x[i];
        }
        if(order == 'N'){
            x[1] = oldx[2];
            x[2] = oldx[6];
            x[6] = oldx[5];
            x[5] = oldx[1];
        } 
        else if(order == 'S'){
            x[1] = oldx[5];
            x[2] = oldx[1];
            x[6] = oldx[2];
            x[5] = oldx[6];
        }
        else if(order == 'W'){
            x[1] = oldx[3];
            x[4] = oldx[1];
            x[6] = oldx[4];
            x[3] = oldx[6];
        }
        else if(order == 'E'){
            x[1] = oldx[4];
            x[4] = oldx[6];
            x[6] = oldx[3];
            x[3] = oldx[1];
        }
    }
     void rotation(int top, int front){
       for(int i = 0; i < 4; i++){
           move('S');
           if(x[2] == top){
               for(int j = 0; j < 4; j++){
                   move('W');
                   if(x[6] == front){
                       move('N');
                       break;
                   }
               }
           }
           else if(x[2] == front){
               for(int j = 0; j < 4; j++){
                   move('E');
                   if(x[1] == top) break;
                   
               }
               
           }
           
       }
        
    }
    void same(Dice a, Dice b){
        char ch[7] = "NNNWWW";
        for(int i = 0; i <= 6; i ++){
            b.rotation(a.print(1),a.print(2));
            if(a.print(1) == b.print(1) && a.print(2) == a.print(2) && a.print(3) == b.print(3) && a.print(4) == b.print(4) && a.print(5) == b.print(5) && a.print(6) == b.print(6)){
                cout << "Yes" << endl;
                break;
            }
            else a.move(ch[i]);
        }
        if(a.print(1) != b.print(1) || a.print(2) != a.print(2) || a.print(3) != b.print(3) || a.print(4) != b.print(4) || a.print(5) != b.print(5) || a.print(6) != b.print(6)) cout << "No" << endl;
    }
    
   
    int print(int num){
        return x[num];
        
    }
    
};

int main(){
    Dice dice1;
    Dice dice2;
    int val1,val2;
    for(int i = 1;i <= 6; i++){
        cin >> val1;
        dice1.input(i,val1);
    }
    for (int i = 1; i <= 6; i++){
        cin >> val2;
        dice2.input(i,val2);
    }
    dice1.same(dice1,dice2);
    return 0;
}




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


vector<ll>vt[sz];
ll cnt[sz];
ll vis[sz];

void dfs(ll u)
{
    vis[u]=1;

    for(ll i=0; i<vt[u].size(); i++)
    {
        ll v=vt[u][i];
        if(vis[v]==0)
        {
            cnt[v]+=cnt[u];
            dfs(v);
        }
    }
}
int main()
{

    ll u,v,a,b,i,j,n,q,x,p;

    cin>>n>>q;

    for(i=1; i<n; i++)
    {
        cin>>u>>v;
        vt[u].push_back(v);
        vt[v].push_back(u);
    }

    while(q--)
    {
        cin>>x>>v;
        cnt[x]+=v;
    }
    dfs(1);

    for(i=1; i<=n; i++)
    {
        cout<<cnt[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 25856
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * (n + 1)
    for ai in a:
        ans[ai] += 1
    for i in range(1, n + 1):
        print(ans[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 32192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c || b+c==a || c+a==b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

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

## Logic

alice = 0
bob = 0

A.sort(reverse=True)
for i in range(0,N):
    if i%2==0:
        alice += A[i]
    else:
        bob += A[i]



print(alice-bob)





Measured memory_bytes: 63980
#include<cstring>
#include<iostream>
using namespace std;
int main(){
	char s[17]={"CODEFESTIVAL2016"};
	char ss[17];
	short sum=0;
	cin>>ss;
	for(int i=0;i<=15;i++){
		if(ss[i]!=s[i])sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())

l = np.zeros((9,9), dtype=np.int)
# l[i][j] : i = 頭文字　j = 最後の文字

for k in range(N):
    x = str(k+1)
    i = int(x[0])
    j = int(x[-1])

    #print(i,j)

    if i == 0 or j == 0:
        continue
    l[i-1][j-1] += 1

ans = 0
for i in range(9):
    for j in range(i,9):
        if i == j:
            n = l[i][j]
            ans += n**2
        else:
            ans += l[i][j] * l[j][i] * 2
            

print(ans)









Measured memory_bytes: 13224
import java.util.Scanner;

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

		int n = sc.nextInt();

		String s = sc.next();
		int ans = 1;
		for (int i = 0; i < n - 1; i++) {

			if (s.charAt(i) != s.charAt(i + 1)) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23844
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::min;
use itertools::Itertools;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr >() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn count_two(n: u64) -> u64 {
    fn go(count: u64, num: u64) -> u64 {
        if num % 2 == 0 {
            go(count + 1, num / 2)
        } else {
            count
        }
    }
    go(0, n)
}

fn main() {
    let n:u64 = read();
    let ss:Vec<String> = (0..n).map(|_|read()).collect();
    let mut hm = HashMap::new();
    for s in ss {
        let first_letter = s.chars().next().unwrap();
        let entry = hm.entry(first_letter).or_insert(0);
        *entry += 1;
    }
    let m = *hm.get(&'M').unwrap_or(&0_u64);
    let a = *hm.get(&'A').unwrap_or(&0_u64);
    let r = *hm.get(&'R').unwrap_or(&0_u64);
    let c = *hm.get(&'C').unwrap_or(&0_u64);
    let h = *hm.get(&'H').unwrap_or(&0_u64);
    let ans:u64 = [m, a, r, c, h].iter().combinations(3).map(|x|x[0] * x[1] * x[2]).sum();
    println!("{}", ans);
}



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

typedef long long ll;

int n, k, t, res;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        if (t >= k)
            ++res;
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
int main(){
    int v;
    cin>>v;
    vector<vector<int> > g(v,vector<int>(v,inf) );
    int e;
    cin>>e;
    for(int i=0;i<e;i++){
	int s,t,d;
	cin>>s>>t>>d;
	g[s][t] = d;
    }
    vector<vector<int> > dp( 1<<v , vector<int>(v,inf) );
    dp[ (1<<v) -1 ][0] = 0;
    for( int i = (1<<v) -1 ; i >=  0 ; i-- ){
	for( int j = 0 ; j < v ; j++ ){ // from
	    for( int k = 0 ; k < v ; k++ ){ // to
		if( ( (i>>k) & 1 ) == 0 ){
		    dp[i][j] = min(dp[i][j] , dp[ i | (1<<k) ] [k] + g[k][j] );
		}
	    }
	}
    }
    if( dp[0][0] == inf ){
	cout<<-1<<endl;
    }else{
	cout<<dp[0][0]<<endl;
    }
    return 0;
}



Measured memory_bytes: 6176
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
 ll n,k;
 cin>>n>>k;
 if(n%k==0)cout<<0<<endl;
 else{
     if(n<k){
         if(n<abs(n-k))cout<<n<<endl;
         else cout<<abs(n-k)<<endl;
     }else{
         ll n_k=n%k;
         if(n_k<abs(n_k-k))cout<<n_k<<endl;
         else cout<<abs(n_k-k)<<endl;
     }
 }
 
}
   



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
const ll mod =1000000007;
#define inf 100000
using namespace std;

int main()
{
  ll n; cin>>n;
  vector<pair<ll,ll> >v,w;
  for(ll i=0;i<n;i++)
    {
        ll x; cin>>x;
        w.push_back({x,i});
        v.push_back({x,i});
    }
    sort(v.begin(),v.end());
    ll k=0;
    for(ll i=0;i<n;i++)
    {
        if(v[i].second!=w[i].second)
            k++;
    }
    if(k>2)
        cout<<"NO";
    else
        cout<<"YES";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A);
    vector<ll> q(B);
    vector<ll> r(C);
    for (ll i = 0; i < A; i++) {
        cin >> p[i];
    }
    for (ll i = 0; i < B; i++) {
        cin >> q[i];
    }
    for (ll i = 0; i < C; i++) {
        cin >> r[i];
    }

    vector<ll> aka(X);
    sort(p.begin(), p.end(), [](ll a, ll b) { return a > b; });
    for (ll i = 0; i < X; i++) {
        aka[X - i - 1] = p[i];
    }

    vector<ll> midori(Y);
    sort(q.begin(), q.end(), [](ll a, ll b) { return a > b; });
    for (ll i = 0; i < Y; i++) {
        midori[Y - i - 1] = q[i];
    }

    //sort(r.begin(), r.end());
    sort(r.begin(), r.end(), [](ll a, ll b) { return a > b; });
    ll ai = 0;
    ll mi = 0;
    for (ll ri = 0; ri < r.size(); ri++) {
        ll ax = aka[ai];
        ll mx = midori[mi];
        ll rx = r[ri];
        // if (ax > rx && ai < aka.size() - 1) {
        //     ai++;
        // }
        // if (mx > rx && mi < midori.size() - 1) {
        //     mi++;
        // }
        if (ax < mx && ax < rx) {
            aka[ai] = rx;
            if (ai < aka.size() - 1) {
                ai++;
            }
        } else if (mx < rx) {
            midori[mi] = rx;
            if (mi < midori.size() - 1) {
                mi++;
            }
        }
    }
    ll total = 0;
    for (ll ak : aka) {
        total += ak;
    }
    for (ll md : midori) {
        total += md;
    }
    print(total);
}


Measured memory_bytes: 6900
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		String s = "";
		while (n != 0) {
			if (n % 2 != 0) {
				n--;
				s = "1" + s;
			} else {
				s = "0" + s;
			}
			n /= -2;
		}
		
		if (s.isEmpty()) {
			System.out.println(0);
		} else {
			
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define ii pair <int, int>
#define MAXN 800100
#define ll long long
using namespace std;

ll bit[MAXN];
const ll MOD = 998244353;

ll mult(ll a, ll b) {
	return ((a%MOD) * (b%MOD)) % MOD;
}

ll soma(ll a, ll b) {
	return ((a%MOD) + (b%MOD)) % MOD;
}

ll sub(ll a, ll b) {
	return (((a%MOD) - (b%MOD)) + MOD) % MOD;
}

void update(ll idx) {
	while(idx <= 400000LL) {
		bit[idx]++;
		idx += idx & (-idx);
	}
}

ll get(ll idx) {
	ll res = 0;
	while(idx > 0) {
		res += bit[idx];
		idx -= idx & (-idx);
	}
	return res;
}

ll arr[MAXN], x[MAXN], y[MAXN];

bool compy(int a, int b) {
	return y[a] < y[b];
}

bool compx(int a, int b) {
	return x[a] < x[b];
}

ll pot[MAXN];

int main() {
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int n;
	scanf("%d", &n);

	pot[0] = 1LL;
	for (int i=1; i<=n; i++) pot[i] = mult(2LL, pot[i-1]);
	for (int i=0; i<=n; i++) pot[i] = sub(pot[i], 1LL);

	ll res = 0;

	set <int> nums;
	for (int i=0; i<n; i++) {
		scanf("%lld %lld", &x[i], &y[i]);
		nums.insert(x[i]);
		nums.insert(y[i]);
		arr[i] = i;
		res = soma(res, pot[n]);
	}

	map <ll, ll> conv;
	ll aux = 1;
	for (ll num : nums) {
		conv[num] = aux++;
	}
	
	for (int i=0; i<n; i++) x[i] = conv[x[i]], y[i] = conv[y[i]];
		
	for (int i=0; i<n; i++) {
		res = sub(res, pot[i]);
		res = sub(res, pot[i]);
		res = sub(res, pot[n-i-1]);
		res = sub(res, pot[n-i-1]);
	}

	sort(arr, arr+n, compx);
	for (int i=n-1; i>=0; i--) {
		res = soma(res, pot[get(aux) - get(y[arr[i]] - 1)]);
		res = soma(res, pot[get(y[arr[i]] - 1)]);
		update(y[arr[i]]);
	}

	memset(bit, 0, sizeof bit);
	for (int i=0; i<n; i++) {
		res = soma(res, pot[get(aux) - get(y[arr[i]] - 1)]);
		res = soma(res, pot[get(y[arr[i]] - 1)]);
		update(y[arr[i]]);
	}


	printf("%lld\n", res);
	
	return 0;
}



Measured memory_bytes: 58368
N = int(input())
a = list(map(int, input().split()))
count = 0

while max(a) >= N:
    plus = 0

    for i in range(N):
        plus += a[i] // N
        a[i] = a[i] % N - a[i] // N

    count += plus
    for j in range(N):
        a[j] += plus

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Edge {
  int from, to, friendliness;
};
map<vector<bool>, int> mp;
ll dfs(int now, vector<bool> &sel, const vector<vector<Edge>> &g, const vvll &d, int n) {
  if(mp[sel] != 0) return mp[sel];
  ll res = 0;
  for(int i=0;i<n;++i) {
    if(!sel[i]) continue;
    ll val = LINF;
    for(int j=0;j<n;++j) {
      if(i == j || !sel[j]) continue;
      val = min(val, d[i][j]);
    }
    if(val == LINF) val = 0;
    res += val;
  }
  for(int i=0;i<(int)(g[now].size());++i) {
    int nxt = g[now][i].to;
    if(sel[nxt]) continue;
    bool ok = true;
    for(int j=0;j<n;++j) {
      if(j == nxt) continue;
      if(sel[j] && d[nxt][j] == 0) {
        ok = false;
        break;
      }
    }
    if(ok) {
      sel[nxt] = true;
      res = max(res, dfs(nxt, sel, g, d, n));
      sel[nxt] = false;
    }
  }
  return mp[sel] = res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<Edge>> g(n);
  vvll d(n, vll(n, 0));
  for(int i=0;i<m;++i) {
    int u, v, f; cin >> u >> v >> f;
    u--; v--;
    g[u].push_back({u, v, f});
    g[v].push_back({v, u, f});
    d[u][v] = f;
    d[v][u] = f;
  }
  vector<bool> sel(n, false);
  ll ans = 0;
  for(int i=0;i<n;++i) {
    sel[i] = true;
    ans = max(ans, dfs(i, sel, g, d, n));
    sel[i] = false;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5320