akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	ll a,b,c;cin>>a>>b>>c;
	if(b*c>=a)cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
int a[100010];
int lis[100010];


signed main(){
    cin >> n;
    rep(i, 0, n) cin >> a[i];

    int ans = 0;
    fill(lis, lis+n, INF);
    rep(i, 0, n){
        int p = lb(lis, lis+n, a[i])-lis;
        lis[p] = a[i];
        chmax(ans, p+1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4652
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	cnt := 0
	for i := 0; i < len(s) / 2; i++ {
		if s[i] != s[len(s)-(i+1)] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> P(N, K - Q);
  REP(i, Q) {
    int a;
    cin >> a;
    a--;
    P[a]++;
  }
  REP(i, N) {
    if (P[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int n;
int arr[250005];
int grid[505][505];
int dist[505][505];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
queue<pi> q;
int main(){
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	cin >> n;
	REP(i, 0, n*n){
		cin >> arr[i];
		arr[i]--;
		dist[i/n][i%n] = min(min(i/n, i%n), min(n - 1 - (i/n), n - 1 - (i%n)));
		grid[i/n][i%n] = 1;
	}
	ll answer = 0;
	REP(i, 0, n*n){
		answer += dist[arr[i]/n][arr[i]%n];
		grid[arr[i]/n][arr[i]%n] = 0;
		q.push(MP(arr[i]/n, arr[i]%n));
		while (!q.empty()){
			pi cur = q.front();
			q.pop();
			int xx = cur.first;
			int yy = cur.second;
			REP(j, 0, 4){
				int newx = xx + dx[j];
				int newy = yy + dy[j];
				if (newx < 0 || newx >= n) continue;
				if (newy < 0 || newy >= n) continue;
				if (dist[newx][newy] > dist[xx][yy] + grid[xx][yy]){
					dist[newx][newy] = dist[xx][yy] + grid[xx][yy];
					q.push(MP(newx, newy));
				}
			}
		}
	}
	cout << answer << "\n";
	
}

Measured memory_bytes: 6588
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////

int a[105][105];
int licznik[1005];

///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		int tab[105];
		for(int j = 0; j < k; j++){
			cin >> tab[j];
			a[i][tab[j]]++;
		}
	}
	
	//cout << "licznik: " << endl;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= m; j++){
			//cout << a[i][j] << " ";
			if(a[i][j] > 0) licznik[j]++;
		}
		//cout << endl;
	}
	
	int ans = 0;
	//cout << "licznik: " << endl;
	for(int i = 0; i <= 40; i++){
		if(licznik[i] == n){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	

						
	return 0;
}


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

int prime[300000];
bool is_prime[300010];

void sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
}

int main(){
    sieve(300000);
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int ans = 0;
        for(int i = n + 1; i <= 2 * n; i++){
            if(is_prime[i] == true) ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3480
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e+5;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0;
    REP(i, 1, n + 1) {
        int x = i;
        int y = 0;
        while (x > 0) {
            y += x % 10;
            x /= 10;
        }
        if (y >= a && y <= b) {
            sum += i;
        }
    }
    cout << sum << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
const long double PI = acos(-1);

int mx, n, x, y, sav, DP[Nmax];
vector<int> v[Nmax];

void dfs(int nod, int h, int ant){
    if (h > mx){
        mx = h;
        sav = nod;
    }
    for (auto it : v[nod]){
        if (it == ant) continue;
        dfs(it, h+1, nod);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i=1;i<n;i++){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1,1,-1);
    mx = 0;
    dfs(sav,1,-1);

    DP[1] = 1;
    DP[2] = 0;
    DP[3] = 1;
    for (int i=4;i<=mx;i++){
        if (DP[i-1] == 0 || DP[i-2] == 0) DP[i] = 1;
    }

    if (DP[mx]) cout << "First\n";
    else cout << "Second\n";

    return 0;
}

Measured memory_bytes: 28416
N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)

n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

for i in c:
    print(str(i + 1))


        
            



     



Measured memory_bytes: 8992
N, M = map(int, input().split())
g = [[False] * N for _ in range(N)]
A = []
B = []
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)
    g[a][b] = True
    g[b][a] = True

def walk(cur):
    visited[cur] = True
    for i in range(N):
        if g[cur][i] and not visited[i]:
            walk(i)
        else:
           continue

ans = 0
for i in range(M):
    g[A[i]][B[i]] = False
    g[B[i]][A[i]] = False
    visited = [False] * N
    walk(0)
    if not all(visited):
        ans += 1
    g[A[i]][B[i]] = True
    g[B[i]][A[i]] = True

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
vector<ll>v1[11];
void rec(int l,int c,ll num)
{
	if(c==l)
	{
		v1[l].pb(num);	
		return;
	}
	if(num%10==0)
	{
		rec(l,c+1,num*10+1);
		rec(l,c+1,num*10+0);
	}
	else if(num%10==9)
	{
		rec(l,c+1,num*10+8);
		rec(l,c+1,num*10+9);
	}
	else
	{
		rec(l,c+1,num*10+num%10);
		rec(l,c+1,num*10+num%10-1);
		rec(l,c+1,num*10+num%10+1);
	}
}
int main()
{
   int n;
   cin>>n;
   if(n<=12)
   {
   	return cout<<n,0;
   }
 
   vector<ll>v;
   rep(i,0,9){
   v1[1].pb(i+1);v.pb(i+1);}
   for(int i=2;i<=10;i++)
   {
   		for(int j=0;j<v1[i-1].size();j++)
   		rec(i,i-1,v1[i-1][j]);
   		for(int j=0;j<v1[i].size();j++)
   		v.pb(v1[i][j]);
   }
   sort(v.begin(),v.end());
   cout<<v[n-1];
}


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

int main() {
	string s; cin >> s;
	
	int snum = 0, tnum = 0, sum = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'T') {
			if (snum == 0) {
				sum += 2;
			}
			else {
				snum--;
			}
		}
		else {
			snum++;
		}
	}
	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 998244353;
ll INF = 1e9;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h+1, vector<int>(w+1));
    vector<vector<int>> b(h+1, vector<int>(w+1));
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cin >> b[i][j];
        }
    }

    bool dp[h+1][w+1][80 * 165 * 2];
    // 0 => 80 * 160
    int v = abs(a[1][1] - b[1][1]);
    dp[1][1][80*160 + v] = true;
    dp[1][1][80*160 - v] = true;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            int diff = abs(a[i][j] - b[i][j]);
            for(int k = 0; k <= 80*165*2-1; k++)
            {
                if(i >= 2)
                {
                    if(dp[i-1][j][k]) 
                    {
                        dp[i][j][k+diff] = true;
                        dp[i][j][k-diff] = true;
                    }
                }
                if(j >= 2)
                {
                    if(dp[i][j-1][k])
                    {
                        dp[i][j][k+diff] = true;
                        dp[i][j][k-diff] = true;
                    }
                }
            }
        }
    }
    int ans = INF;
    for(int k = 0; k <= 80*165*2-1; k++)
    {
        if(dp[h][w][k])
        {
            ans = min(ans, abs(80*160 - k));
        }
    }
    cout << ans << endl;
}


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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> color{a, b, c};

    int cnt = 0;
    rep (i,4) {
        if (i == 3) break;
        if (color[i] != color[i+1]) {
            if (color[i] != color[i+2]) {
            cnt++;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    string s;
    ll k;
    cin >> s >> k;
    int n=s.size();
    ll ctr=1;
    bool first=true;
    ll ans=0;
    ll fi=0;
    rp(i,n-1){
        if(s[i]==s[i+1]) ctr++;
        else{
            if(first){
                ans+=ctr/2;
                fi=ctr;
                first=false;
            }
            else{
                ans+=ctr/2;
            }
            ctr=1;
        }
    }
    if(s[0]!=s[n-1]){
        ans+=ctr/2;
        print(ans*k);
        return 0;
    }
    else{
        if(!first){
            ans -= fi/2;
            print(ans*k+fi/2+ctr/2+((fi+ctr)/2)*(k-1));
        }
        else{
            print(n*k/2);
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI()
	A.sort()
	pa= A[0]
	f = True
	for a in A[1:]:
		if(pa==a):
			f=False
			break
		pa = a
	if f :
		print("YES")
	else:
		print("NO")



main()

Measured memory_bytes: 80980
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
let array;
let index = 0;
let n;
let m;
let answers = [];
while (line = lines.shift()) {
    if(index === 0){
        const test = line.split(' ').map(Number);
        n = test[0];
        m = test[1];
        index ++;
    } else {
        array = line.split(' ').map(Number);
        let answer = 0;
        for(let i = 0; i<n ;i++){
            for(let j = 0;j<n;j++){
                if(i === j){
                    continue;
                }
                const test = array [i] + array [j];
                if(test > answer && test <= m){
                    answer = test;
                }
            }
        }
        index = 0;
        answers.push(answer);
    }
}
answers.forEach(data => console.log(data ? data : 'NONE'))


Measured memory_bytes: 18516
len = gets.chomp.to_i
one = gets.chomp.split("")
two = gets.chomp.split("")
three = gets.chomp.split("")

array = []
len.times do |index|
    x = 0
    if one[index] != two[index]
        x += 1
    end
    if one[index] != three[index]
        x += 1
    end

    y = 0
    if two[index] != one[index]
        y += 1
    end
    if two[index] != three[index]
        y += 1
    end

    z = 0
    if three[index] != one[index]
        z += 1
    end
    if three[index] != two[index]
        z += 1
    end

    max = [x,y,z].min
    array.push(max)
end


print(array.reduce{|sum, n| sum+n})



Measured memory_bytes: 3836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#define ll long long
#define rei register int
#define bl putchar(' ')
#define ed putchar('\n')
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define test std::cout<<"this:"
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f
#define pai acos(-1)
#define inv inline void
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define read4(a,b,c,d) read(a),read(b),read(c),read(d)
template <typename QvQ>inv read(QvQ &x)
{
    x=0;int f=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
    if(x<0) x=-x,putchar('-');
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
using namespace std;
int n,a[55],b[55];
int check()
{
	for(rei i=1;i<=n;++i) if(a[i]!=b[i]) return 0;
	return 1;
}
int main()
{
	read(n);
	for(rei i=1;i<=n;++i) read(a[i]),b[i]=a[i];
	sort(b+1,b+n+1);
	if(check()) 
	{
		puts("YES");
		return 0;
	}
	for(rei i=1;i<=n;++i)
	{
		for(rei j=i+1;j<=n;++j)
		{
			swap(a[i],a[j]);
			if(check()) 
			{
				puts("YES");
				return 0;
			}
			swap(a[i],a[j]);
		}
	}
	puts("NO");
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


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

	cout << min(B/A, C);
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {

	static int n;
	static double[] x1, y1, x2, y2;
	static double sx, sy, gx, gy;
	static ArrayList<Integer>[] g;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		while (q-- > 0) {
			long x0, y0, x1, y1, x2, y2, x3, y3;
			x0 = sc.nextLong();
			y0 = sc.nextLong();
			x1 = sc.nextLong();
			y1 = sc.nextLong();
			x2 = sc.nextLong();
			y2 = sc.nextLong();
			x3 = sc.nextLong();
			y3 = sc.nextLong();
			Point p0 = new Point(x0, y0);
			Point p1 = new Point(x1, y1);
			Point p2 = new Point(x2, y2);
			Point p3 = new Point(x3, y3);
			if (linesIntersect(p0, p1, p2, p3)) {
				System.out.println(1);
			} else {
				System.out.println(0);
			}
		}

	}

	static class Point {
		long x, y;
		int id;

		public Point(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}

	static boolean linesIntersect(Point s1, Point d1, Point s2, Point d2) {
		long prd1 = crossProduct(s1, d1, s1, d2) * crossProduct(s1, d1, s1, s2);
		long prd2 = crossProduct(s2, d2, s2, s1) * crossProduct(s2, d2, s2, d1);
		if (prd1 == 0 && prd2 == 0) {
			if (((s2.x - s1.x) * (s2.x - d1.x) <= 0 && (s2.y - s1.y) * (s2.y - d1.y) <= 0)
					|| ((d2.x - s1.x) * (d2.x - d1.x) <= 0 && (d2.y - s1.y) * (d2.y - d1.y) <= 0)
					|| ((s1.x - s2.x) * (s1.x - d2.x) <= 0 && (s1.y - s2.y) * (s1.y - d2.y) <= 0)
					|| ((d1.x - s2.x) * (d1.x - d2.x) <= 0 && (d1.y - s2.y) * (d1.y - d2.y) <= 0)) {
				return true;
			} else
				return false;
		} else
			return prd1 <= 0 && prd2 <= 0;
	}

	static long crossProduct(Point s1, Point d1, Point s2, Point d2) {
		return (d1.x - s1.x) * (d2.y - s2.y) - (d1.y - s1.y) * (d2.x - s2.x);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<double> T(N), V(N);
    double tsum = 0;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        tsum += T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    map<double, double> ans;
    for (double t = 0; t <= tsum; t += 0.5) {
        ans[t] = min(t, tsum - t);
    }

    double s = 0;
    for (int i = 0; i < N; i++) {
        double t = s + T[i];
        for (double x = s; x >= 0; x -= 0.5) {
            ans[x] = min(ans[x], V[i] + s - x);
        }
        for (double x = t; x <= tsum; x += 0.5) {
            ans[x] = min(ans[x], V[i] + x - t);
        }
        for (double x = s; x <= t; x += 0.5) {
            ans[x] = min(ans[x], V[i]);
        }
        s = t;
    }

    double ss = 0;
    for (double t = 0; t < tsum; t += 0.5) {
        ss += ans[t] + ans[t + 0.5];
    }
    cout << ss / 4 << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[4];
    
    for(int i=0; i<3; i++){
        cin >> a[i];
    }
    sort(a, a+3);

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define input(v,n) for(int i=0;i<n;i++)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

int n,m;

void test() {

    cin >> n >> m;
    int s = 0;
    for( int i = 0; i < m; i++) {
        int t;
        cin >> t;
        s += t;
    }
    int t = s;
    if ( n >= t ) {
        cout << n - t;
    } else cout << -1;
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

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

typedef long long ll;
typedef long double ld;

int mat[1005][1005];

int ima(int i1, int j1, int i2, int j2){
    int res = 0;
    for(int i=i1; i<=i2; i++){
        for(int j=j1; j<=j2; j++){
            res += mat[i][j];
        }
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        string s;
        cin >> s;
        for(int j=1; j<=m; j++){
            if(s[j-1] == '#') mat[i][j] = 1;
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(mat[i][j] == 1){
                cout << "#";
            }
            else{
                cout << ima(i-1, j-1, i+1, j+1);
            }
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 512
import kotlin.system.exitProcess

fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }

    // 鶴:a, 亀:bと仮定
    // x =  a +  b
    // y = 2a + 4b
    // -> y = 2x + 2b
    //    b を0からxの範囲でループして検証

    for (b in 0..x) {
        if (y == 2 * x + 2 * b) {
            print("Yes")
            exitProcess(0)
        }
    }

    print("No")
}

Measured memory_bytes: 36440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  ll N; cin >> N;
  ll K; cin >> K;
  ll MOD = 1000000007;
  ll s=0;
  for(int i=K;i<N+2;i++){
    s+=(i*(N-i+1))%MOD + 1;
  }
  cout << s%MOD << endl;
  return 0;
}

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

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    double a,b,h,m,x,result,y=M_PI/double(180);
    cin>>a>>b>>h>>m;
    h+=m/60;
    //cout<<h<<endl;
    x=abs(h-m/double(5))/double(12);
    //cout<<x<<endl;
    x*=360;
    result=a*a+b*b-2*a*b*cos(y*x);
    result=sqrt(result);
    printf("%.9f",result);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, m, k, ra=0, rb=0, rt=0, ma=0;
	vector<LLi> a, b;

	cin>> n >> m >> k;
	a.resize(n);
	b.resize(m);

	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	rep(i, n) {
		if(rt+a[i]<=k){
			rt+=a[i];
			ra++;
		}else{
			break;
		}
	}

	rep(i, m) {
		if(rt+b[i]<=k){
			rt+=b[i];
			rb++;
		}else{
			break;
		}
	}

	ma=ra+rb;

	while(1){
		if(ra==0) break;
		ra--;
		rt-=a[ra];

		while(1){
			if(rb==m) break;
			if(rt+b[rb]<=k){
				rt+=b[rb];
				rb++;
			}else{
				break;
			}
		}

		ma=max(ma, ra+rb);
	}

	cout<< ma << endl;
 
	return 0;
}

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

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

int main(){
string s;
cin>>s;
int ans=0;
rep(i,s.size()-1){
  if(s[i]!=s[i+1]){
ans++;
  }
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
const int N = 1e2 + 5;

int v[N], w[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n, m, i, j, x, p;
	cin >> n >> m;
	for (j=1;j<=m;j++) v[j] = 1;
	for (i=0;i<n;i++) {
		cin >> x;
		for (j=0;j<x;j++) {
			cin >> p;
			w[p] = 1;
		}
		for (j=1;j<=m;j++) v[j] *= w[j];
		memset(w, 0, sizeof(w));
	}
	int ans = 0;
	for (j=1;j<=m;j++) ans += v[j];
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC080
{
    class GridColoring
    {
        public static void Main()
        {
            var hw = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_));
            var n = int.Parse(ReadLine());
            var stack = new Stack<int>();
            foreach(var a in ReadLine().Trim().Split(' ').Select(_ => int.Parse(_))) {
                stack.Push(a);
            }
            while(stack.Count() != 0) {
                WriteLine(BuildStringForward(ref stack, hw.Last()));
                if (stack.Count() != 0) WriteLine(BuildStringBackward(ref stack, hw.Last()));
            }
        }
        static string BuildStringForward(ref Stack<int> stack, int width)
        {
            var arr = new int[width];
            var len = 0;
            for (var idx = 0; idx < width; ++idx) {
                if (len == 0) len = stack.Pop();
                arr[idx] = stack.Count() + 1;
                --len;
            }
            if (len != 0) stack.Push(len);
            return string.Join(" ", arr.Select(_ => _.ToString()).ToArray());
        }
        static string BuildStringBackward(ref Stack<int> stack, int width)
        {
            var arr = new int[width];
            var len = 0;
            for (var idx = width - 1; idx >= 0; --idx) {
                if (len == 0) len = stack.Pop();
                arr[idx] = stack.Count() + 1;
                --len;
            }
            if (len != 0) stack.Push(len);
            return string.Join(" ", arr.Select(_ => _.ToString()).ToArray());
        }
    }
}

Measured memory_bytes: 13664
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();
        int k = sc.nextInt();

        boolean flag = false;

        for(int i=0; i<=k; i++){
            int temp = b * (int)Math.pow(2, i);
            if(a < temp){
                for(int j=0; j<=k-i; j++){
                    if(temp < c * (int)Math.pow(2, j)){
                        flag = true;
                        break;
                    }
                }
            }
        }

        if(flag){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

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

using namespace std;

#define li long long int

const int N = 1e6 + 6;

li a, b;

void solve() {
	cin >> a >> b;
	li g = __gcd(a, b);
	int res = 0;
	for (int i = 2; i * 1ll * i <= g; i++) {
		int ok = 0;
		while (g % i == 0) {
			ok = 1;
			g /= i;
		}
		res += ok;
	}
	if (g != 1) res++;
	cout << res + 1;
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int N;
  cin >> N;

  vi a(N), b(N), c(N);
  REP(i, N) cin >> a[i];
  REP(i, N) cin >> b[i];

  int ans = 0;

  ll r = 0;
  REP(i, N) {
    c[i] = a[i] - b[i];
    if (c[i] < 0) {

      r += c[i];
      ans++;
    }
  }

  sort(c.begin(), c.end(), greater<int>());

  REP(i, N) {

    if (r >= 0)
      break;
    else if (c[i] <= 0) {
      ans = -1;
      break;
    } else {
      r += c[i];
      ans++;
    }
  }

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


Measured memory_bytes: 1408
n = int(input())
s = [0]*5
ans = 0
for i in range(n):
    x = list(input())[0]
    if x == "M":
        s[0] += 1
    if x == "A":
        s[1] += 1
    if x == "R":
        s[2] += 1
    if x == "C":
        s[3] += 1
    if x == "H":
        s[4] += 1
    
for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            ans += s[a]*s[b]*s[c]
            
print(ans)

Measured memory_bytes: 9224
n=int(input())
l=list(map(int,input().split()))

d={}
sum=0
for i in range(n):
  if l[i] not in d:
    d[l[i]]=1
  else:
    d[l[i]]+=1
   
l1=[]
for i in d:
  if d[i]>1:
    l.append((d[i]*(d[i]-1))//2)
    sum+=((d[i]*(d[i]-1))//2)

#print(d,sum)
for i in range(n):
  if d[l[i]]==2:
    print(sum-1)
  elif d[l[i]]>2:
    we=((d[l[i]]*(d[l[i]]-1))//2-((d[l[i]]-1)*(d[l[i]]-2))//2)
    print(sum-we)
  else:
    print(sum)



Measured memory_bytes: 25736
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
#define Forr(i,j,k) for(int i=j;i>=k;--i)
#define ll long long 
using namespace std;
const int N=10010,INF=0x3f3f3f3f;
template<class T>void read(T &x){
	x=0;char c=getchar();
	while(!isdigit(c))c=getchar();
	while( isdigit(c))x=x*10+c-48,c=getchar();
}
int n,X[N<<1],K,Lim,id[N<<1],sz[N<<2],m,Low;
vector<int>G[N<<2];
inline void add(int x,int y){G[y].push_back(x);}
inline void Add(int x,int y){add(x,y),add(y,x);}
inline void link(int x,int y){
	Add(x*2+1,y*2),Add(y*2+1,x*2);
}
inline void Link(int x,int y){
	add(x*2+1,y*2),add(y*2+1,x*2);
}
inline bool cmp(int a,int b){return X[a]<X[b];}
int pre[N<<2],sccno[N<<2],scc[N<<2],scc_cnt,low[N<<2],dfs_cnt;
stack<int>s;
void dfs(int u){
	low[u]=pre[u]=++dfs_cnt;
	sccno[u]=1;s.push(u);
	int S=G[u].size();
	For(i,0,S-1){
		int v=G[u][i];
		if(!pre[v])dfs(v),low[u]=min(low[u],low[v]);
		else if(sccno[v])low[u]=min(low[u],pre[v]);
	}
	if(pre[u]==low[u]){
		++scc_cnt;
		int w;
		do{
			w=s.top();s.pop();
			scc[w]=scc_cnt;sccno[w]=0;
		}while(w!=u);
	}
}
bool check(int dis){
	For(i,0,m)G[i].resize(sz[i]);
	For(i,0,2*n-1){
		For(j,max(i-9,0),min(i+9,2*n-1)){
			if(j==i)continue;
			if(abs(X[id[j]]-X[id[i]])>=dis)continue;
			if(abs(id[i]-id[j])==n)continue;
			Link(id[i],id[j]);
		}
	}
	dfs_cnt=0;scc_cnt=0;
	For(i,0,m)pre[i]=0,scc[i]=0;
	For(i,0,m)if(!pre[i])dfs(i);
	For(i,0,2*n-1)if(scc[i*2]==scc[i*2+1])return 0;
	return 1;
}
inline bool Check(int dis){
	int cnt=0,last=-INF;
	For(i,0,2*n-1){
		if(X[id[i]]-last>=dis)cnt++,last=X[id[i]];
		if(cnt==n)break;
	}
	return cnt==n;
}
void solveLim(){
	int L=0,R=Lim,ans=0;
	while(L<=R){
		int Mid=(L+R)>>1;
		if(Check(Mid))ans=Mid,L=Mid+1;
		else R=Mid-1;
	}
	Lim=ans;
}
int main(){
	read(n);Low=INF;
	For(i,0,n-1){
		read(X[i]),read(X[i+n]);
		link(i,i+n);
		Lim=max(Lim,max(X[i],X[i+n]));
		if(i)Low=min(Low,X[i]-X[i-1]);
	}
	m=4*n-1;
	For(i,0,2*n-1)id[i]=i;
	For(i,0,m)sz[i]=G[i].size();
	sort(id,id+2*n,cmp);
	solveLim();
	int L=Low,R=Lim,ans=0;
	while(L<=R){
		int Mid=(L+R)>>1;
		if(check(Mid))L=Mid+1,ans=Mid;
		else R=Mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6016
#include <iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  int t = 0;
  if (a > b) {
    t = a + a - 1;
  }
  else if (a < b) {
    t = b + b - 1;
  }
  else {
    t = a + b;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;
  string s,t;

  cin >> n >> s >> t;

  string ret = "";

  REP(i,n){
    ret += s[i];
    ret += t[i];
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
x = []
for i in range(5):
  tmp = int(input())
  x.append(tmp)
k = int(input())

flag = 1
for i in range(len(x)-1):
  for j in range(len(x)):
    if x[j]-x[i] > k:
      flag = 0
      break
  if flag == 0:
    break
if flag == 0:
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 9136
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {
	
	int N;
	int A;
	int B;
	cin >> N;
	cin >> A;
	cin >> B;

	int ans = min(N * A, B);

	cout << ans << endl;


	return 0;
}


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

using namespace std;

int main (){
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    int a, b, c, sum;
    cin >> a >> b >> c;
    sum = a + b + c;
    if (!(sum % 2) && ((sum / 2 == a) || (sum / 2 == b) || (sum / 2 == c))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << 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++)

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

    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    long long ans = 0;
    REP(i, n - 1){
        if(A[i] == A[i + 1]) ans += A[i + 1];
        else if(A[i] + 1 == A[i + 1]) ans++;
        else if(A[i] > A[i + 1]) ans += A[i + 1];
        else if(A[i] + 1 < A[i + 1]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,K,A[101010];
ll Kp;
ll i,j,x,ans;
int main(){
    scanf("%lld%lld", &N,&K);
    fornum(i, 0,N){
        scanf("%lld",&A[i]);
    }
    
    for (Kp = 0; (1ll << Kp) <= K;Kp++)
        ;
    fornum(i, 0, Kp)
    {
        ll k = (1ll << (Kp - i - 1));
        ll ct = 0;
        fornum(j,0,N){
            if((A[j]&k)==0){
                ct ++;
            }
        }
        if(N/2<ct&&x+k<=K){
            x += k;
        }
    }
    fornum(i,0,N){
        ans+=(x^A[i]);
    }
    printf("%lld", ans);

    return 0;
}

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

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

    int n;
    cin >> n;
    
    vector<vector<pair<int,int>>> V;
    
    V.resize(n);
    
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        
        for(int j = 0; j < a; j++){
            int x,y;
            cin >> x >> y;
            
            x--;
            V[i].push_back({x,y});
        }
    }
    
    int ans = 0;
    
    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> S(n);
        int I = bit, cnt = 0;
        bool flag = true;
        for(int j = 0; j < n; j++) S[j] = I % 2, I /= 2;
        for(int j = 0; j < n; j++){
            if(S[j] == 1){
                cnt++;
                for(int k = 0; k < V[j].size(); k++){
                    if(V[j][k].second != S[V[j][k].first]) flag = false;
                }
            }
        }
        if(flag) ans = max(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

char Move(int position, int n, int q, string s, vector<char> &t, vector<char> &d)
{
	for (int i = 0; i < q; ++i) {
		if (s[position] == t[i]) {
			if (d[i] == 'L') {
				position--;
			}
			else {
				position++;
			}
		}
		if (0 > position) {
			return 'L';
		}
		if (n <= position) {
			return 'R';
		}
	}
	return ' ';
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  
	int n, q;

	cin >> n >> q;
	string s;
	cin >> s;
	vector<char> t(q);
	vector<char> d(q);
	for (int i = 0; i < q; ++i) {
		cin >> t[i] >> d[i];
	}


	int left = -1;
	int right = n;
	while (right - left > 1) {
		int mid = (left + right) / 2;
		if ('R' == Move(mid, n, q, s, t, d)) {
			right = mid;
		}
		else {
			left = mid;
		}
	}
	int from_right = right;

	left = -1;
	right = n;
	while (right - left > 1) {
		int mid = (left + right) / 2;
		if ('L' == Move(mid, n, q, s, t, d)) {
			left = mid;
		}
		else {
			right = mid;
		}
	}
	int from_left = left;

	int alive = from_right - from_left - 1;
	alive = max(alive, 0);
	//cout <<  from_right << " " << from_left << " ";
	cout << alive << endl;


	return 0;
}

Measured memory_bytes: 1156
K, N = map(int,input().split())
A = list(map(int, input().split()))
List = []

for i in range(1, N):
  List.append(A[i] - A[i-1])
  
d = K - A[-1] + A[0]
List.append(d)
List.sort()
print(sum(List[:-1]))
  

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	long long n;
	cin>>n;

	long long ans=0;
	int i=0;
	while(n>0)
	{
		n=n/2;
		ans+=pow(2,i);
		i++;
	}
  
  cout<<ans;
	return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define int long long
int x[200005],y[200005];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=n-1;i>=1;i--)y[i]=x[i+1]+y[i+1];
	int mod=1e9+7;
	int ans=0;
	for(int i=1;i<n;i++){
	//	cout<<x[i]<<" "<<y[i]<<endl;
		ans+=x[i]*(y[i]%mod)%mod;
	//	cout<<ans<<endl;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0) {
		if ((a + 1) * 25 / 2 < b * 10 || (b + 1) * 10 - 1 < a * 25 / 2) {
			cout << -1 << endl;
			return 0;
		}
		cout << max(a * 25 / 2, b * 10) << endl;
	}

	else {
		if ((a + 1) * 25 / 2 - 1 < b * 10 || (b + 1) * 10 - 1 < a * 25 / 2 + 1) {
			cout << -1 << endl;
			return 0;
		}
		cout << max(a * 25 / 2 + 1, b * 10);
	}
	return 0;
}

Measured memory_bytes: 256
function main()
  
  (K,N) = map(x -> parse(Int,x), split(readline()))
  A = map(x -> parse(Int,x), split(readline()))
  
  ans = abs(K-A[end])+A[1]
  
  for i in 1:N-1
    ans = max(ans, abs(A[i] - A[i+1]))
  end
  
  println(K - ans)
  
end

main()

Measured memory_bytes: 205372
#include<stdio.h>

int m[]={0,31,29,31,30,31,30,31,31,30,31,30,31},s,a,b,i;

int main(){
    scanf("%d%d",&a,&b);
    while(a!=0 && b!=0){
        s=0;
        for(i=1;i<a;i++)s+=m[i];
        s+=b;
        if(s%7==0)printf("Wednesday\n");
        if(s%7==1)printf("Thursday\n");
        if(s%7==2)printf("Friday\n");
        if(s%7==3)printf("Saturday\n");
        if(s%7==4)printf("Sunday\n");
        if(s%7==5)printf("Monday\n");
        if(s%7==6)printf("Tuesday\n");
        scanf("%d%d",&a,&b);
    }
    return 0;
}


Measured memory_bytes: 1984
//
#include <bits/stdc++.h>
using namespace std;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

int main(){
	string S; cin>>S;
	int N = S.size();
	// cout<<S<<","<<N<<"\n--\n";///

	for(int d=1; d<N-1; ++d){//number of del char
		int n = N - d;
		if(n%2) continue; //n: odd
		int len = n/2;
		// printf("len %d n %d\n",len,n);//
		// ote(S.substr(0,n));///

		int f;
		for(f=0; f<len; ++f){
			int b = len + f;
			// printf("%d %d\n",f,b);//
			if(S[f] != S[b]){
				break;
			}
		}
		if(f<len){
			// puts("-----");///
			continue;
		}
		// printf("len %d f %d n %d\n",len,f,n);//

		string t = "";
		for(f=0; f<len; ++f){
			t += S[f];
			int c = S.compare(t.size(),n-t.size(),t);
			if(c == 0){
				if(t.size()==len){
					ote(n);
					return 0;
				}
			}
			// cout<<t<<","<<c<<"\n";
		}

		// puts("--");//
	}

}


Measured memory_bytes: 256