akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL a, b, c; cin >> a >> b >> c;

	LL ans = (b);

	LL cure = a + b;

	ans += min(c, cure + 1);

	cout << ans << endl;

	return 0;
}

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

int     main() {
        long D;
        cin >>D;
        if (D==25) cout << "Christmas";
        else if (D==24) cout << "Christmas Eve";
        else if (D==23) cout << "Christmas Eve Eve";
        else cout << "Christmas Eve Eve Eve";
        cout << endl;
        return 0;
}

Measured memory_bytes: 256
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $n, $k); //n部屋、k回移動
$k = min($n-1, $k);//0人の部屋の数の上限
prepareMod(200000);
$count = 0;
for($i = 0; $i <= $k; $i++){
    $count += nCm($n, $i) * nHm($n-$i, $i);
    $count %= MOD;
}
echo $count,"\n";

/**
 * とても高速なnCm関数です
 *  prepareModで事前計算しておき、
 *  nCmを呼び出しましょう。
 *  AtCoderの2秒制約ならN=10^6ぐらいまで通ります
 */

function prepareMod($n){
    global $f, $invf;
    $f[0] = $invf[0] = $invf[1] = 1;
    for($i = 1; $i <= $n; $i++)$f[$i] = $f[$i-1]*$i%MOD;
    for($i = 2; $i <= $n; $i++)$invf[$i] = (MOD - intdiv(MOD, $i))*$invf[MOD%$i]%MOD;
    for($i = 2; $i <= $n; $i++)$invf[$i] = $invf[$i]*$invf[$i-1]%MOD;
}
function nHm($n, $m){
    global $f, $invf;
    return nCm($n+$m-1, $m);
}
function nCm($n, $m){
    global $f, $invf;
    if($n < 0 || $n - $m < 0)return 0;
    return $f[$n] * $invf[$n-$m] % MOD * $invf[$m] % MOD;
}


Measured memory_bytes: 25716
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    std::vector<string> S(N);
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    for(int i=0;i<N;i++){
        cin >> S.at(i);
        if(S.at(i)=="AC")ac++;
        if(S.at(i)=="WA")wa++;
        if(S.at(i)=="TLE")tle++;
        if(S.at(i)=="RE")re++;
    }
    cout<<"AC x "<< ac<<endl;
    cout<<"WA x "<< wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<< re<<endl;
    
}


Measured memory_bytes: 6360
#include <iostream>

using namespace std;

int main(void) {
    long long N, K;
    cin >> N >> K;

    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    long long ans = 0;
    for (long long i = 1; i <= N; ++i) {
        if (i - 1 >= K) {
            ans += (i - K) * (N / i);
            ans += max(0LL, (N % i) - K + 1);
        }
    }

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

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> ans;
    int m = (n%2 == 0 ? n+1 : n);
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            if(i+j == m)continue;
            ans.emplace_back(i, j);
        }
    }
    cout << ans.size() << endl;
    for(auto e: ans){
        cout << e.first << " " << e.second << endl;
    }

    return 0;
}


Measured memory_bytes: 384
// In the name of Allah 
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9+7, MAX = 1e5+5;
int n, arr[MAX], now, cnt;
map<int, bool> m;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	now = 0;
	while (true) {
		now = arr[now]-1;
		if (m[now])
			return cout << -1 << endl, 0;
		if (now == 1)
			return cout << cnt+1 << endl, 0;
		cnt ++;
		m[now] = true;
	}

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cmath>

using namespace std;

struct Point {
  double x;
  double y;
  
  Point(){}
  Point(double x,double y) : x(x),y(y){}
  Point operator + (Point p) { return Point(x + p.x, y + p.y); } //演算子のオーバーロード
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double k) { return Point(x * k, y * k); }
  Point operator / (double k) { return Point(x / k, y / k ); }
  bool operator == (Point p1) {
    if(p1.x == x && p1.y == y)
      return true;
    else 
      return false;
  }

};

double norm(Point p0, Point p1) {
  return sqrt(pow(p1.x - p0.x, 2) + pow(p1.y - p0.y, 2));
}

