akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

int main()
{
    /*ABC144 B
    int x;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(x==i*j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    */
    
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
           if(s[i+1]=='B')
           {
               if(s[i+2]=='C')
               {
                   count++;
               }
           }
        }
    }
    cout<<count<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	ll n; cin >> n; vector<ll> a(n), b(n);
	for(ll i = 0; i < n; i++)cin >> a[i];
	for(ll i = 0; i < n; i++)cin >> b[i];
	ll amari = 0;

	for(int i = 0; i < n; i++) amari += max(0LL, (b[i] - a[i]) / 2);
	for(int i = 0; i < n; i++) {
		if(a[i] <= b[i])continue;
		if(amari + b[i] >= a[i]) {
			amari -= (a[i] - b[i]);
		}else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
};

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  long long ans = n;
  int now = 0;
  for (int i = 0, j; i < n; i = j) {
    for (j = i + 1; j < n && a[j] == a[j - 1] + 1; ++j);
    if (a[i] > now) return puts("-1"), 0;
    now = j - i + a[i];
    ans += a[i] - 1;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
N = int(input())

if N == 2:
    print(1)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+100):
        if i > temp / i:
            break
        if i * i == temp:
            arr.append(i)
            break
        if temp % i == 0:
            arr.append(i)
            arr.append(temp // i)
    arr.append(n)
    return arr

N_div = factorization(N)
N_1_div = factorization(N-1)


ans = len(N_1_div)
for K in N_div:
    temp = N
    while temp % K == 0:
        temp = temp // K
    if temp % K == 1:
        ans += 1
print(ans)


Measured memory_bytes: 3188
#pragma region Header

#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

template <typename T>
int SZ(T x)
{
    return static_cast<int>(x.size());
}

#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int a, b, c;
    cin >> a >> b >> c;
    set<int> s = {a, b, c};
    cout << (s.size() == 2 ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,P[1000010],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&P[i]);
	for(int i=2;i<=n-1;i++){
		int tmp=0;
		if(P[i]>P[i-1])tmp++;
		if(P[i]>P[i+1])tmp++;
		if(tmp==1)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int L, R, d, ans;
  ans = 0;
  cin >> L >> R >> d;
  for (int i = L; i <= R; ++i) {
    if (i % d == 0) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3744
def search_binary(target_list, target_length, key_value):
    exit_flag = False
    left = 0
    right = target_length
    while left < right:
        mid = int((left + right)/2)
        if target_list[mid] == key_value:
            exit_flag = True 
            break
        elif target_list[mid] > key_value:
            right = mid
        else:
            left = mid + 1
    return exit_flag

target_length = int(input())
target_list = list(map(int,input().split()))
key_length = int(input())
key_list = list(map(int,input().split()))

exit_count = 0
for key_value in key_list:
    exit_count += 1 if search_binary(target_list, target_length, key_value) else 0
print(exit_count)


Measured memory_bytes: 16708
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;


///a^b % MOD
ll bigMod(ll a , ll b) {

    ll p ;
    if( b == 0) return 1;
    p = ( bigMod(a , b/2) % MOD );
    p = ( p * p) % MOD;
    if( b & 1 ) p = ( p * a) % MOD;
    return p;
}
int main() {
    ll n; 
    cin>>n;
    ll a = bigMod(10 , n);
    ll b = bigMod(9 , n);
    ll c = bigMod(8 , n);
    ll ans = (a + c)%MOD;
    ans = (ans - b + MOD) %MOD;
    ans = (ans - b + MOD) %MOD;
    cout<<ans<<'\n';


    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define inf 1000000000000000000ll
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c;
	c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const int maxn=50+5;
int n,a[maxn],b[maxn],c[maxn];
ll dis[maxn][maxn],res;
vector<int>v;
//
void finit(int x)
{
	rep(i,50+1)rep(j,50+1)dis[i][j]=1ll*(i!=j)*inf;
	rep(i,50+1)
	{
		for(int j=1;j<=x;j++)dis[i][i%j]=min(dis[i][i%j],(1ll<<j));
		rep(j,v.size())dis[i][i%v[j]]=min(dis[i][i%v[j]],(1ll<<v[j]));
	}
}
bool doit(int x)
{
	finit(x);
	rep(i,50+1)rep(j,50+1)rep(k,50+1)dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k]);
	rep(i,n)if(dis[a[i]][b[i]]>=inf)return false;
	return true;
}
int main()
{
	n=getint();
	rep(i,n)a[i]=getint();
	rep(i,n)b[i]=getint();
	int p=50;
	bool flag=false;
	while (1)
	{
		if(doit(0))break;
		if(!p)
		{
			res=-1;
			break;
		}
		for(int i=1;i<=p;i++)if(doit(i))
		{
			v.push_back(i);
			p=i-1;
			res|=(1ll<<i);
			flag=true;
			break;
		}
		if(!flag)
		{
			res=-1;
			break;
		}
	}	
	printf("%lld\n",res);
	return 0;	
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;
	cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	vector<ll> x(n);
	ll mm = 0;
	for (ll i = 0; i < n; ++i) {
		cin >> x[i];
		if (mm < x[i]) {
			mm = x[i];
		}
	}
	ll m = 1LL << 60;
	for (ll i = 0; i < mm + 1; ++i) {
		ll s = 0;
		for (ll j = 0; j < n; ++j) {
			s += (i - x[j]) * (i - x[j]);
		}
		if (s < m) {
			m = s;
		}
	}

	cout << m << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func IsKaibun(S string) bool {
	N := len(S)
	for i := 0; i < N/2; i++ {
		if S[i] != S[N-1-i] {
			return false
		}
	}
	return true
}

func main() {
	stdin.Split(bufio.ScanWords)
	S := nextStr()
	N := len(S)
	SS := S[:(N-1)/2]
	SSS := S[(N+3)/2-1:]

	if IsKaibun(S) && IsKaibun(SS) && IsKaibun(SSS) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt64() int64 {
	stdin.Scan()
	i, err := strconv.ParseInt(stdin.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    int a, b;
    int i1[200001] = { 0 } , in[200001] = { 0 };

    cin >> n >> m;

    for (int i=0; i<m; i++) {
        cin >> a >> b;
        if (min(a, b) == 1) {
            i1[max(a, b)] = 1;
        }
        else if (max(a, b) == n) {
            in[min(a, b)] = 1;
        }
    }

    for (int i=1; i<n; i++) {
        if(i1[i] && in[i]) {
            cout << "POSSIBLE" << endl;

            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 1792
n, m = map(int, input().split())
mod = 10**9 + 7

factorial = [1]
inverse = [1]
for i in range(1, m+1):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))
def comb(n, r, mod):
    if n < r or r < 0: return 0
    elif r == 0: return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod
def perm(n, r, mod):
    if n < r or r < 0: return 0
    elif r == 0: return 1
    return factorial[n] * inverse[n - r] % mod

ans = 0
for i in range(n+1):
    ans += (-1)**i * comb(n, i, mod) * perm(m, i, mod) * (perm(m-i, n-i, mod))**2
    ans %= mod
print(ans)

Measured memory_bytes: 155352
#include <stdio.h>
 
int main(void){
  int i,j,v,a[100],n;
   
  scanf("%d",&n);
  for(i=0; i<n; ++i){
    scanf("%d",&a[i]);
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  
 }
  printf("\n");
 
  for(i=1; i<n; i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
       
    }
    a[j+1]=v;
     
    for(j=0;j<n;j++){
      printf("%d",a[j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
int n,ans = 2147483647,a[105];
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = -100; i <= 100; i++) {
		int num = 0;
		for(int j = 1; j <= n; j++)
			num += (a[j] - i) * (a[j] - i);
		ans = min(ans,num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#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 vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,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 rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll 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 T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
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;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vi a(n,0);
	rep(i,n){
		int t;
		cin>>t;
		a[t-1]=i+1;
	}
	puta(a);
	return 0;
}

Measured memory_bytes: 1664
package main

import (
	"fmt"
	"math"
)

var N, K int
var ans int = 9999999999

func main() {
	fmt.Scan(&N)
	a := make([]int, N)

	var sum int
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	average_1 := sum / len(a)
	average_2 := sum/len(a) + 1

	var res_1, res_2 int
	for i := 0; i < N; i++ {
		res_1 += pow(a[i]-average_1, 2)
	}
	for i := 0; i < N; i++ {
		res_2 += pow(a[i]-average_2, 2)
	}

	fmt.Println(min(res_1, res_2))
}

/*  ----------------------------------------  */

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
using namespace std;
int main(){
  string s;
  cin>>s;
  s[0] = '2';
   s[1] = '0';
   s[2] = '1';
 s[3] = '8';
  cout<<s<<endl;
 return 0; 
}

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

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

  int maxval = 1;
  int maxnum = 0;
  for (int i = 1; i <= n; ++i) {
    int tmp = i;
    int num = 0;
    while (tmp % 2 == 0) {
      tmp = tmp / 2;
      ++num;
    }
    
    if (num > maxnum) {
      maxnum = num;
      maxval = i;
    }
  }

  cout << maxval << endl;
  return 0;
}

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

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

  bool odd = 1;
  bool even = 1;
  
  for (int i= 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S.at(i) == 'L') {
        even = 0;
      }
    }
    if (i % 2 == 1) {
      if (S.at(i) == 'R') {
        odd = 0;
      }
    }
  }
  if(odd == 1 && even == 1) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}





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

int main() {
  int p, q, r;
  vector<int> ans;
  cin >> p >> q >> r;

  ans.push_back(p);
  ans.push_back(q);
  ans.push_back(r);

  sort(ans.begin(), ans.end());

  cout << ans[0] + ans[1] << endl;


  


  return 0;
}

Measured memory_bytes: 256
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
#define bp __builtin_popcount
typedef long long ll;
const ll MAX_N = 3000+10;
const ll MOD = 1e9+7;
using namespace std;

int dp1[MAX_N];
int dp2[MAX_N];
int sum[MAX_N];
int a[MAX_N];
int n;

int main()
{
    string s;
    cin >> n >> s;
    for(int i = 2;i<=n;++i)
        a[i] = (s[i-2]=='<');
    dp1[1] = 1;
    for(int i = 1;i<=n;++i)
        sum[i] = 1;
    for(int i = 2;i<=n;++i)
    {
        for(int j = 1;j<=i;++j)
        {
            if (a[i])
                dp2[j] += sum[j-1];
            else
                dp2[j] += (sum[n]-sum[j-1]+MOD)%MOD;
            dp2[j] %= MOD;
        }
        memset(sum , 0 , sizeof sum);
        memcpy(dp1 , dp2, sizeof dp1);
        memset(dp2, 0 , sizeof dp2);
        for(int j = 1;j<=n;++j)
            sum[j] = (sum[j-1]+dp1[j])%MOD;
    }
    cout << sum[n];
    return 0;
}


Measured memory_bytes: 256
class Node
  attr_accessor :parent, :rank

  def initialize
    @parent = -1 # Positive value means its parent,and Negative value means its size.
    @rank = 0
  end
end

class UnionFindTree
  def initialize(n)
    @nodes = (0..n).to_a.map { |i| Node.new }
  end

  def find(x)
    return @nodes[x].parent < 0 ? x : @nodes[x].parent = find(@nodes[x].parent)
  end

  def unite(a, b)
    a = find(a)
    b = find(b)
    return if a == b

    if @nodes[a].rank < @nodes[b].rank
      @nodes[b].parent += @nodes[a].parent
      @nodes[a].parent = b
    else
      @nodes[a].parent += @nodes[b].parent
      @nodes[b].parent = a
      @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
    end
  end

  def same?(a, b)
    find(a) == find(b)
  end
  
  def size(a)
    -@nodes[find(a)].parent
  end

  # 確認用。アルゴリズムとは関係無い
  def parents
    @nodes.map(&:parent)
  end
end

N, M = gets.split.map(&:to_i)

class Bridge
  attr_accessor :first, :second

  def initialize
    @first = nil
    @second = nil
  end
  
  def nodes=(a)
    a[0], a[1] = a[1], a[0] if a[0] > a[1]
    @first = a[0]
    @second = a[1]
  end
  
end

bridges = (0...M).to_a.map { Bridge.new }

M.times do |i|
  bridge = gets.split.map(&:to_i)
  bridge.map! { |n| n - 1 }
  bridges[i].nodes = bridge
end
# p bridges

f = Array.new(N, N)
ans = Array.new(M, 0)

inco = N * ( N - 1 ) / 2 # inconvenience

n = N
q = M

uft = UnionFindTree.new(n)

q.times do |i|
  
  j = (M-1)-i
  ans[j] = inco
  
  x, y = bridges[j].first, bridges[j].second
  
  inco -= uft.size(x) * uft.size(y) if !uft.same?(x, y)
  break if inco == 0
  
  uft.unite(x, y)
  
end

puts ans


Measured memory_bytes: 18940
#include <iostream>
#include <vector>
using namespace std;
int main() {
	while (1) {
		int a, b, c, n;
		cin >> a >> b >> c;
		vector<int>v(a + b + c + 5, 2);
		if (a == 0 && b == 0 && c == 0) return 0;
		cin >> n;
		int i[1005], j[1005], k[1005], r[1005];
		for (int m = 0; m < n; m++) {
			cin >> i[m] >> j[m] >> k[m] >> r[m];
			if (r[m] == 1) {
				v[i[m]] = 1;
				v[j[m]] = 1;
				v[k[m]] = 1;
			}
		}
		for (int p = 0; p < 2; p++) {
			for (int m = 0; m < n; m++) {
				if (r[m] == 0) {
					if (v[i[m]] != 1 && v[j[m]] == 1 && v[k[m]] == 1) v[i[m]] = 0;
					if (v[j[m]] != 1 && v[i[m]] == 1 && v[k[m]] == 1) v[j[m]] = 0;
					if (v[k[m]] != 1 && v[j[m]] == 1 && v[i[m]] == 1) v[k[m]] = 0;
				}
			}
		}
		for (int m = 1; m < a + b + c+1; m++) {
			cout << v[m] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
struct po{
    ll a, b, c, d;
};
int main(){
    ll H, W;
    cin >> H >> W;
    ll a[H][W];
    vector<po> ans;
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++) cin >> a[i][j];
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++){
        ll dh[] = {1, 0};
        ll dw[] = {0, 1};
        for(ll k = 0; k < 2; k++){
            ll ni = i + dh[k], nj = j + dw[k];
            if(!(0 <= ni && ni < H && 0 <= nj && nj < W)) continue;
            if((a[i][j] & 1)){
                a[ni][nj] += a[i][j];
                a[i][j] = 0;
                ans.push_back(po{i, j, ni, nj});
                break;
            }
        }
    }
    cout << ans.size() << endl;
    for(auto yo : ans) cout << yo.a + 1 << " " << yo.b + 1 << " " << yo.c + 1 << " " << yo.d + 1 << endl;
    return 0;
}



Measured memory_bytes: 8432
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a + b) > (c + d))cout << "Left" << endl;
	else if ((a + b) < (c + d))cout << "Right" << endl;
	else cout << "Balanced" << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1e8;


int main(){
  int N;
  cin >> N;
  ll A[N+1],B[N+1],C[N+1];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  A[N] = INFLL;
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  C[N] = INFLL;
  sort(A,A+N);
  sort(C,C+N);
  ll sum=0;
  for(ll i=0; i<N; i++){
    ll *a;
    a = lower_bound(A,A+N,B[i]);
    ll ai;
    ai = distance(A,a);
    ll *c;
    c = lower_bound(C,C+N,B[i]+1);
    ll ci;
    ci = distance(C,c);
    sum += ai*(N-ci);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 2147483647

int N,input[263000];
vector<int> SegTree[263000];

void construct_segtree(int node_id,int node_left,int node_right){
	if(node_left == node_right){

		SegTree[node_id].push_back(input[node_left]);
	}else{
		construct_segtree(2*node_id+1,node_left,(node_left+node_right)/2);
		construct_segtree(2*node_id+2,(node_left+node_right)/2+1,node_right);
		SegTree[node_id].resize(node_right-node_left+1);

		merge(SegTree[2*node_id+1].begin(),SegTree[2*node_id+1].end(),SegTree[2*node_id+2].begin(),SegTree[2*node_id+2].end(),SegTree[node_id].begin());

	}
}

int calc(int base_value,int search_left,int search_right,int node_id,int node_left,int node_right,bool isUpper){

	if(search_right < node_left || search_left > node_right){
		return 0;
	}

	if(search_left <= node_left && search_right >= node_right){

		int left = 0,right =  SegTree[node_id].size()-1,m = (left+right)/2,index=-1;

		if(isUpper){
			while(left <= right){
				if(SegTree[node_id][m] > base_value){
					index = m;
					right = m-1;
				}else{
					left = m+1;
				}
				m = (left+right)/2;
			}

			if(index == -1){
				return 0;
			}else{
				return SegTree[node_id].size()-index;
			}

		}else{
			while(left <= right){
				if(SegTree[node_id][m] < base_value){
					index = m;
					left = m+1;
				}else{
					right = m-1;
				}
				m = (left+right)/2;
			}

			if(index == -1){
				return 0;
			}else{
				return index+1;
			}
		}
	}

	int left_num = calc(base_value,search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2,isUpper);
	int right_num = calc(base_value,search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right,isUpper);

	return left_num+right_num;

}

int main(){

	int first_N;

	scanf("%d",&first_N);
	N = 1;

	while(N < first_N)N *= 2;

	for(int i = 0; i < N; i++)input[i] = BIG_NUM;

	for(int i = 0; i < first_N; i++){
		scanf("%d",&input[i]);
	}

	construct_segtree(0,0,N-1);

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

	int left,right,diff,ans;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&left,&right,&diff);
		left--;
		right--;
		ans = calc(max(input[left],input[right])+diff,left,right,0,0,N-1,true);
		ans += calc(min(input[left],input[right])-diff,left,right,0,0,N-1,false);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 25048
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main(){
    ll n;
    std::cin >> n;
    vector<ll> p(n);
    vector<ll> q(n);
    ll k = 1;
    ll mk = 1;
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i]--;
        q[p[i]]=i;
    }
    for (int i = 0; i < n-1; i++) {
        if(q[i+1] - q[i]>0){
            k++;
            mk = max(mk,k);
        }else{
            k=1;
        }
    }
    std::cout << n-mk << std::endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define LL unsigned long long int
using namespace std;
#define MAXN 10000001 
vector<LL> findDivisors(LL N) 
{ 
    vector<LL> div(N+1,0); 
    for (LL i = 1; i<= N; i++) { 
        for (LL j = 1; j * i <= N; j++) 
            div[i * j]++; 
    } 
    return div;
} 
int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    LL N;
    cin>>N;
    LL ans=0;
    vector<LL> arr=findDivisors(N);
    for(LL i=1;i<=N;i++)
    {
        ans+=i*arr[i];
    }
    cout<<ans;

}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return a + b;
	}
	
	T get(int k){return dat[k+n-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

bool check(ll mid,vector<ll> &v){
	ll ret = 0;
	vector<ll> now;
	REP(i,v.size()){
		if(v[i] >= mid)now.PB(1);
		else now.PB(-1);
	}
	
	DBG(SHOW1d(now,now.size()));
	
	ll mi = 0;
	REP(i,now.size()){
		if(i < now.size() - 1)now[i+1] += now[i];
		mi = min(mi,now[i]);
	}
	DBG(SHOW1d(now,now.size()));
	REP(i,now.size())now[i] -= mi;
	
	segtree<ll> sg(v.size()+2,0);
	sg.update(-mi,1);
	
	DBG(SHOW1d(now,now.size()));
	DBG(cout << "   ";REP(i,now.size())cout << sg.get(i) << ' ';cout << ret << endl;)
	REP(i,now.size()){
		ret += sg.que(0,now[i]+1);
		sg.update(now[i],sg.get(now[i])+1);
		DBG(cout << "   ";REP(i,now.size())cout << sg.get(i) << ' ';cout << ret << endl;)
	}
	
	DBG(cout << ret << ' ' << v.size() * (v.size()+1) / 4 << endl;)
	return ret >= v.size() * v.size() / 4;
}

int main(){
	
	int n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	ll tb = LLINF;
	ll ub = -LLINF;
	
	if(n == 1){
		cout << v[0] << endl;
		return 0;
	}
	
	while(abs(tb-ub) > 1){
		ll mid = (tb + ub) / 2;
		if(check(mid,v))ub = mid;
		else tb = mid;
		DBG(cout << mid << endl;)
	}
	
	cout << ub << endl;
	
	return 0;
}


Measured memory_bytes: 4944
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define INF 1e9

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

  int dp[200000];
  for (int i = 1; i <= N; i++) {
    dp[i] = INF;
  }

  dp[0] = 0;
  for (int i = 1; i <= N; i++) {
    int k = 1;
    while (k <= i) {
      dp[i] = min(dp[i], dp[i - k] + 1);
      k *= 6;
    }
    k = 1;
    while (k <= i) {
      dp[i] = min(dp[i], dp[i - k] + 1);
      k *= 9;
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
def int_(num_str):
    return int(num_str) - 1


N, M = map(int, input().split())
ablist = [list(map(int_, input().split())) for _ in range(M)]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i != j:
            uf.union(*ablist[j])
    if uf.group_count() >= 2:
        ans += 1
print(ans)


Measured memory_bytes: 3188
n = int(input())
nums = list(map(int, input().split()))
nums.sort(reverse=True)
if nums[-1] == 0:
    print(0)
else:
    ans = 1
    for num in nums:
        ans *= num
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)

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

using namespace std;
#define ll long long

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    char n;
    cin>>n;
    if(n>='A'&&n<='Z')
    {
        cout<<'A';
        return 0;

    }
    if(n>='a'&&n<='z')
    {
        cout<<'a';
        return 0;

    }

}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
ll n,c,k;
vector<ll> v;
ll make(vector<ll> &a,vector<ll> &a2,vector<ll> b){
    priority_queue<ll> p,q;
    ll stock = 0;
    rep(i,n){
        stock += v[i]-2*b[i];
        p.push(stock+b[i]);
        q.push(stock);
        stock += 2*b[i];
        a.push_back(q.top());
        a2.push_back(p.top());
    }
    return p.top();
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> c;
    vector<ll> clock(n),rclock(n);
    v.resize(n);
    rep(i,n){
        cin >> k >> v[i];
        clock[i] = k;
        rclock[i] = c-k;
    }
    vector<ll> cm,rcm,cm2,rcm2;
    ll a,b;
    a = make(cm,cm2,clock);
    reverse(all(v));
    reverse(all(rclock));
    b = make(rcm,rcm2,rclock);
    ll ans = 0;
    rep(i,n-1){
        chmax(ans,cm[i]+rcm2[n-i-2]);
        chmax(ans,cm2[i]+rcm[n-i-2]);
    }
    PRINT(max({ans,a,b,0ll}));
}


Measured memory_bytes: 10404
#include <algorithm>
//#include <cstdio>
//#include <functional>
//#include <bits/stdc++.h>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
using namespace std;
 
int main()
{
	int n,i,j;
	long long c,ans,temp;

	cin>>n>>c;
	
	vector<int> v(n),max_xs(n,-1),max_xn(n,-1); //-1代表起始位置 
	vector<long long> x(n),max_vs(n,0),max_vn(n,0);

	for(i=0;i<n;i++) cin>>x[i]>>v[i];
	
	long long maxv=0;
	int maxx=-1;
	temp=0;
	for(i=0;i<n;i++) {//顺时针依次计算以每个点为终点的路径上所能达到的最大v及对应的点 
		temp-=x[i];
		if(i>0) temp+=x[i-1];
		temp+=v[i];
		if(temp>maxv) {//新的记录i 
			maxv=temp;
			maxx=i;
		} 
		max_vs[i]=maxv;
		max_xs[i]=maxx;		
	}

	maxv=0;
	maxx=-1;
	temp=0;
	for(i=n-1;i>=0;i--) {//逆时针依次计算以每个点为终点的路径上所能达到的最大v及对应的点 
		temp-=(c-x[i]);
		if(i<n-1) temp+=(c-x[i+1]);
		temp+=v[i];
		if(temp>maxv) {//新的记录i 
			maxv=temp;
			maxx=i;
		} 
		max_vn[i]=maxv;
		max_xn[i]=maxx;		
	}	
	
	ans=0;	
//全顺和全逆单独处理
	ans=max(ans,max_vs[n-1]);
	ans=max(ans,max_vn[0]);	
//查找两个方向组合和的最大值: 4选1：仅顺，仅逆，先顺后逆，先逆后顺 
	for(i=0;i<n-1;i++) {
		temp=max(max_vs[i],max_vn[i+1]);
		if(max_xs[i]>=0) temp=max(temp,max_vs[i]+max_vn[i+1]-x[max_xs[i]]);
		if(max_xn[i+1]>=0) temp=max(temp,max_vs[i]+max_vn[i+1]-(c-x[max_xn[i+1]]));
		ans=max(ans,temp);	
	}
				
	cout<<ans;
    rt0;
}


Measured memory_bytes: 3712
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, x, n = 100100;
  bool p[n];
  for(i = 0; i < n; ++i) p[i] = true;
  for(i = 2; i * i < n; ++i) if(p[i]) for(j = 2; i * j < n; ++j) p[i * j] = false;
  scanf("%lld", &x);
  for(i = x; ; ++i) if(p[i]) {
    printf("%lld", i);
    return 0;
  }
}

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

int N, A, B;
int ans = 0;

int sumofdigits (int n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main() {
    cin >> N >> A >> B;
    
    int t = 0;
    for (int i = 0; i <= N; i++) {
        t = sumofdigits(i);
        if (t >= A && t <= B) ans += i;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n; cin >> n;
	int a[n], answer = 0;;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	bool flag = true;
	while(flag){
		flag = false;
		for(int i = 0; i < n; i++){
			if(a[i] % 2 == 0){
				a[i] /= 2; flag = true; answer += 1;
			}
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
alpha = "abcdefghij"
ans = []
N = int(input())

def dfs(S, num):
    if len(S) == N:
        ans.append(S)
    else:
        right = num + 2
        seq = alpha[:right]
        for i, c in enumerate(seq):
            dfs(S+c, max(i, num))

dfs("a", 0)
ans = sorted(ans)
for a in ans:
    print(a)

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

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
C = A - B

hi = 10**9 + 1
lo = -1

while hi - lo > 1:
    mid = (hi + lo) // 2
    rem = 0
    for i in range(N):
        rem += max(0, (H[i] - B * mid + C - 1) // C)
    if rem <= mid:
        hi = mid
    else:
        lo = mid

print(hi)

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

int main()
{
   int n;
   cin>>n;
   int permu[n];
   for(int i = 0 ; i < n ; ++i)cin>>permu[i];
   int mx=permu[0];
   int count=0;
   for(int i = 0 ; i < n ; ++i){
      if(mx>=permu[i]){count++;
   //   cout<<i<<" "<<mx<<endl;
   }
   mx=min(mx,permu[i]);
   }
   cout<<count<<endl;
   return 0 ;
}


Measured memory_bytes: 1024
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val x = nextIntList()
    println(x.indexOf(0) + 1)
}


Measured memory_bytes: 36380
#include <bits/stdc++.h>
typedef long long LL;
LL A,B,C,D;
int main()
{
    scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
    LL ans = A*B > C*D ? A*B : C*D;
    printf("%lld\n", ans );
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n, i; cin >> n >> i;
    cout << n+1-i << ln;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  
  count = 0
  for p in range(2, int(g ** 0.5 + 1)):
    if g % p == 0:
      count += 1
    while g % p == 0:
      g //= p
      
  if g != 1:
    count += 1
    
  print(count + 1)

if __name__=='__main__':
  main()



Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

namespace _085_Joseph_sPotato
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != "0 0")
			{
				int[] inputNum = Array.ConvertAll (inputStr.Split (' '), int.Parse);

				int joinCount = inputNum[0];
				int interval = inputNum[1];

				bool[] isHit = new bool[joinCount];

				int index = 0;

				for (int lp = 0; lp < isHit.Length; lp++)
				{
					int rest = interval;

					while (0 < rest)
					{
						index++;

						if (isHit.Length <= index)
						{
							index %= isHit.Length;
						}

						if (!isHit[index])
						{
							rest--;
						}
					}

					isHit[index] = true;
				}

				index = index == 0 ? isHit.Length : index;
				Console.WriteLine (index);
			}
		}
	}
}

Measured memory_bytes: 9004
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    long long int mini=1e9;
    long long int z=n*n*n;
    for(long long int x=1;x*x*x<z;x++){
      for(long long int y=1;x*x*x+y*y*y<z;y++)
	mini=min(mini,z-x*x*x-y*y*y);
    }
    cout<<mini<<endl;
  }
}

Measured memory_bytes: 1156
#include<stdio.h>
int main(void)
{
	int a[1000],n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)  scanf("%d",&a[i]);
	printf("%d",a[n]);
	for(i=n-1;i>=1;i--)  printf(" %d",a[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmax(T &x,T y){x=x>y?x:y;}
long long co[200010];int p[200010][2];
int cnt[110][110];

int main(){
	int n;read(n);
	rep(i,1,n){double x;scanf("%lf",&x);co[i]=round(x*1000000000.0);}
	
	int mx1=0;int mx2=0;
	rep(i,1,n){
		int n1=0;int n2=0;
		while(co[i]%2==0){co[i]/=2;n1++;}
		while(co[i]%5==0){co[i]/=5;n2++;}
		cnt[n1][n2]++;chkmax(mx1,n1);chkmax(mx2,n2);
		p[i][0]=n1;p[i][1]=n2;
	}
	
	long long ans=0;
	rep(i,0,mx1){
		rep(j,0,mx2){
			if(!cnt[i][j])continue;
			if(min(i,j)>=9)ans-=cnt[i][j];
			rep(k,0,mx1){
				rep(l,0,mx2){
					if(!cnt[k][l])continue;
					if(min(i+k,j+l)>=18)ans+=1ll*cnt[i][j]*cnt[k][l];
				}
			}
		}
	}
	write(ans/2);
	return 0;
}

Measured memory_bytes: 6828
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1e9+7;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗 1*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*n乗 2*/ll modpow(ll x,ll n,ll m){ll ans=x,tmp=x,t1=1;i=1; while(i<n){if(i*2<n){ans*=ans;ans%=m;i*=2;}else{t1=1;tmp=x;while(t1*2<n-i){tmp*=tmp;tmp%=m;t1*=2;}ans*=tmp;ans%=m;i+=t1;}}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x){ans*=(x-i);ans%=mod;}return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,l=2;rep(i,0,min(n-r,r)){ans*=(n-i);ans%=mod;while(ans%l==0&&l<=min(r,n-r)){ans/=l;l++;}}return ans;}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}//素数の時true
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll x[n+10],sum=0;
 rep(i,0,n){
  cin>>x[i];
  sum+=x[i];
 }
 ll ans=1e9;
 ll tmp=0;
 rep(i,0,sum+1){
  tmp=0;
  rep(j,0,n){
   tmp+=(i-x[j])*(i-x[j]);
  }
 // cout<<i<<" "<<sum<<" "<<tmp<<" "<<ans<<endl;
  ans=min(ans,tmp);
 }
 pr(ans);
return 0;}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;
const int mod = 1e+9 + 7;
 
std::vector<bool> IsPrime;
 
 
 
int main() {
	//14日目
 
	cin.tie(0); ios::sync_with_stdio(false);
 
	int n = 0, x = 0;
	cin >> n >> x;
	int a[100] = {};
	rep(i, n) {
		cin >> a[i];
	}
	std::sort(a, a + n);
 
	int count_kasi = 0;
	int i = 0;
	while (1) {
		count_kasi += a[i];
		if (count_kasi > x) {
			cout << i << endl;
			return 0;
		}
		if (i == (n - 1)) {
			if (count_kasi != x) {
				cout << i << endl;
			}
			else {
				cout << i + 1<< endl;
			}
			return 0;
		}
		i++;
	}
 
}

Measured memory_bytes: 256
n = int(input())
s = input()
r = []
count = 0
for i in range(1, n):
    if s[i] == 'E':
        count += 1
r.append(count)
for i in range(1, n):
    count = r[i-1]
    if s[i] == 'E':
        count -= 1
    if s[i-1] == 'W':
        count += 1
    r.append(count)
print(min(r))

Measured memory_bytes: 15520
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int r,g,b;
	cin>>r>>g>>b;
	if((r*100+g*10+b)%4==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
	
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

const int maxn = 2e5+5;
const int intinf = 1<<29;
const ll inf = 1ll<<60;


void GG(){cout<<"No\n"; exit(0);}

map<int, bool> mp;

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   	int n; cin>>n;
   	vector<int> a(n);
   	REP(i,n) cin>>a[i];
   	vector<int> b = a;
   	sort(ALL(a));
   	REP(i,n){
   		if (i%2==0){
   			mp[a[i]]=1;
   		}
   	}
   	int cnt = 0;
   	REP(i,n){
   		if (i%2==0){
   			if (!mp.count(b[i])){
   				cnt++;
   			}
   		}
   	}
   	cout<<cnt<<endl;
}

Measured memory_bytes: 3456