akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

	vector<LL> A(N);
	vector<LL> B(N);
	vector<LL> diff_array(N,0);

	LL diff = 0;

	REP(i, N) {
		cin >> A[i];
		diff -= A[i];
		diff_array[i] -= A[i];
	}
	REP(i, N) {
		cin >> B[i];
		diff += B[i];
		diff_array[i] += B[i];
	}

	if (diff < 0) {
		cout << "No" << endl;
	}
	else {
		LL num = 0;

		REP(i, N) {
			if (diff_array[i] > 0) {
				LL num_diff = (diff_array[i] + 1) / 2;
				diff_array[i] -= num_diff*2;
				num += num_diff;
			}
		}

		if (num <= diff) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
   int N,K;
   cin >> N >> K;
   long long A[N];
   vector<long long> pos;
   vector<long long> neg;
   for (int i = 0; i < N; i++)
   {
      cin >> A[i];
      if(A[i]>=0) pos.emplace_back(A[i]);
      if(A[i]<0) neg.emplace_back(A[i]);

   }
   sort(pos.begin(),pos.end());
   reverse(pos.begin(),pos.end());
   sort(neg.begin(),neg.end());
   int psize=pos.size();
   int nsize=neg.size();

   mint ans = 1;
   if(N==K){
      for(int i=0;i<N;i++) ans *= A[i];
      cout << ans << endl;
   }
   else if(psize==0){
      if(K%2==1){
         reverse(neg.begin(),neg.end());
      }
      for(int i=0;i<K;i++) ans *= neg[i];
      cout << ans << endl;
   }
   else{
      int pind = 0;
      int nind = 0;
      if(K%2==1){
         ans *= pos[0];
         pind++;
         K--;
      }
      while(K>0){
            if(pind+2>psize){
               ans *= neg[nind];
               ans *= neg[nind+1];
               nind+=2;
            }
            else if(nind+2>nsize){
               ans *= pos[pind];
               ans *= pos[pind+1];
               pind+=2;
            }
            else if(neg[nind]*neg[nind+1]<pos[pind]*pos[pind+1]){
               ans *= pos[pind];
               ans *= pos[pind+1];
               pind+=2;
            }else{
               ans *= neg[nind];
               ans *= neg[nind+1];
               nind+=2;
            }
            K-=2;
      }
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s;
  cin >> s;
  if(s.at(2)==s.at(3) && s.at(4)==s.at(5)){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int ret = 0;
    string s; cin >> s;
    for(auto ch : s)
    {
        if(ch == '+') ret += 1;
        else ret -= 1;
    }
    cout << ret;
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  while (n--) {
    string s; cin >> s;
    sort(all(s));
    int mn = 0, mx = 0;
    rep(i, 8) mn += (s[i] - '0') * power(10, 7 - i);
    rep(i, 8) mx += (s[i] - '0') * power(10, i);
    cout << mx - mn << '\n';
  }
}



Measured memory_bytes: 3076
n, k = map(int, input().split())
x = []
for i in range(n):
	a,b = map(int, input().split())
	x.append([a,b])
x.sort()
c = 0
for i,j in x:
	c += j
	if k <= c:
		print (i)
		exit()
print (j)

Measured memory_bytes: 20104
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;

void solve(){
  string s; cin >> s;
  cout << s[0] << s[1] << s[2] << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    string s;
    cin >> s;
    int c = 0;
    rep(i, s.size()) {
        if (s[i] == '1') {
            c ++;
        }
    }
    cout << c << endl;
    return 0;
}

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

int main() {
  string st1, st2, st3;
  int num1, num2;
  cin >> st1 >> st2 >> num1 >> num2 >> st3;

  if(st3 == st1){
      num1--;
  } 
  else num2--;

  cout << num1 << " " << num2 << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List

check :: [Integer] -> Integer
check [a, b, c] 
    | mod b 2 == mod a 2 && mod a 2 == mod c 2 = (div (c - a) 2) + (div (c - b) 2)
    | mod a 2 == mod b 2 = 1 + check [a + 1, b + 1, c]
    | mod a 2 == mod c 2 = 1 + check [a + 1, b, c + 1]
    | otherwise =  1 + check [a, b + 1, c + 1]

main = print =<< check <$> sort . map (\a -> read a :: Integer) <$> words <$> getLine


Measured memory_bytes: 508
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
	int bamboo[10];
int main() {
	
	int N,A,B,C;
	
	cin>>N>>A>>B>>C;
	int ans=INT_MAX;

	fx(N){
		cin>>bamboo[x];
	}
	for(int x=0;x<4<<(N*2);x++){
		int a=0,b=0,c=0,mp=-3;
		fy(N){
		int z=(x>>y*2)%4;
			switch(z){
				case 1:a+=bamboo[y];mp++;break;
				case 2:b+=bamboo[y];mp++;break;
				case 3:c+=bamboo[y];mp++;break;
				default:break;
			}
		}
		if(mp<0){continue;}
      if(a==0||b==0||c==0){continue;}
		ans=min(ans,abs(A-a)+abs(B-b)+abs(C-c)+mp*10);
	}
	ce(ans)

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
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; }

string S;

int main() {
	int op[8][4] = {
		0,1,1,1,
		0,1,-1,1,
		0,1,1,-1,
		0,-1,1,1,
		0,1,-1,-1,
		0,-1,-1,1,
		0,-1,1,-1,
		0,-1,-1,-1
	};

	cin >> S;
	
	for (int j = 0; j < 8; j++)
	{
		int ans = S.at(0) - '0';
		for (int i = 1; i < 4; i++)
		{
			ans += op[j][i] *( S.at(i)-'0');
		}
		if (ans == 7) {
			cout << S.at(0);
			for (int i = 1; i < 4; i++)
			{
				if (op[j][i] == 1) {
					cout << '+';
				}
				else {
					cout << '-';
				}
				 
					cout<<S.at(i);
			}

			cout << "=7"<<endl;
			return 0;
		}
	}
	
}

Measured memory_bytes: 3600
from collections import deque

S = [l for l in input()]
Q = int(input())
d = deque(S)
direction = 'f'

for i in range(Q):
    query = input()
    if query[0] == '1':
        if direction == 'f':
            direction = 'r'
        else :
            direction = 'f'
    else :
        t, f, c = query.split()
        if f == '1':
            if direction == 'f':
                d.appendleft(c)
            else :
                d.append(c)
        else :
            if direction == 'f':
                d.append(c)
            else :
                d.appendleft(c)

if direction == 'r':
    d.reverse()

print(''.join(d))

Measured memory_bytes: 9204
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b, c = sc.nextInt()

    if (a == b) {
      println(c)
    } else if (b == c) {
      println(a)
    } else {
      println(b)
    }
  }
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int x, y; cin >> x >> y;
	--x, --y;
	int ans[n + 1] = {};
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			int len = INF;
			len = min(len, j - i);
			len = min(len, abs(x - i) + abs(y - j) + 1);
			len = min(len, abs(y - i) + abs(x - j) + 1);
			ans[len]++;
		}
	}
	for(int i = 1; i < n; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.read
N, M, *A = map(int, read().split())

A.sort()
A_as = np.array(A, np.int64)
A_rev = np.array(A[::-1], np.int64)
a = A_rev.cumsum()
a_max = a[-1]

left = 0
right = A[-1] * 2 + 1
while right - left > 1:
    mid = (right + left) // 2
    n = N - np.searchsorted(A_as, mid - A_as)
    n[n < 0] = 0
    m = n.sum()
    if m >= M:
        left = mid
    else:
        right = mid

threshold = left

n = N - np.searchsorted(A_as, threshold - A_as, side='right')
n[n < 0] = 0
answer = a[n[n > 0] - 1].sum() + (A_as * n).sum()
if n.sum() != M:
    answer -= threshold * (n.sum() - M)

print(answer)


Measured memory_bytes: 23028
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> Int -> Int -> Int -> Int
solve i j t k s
    | i > s || i > k = t
    | j - i > k || j > s = solve (i + 1) (i + 1) t k s
    | s - j > k = solve i (j + 1) t k s
    | otherwise = solve i (j + 1) (t + 1) k s

main :: IO ()
main = do
    [k, s] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    print $ solve 0 0 0 k s


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

int main(){
  int n, l;
  cin >> n >> l;
  string s[n];

  for(int i=0;i<n;i++)
    cin >> s[i];

  sort(s, s+n);

  for(int i=0;i<n;i++)
    cout << s[i];

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int n = Integer.parseInt(str);
		for (int i = 1; i <= n; i++) {
			String strA = br.readLine();
			String strB = br.readLine();
			int lengthA = strA.length();
			int lengthB = strB.length();
			if (lengthA > 80 || lengthB > 80) {
				System.out.println("overflow");
				continue;
			}
			int length;
			if (lengthA >= lengthB) {
				length = lengthA;
			} else {
				length = lengthB;
			}
			String[] charastrA = strA.split("", 0);
			String[] charastrB = strB.split("", 0);
			Reverse(charastrA);
			Reverse(charastrB);
			int[] charaA = new int[length + 1];
			int[] charaB = new int[length + 1];
			for (int j = 0; j < lengthA; j++) {
				charaA[j] = Integer.parseInt(charastrA[j]);
			}
			for (int j = 0; j < lengthB; j++) {
				charaB[j] = Integer.parseInt(charastrB[j]);
			}
			int[] sum = new int[length + 1];
			for (int k = 0; k <= length; k++) {
				if (charaA[k] + charaB[k] >= 10) {
					sum[k] = charaA[k] + charaB[k] - 10;
					charaA[k + 1]++;
				} else {
					sum[k] = charaA[k] + charaB[k];
				}
			}
			if (sum.length == 81 && sum[length] != 0) {
				System.out.println("overflow");
				continue;
			}
			Boolean isHeadZero = true;
			for (int l = 0; l <= length; l++) {
				if (isHeadZero) {
					if (sum[length - l] == 0) {
						continue;
					} else {
						isHeadZero = false;
					}
				}
				System.out.print(sum[length - l]);
			}
			if (isHeadZero){
				System.out.print("0");
			}
			System.out.println();
		}
	}

	public static void Reverse(String[] num) {
		int length = num.length;
		for (int i = 0; i <= length / 2; i++) {
			int j = length - i - 1;
			if (i >= j) {
				break;
			}
			String temporary = num[i];
			num[i] = num[j];
			num[j] = temporary;

		}
	}
}