double dot(Point p0, Point p1, Point p2) {
  return (p1.x - p0.x) * (p2.x - p0.x) + (p1.y - p0.y) * (p2.y - p0.y);
}

double cross(Point p0, Point p1, Point p2) {
  return ( p1.x - p0.x ) * ( p2.y - p0.y ) - ( p2.x - p0.x) * (p1.y - p0.y);
}

int positional_relationship(Point p0, Point p1, Point p2) {
  if(cross(p0, p1, p2) > 0) //反時計回り
    return 1;
  else if(cross(p0, p1, p2) < 0) //時計回り
    return -1;
  else if(dot(p0, p1, p2) < 0) //一直線上で反転向き
    return 2;
  else if(norm(p0, p1) < norm(p0, p2)) // 一直線上で同じ向き
    return -2;
  else //線分上に存在
    return 0;  
}

bool isIntersected(Point p0, Point p1, Point p2, Point p3) {
  if(positional_relationship(p0, p1, p2) * positional_relationship(p0, p1, p3) <= 0 && positional_relationship(p2, p3 ,p0) * positional_relationship(p2, p3, p1) <= 0)
    return true;
  return false;
};


int main(void) {
  int q;
  cin >> q;
  Point p0, p1, p2, p3;

  for(int i = 0; i < q; i++) {
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    
    if(isIntersected(p0, p1, p2, p3))
      cout << "1" << endl;
    else 
      cout << "0" << endl;
  }

}


Measured memory_bytes: 3232
#include <stdio.h>
#include <math.h>

int main() {
    int a,b,k,r;

    scanf("%d %d",&a,&b);
    
    k = (a+b)/2;
    r = (a+b)%2;
    
    if(r == 0){
        printf("%d\n", k);
    }else{
        printf("IMPOSSIBLE\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    
    int X, A, B;
    
    cin >> X >> A >> B;
    
    if (A >= B) cout << "delicious" << endl;
    else if (X + A >= B) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    
    return 0;
    
}

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

using namespace std;

int main(void){
    int x;
    cin >> x;
    
    if (400 <= x && x <= 599) cout << 8 << endl;
    else if (600 <= x && x <= 799) cout << 7 << endl;
    else if (800 <= x && x <= 999) cout << 6 << endl;
    else if (1000 <= x && x <= 1199) cout << 5 << endl;
    else if (1200 <= x && x <= 1399) cout << 4 << endl;
    else if (1400 <= x && x <= 1599) cout << 3 << endl;
    else if (1600 <= x && x <= 1799) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
    
}



Measured memory_bytes: 3632
using System;

public class Hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var n = int.Parse(line.Trim());
            var f = new bool[n + 1];
            generatePrime(f);
            var count = 0;
            for (int i = 2; i < n + 1; i++)
                if (!f[i]) count++;
            Console.WriteLine(count);
        }
    }
    public static void generatePrime(bool[] f)
    {
        var pL = f.Length;                                           // prime :  false
        f[0] = true; f[1] = true;
        for (int i = 2; i < pL; i++)
            if (!f[i])
                for (int j = i + i; j < pL; j += i) f[j] = true;
    }
}


Measured memory_bytes: 12056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,y;
	cin>>n>>y;
	y/=1000;
	rep(i,n+1){
		rep(j,n+1-i){
			int k=n-i-j;
			if(i*10+j*5+k==y){
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> res(n+1,0);
    for(ll i = 1;i <= n; i++){
        for(ll j = 1;j <= n;j++){
            for(ll k = 1;k <= n;k++){
                ll pro = i*i + j*j + k*k + i*j + j*k + i*k;
                if(pro <= n){
                    res[pro] += 1;
                }else break;
            }
        }
    }
    repp(i,1,n+1)cout << res[i] << "\n";
    return 0;
}

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

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<char> a(n);
	set<char> b;
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
		b.insert(a.at(i));
	}
	if (b.size() == 3)
	{
		cout << "Three" << endl;
	}
	else
	{
		cout << "Four" << endl;
	}
	
}

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

