akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

res = 0
for i in range(2**N):
    s = bin(i)[2:].zfill(N)
    l_count = 0
    for p,x in zip(P,X):
        s_count = 0
        for si in x[1:]:
            if s[si-1]=='1':
                s_count += 1
        if s_count%2 == p:
            l_count += 1
    if l_count == M:
        res += 1
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{

double a,b,c,d,yo=0.0,sum=0.0;
vector<double>vc;

cin>>a>>b;
for(long long i=0;i<a;i++)
{
    cin>>c;
    sum=sum+c;
    vc.push_back(c);
}
double xd=0.25*sum/b;

for(long long i=0;i<a;i++)
{
 if(vc[i]>=xd)
   yo++;

}
if(yo>=b)
    cout<<"Yes";
else cout<<"No";



}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int tmp,num,rmd,count,t,n;
    char a,b ,c,d,e,f;
    cin >> a>>b>>c ;
    cin >> d >>e >> f;
    if (a==f && b ==e && c==d)
        cout << "YES\n";
    else
        cout <<"NO\n";
return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int A, B;
	cin >> A >> B;

	cout << max(0, A - 2 * B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
 
{
 
int a,b,d,r;
 
double f;
 
scanf("%d %d",&a,&b);
 
d=a/b;
 
r=a%b;
 
f=(double)a/b;
 
printf("%d %d %.5lf",d,r,f);
 
return 0;
 
}

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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

const int MOD = 1000000007;
const int N = 2005;


int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % MOD;
        x = 1LL * x * x % MOD;
        y >>= 1;
    }
    return res;
}

int inv(int x) {
    return power(x, MOD - 2);
}

int fac[N], ifac[N];

void init_combi() {
    fac[0] = 1;
    ifac[0] = 1;
    for (int i = 1; i < N; i++) {
        fac[i] = 1LL * fac[i - 1] * i % MOD;
        ifac[i] = inv(fac[i]); 
    }
}