Measured memory_bytes: 24264
import java.util.*;

public class Main {
    public static void main(String[] args) {
        solve(new Scanner(System.in));
//        solve(new Scanner(ex));
    }

//    private static final String ex = "3 2\n" +
//            "100 50 200";
//    private static final String ex = "5 8\n" +
//            "50 30 40 10 20\n";
    private static final String ex = "10 100\n" +
        "7 10 4 5 9 3 6 8 2 1";

    private static void solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");
        int N = Integer.parseInt(split[0]);
        int T = Integer.parseInt(split[1]);

        split = scanner.nextLine().split(" ");
        long nums[] = new long[N];
        for (int i = 0; i < N; i ++) nums[i] = Long.parseLong(split[i]);

        long min = nums[0];
        long maxGap = 0;
        for (int i = 1; i < N; i ++) {
            maxGap = Math.max(maxGap, nums[i] - min);
            min = Math.min(min, nums[i]);
        }

        int result = 0;
        Set<Long> set = new TreeSet<>();
        for (int i = 0; i < N; i ++) {
            if (set.contains(nums[i] - maxGap)) result ++;
            set.add(nums[i]);
        }

        System.out.println(result);
    }
}


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

int main()
{
	int N;
	vector<int> a;
	cin >> N;
	a.reserve(N);
	for (int i = 0, ai; i < N; i++) {
		cin >> ai;
		a.push_back(ai);
	}
	int res = 100000000;
	for (int i = -100; i <= 100; i++) {
		int sum = 0;
		for (int j = 0; j < N; j++) {
			sum += (a[j] - i) * (a[j] - i);
		}
		if (sum < res) {
			res = sum;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[233],b[233];
int main (){
	int n;scanf ("%d",&n);
	scanf ("%s",a+1);
	scanf ("%s",b+1);
	for (int i=1;i<=n;i++) printf ("%c%c",a[i],b[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin>>s;
if(s=="RRS"||s=="SRR")
	cout<<"2";
else if(s=="SSS")
	cout<<"0";
else if(s=="RSR"||s=="RSS"||s=="SSR"||s=="SRS")
	cout<<"1";
else
	cout<<"3";






}


Measured memory_bytes: 3600
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var ans = 0

    for (a in 0..9) {
        val d1 = a.toString()
        for (b in 0..9) {
            val d2 = b.toString()
            for (c in 0..9) {
                val d3 = c.toString()

                for (i in 0 until n-2) {
                    if (d1 == s[i].toString()) {
                        for (j in i + 1 until n - 1) {
                            if (d2 == s[j].toString()) {
                                for (k in j + 1 until n) {
                                    if (d3 ==  s[k].toString()) {
                                        ans++
                                        break
                                    }
                                }
                                break
                            }
                        }
                        break
                    }
                }
            }
        }
    }
    println(ans)
}


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

int main()
{
	long long n, money = 1000;
	std::cin >> n;

	std::vector<long long> day(n);
	for (int i = 0; i < n; i++)
		std::cin >> day[i];

	day.resize(std::unique(day.begin(), day.end()) - day.begin());
	day.push_back(day.back());

	for (int i = 0; i < (int)day.size() - 1; i++)
		if (day[i] < day[i + 1])
			money += money / day[i] * (day[i + 1] - day[i]);

	std::cout << money;
}

Measured memory_bytes: 3620
// abc058_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string o,e;
  cin>>o>>e;
  int i=0,cnt = o.size() + e.size();
  while(i!=cnt){
    if (i%2==0) {
      cout << o[i/2];
    } else {
      cout << e[i/2];
    }
    i++;
  }
  cout << endl;
  return 0;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];
    rep(i, n) numbers[i]--;

    vector<int> indexes(n);
    rep(i, n) indexes[numbers[i]] = i;

    vector<int> dp(n, 0);

    rep(i, n) {
        if (i == 0) continue;
        int ii = indexes[i];
        int bi = indexes[i - 1];
        if (bi < ii) {
            dp[i] = 1;
        }
    }
    rep(i, n) {
        if (i == 0) continue;
        else if (dp[i] == 0) continue;
        else dp[i] += dp[i - 1];
    }


    int ma = *max_element(dp.begin(), dp.end());
    cout << n - ma - 1 << endl;

    cout << endl;

}





Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, M;

int main()
{
	in >> N >> M;

	if (abs(N - M) > 1)
	{
		out << 0 << std::endl;
	}
	else
	{
		LL ans = 1;
		for (int i = N; i >= 1; --i)
		{
			ans *= i;
			ans %= MOD;
		}
		for (int j = M; j >= 1; --j)
		{
			ans *= j;
			ans %= MOD;
		}
		if (N == M) { out << ((ans%MOD) * 2) % MOD << std::endl; }
		else out << ans%MOD << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = tuple([int(x) for x in input().split()])
Q = tuple([int(x) for x in input().split()])

for i,t in enumerate(itertools.permutations(tuple(list(range(1,N+1))), N)):
    if t == P:
        i_p = i
    if t == Q:
        i_q = i

print(abs(i_p-i_q))



Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>

const int MAXN = 105;

int main() {
    char s_list[MAXN], t_list[MAXN];
    scanf("%s%s", s_list, t_list);
    printf("%s%s", t_list, s_list);
    return EXIT_SUCCESS;
}

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

int main()
{
    vector<vector<int>> v(3, vector<int>(3));
    rep(i, 3)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> v.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n)
    {
        cin >> b.at(i);
    }
    vector<vector<int>> bingo(3, vector<int>(3));
    rep(i, 3)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int l = 0; l < n; l++)
            {
                if (v.at(i).at(j) == b.at(l))
                {
                    bingo.at(i).at(j) = 1;
                }
            }
        }
    }
    if (bingo.at(0).at(0) == 1 && bingo.at(0).at(1) == 1 && bingo.at(0).at(2) == 1 ||
        bingo.at(1).at(0) == 1 && bingo.at(1).at(1) == 1 && bingo.at(1).at(2) == 1 ||
        bingo.at(2).at(0) == 1 && bingo.at(2).at(1) == 1 && bingo.at(2).at(2) == 1 ||
        bingo.at(0).at(0) == 1 && bingo.at(1).at(0) == 1 && bingo.at(2).at(0) == 1 ||
        bingo.at(0).at(1) == 1 && bingo.at(1).at(1) == 1 && bingo.at(2).at(1) == 1 ||
        bingo.at(0).at(2) == 1 && bingo.at(1).at(2) == 1 && bingo.at(2).at(2) == 1 ||
        bingo.at(0).at(0) == 1 && bingo.at(1).at(1) == 1 && bingo.at(2).at(2) == 1 ||
        bingo.at(0).at(2) == 1 && bingo.at(1).at(1) == 1 && bingo.at(2).at(0) == 1 )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
	int h, w; cin >> h >> w;
	char a[100][101], b[102][102];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			b[i][j] = '#';
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			b[i + 1][j + 1] = a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			cout << b[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



void chmax(int &a, int b) {
	if (a == -1)a = b;
	else if (a < b)a = b;
}

ll match[9] = { 2,5,5,4,5,6,3,7,6 };
//i本のマッチで作れる最大桁数
int dp[10101];




int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	rep(i, 0, M)cin >> A[i];

	dp[0] = 0;
	rep(i, 1, 10101) {
		dp[i] = -1;
	}


	rep(i, 0, N + 1) {
		if (dp[i] == -1)continue;
		for (auto a : A)chmax(dp[i+match[a-1]],dp[i]+1);
	}

	sort(A.begin(), A.end());
	
	int rem = dp[N];
	int remmatch = N;
	string ans = "";



	while (remmatch > 0) {

		for (int i = M - 1; i >= 0; i--) {
			if ((remmatch - match[A[i]-1] >= 0) && (rem - 1 == dp[remmatch - match[A[i]-1]])) {
				rem--;
				remmatch -= match[A[i]-1];
				ans += to_string(A[i]);
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];

    string ans = "APPROVED";
    rep(i,N) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                ans = "DENIED";
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S.length() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, S.length()) {
        if (i % 2 == 0) {
            if (S[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if (S[i] != 'i') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100001;
typedef pair<int, int> pii;

namespace matching {

vector<int> g[N];   //  g[u]:X中顶点$u$的邻接表
bool vis[N];        //  vis[u]:当前dfs中Y中顶点u是否已被访问过
int lnk[N];         //  lnk[u]:Y中顶点u对应的匹配点。若u未被匹配则lnk[u]=0

//  从X顶点u出发寻找增广路
bool dfs(int u) {
    for (int v : g[u]) {
        //  v已被访问过，且无法从v出发找到增广路或增广路的上一个节点是v则跳过
        if (vis[v] || lnk[v] == u) continue;
        //  v未被访问过，标记v
        vis[v] = 1;
        //  v已有匹配点，且无法从v出发找到增广路则跳过
        if (lnk[v] && !dfs(lnk[v])) continue;
        //  v没有匹配点或找到从lnk[v]出发的增广路，则设v的匹配点为u
        lnk[v] = u; return true;
    }
    //  找不到增广路
    return false;
}

//  接口:
//  int nl: X节点数; X中节点编号为[1...nl]
//  int nr: Y节点数; Y中节点编号为[1...nr]
//  const vector<pii>& es: 二分图中的边集。pii的first为X中节点编号，second为Y中节点编号
//  返回值vector<pii> res: 得到的最大匹配。
int match(int nl, int nr, const vector<pii>& es) {
    //  初始化，建图
    for (int i = 1; i <= nl; ++i)
        g[i].clear();
    fill_n(lnk + 1, nr, 0);
    for (pii e : es)
        g[e.first].push_back(e.second);
    //  依次从每个点出发寻找增广路
    for (int i = 1; i <= nl; ++i) {
        fill_n(vis + 1, nr, false);
        dfs(i);
    }
    //  按Y中每个点i的匹配点lnk[i]得到结果
    int res = 0, lx = nl, ly = nr;
    for (int i = 1; i <= nr; ++i)
        if (lnk[i]) res++, lx--, ly--;
    res += lx / 2 * 2; lx -= lx / 2 * 2;
    res += ly / 2 * 2; ly -= ly / 2 * 2;
    assert((lx ^ ly) == 0);
    if (lx && ly) res += 3;
    return res;
}

}

namespace prime
{

const int maxn = 1e7 + 7;
int vis[maxn];
int prime[maxn], mu[maxn], minprim[maxn], tot = 0; //1 ~ tot
void get_prime(int maxl) // get prime <= maxl
{
    minprim[1] = 1;
    for (int i = 2; i <= maxl; i++)
    {
        if (!vis[i])
        {
            prime[++tot] = i; minprim[i] = i;
        }
        for (int j = 1; j <= tot; j++)
        {
            if (i * prime[j] > maxl) break;
            vis[i * prime[j]] = 1;
            minprim[i * prime[j]] = prime[j];
            if (i % prime[j] == 0) 
            {
            	break;
            }
        }
    }
    vis[1] = vis[2] = 1;
    //vis[i] == 0 -> i is a prime
}

}
vector<int>pt;
vector<pii>es;
int x[301], lp[301], rp[301];
int main()
{
    prime::get_prime(1e7 + 5);
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
    x[0] = -1;
    for (int i = 1; i <= n; i++)
    {
        if (x[i] - 1 != x[i - 1]) pt.push_back(x[i]);
        if (x[i] + 1 != x[i + 1]) pt.push_back(x[i] + 1);
    }
    sort(pt.begin(), pt.end());
    pt.erase(unique(pt.begin(), pt.end()), pt.end());
    int nl = 0, nr = 0;
    for (int x : pt) if (x % 2) lp[++nl] = x;
    else rp[++nr] = x;
    for (int i = 1; i <= nl; i++)
        for (int j = 1; j <= nr; j++)
        {
            if (!prime::vis[abs(lp[i] - rp[j])]) es.emplace_back(i, j); 
        }
    // for (int x : pt) printf(" %d\n", x);
    printf("%d\n", matching::match(nl, nr, es));
    return 0;   
}

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

using namespace std;

using ll = long long;

int main() {
   ll L, R;
   cin >> L >> R;
   function<ll(ll, ll)> solve = [&](ll L, ll R) {
      if (L == R) return 1ll;
      ll M = 1ll << __lg(R);
      if (L >= M) return solve(L - M, R - M);
      ll ans = M - L;
      ll limit;
      if (R == M) limit = 1;
      else limit = (2ll << __lg(R - M));
      ans += limit;
      limit = max(limit, L);
      ans += M - limit;
      return ans;
   };
   cout << solve(L, R) << "\n";
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    String s = scanner.next();
    switch (s) {
      case "Sunny":
        System.out.println("Cloudy");
        return;
      case "Cloudy":
        System.out.println("Rainy");
        return;
      case "Rainy":
        System.out.println("Sunny");
    }
  }
}


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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  if(a <= b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
    cout << endl;
  }else{
    for(int i = 0; i < a; i++){
      cout << b;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, tmp, ans = 0;
	cin >> nn;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> tmp;
		if((ii + 1) % 2 && tmp % 2)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  X -= A;
  for (int i = 0;i < X;i++){
    X -= B;
    if (X - B < 0) break;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
from collections import deque
s=deque(input())
ans=""
while s:
    t=s.popleft()
    if t=="0":
        ans=ans+"0"
    elif t=="1":
        ans=ans+"1"
    elif t=="B":
        if len(ans)>0:
            ans=ans[:-1]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vi;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<ll> A;

void solve() {
	cin >> N;
	A = vi(N);
	ll sum = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum += A[i];
	}
	ll ans = linf, res = 0;
	rep(i, 0, N) {
		if(i != 0) {
			MIN(ans, abs(sum - 2 * res));
		}
		res += A[i];
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(5);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}






Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
const int MAX = 9;
typedef pair<int,char> P;
P data[MAX];
vector<int> R,G,B;

bool isOK(int a, int b, int c){

  int in[3] = {a,b,c};
  sort(in,in+3);

  if(a == b && b == c) return true;
  if(in[0]+1 == in[1] && in[1]+1 == in[2]) return true;
  return false;
}

bool isPair(vector<int> V){

  bool out = false;

  if(V.size()%3) return false;
  sort(V.begin(),V.end());
  
  do{
    bool check = true;

    for(int i = 0; i < V.size()/3; i++)
      if(!isOK(V[i*3],V[i*3+1],V[i*3+2])) check = false;
    
    out = (out||check);
    if(out) break;

  }while(next_permutation(V.begin(),V.end()));

  return out;
}
void solve(){
  if(isPair(R)&&isPair(G)&&isPair(B)) cout << "1" << endl;
  else cout << "0" << endl;
}

void make(){
  for(int i = 0; i < MAX; i++)
    if(data[i].second == 'R') R.push_back(data[i].first);
    else if(data[i].second == 'G') G.push_back(data[i].first);
    else if(data[i].second == 'B') B.push_back(data[i].first);
}

void init(){
  R.clear();
  G.clear();
  B.clear();
}


void input(){
  for(int i = 0; i < MAX; i++)
    cin >> data[i].first;
  
  for(int i = 0; i < MAX; i++)
    cin >> data[i].second;

}


int main(){
  int N;
  cin >> N;
  while(N--){
    init();
    input();
    make();
    solve();
  }
  return 0;
}

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

#define ll    long long
#define endl  "\n"
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){

    fast;
    string num;
    cin>>num;

    ll sum = 0;
    for(int i=0;i<num.size();i++){
        sum = sum + (num[i]-48);
    }
    if(sum%9==0){
        cout<<"Yes\n";
    } else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3760
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  
  switch(N%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
      
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
		break;
    case 3:
        printf("bon\n");
		break;
  }
  return 0;
}


Measured memory_bytes: 1620
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

struct Edge
{
    int to;
    int cap;
    int rev;
};

void add_edge(map<int, vector<Edge>> &g, int from, int to, int cap)
{
    g[from].push_back((Edge){to, cap, (int)g[to].size()});
    g[to].push_back((Edge){from, 0, (int)g[from].size() - 1});
}

int dfs(map<int, vector<Edge>> &g, map<int, bool> &visited, int cur, int dst, int f)
{
    if (cur == dst)
        return f;
    visited[cur] = true;
    for (auto &e : g[cur])
    {
        if (!visited[e.to] && e.cap > 0)
        {
            int tmp = dfs(g, visited, e.to, dst, min(f, e.cap));
            if (tmp > 0)
            {
                e.cap -= tmp;
                g[e.to][e.rev].cap += tmp;
                return tmp;
            }
        }
    }
    return 0;
}
int maxFlow(map<int, vector<Edge>> &g, int s, int t)
{
    map<int, bool> visited;
    int ret = 0, tmp = 0;
    do
    {
        visited.clear();
        tmp = dfs(g, visited, s, t, IINF);
        ret += tmp;
    } while (tmp != 0);
    return ret;
}

int main(int argc, char const *argv[])
{
    map<int, vector<Edge>> g;
    int v, e;
    cin >> v >> e;
    rep(i, e)
    {
        int s, t, c;
        cin >> s >> t >> c;
        add_edge(g, s, t, c);
    }
    cout << maxFlow(g, 0, v - 1) << endl;
    return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define FL "a"
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+10;
const ll INF=1ll<<60;
inline ll read(){
  ll d=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')d=d*10+ch-48,ch=getchar();
  return d*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int n,q,x[N];
ll mnv[2][N<<2],lz[N<<2],ans=INF;//0:+ 1:-
#define ls (i<<1)
#define rs (i<<1|1)
#define mid ((l+r)>>1)
inline void update(int i){
  mnv[0][i]=min(mnv[0][ls],mnv[0][rs]);mnv[1][i]=min(mnv[1][ls],mnv[1][rs]);
}
inline void cover(int i,ll v){lz[i]+=v;mnv[0][i]+=v;mnv[1][i]+=v;}
inline void pushdown(int i){
  if(lz[i])cover(ls,lz[i]),cover(rs,lz[i]),lz[i]=0;
}
void build(int i,int l,int r){
  mnv[0][i]=mnv[1][i]=INF;if(l==r)return;build(ls,l,mid);build(rs,mid+1,r);
}
inline void insert(int i,int l,int r,int p,ll v){
  if(l==r){mnv[0][i]=min(mnv[0][i],v+p);mnv[1][i]=min(mnv[1][i],v-p);return;}
  pushdown(i);p<=mid?insert(ls,l,mid,p,v):insert(rs,mid+1,r,p,v);update(i);
}
inline ll query(int i,int l,int r,int x,int y,int p){
  if(x<=l&&r<=y)return mnv[p][i];pushdown(i);ll s=INF;
  if(x<=mid)s=query(ls,l,mid,x,y,p);
  if(mid<y)s=min(s,query(rs,mid+1,r,x,y,p));return s;
}

int main()
{
  n=read();q=read();x[0]=read();
  build(1,1,n);insert(1,1,n,read(),0);
  for(int i=1;i<=q;i++)x[i]=read();
  for(int i=1;i<=q;i++){
    ll ql=query(1,1,n,1,x[i],1)+x[i],qr=query(1,1,n,x[i],n,0)-x[i];
    cover(1,abs(x[i]-x[i-1]));insert(1,1,n,x[i-1],min(ql,qr));
  }
  for(int i=1;i<=n;i++)ans=min(ans,query(1,1,n,i,i,0)-i);
  printf("%lld\n",ans);return 0;
}


Measured memory_bytes: 19456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        long sum = a+b;
        if(sum%2!=0) {
            System.out.println("IMPOSSIBLE");
        }
        else {
            System.out.println(sum/2);
        }
    }
}


Measured memory_bytes: 21712
import scala.util.Sorting

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    import scala.io.StdIn._
    val s = readLine().split(" ")
    val n = s(0).toInt
    val m = s(1).toInt
    val items = new Array[(Int, Int, Int)](m)
    for (i <- 0 until m) {
      val line = readLine().split(" ")
      items(i) = (i, line(0).toInt, line(1).toInt)
    }

    Sorting.quickSort(items)(Ordering.by(_._3))
    val cityCount = new Array[Int](n)
    val cityNumbers = new Array[String](m)
    for (item <- items) {
      val i = item._1
      val p = item._2 - 1
      val num = cityCount(p) + 1
      cityNumbers(i) = "%06d%06d".format(p + 1, num)

      cityCount(p) += 1
    }

    val out = new java.io.PrintWriter(System.out)

    cityNumbers.foreach(out.println)
    out.flush()
  }

}


Measured memory_bytes: 136356
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
        --c;
        int i;
        for(i=a; i<=a+c&&i<=b; i++)
        {
            printf("%d\n",i);
        }
        if(b-c>i) i=b-c;
        for( ;i<=b; i++)
        {
                printf("%d\n",i);
        }
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var a, b, c, k int
	fmt.Scanf("%d %d %d", &a, &b, &k)

	if a < b {
		c = b
	} else {
		c = a
	}

	for k > 0 {
		if a%c == 0 && b%c == 0 {
			k--
		}
		c--
	}
	c++
	fmt.Println(c)
}


Measured memory_bytes: 512
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))

B = []
for j in range(n):
    B.append(j - A[j])

C = []
for i in range(n):
    C.append(i + A[i])

d = defaultdict(int)

for j in C:
    d[j] += 1

count = 0
for k in B:
    count += d[k]

print(count)

# 時間超過
# count = 0
# for i in range(n):
#     b = i + A[i]
#     count += B[(i+1):].count(b)
# print(count)

Measured memory_bytes: 66312