int main() {
	int k;
	cin >> k;
	long long tot = 0;
	for(int i = 1; i <= k; ++i)
		for(int j = 1; j <= k; ++j)
			for(int p = 1; p <= k; ++p)
				tot += __gcd(i, __gcd(j, p));
	cout << tot;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

long long int A[210000];
P DP1[210000], DP2[210000];

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	long long int S1 = A[0], S2 = A[1], index = 1;
	DP1[1].first = S1;
	DP1[1].second = S2;
	for(int i = 2; i < N; i++){
		S2 += A[i];
		while(true){
			long long int S1_next = S1 + A[index];
			long long int S2_next = S2 - A[index];
			if(abs(S2 - S1) > abs(S2_next - S1_next)){
				S2 = S2_next;
				S1 = S1_next;
				index++;
			}else{
				break;
			}
		}
		DP1[i].first = S1;
		DP1[i].second = S2;
	}
	
	reverse(A, A + N);
	
	S1 = A[0], S2 = A[1], index = 1;
	DP2[1].first = S1;
	DP2[1].second = S2;
	for(int i = 2; i < N; i++){
		S2 += A[i];
		while(true){
			long long int S1_next = S1 + A[index];
			long long int S2_next = S2 - A[index];
			if(abs(S2 - S1) > abs(S2_next - S1_next)){
				S2 = S2_next;
				S1 = S1_next;
				index++;
			}else{
				break;
			}
		}
		DP2[i].first = S1;
		DP2[i].second = S2;
	}
	
	reverse(DP2, DP2 + N);
	
	long long int ans = INF;
	
	for(int i = 1; i < N - 2; i++){
		long long int p = DP1[i].first;
		long long int q = DP1[i].second;
		long long int r = DP2[i + 1].first;
		long long int s = DP2[i + 1].second;
		//cout << p << " " << q << " " << r << " " << s << endl;
		long long int diff = max(p, max(q, max(r, s))) - min(p, min(q, min(r, s)));
		ans = min(ans, diff);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double a,t;
	cin>>n;
	cin>>t>>a;
	double te[n+1];
	int i,b;
	int ans=0;
	double cha=99999.99;
	for(i=1;i<=n;i++){
		cin>>b;
		te[i]=t-0.006*b;
		//cout<<i<<te[i]<<endl;
		if(abs(te[i]-a)<cha){
			cha=abs(te[i]-a);
			ans=i;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    map<int, int> c;
    for (int i = 0; i < n; i++) {
        if (c.count(a[i]) == 0) {
            c[a[i]] = 0;
        }
    }
    for (int i = 0; i < n; i++){
        c[a[i]]++;
    }

    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    int n_kind = a.size();
    // cout << "n_kind: " << n_kind << endl;

    int rm_kind = n_kind - k;
    // cout << "rm_kind: " << rm_kind << endl;

    vector<int> tmp;
    for (int i = 0; i < n_kind; i++){
        tmp.push_back(c[a[i]]);
        // cout << "c[a[i]]: " << c[a[i]] << endl;
    }
    sort(tmp.begin(), tmp.end());

    int ans = 0;
    for (int i = 0; i < rm_kind; i++){
        ans += tmp[i];
    }

    cout << ans << endl;


    return 0;
}










Measured memory_bytes: 13052
import java.util.Scanner;

public class Main {
	final static int mod = 998244353;
	final static int INF = 100000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		boolean flag = false;

		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
			if (i != 0 && d[i] == 0) flag = true;
		}

		if(d[0] != 0) {
			System.out.println(0);
		}else if(flag) {
			System.out.println(0);
		}else {
			long[] num = new long[INF];
			num[0] = 0;
			int max = 1;
			long count = 1;
			for (int i = 1; i < n; i++) {
				num[d[i]]++;
				max = Math.max(max,d[i]);
			}
			for (int i = 1; i < max; i++) {
				for(int j = 1; j <= num[i+1]; j++) {
					long mul = num[i]%mod;
					count = count * mul;
					count %= mod;
				}
			}
			System.out.println(count);
		}
		sc.close();
	}
}

Measured memory_bytes: 52560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define ll long long 
#define il inline
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 3620
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

signed main(){
	fast_io();
	int k, x;
	cin >> k >> x;
	for(int i = x - k + 1; i <= x + k - 1; i++){
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
def search(a,b):
    na=len(a)
    nb=len(b)
    array = [[0]*(nb+1) for _ in range(na+1)]
    for i in range(na+1):
        array[i][0]=i
    for j in range(nb+1):
        array[0][j]=j
    for i,x in enumerate(a,1):
        prerow=array[i-1]
        row=array[i]
        for j,y in enumerate(b,1):
            if x == y:
                row[j]=prerow[j-1]
            else:
                row[j]=min(prerow[j], prerow[j-1], row[j-1])+1
    #pprint(array)
    return array[-1][-1]

a=input()
b=input()
print(search(a,b))




Measured memory_bytes: 41880
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll a,b;
    cin>>a>>b;
    if (a<b)
    {
        rep (i,0,b)
        {
            cout<<a;
        }
    }
    else
    {
        rep (i,0,a)
        {
            cout<<b;
        }
    }
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	VI a(n);
	VI b(n);
	FOR(i, 0, n) cin >> a[i];
	b = a;
	
	sort(ALL(b));
	bool ok = 0;
	ok |= a == b;
	FOR(i, 0, n) FOR(j, i + 1, n)
	{
		swap(a[i], a[j]);
		ok |= a == b;
		swap(a[i], a[j]);
	}
	
	if (ok) cout << "YES";
	else cout << "NO";
	
	
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    A.append(int(input())-1)  
    
index = 0
count = 1
flag = True
while flag:
    index = A[index]
    if index == 1:
        flag = False
    else:
        count += 1
    if count > N:
        flag = False
        count = -1
print(count)

Measured memory_bytes: 7084
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <set>
#include <map>
#define INT long long
#define MOD 1000000007
#define oo 1987654321

using namespace std;
INT n, t[100001], a[100001], s[100001], e[100001], ans = 1;
int main()
{
    ios::sync_with_stdio(false);

    cin>>n;

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

    for(int i = 0 ; i < n ; i++ )
        if( i == 0 ) s[i] = e[i] = t[i];
        else
        {
            if( t[i] > t[i-1] ) s[i] = e[i] = t[i];
            else s[i] = 1, e[i] = t[i];
        }

    for(int i = n-1 ; i >= 0 ; i-- )
        if( i == n-1 )
        {
            if( s[i] <= a[i] and a[i] <= e[i] )
                s[i] = a[i], e[i] = a[i];
            else
            {
                puts("0");
                return 0;
            }
        }
        else
        {
            if( a[i] > a[i+1] )
            {
                if( s[i] <= a[i] and a[i] <= e[i] )
                    s[i] = a[i], e[i] = a[i];
                else
                {
                    puts("0");
                    return 0;
                }
            }
            else s[i] = max( 1LL, s[i] ), e[i] = min(e[i], a[i]);
        }

    for(int i = 0 ; i < n ; i++ )
    {
        ans *= e[i]-s[i]+1;
        ans %= MOD;
        if( s[i] > e[i] )
        {
            puts("0");
            return 0;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, L;
  cin >> N >> L;
  vector<string> S(N);
  for_each(begin(S), end(S), [](auto& x) { cin >> x; });
  sort(begin(S), end(S));

  string ans;
  for_each(begin(S), end(S), [&](auto& x) { ans += x; });

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


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split(" "))
Xs = [int(a) for a in input().split()]
Ys = [int(a) for a in input().split()]
maxX = X
minY = Y
for i in Xs:
    if i>maxX:
        maxX = i

for i in Ys:
    if i<minY:
        minY = i
        
if maxX < minY:
    print ("No War")
else:
    print ("War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main()
{
	string s, t;
	cin >> s >> t;
	if(s.back() == '\0') s.pop_back();
	if(t.back() == '\0') t.pop_back();
	
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());	
	
	cout << (s<t?"Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 256
#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 <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1e9
typedef long long ll;

#define PI acos(-1)

int a[100010];

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

	int sum = abs(a[0]);
	for (int i = 0; i < n; i++) {
		if (i == n - 1)sum += abs(a[n - 1]);
		else sum += abs(a[i + 1] - a[i]);
	}
	
	for (int i = 0; i < n; i++) {
		int t, p;
		if (i == 0) {
			t = abs(a[0])+abs(a[1]-a[0]);
			p = abs(a[1]);
		}
		else if (i == n - 1) {
			t = abs(a[n - 1]) + abs(a[n - 1] - a[n - 2]);
			p = abs(a[n - 2]);
		}
		else {
			t = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
			p = abs(a[i + 1] - a[i - 1]);
		}
		sum -= t; sum += p;
		cout << sum << endl;
		sum += t; sum -= p;
	}

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> X(N), Y(N);
	REP(i, N) cin >> X[i] >> Y[i];

	bool flag = true;
	int oe = (abs(X[0]) + abs(Y[0]))%2;
	ll ma = 0;
	REP(i, N){
		if (ma < abs(X[i]) + abs(Y[i])) ma = abs(X[i]) + abs(Y[i]);
		if (oe != (abs(X[i]) + abs(Y[i]))%2) flag = false;
	}
	if(!flag){
		cout << -1 << endl;
		return 0;
	}

	vector<ll> ds;
	for(int i=30;i>=0;i--) ds.push_back(1<<i);
	if(oe==0) ds.push_back(1);
	cout << ds.size() << endl;
	REP(i, ds.size()) cout << ds[i] << " ";
	cout << endl;

	REP(i, N){
		ll xdir, ydir;
		ll xsum = 0;
		ll ysum = 0;
		ll Z = X[i] + Y[i];
		ll W = X[i] - Y[i];
		REP(j, ds.size()){
			if(xsum<=Z){
				xdir = 1;
				xsum += ds[j];
			}else{
				xdir = -1;
				xsum -= ds[j];
			}
			if(ysum<=W){
				ydir = 1;
				ysum += ds[j];
			}else{
				ydir = -1;
				ysum -= ds[j];
			}
			if(xdir==1 && ydir==1) cout << "R";
			else if(xdir==1 && ydir==-1) cout << "U";
			else if(xdir==-1 && ydir==1) cout << "D";
			else if(xdir==-1 && ydir==-1) cout << "L";
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int w, h, n;
    std::cin >> w >> h >> n;

    int left = 0, bottom = 0;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        std::cin >> x >> y >> a;

        switch (a) {
        case 1:
            left = std::max(left, x);
            break;
        case 2:
            w = std::min(w, x);
            break;
        case 3:
            bottom = std::max(bottom, y);
            break;
        case 4:
            h = std::min(h, y);
            break;
        }
    }

    std::cout << ((w - left > 0 && h - bottom > 0) ? std::max(0, (w - left) * (h - bottom)) : 0) << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(b+c<=a)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<b+c-a<<endl;
	}
}

Measured memory_bytes: 888
import sys
input = sys.stdin.readline

S = input().split()
S = list(S[0])
ans=100000000
for i in range(len(S)-2):
    s = ""
    for j in range(3):
        s+=S[i+j]
    if abs(int(s)-753) < ans:
        ans = abs(int(s)-753)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll t,x;


int main(int argc, char** argv) {
	cin>>n>>t;
	ll sum = 0, now = -1, st;
	cin>>x;now = x + t;st = x;
	for(int i=1;i<n;i++) {
		scanf("%lld",&x);
		if(x>now) {
			sum += (now - st);
			st = x;
		}
		now = x + t;
	}
	sum += (now - st);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a1 = Integer.parseInt(sc.next());
    int a2 = Integer.parseInt(sc.next());
    int a3 = Integer.parseInt(sc.next());
    
    if (a1 + a2 + a3 >= 22) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}


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

int main() {
  string s;
  cin >> s;
  string t[4] = {"dream", "dreamer", "erase", "eraser"};
  while (!s.empty()) {
    bool flag = false;
    for (int i = 0; i < 4; i++) {
      if (s.rfind(t[i]) == s.size() - t[i].size()) {
        s = s.substr(0, s.size() - t[i].size());
        flag = true;
      }
    }
    if (!flag) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    ll ans=0;
    for(i=1;i<=n;i++)
        ans+=i*(n-i+1);
    for(i=0;i<(n-1);i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x>y)
            swap(x,y);
        ans-=x*(n-y+1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int janten(int r, int s, int p, char rsp){
  
  if (rsp =='r'){return p;}
  if (rsp == 'p'){return s;}
  if (rsp == 's'){return r;}
}

int main() {
  int n,k,r,s,p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;

  int ten = 0;

  for (int i = 0; i < n; i++){
    if (i >= k && t.at(i-k) == t.at(i)){
      ten = ten;
      t.at(i)='h';}
    else{ten += janten(r,s,p,t.at(i)); }
  }
  cout << ten;
  }



Measured memory_bytes: 512
/*input
10
8 5
10 8
6 5
1 5
4 8
2 10
3 6
9 2
1 7
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

vector<vector<int>> adj;
vector<vector<ll>> dp;

void dfs(int v, int p)
{
	for(int i = 0; i < adj[v].size(); i++) if(adj[v][i] != p)
	{
		dfs(adj[v][i], v);
		dp[v][0] = (dp[v][0] * ((dp[adj[v][i]][0] + dp[adj[v][i]][1]) % MOD)) % MOD;
		dp[v][1] = (dp[v][1] * dp[adj[v][i]][0]) % MOD;
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    adj.resize(n);
    dp.resize(n);
    for(int i = 0; i < n; i++)
    {
    	dp[i].resize(2);
    	dp[i][0] = dp[i][1] = 1;
    }
    for(int i = 0; i < n - 1; i++)
    {
    	int u, v; cin >> u >> v;
    	u--; v--;
    	adj[u].push_back(v);
    	adj[v].push_back(u);
    }
    dfs(0, -1);
    cout << (dp[0][0] + dp[0][1]) % MOD;

    return 0;
}

Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
string s;
int a[maxn];
int b[maxn];
int main()
{
 cin>>s;
 int len=s.size();

    int sum=0;
  for(int i=0;i<len;)
  {
      if(s[i]=='R')
        sum++,i++;
      else
      {
      int temp=i;
          int cnt=0;
          while(s[i]=='L'&&(i)<len)
                cnt++,i++;
            int e=max(sum,cnt)-1;
            int t=sum-cnt;
            if(t==0)
            a[temp]=a[temp-1]=sum;
            if(t%2==0)
            {
                a[temp]=a[temp-1]=(sum+cnt)/2;
            }
            else
            {
               if(e%2==0)
               {
                   if(sum>cnt)
                   {
                        a[temp]=(sum+cnt)/2;
                        a[temp-1]=(sum+cnt)/2+1;
                   }
                   else
                   {
                        a[temp]=(sum+cnt)/2+1;
                        a[temp-1]=(sum+cnt)/2;
                   }
               }
               else
               {
                     if(sum>cnt)
                     {
                      a[temp]=(sum+cnt)/2+1;
                        a[temp-1]=(sum+cnt)/2;
                     }
                     else
                     {
                         a[temp]=(sum+cnt)/2;
                        a[temp-1]=(sum+cnt)/2+1;
                     }

               }

            }

            sum=0;

      }

  }
  for(int i=0;i<len;i++)
    printf("%d%c",a[i],i==len-1?'\n':' ');
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define sz(x) x.size()

using namespace std;

int main(){
    int n;cin>>n;
    vector<long long>a(n+1),b(n);
    for(int i = 0;i <=n;i++){
        cin>>a[i];
    }
    long long ans = 0;
    for(int i = 0;i <n;i++){
        cin>>b[i];
        if(a[i]<b[i]){
            ans+=a[i];
            b[i]-=a[i];
            ans+=min(a[i+1],b[i]);
            a[i+1]-=min(a[i+1],b[i]);
        }
        else{
            ans+=b[i];
            b[i]-=b[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int co=0;
    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
		if(a%4==0)co+=2;
		else if(a%2==0)co++;
    }
    if(co>=n/2*2)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  int n;
  cin >> n;


  int v[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) {
      sum += (v[i] - c[i]);
    }
  }

  cout << sum << endl;
}

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

bool judge(int dice1[], int dice2[]);
bool subJudge(const int dice1[], const int dice2[]);
void moveE(int dice[]);
void moveN(int dice[]);
void moveS(int dice[]);
void moveW(int dice[]);
void moveR(int dice[]);

int main(void)
{	
	int n;
	cin >> n;
	
	int dice[100][6];
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < 6; i++) {
			 cin >> dice[j][i];
		}
		for (int k = 0; k < j; k++) {
			if (judge(dice[k], dice[j])) {
				cout << "No" << endl;
				return 0;
			}
		}
	}	
	cout << "Yes" << endl;
	
	return 0;
}

bool judge(int dice1[], int dice2[])
{
	for (int i = 0; i < 4; i++) {
		moveE(dice2);
		for (int j = 0; j < 4; j++) {
			moveN(dice2);
			for (int k = 0; k < 4; k++) {
				moveR(dice2);
				if (subJudge(dice1, dice2)) {
					return true;
				}
			}
		}
	}
	return false;
}

bool subJudge(const int dice1[], const int dice2[])
{
	for (int i = 0; i < 6; i++) {
		if (dice1[i] != dice2[i]) return false;
	}
	return true;
}

void moveE(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = temp;
}

void moveN(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[4];
	dice[4] = temp;
}

void moveS(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = temp;
}

void moveW(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[2];
	dice[2] = dice[5];
	dice[5] = dice[3];
	dice[3] = temp;
}

void moveR(int dice[])
{
	int temp = dice[1];
	dice[1] = dice[2];
	dice[2] = dice[4];
	dice[4] = dice[3];
	dice[3] = temp;
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static long[] ans = new long[]{-1,-1,-1};
	public static void main(String[] args) throws Exception {


		int N=nextInt();

		int[] h = nextInts();
		int i=0;
		int ans = 0;
		while(i<h.length){
			int min=10101;
			for(int k=i;k<N;k++){
				if(h[k]==0){
					break;
				}
				min=Math.min(min, h[k]);
			}
			for(int k=i;k<N;k++){
				if(h[k]==0){
					break;
				}
				h[k]-=min;
			}
			if(min!=10101){
				ans+=min;
			}
			if(h[i]==0){
				i++;
				continue;
			}
		}
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#-*- coding:utf-8 -*-
from heapq import heappush, heappop
func1 = lambda A,B,C: [(A+1,B+1,C),(A,B+1,C+1),(A+1,B,C+1)]
func2 = lambda A,B,C: [(A+2,B,C),(A,B+2,C),(A,B,C+2)]
def cost_func(A,B,C):
	return abs(A-B)+abs(A-C)+abs(B-C)
def makeNode(alphabets,count):
	A,B,C = alphabets
	return cost_func(A,B,C),A,B,C,count+1

A,B,C = [int(n) for n in input().split()]
first_cost = cost_func(A,B,C)
nodes = [(first_cost,A,B,C,0)]
check = set()
check.add((A,B,C))
while len(nodes)!=0:
	cost,A,B,C,count = heappop(nodes)
	if cost == 0:
		print(count)
		break
	for alphabets in func1(A,B,C) + func2(A,B,C):
		A,B,C = alphabets
		cost = cost_func(A,B,C)
		if alphabets not in check:
			check.add(alphabets)
			heappush(nodes,(cost,A,B,C,count+1))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x=sc.nextLong();
		long count=0;
		if(x>11){
			count+=2*(x/11);
			x=x%11;
		}
		if(x>6){
			count+=2;
			x-=11;
		}
		if(x>0)count++;
		
		System.out.println(count);
	}
}


Measured memory_bytes: 9808
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(final String[] args) {
        try(final Scanner scanner = new Scanner(System.in);) {
            final int n = scanner.nextInt();
            final int[] allInput = IntStream.rangeClosed(1, n).map(i -> scanner.nextInt()).toArray();

            int[] judgeNumbers = allInput;
            int cnt = 0;
            // 全て偶数の場合、配列のすべての値を2で割る
            // この操作が何回できるのかカウントする
            while (Arrays.stream(judgeNumbers).allMatch(i -> i % 2 == 0)) {
                judgeNumbers = Arrays.stream(judgeNumbers).map(i -> i / 2).toArray();
                cnt++;
            }
            System.out.println(cnt);

        }
    }
}


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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;

struct prime
{
  vector<bool> num;
  prime(int n) : num(n+1, true)
  {
    num[0] = false;
    num[1] = false;
    for(int i = 2; i <= n; i++) {
      if(num[i]) {
        for(int j = 2; i*j <= n; j++) num[i*j] = false;
      }
    }
  }
  bool isPrime(int x)
  {
    return num[x];
  }
};
struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

long long gcd(long long a, long long b)
{
  if (a < b)
    swap(a, b);
  while (true)
  {
    if (a % b == 0ll)
      break;
    ll _a = a;
    a = b;
    b = _a % b;
  }
  return b;
}

long long lcm(long long a, long long b)
{
  return (max(a, b) / gcd(a, b)) * min(a, b);
}

void solve()
{
  ll a, b;
  cin >> a >> b;
  ll ans = (b - a)*(b - a + 1) / 2ll - b;
  cout << ans << "\n";
}

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


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

class Main {

    // Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String s;
        s = sc.next();
        solve(s);
    }

    static void solve(String s){
        String[] str = s.split("");
        int n = str.length;
        int k[] = new int[(int)n+1];
        for(int i = 1 ; i <= n ; i++) k[i] = Integer.parseInt(str[i-1]);
        if( k[1] == 0 || k[n] == 1) exit();
        for(int i = 1 ; i < (n+1)/2 ; i++){
            if(k[i] != k[n-i]) exit();
        }
        int v[] = new int[(int)n];
        int next_one = 1;
        for(int i = 1 ; i < n ; i++){
            if(k[i] == 1){
                for(int j = i+1 ; j < n ; j++){
                    if(k[j] == 1){
                        v[i] = j;
                        next_one = j;
                        break;
                    }
                }
            }else{
                v[i] = next_one;
            }
            v[n-1] = n;
            System.out.println(i + " " + v[i]);
        }
    }

    static void exit(){
        System.out.println(-1);
        System.exit(0);
    }
}


Measured memory_bytes: 55948
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << (e - a <= k ? "Yay!" : ":(");
    
    
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int r=0,g=0,b=0;
  rep(i,n){
    if(s[i]=='R')r++;
    if(s[i]=='G')g++;
    if(s[i]=='B')b++;
  }
  ll ans = r*g*b;
  rep(j,n)rep(i,j){
    if(s[i]!=s[j]){
      if(2*j-i>=n)continue;
      if(s[i]!=s[2*j-i]&&s[j]!=s[2*j-i])ans--;
    }
  }
  cout << ans << endl;
}

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

const ll B = 41;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, K;
	cin >> N >> K;
	vector<ll> a(N), sum(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	ll res = 0;
	for (ll b = B - 1; b >= 0; b--) {
		res |= 1LL << b;
		ll cnt = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (((sum[j] - sum[i]) & res) == res) ++cnt;
			}
		}
		if (cnt < K) {
			res -= 1LL << b;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n, t; cin>>n>>t;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];

  multiset<ll> st;
  ll mi = inf;
  rep(i, n) {
    mi = min(mi, a[i]);
    st.insert(a[i]-mi);
  }

  cout << st.count(*st.rbegin()) << endl;

  return 0;
}


Measured memory_bytes: 8788