int C(int n, int k) {
    if (k > n) return 0;
    return 1LL * ifac[k] * ifac[n - k] % MOD * fac[n] % MOD;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    init_combi();
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int t = n - 2 * i;
        ans = (ans + C(t - 1, i - 1)) % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3664
#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 <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


map<string, set<string> > graph;
set<string> answ;
map<string,bool> used;
void dfs(string name){
	if(used[name]) return;
	used[name] = true;
	
	if(!graph.count(name) ){ answ.insert(name); return; }
	
	EACH(it,graph[name]){
		dfs(*it);
	}
}
int main(){
	int n;
	while(cin >> n && n){
		graph.clear();
		answ.clear();
		used.clear();
		
		string www = "";
		for(int i = 0 ; i < n ; i++){
			string s;
			cin >> s;
			for(int j = 0 ; j < s.size() ; j++)
				if(s[j] == ',' || s[j] == '.' || s[j] == ':' ) s[j] = ' ';
			stringstream ss(s);
			string w,t;
			ss >> w;
			if(www=="") www = w;
			while(ss >> t){
				graph[w].insert(t);
			}
		}
		 dfs(www) ;
		cout << answ.size() << endl;
	}
}

Measured memory_bytes: 1096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll p = 1000000007;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    bool dp[k+1];
    dp[0] = false;
    for(ll i = 1;i <= k;i++){
        bool x = true;
        for(ll j = 0;j < n;j++){
            if(i >= a[j]){
                x = x && dp[i-a[j]];
            }
        }
        dp[i] = !x;
    }
    if(dp[k]){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A < B)
    {
        if (C < B and A < C)
        {
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }
    else if (A > B)
    {
        if (B < C and C < A)
        {
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s,t; cin>>s>>t;
	int cnt = 0;
	rep(i,3){
		if(s[i]==t[i]) cnt++;
	}
	cout << cnt;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, ans = -1;
  string s;
  cin >> n >> s;
  for (ll i = 1; i < n; i++) {
    string x = s.substr(0, i);
    string y = s.substr(i, n - i);
    set<char> st1,st2;
    ll t=0;
    REP(i, x.size()) { st1.insert(x[i]); }
    REP(i, y.size()) {
      if (st1.count(y[i])&&!st2.count(y[i])) t++;
      st2.insert(y[i]);
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3624
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pair = Tuple!(long, "one", long, "two", long, "three");
alias Cake = Tuple!(long, "sum", Pair, "p");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long x, y, z, k, cnt;
    scan(x, y, z, k);
    auto a = aryread();
    auto b = aryread();
    auto c = aryread();
    a.sort!"a>b"(), b.sort!"a>b"(), c.sort!"a>b"();
    PQueue!(Cake, "a.sum < b.sum") pq;
    bool[Pair] pairs;
    auto ans = new long[](k);

    pq.insert(Cake(a[0] + b[0] + c[0], Pair(0, 0, 0)));
    while (cnt < k)
    {
        long s = pq.front.p.one, t = pq.front.p.two, u = pq.front.p.three;
        ans[cnt] = pq.front.sum;
        pq.removeFront();
        if (s + 1 < x && !(Pair(s + 1, t, u) in pairs))
        {
            pq.insert(Cake(a[s + 1] + b[t] + c[u], Pair(s + 1, t, u)));
            pairs[Pair(s + 1, t, u)] = true;
        }
        if (t + 1 < y && !(Pair(s, t + 1, u) in pairs))
        {
            pq.insert(Cake(a[s] + b[t + 1] + c[u], Pair(s, t + 1, u)));
            pairs[Pair(s, t + 1, u)] = true;
        }
        if (u + 1 < z && !(Pair(s, t, u + 1) in pairs))
        {
            pq.insert(Cake(a[s] + b[t] + c[u + 1], Pair(s, t, u + 1)));
            pairs[Pair(s, t, u + 1)] = true;
        }
        cnt++;
    }
    foreach (e; ans)
        e.writeln();
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3324
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int n = sc.nextInt();
		double x = Math.pow(n, 2);
		System.out.println((int)x);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<random> // random_device mt19937
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  random_device rnd;
  int n; cin >>n;
  cout << (n+1)/2;
}


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

int main(){
  string s,ans = "Yes";
  cin >> s;
  rep(i,s.size()){
  if((i%2 == 0)&&(s.at(i) == 'L')) ans ="No";
  if((i%2 == 1)&&(s.at(i) == 'R')) ans ="No";
  }
  cout << ans;
}

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

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

    int room[4][3][10];
    for(int i=0; i<4; i++)
    {
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<10; k++)
            {
                    room[i][j][k] = 0;
            }
        }
    }
    
    int b,f,r,v;

    for(int i=0; i<n; i++)
    {
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1] += v;
    }

    int x = 1;
    int i = 0;
    do
    {
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<10; k++)
            {
                cout << ' ' << room[i][j][k];
            }
            cout << endl;
        }

        i++;
        if(i>3) break;

        for(int i=0; i<20; i++) cout << '#';
        cout << endl;

    }while(x);

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc,char** argv){
  int a,b,k,i,n;
  cin >> a >> b >> k;
  i = min(a,b);
  n = 0;
  while(i > 0){
    if(a % i == 0 && b % i == 0){n++;}
    if(n == k){break;}
    i--;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n, d;in(n), in(d);
  vector<ll> X(n), Y(n);
  loop(i,0,n) in(X[i]),in(Y[i]);
  d*=d;
  int ans = 0;
  loop(i,0,n) {
    ans += X[i]*X[i]+Y[i]*Y[i] <= d;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 6332
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, K, ans = 0;
    bool flag = true;
    cin >> N >> K;

    while(flag){
        if(N >= K) ans++;
        else {
            ans++;
            flag = false;
            break;
        }
        N = N/K;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3472
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    string s;
    cin >> s;

    ll ans = MAX_OF(ll);
    for (int b = 0; b <= 1; b++) {
        ll flips = 0;
        for (size_t i = 0; i < s.length(); i++) {
            if (i % 2 == 0 && s[i] != '0' + b) {
                flips++;
            } else if (i % 2 != 0 && s[i] != '0' + (1-b)) {
                flips++;
            }
        }

        ans = min(ans, flips);
    }

    ECHO(ans)
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

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

#define ll unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;t=1;
    while(t--){
        char c;cin>>c;
        if(c<='Z')
        cout<<"A";
        else
        cout<<"a";
    }
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	ll dp[2][3];
	dp[0][0] = 0;
	dp[0][1] = -1e18;
	dp[0][2] = -1e18;
	dp[1][0] = -1e18;
	dp[1][1] = -1e18;
	dp[1][2] = -1e18;

	int n = N / 2;
	if (N % 2) {
		rep(i, n) {
			int a, b;
			cin >> a >> b;
			chmax(dp[1][1], dp[0][0]);
			dp[0][0] += a;
			dp[0][2] += a;
			chmax(dp[0][2], dp[1][1]);
			dp[1][1] += b;
		}
		int a;
		cin >> a;
		chmax(dp[1][1], dp[0][0]);
		dp[0][2] += a;
		printf("%lld\n", max(dp[0][2], dp[1][1]));
	}
	else {
		rep(i, n) {
			int a, b;
			cin >> a >> b;
			chmax(dp[1][1], dp[0][0]);
			dp[0][0] += a;
			dp[1][1] += b;
		}
		printf("%lld\n", max(dp[1][1], dp[0][0]));
	}


	Would you please return 0;
}

Measured memory_bytes: 3744
_N, _K = [int(i) for i in input().split()]
_H = [int(i) for i in input().split()]

def solve(N, K, H):
  dp = [float('inf')] * N
  dp[0] = 0

  for i in range(1, N):
    dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(i - K, 0), i))

  return dp[N - 1]

print(solve(_N, _K, _H))


Measured memory_bytes: 13928
INF = 10 ** 10
MOD = 10 ** 9 + 7

def solve(A,B,C):
    A = A[::-1]
    B = B[::-1]
    C = C[::-1]
    before =[1,0,0]
    N = len(A)
    for i in range(N):
        dp = [0]*3
        s = 0
        if i == N - 1:
            s += 1
        for j in range(3):
            for a in range(s,10):
                if A[i] != '?' and int(A[i]) != a:
                    continue
                for b in range(s,10):
                    if B[i] != '?' and int(B[i]) != b:
                        continue
                    for c in range(s,10):
                        if C[i] != '?' and int(C[i]) != c:
                            continue
                        if (j + a + b)%10 != c:
                            continue
                        dp[(j + a + b)//10] += before[j]
                        dp[(j + a + b)//10] %= MOD
        before = dp
    ans = before[0]
    print(ans)

def main():
    while True:
        A = input()
        if A == '0':
            return
        B = input()
        C = input()
        solve(A,B,C)
if __name__ == '__main__':
    main()



Measured memory_bytes: 5616
import sys

readline = sys.stdin.readline
h, w = map(int, readline().split())
grid = [readline() for _ in range(h)]
light = [[0] * w for _ in range(h)]

# row
for i in range(h):
    start = -1
    for j in range(w):
        if grid[i][j] == '.' and start == -1:
            start = j
        elif grid[i][j] == '#' and start != -1:
            length = j - start
            light[i][start:j] = [length] * length
            start = -1
    if start != -1:
        length = w - start
        light[i][start:w] = [length] * length
# column
for i in range(w):
    start = -1
    for j in range(h):
        if grid[j][i] == '.' and start == -1:
            start = j
        elif grid[j][i] == '#' and start != -1:
            length = j - start
            for k in range(start, j):
                light[k][i] += length
            start = -1
    if start != -1:
        length = h - start
        for k in range(start, h):
            light[k][i] += length
ans = max(max(row) for row in light)
print(ans-1)


Measured memory_bytes: 93148
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
  
  
  
int n,cost;
int A[1001],B[1001];
int L[501],R[502];
  
  
void merge(int left,int mid,int right){
  int i,j,n1=mid-left,n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  L[n1]=INT_MAX;
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  R[n2]=INT_MAX;
  int l=0,r=0;
  for(i=left;i<right;i++){
    if(L[l]<=R[r]){
      A[i]=L[l];
      l++;
    }
    else{
      A[i]=R[r];
      r++;
    }
  }
}
  
  
void m_sort(int left,int right){
  int mid;
  if( left+1 >= right) return;
  mid=(left+right)/2;
  m_sort(left,mid);
  m_sort(mid,right);
  merge(left,mid,right);
}
  
  
void swap(int a,int b,int *C){
  int swap;
  swap=C[a];
  C[a]=C[b];
  C[b]=swap;
}
  
  
  
  
  
  
    
   
    
  
int main(){
  scanf("%d",&n);
  int i,j;
  int cnt,sum,min,start,x;
  int C[1001]={};
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }
  m_sort(0,n);
  for(i=0;i<n;i++){
    if(A[i]==B[i]) C[i]=1;
  }
  cost=0;
  for(i=0;i<n;i++){
    if(C[i]!=1){
      C[i]=1;
      cnt=0;
      sum=0;
      min=B[i];
      x=i;
      while(1){
        for(j=0;j<n;j++){
          if(B[x]==A[j]){
            C[j]=1;
            cnt++;
            sum+=B[j];
            if(min > B[j]) min=B[j];
            x=j;
            break;
          }
        }
        if(x==i) break;
      }
      sum-=min;
      if( (cnt -1)*min > (cnt -1)*A[0]+2*(min +A[0])) cost+=sum+(cnt-1)*A[0]+2*(min +A[0]);
      else cost+=sum+(cnt-1)*min;
    }
  }
  printf("%d\n",cost);
  return 0;
}

Measured memory_bytes: 1840
class UnionFind
    def initialize(n) # 必要な配列を設定、nはノード(頂点)の数
        @rank = Array.new(n,0) # 端っこからたどって何番目の階層かを記録、大きいほうが親となる
        @parent = Array.new(n,&:itself) #初期設定では自分の親は自分の番号と同じ
    end
    def get_parent(id_x) # 根(親)を表示する関数
        @parent[id_x] = get_parent(@parent[id_x]) if id_x != @parent[id_x]
        return @parent[id_x]
    end
    def same_parent?(id_x, id_y) # ２つのノードid_x、id_yが連結しているかどうかを調べる
        get_parent(id_x) == get_parent(id_y)
        # if same_parent?(x,y)のように使う、同じ親ならtrue、別であればfalse
    end
    def unite(id_x, id_y) # ２つのノードid_x、id_yをつなげる
        x_parent = get_parent(id_x) # id_xの親
        y_parent = get_parent(id_y) # id_yの親
        return if x_parent == y_parent # この場合はすでにつながっているので何もしない,この操作をを終える
        if @rank[x_parent] > @rank[y_parent] # それぞれの親のうちより頂点に近い方にもう一方を付け加える
          @parent[y_parent] = x_parent
        else
          @parent[x_parent] = y_parent # rankが同じ場合も含めてyが大親になっている
          @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
          # rankが同じ場合は仕方なく後者を親にしてrankを一つ増やす、これで一行上の操作は正当化される
        end
    end
    def tree_size(id_x) # id_xが存在するツリーに存在するノードの数
        return @parent.count(@parent[id_x])
    end
    def group_size # 全体の独立した集合の数、すなわち互いに素な集合の個数
        return @parent.uniq.size
    end
    def look_parent # 配列@parentを表示する
        return @parent
    end
    def look_rank # 配列@rankを表示する
        return @rank
    end
end

n, m = gets.strip.split.map(&:to_i)
uf = UnionFind.new(n)
rec = Array.new(n,0)
m.times do
  a,b = gets.chomp.split.map(&:to_i)
  uf.unite(a-1,b-1)
end
n.times do |i|
  rec[uf.get_parent(i)] += 1
end
rec.delete(0)
p rec.size-1

Measured memory_bytes: 16656
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
const ll base=1123;
const int MAXN=5e5+5;

string s;
int n;
ll pow[MAXN],Hash[MAXN];
bool l[MAXN],r[MAXN];

void Init(){
    s=' '+s;
    pow[0]=1;
    for(int i=1;i<=n;i++) pow[i]=(1ll*pow[i-1]*base)%MOD;
    for(int i=1;i<=n;i++) Hash[i]=(1ll*Hash[i-1]*base+s[i]-'a')%MOD;
}

ll get(int l,int r){
    return ((1ll*Hash[r]-1ll*Hash[l-1]*pow[r-l+1])%MOD+MOD)%MOD;
}

int main(){
    cin >> s;
    n=s.length();
    bool same=1;
    for(int i=1;i<s.length();i++) if(s[i]!=s[i-1]){same=0;break;}
    if(same) return printf("%d\n1",s.length()),0;
    Init();
    for(int i=1;i<=n;i++)
        for(int j=i*2;j<=n;j+=i){
            if(get(1,i)==get(j-i+1,j)) l[j]=1;
            else break;
        }
    for(int i=1;i<=n;i++)
        for(int j=n-i*2+1;j>=1;j-=i){
            if(get(j,j+i-1)==get(n-i+1,n)) r[j]=1;
            else break;
        }
    if(!l[n]) return printf("1\n1"),0;
    int ans=0;
    for(int i=1;i<n;i++) if(!l[i]&&!r[i+1]) ans++;
    printf("2\n%d",ans);
}


Measured memory_bytes: 9624
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

int main(){
    int A,B;
    char op;
    cin>>A>>op>>B;
    if(op=='+')cout<<A+B<<endl;
    else cout<<A-B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            cout<<'x';
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  rep(i,N) {
    cin >> c[i] >> t[i];
  }
  int ans = mod;
  rep(i,N){
    if(t[i]<=T){
      ans = min(ans, c[i]);
    }
  }
  if(ans > 1e9) cout << "TLE" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var x = fs.nextLong()
    var k = fs.nextLong()
    var d = fs.nextLong()
    x = abs(x)
    if (x / d > k) {
        println(x - k * d)
    } else {
        x -= ((x/d) *d).also { k -= x/d }
        if(k%2==0L) println(abs(x))
        else println(abs(abs(x)-d))
    }
}

class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 34372
import java.util.Scanner;
public class Main{
    int a;
    int b;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        if(a<b){
            System.out.println("a < b");
        }
        if(a>b){
            System.out.println("a > b");
        }
        if(a==b){
            System.out.println("a == b");
        }
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17224
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str;
	cin>>str;
	int i;
	for(i=0;i<str.size();i++){
		if(str[i]<'D') str[i]=str[i]+23;
		else str[i]=str[i]-3;
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 3156
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	int n = in();
	vector<bitset<64>>mask(n);
	REP(i, n) {
		int k = in();
		REP(j, k) {
			int b = in();
			mask[i].set(b);
		}
	}
	bitset<64>bs;
	int q = in();
	REP(i, q) {
		int que = in(), arg = in();
		switch (que) {
		case 0:
			cout << (bs.test(arg) ? '1' : '0') << endl;
			break;
		case 1:
			bs |= mask[arg];
			break;
		case 2:
			bs &= ~mask[arg];
			break;
		case 3:
			bs ^= mask[arg];
			break;
		case 4:
			cout << ((bs | mask[arg]) == bs ? '1' : '0') << endl;
			break;
		case 5:
			cout << ((~bs | mask[arg]) != ~bs ? '1' : '0') << endl;
			break;
		case 6:
			cout << ((~bs | mask[arg]) == ~bs ? '1' : '0') << endl;
			break;
		case 7:
			cout << (bs & mask[arg]).count() << endl;
			break;
		case 8:
			cout << (bs & mask[arg]).to_ulong() << endl;
			break;
		}
	}
}


Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

void solve() {
  int n;
  vector<pll> v; // {difference, a term}
  cin >> n;
  for(int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    v.push_back({a-b, a});
  }
  sort(v.begin(), v.end());
  if(v[0].first == 0) {
    cout << "0\n";
    return;
  }
  ll ret = 0;
  ll smallest = 1e9;
  for(pll out: v) {
    ret += out.second;
    if(out.first > 0) smallest = min(smallest, out.second - out.first);
  }
  cout << ret - smallest << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 892
MOD = 10**9 + 7

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = [0] * (n + 1)
for _ in range(m):
    a[int(input())] = 1

# i段目にたどり着く方法
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if a[1] == 0 else 0

for i in range(2, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % MOD if a[i] == 0 else 0

print(dp[-1])

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  vector<int> v(3); for(int &e : v) cin >> e;
  sort(begin(v), end(v));
  #define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;
  Yes(v[0] + v[1] == v[2]);
}


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

int main() {
    string S;
    cin >> S;

    string candidate = "";
    set<string> dic;
    dic.insert("dream");
    dic.insert("dreamer");
    dic.insert("erase");
    dic.insert("eraser");

    // reverse(S.begin(), S.end());
    for (int i = S.size() - 1; i >= 0; i--)
    {
        candidate = S.at(i) + candidate;
        if (dic.count(candidate))
            candidate = "";
    }

    if (candidate.size() == 0)
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e5 + 10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

unordered_map<string, int> items;
int main()
{
    int N,ans=0;
    cin >> N;
    for (int i = 0; i < N;i++)
    {
        string a;
        cin >> a;
        auto iterator = items.find(a);
        if(iterator!=items.end())
            iterator->second += 1;
        else
            items[a] = 1;

    }
    auto iter = items.begin();
    while(iter!=items.end())
    {
        ans += 1;
        ++iter;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 17696
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
 
using namespace std;

typedef long long ll;

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

    int N;

    cin >> N;

    double n = static_cast<double> (N);

    if(N % 2 == 0) {
        cout << fixed << setprecision(10) << 1.0 / 2.0 << endl;
    } else {
        cout << fixed << setprecision(10) << (static_cast<double>(N / 2) + 1.0) / n << endl;
    }
}


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

using namespace std;

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define REP(v, n)      FOR(v, 0, n)

#define ALL(c)         (c).begin(), (c).end()

void p (int si, int sc, vector<int>& m, vector<vector<int>>& g) {
	if (m[si] != 0) return;
	m[si] = sc;
	for (auto v : g[si]) p(v, sc - 1, m, g);
}

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

	int N;
	cin >> N;

	vector<vector<int>> g(N, vector<int>());
	int n0, n1;
	REP(i, N - 1) {
		cin >> n0 >> n1;
		g[n0 - 1].push_back(n1 - 1);
		g[n1 - 1].push_back(n0 - 1);
	}

	vector<int> b(N);
	b[N - 1] = -1000000;
	p(0, 500000, b, g);

	vector<int> w(N);
	w[0] = -1000000;
	p(N - 1, 500000, w, g);

	int wc = 0;
	int bc = 0;
	REP(i, N) {
		if (b[i] >= w[i]) {
			++bc;
		} else {
			++wc;
		}
	}

	if (bc > wc) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int count = 0;
    for(int i=a;i<=b;i++)
    {
        string str = to_string(i);
        string str2 = str;
        reverse(str2.begin(),str2.end());
        if(str == str2)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll INF = 1ll << 50;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    vector<ll> V(N);
    for (ll& x : V) cin >> x;
    ll res = -INF;
    for (int l = 0; l <= K && l <= N; l++) {
      for (int r = 0; l + r <= K && l + r <= N; r++) {
        vector<ll> got;
        for (int i = 0; i < l; i++) got.push_back(V[i]);
        for (int i = 0; i < r; i++) got.push_back(V[N - i - 1]);
        sort(got.begin(), got.end());
        int rem = K - l - r;
        ll sum = accumulate(got.begin(), got.end(), 0ll);
        for (int i = 0; i < got.size() && rem > 0; i++, --rem) {
          if (got[i] >= 0) break;
          sum -= got[i];
        }
        chmax(res, sum);
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 100*1000+5;
int n;
vector<int> a;

int dp[N];

int main() {
    cin >> n;
    loop(i,n){
        int e;
        cin >> e;
        a.push_back(e);
    }

    loop(i,N) dp[i] = 2e9;
    dp[0] = 0;

    for(int i = 1; i < n; i++){
        dp[i] = min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if(i-2 >= 0)
        dp[i] = min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
#define INF 1000000007
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a/3 << endl;
    return 0;
}

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int x = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		
		int last = -1;
		for (int i = 1; i < n; i++) {
			if (a[i - 1] + a[i] >= x) {
				last = i;
				break;
			}
		}
		
		if (last == -1) {
			out.println("Impossible");
			return;
		}
		
		out.println("Possible");
		
		for (int i = n - 1; i > last; i--) {
			out.println(i);
		}
		for (int i = 1; i < last; i++) {
			out.println(i);
		}
		out.println(last);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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

Measured memory_bytes: 24016
#include <iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    std::cout << "Possible" << std::endl;
  else
    std::cout << "Impossible" << std::endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  bool same = false;
  for (int i=0; i+1<N; i++) {
    if (A.at(i)==A.at(i+1)) {
      same = true;
      break;
    }
  }
  if (!same) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#include <atcoder/math>
#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// int64 crt(const vector<int64>& rs, const vector<int64>& ms) {
//   return 0;
// }

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int64 ans = INT64_MAX;

  int64 n;
  cin >> n;
  for (int64 a = 1; a * a <= 2LL * n; a++) {
    if (2LL * n % a != 0) continue;
    int64 b = 2LL * n / a;
    auto [c1, m1] = atcoder::crt(vector<int64> {0, b - 1}, vector<int64> {a, b});
    if (c1 > 0) UpdateMin(ans, c1);
    auto [c2, m2] = atcoder::crt(vector<int64> {0, a - 1}, vector<int64> {b, a});
    if (c2 > 0) UpdateMin(ans, c2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b && b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
   }
}


Measured memory_bytes: 26184
use std::cmp::*;
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, m) = (v[0], v[1]);
    let mut edges = Vec::new();
    for _ in 0..m {
        let a = read_vec::<usize>();
        edges.push((a[0], a[1]));
    }

    let mut outs = HashMap::new();
    let mut ins = HashMap::new();

    for (v1, v2) in edges.clone() {
        (*outs.entry(v1).or_insert(Vec::new())).push(v2);
        *ins.entry(v2).or_insert(0) += 1;
    }

    let mut q = VecDeque::new();
    for v in 0..n + 1 {
        if !ins.contains_key(&v) || ins[&v] == 0 {
            q.push_back(v);
        }
    }

    let mut sorted_vertexes = Vec::new();
    while let Some(v1) = q.pop_front() {
        sorted_vertexes.push(v1);
        if !outs.contains_key(&v1) {
            continue;
        }
        for v2 in outs[&v1].iter() {
            *ins.get_mut(v2).unwrap() -= 1;
            if !ins.contains_key(&v2) || ins[v2] == 0 {
                q.push_back(*v2);
            }
        }
    }

    // println!("{:?}", sorted_vertexes);

    let mut ins = HashMap::new();
    for (v1, v2) in edges {
        (*ins.entry(v2).or_insert(Vec::new())).push(v1);
    }

    let mut dp = vec![0; n + 1];
    for i in 0..n + 1 {
        let i = sorted_vertexes[i];
        if !ins.contains_key(&i) {
            continue;
        }
        for j in ins[&i].iter() {
            dp[i] = max(dp[i], dp[*j] + 1);
        }
    }

    let mut ans = 0;
    for i in 0..n + 1 {
        ans = std::cmp::max(ans, dp[i]);
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 33508
#include "bits/stdc++.h"
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz 200100


int tree[4 * sz];



int get(int s,int e,int qs,int qe,int idx){

	if(qs>e || qe<s || qs>qe)
		return 0;

	if(qs<=s && qe>=e){
		return tree[idx] ;
	}

	int mid=s+(e-s)/2;
	int a=get(s,mid,qs,qe,2*idx+1);
	int b=get(mid+1,e,qs,qe,2*idx+2);

	return max(a,b) ;
}

void upd(int s,int e,int idx,int val,int node){

	if(s > idx || e < idx)
		return ;

	if(s==e){
		tree[node]=val;
		return ;
	}

	int mid=s+(e-s)/2;
	upd(s,mid,idx,val,2*node+1);
	upd(mid+1,e,idx,val,2*node+2);
	tree[node]=max(tree[2*node+1],tree[2*node+2]);


}

signed main(){

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// online submission
#endif

memset(tree,0,sizeof tree);

int n;
cin >> n;

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


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

	int m=get(0,n,0,h[i],0);

	upd(0,n,h[i],a[i]+m,0);
}


cout<<tree[0];


    return 0;
}




Measured memory_bytes: 13008
n, m = map(int, input().split())
r = 1
for i in range(1, int(m**0.5)+1)[::-1]:
    if i<=m//n and m%i==0:
        if m//i<=m//n:
            r = max(r, m//i)
        else:
            r = max(r, i)
print(r)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
  int n,m,i,j,k[10],s[10][10],p[10],t,di,ans=0,d[10]={1,2,4,8,16,32,64,128,256,512};
  bool g;
  cin >> n >> m;
  for (i=0;i<m;i++){
    cin >> k[i];
    for (j=0;j<k[i];j++) cin >> s[i][j];
  }
  for (i=0;i<m;i++) cin >> p[i];
  for (t=0;t<d[n-1]*2;t++){
    g=true;
    for (i=0;i<m;i++){
      di=0;
      for (j=0;j<k[i];j++) if (t&d[s[i][j]-1]) di++;
      if (di%2!=p[i]){
        g=false;
        break;
      }
    }
    if (g) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll ans = 0;
	ll sum = 0;
	vector<ll> d(n);
	rep(i, n) {
		d[i] = a[i] - b[i];
		if (d[i] < 0) {
			ans++;
			sum += -d[i];
		}
	}
	sort(d.rbegin(), d.rend());
	rep(i, n) {
		if (sum <= 0) break;
		if (d[i] > 0) {
			sum -= d[i];
			ans++;
		}
	}
	if (sum > 0) ans = -1;
	cout << ans << endl;
	return 0;
}

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

// ll f(ll x, ll y){
//     if(x <= 0 || x == y){
//         return y;
//     }
//     ll z = y - x;
//     if(x < z){
//         f(x, z);
//     } else {
//         f(z, x);
//     }

// }

// 最大公約数 gcd(6, 8) -> 2
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    ll ans = v[1];
    for(int i = 0; i < N-1; i++){
        ans = gcd(v[i], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024