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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, D;
    ll ans = 0;
    cin >> N >> D;
    D *= D;
    rep(i, N) {
        ll X, Y;
        cin >> X >> Y;
        if(X * X + Y * Y <= D) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import math
import sys
import bisect

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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N=int(input())
if N==1:
  print(0)
  sys.exit()
L=(factorization(N))
#print(L)
L_ans = [1,3,6,10,15,21,28,36,45,55,66,78]
L_2 = [bisect.bisect(L_ans,L[i][1]) for i in range(len(L))]
#print(L_2)
print(sum(L_2))

Measured memory_bytes: 9536
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RLong;
            var a = IO.RSLong;

            long rui = 0;
            for (int i = 0; i < a.Length; i++)
            {
                rui ^= a[i];
            }
            var lis = new List<long>();
            for (int i = 0; i < n; i++)
            {
                long ans = rui ^ a[i];
                lis.Add(ans);
            }
            IO.OutJoinSpace(lis);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 70236
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l,i,k;
  cin>>n>>l;
  k=n;
  vector<string>v;
  string s;
  while(n--)
  {
    cin>>s;
    v.push_back(s);
  }
 /* for(i=0;i<k;i++)
  {
    sort(v[i].begin(),v[i].end());
  } */

  sort(v.begin(),v.end());
  string s1;
  for(i=0;i<k;i++)
  {
    s1=s1+v[i];
  }
  cout<<s1;

  return 0;
}


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


int a[4];
int b[4];
int hit;
int blow;

void format(){
	hit=blow=0;
}

int main(){
	
	int i;
	while((scanf("%d",&a[0]))!=EOF){
		format();
		for(i=1;i<4;i++){
			scanf("%d",&a[i]);
		}
		for(i=0;i<4;i++){
			scanf("%d",&b[i]);
			if(a[i]==b[i]){
				hit++;
			}
		}
		
		for(i=4;i--;){
			for(int j=4;j--;){
				if((a[i]==b[j])&&(a[i]!=b[i])){
					blow++;
				}
			}
		}
		
		
		printf("%d %d\n",hit,blow);
		
	}
	
	
	
	return 0;
}

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

#define pb push_back
#define int ll

using ll=long long;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;
using vi=vector<int>;
using vvi=vector<vi>;

signed main() {
    ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  if (n == k ||
      n == 0) {
    cout << "0\n";
    return 0;
  }
  if (n < k) {
    cout << min(n, k-n) << "\n";
    return 0;
  }
  // n > k; n,k >= 1
  int x = (n + k - 1) / k;
  cout << min(n-(x-1)*k, x*k-n) << "\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// １つの整数 x を読み込んで、x の３乗を計算し結果を出力するプログラム
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println(x * x * x);
		
	}

}



Measured memory_bytes: 26168
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
H = {i: H[i] for i in range(N)}

for j in range(N):
    H[j] = abs(A-T+0.006*H[j])

ans = min(H.items(), key=lambda x:x[1])
print(ans[0]+1)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] S = new int [n];
    for (int i = 0; i<n; i++){
      S[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    int[] T = new int[q];
    for (int i = 0; i<q;i++){
      T[i] = sc.nextInt();
    }
    int count = 0;
    for (int i = 0;i<q;i++){
      for (int j = 0;j<n;j++){
        if (S[j] == T[i]) {
          count++;
          break;
        }
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 40436
import random

x = int(input())

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

i = 0
while True:
    if is_prime(x+i):
        break
    i += 1

print(x+i)


Measured memory_bytes: 3824
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    string s; cin >> s;
    int s753 = 753;
    int sa = 1e9;
    for(int i=0; i<s.size()-2; i++){
        int a = (s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        if(abs(s753-a)<sa){
            sa = abs(s753-a);
        }
    }
    cout << sa << endl;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)


void solve()
{
  string s; cin>> s;  
  cout << (s[0]==s[2]?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3592
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

//#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt(s) cout<<s,exit(0)IFD(,cout<<"\n\nTIME: "<<runtime<<" sec\n\n")
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)
#define loop(n) for0(LOOP_COUNTER,n)
#define runtime (clock()*1.0/CLOCKS_PER_SEC)
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define int ll

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

template
<
    class key,
    class val=null_type, /// null_mapped_type
    class comp=less<key>
>
using ord_set=tree /// find_by_order(), order_of_key()
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

typedef trie
<
    string,
    null_type,
    trie_string_access_traits<>,
    pat_trie_tag,
    trie_prefix_search_node_update
>
pref_trie; /// insert(), prefix_range()

template<class T,class U>
ostream&operator<<(ostream&out,pair<T,U> p)
{
    return out<<"("<<p.x<<","<<p.y<<")";
}

template<class Iter>
struct rng
{
    Iter from,to;
    rng(Iter from,Iter to):from(from),to(to){}
};

template<class Iter>
rng<Iter> range(Iter from,Iter to)
{
    return rng<Iter>(from,to);
}

template<class Iter>
ostream&operator<<(ostream&out,rng<Iter> r)
{
    out<<distance(r.from,r.to)<<":";
    for(Iter i=r.from;i!=r.to;i++)
        out<<" "<<*i;
    return out;
}

ll ppow(ll x,ll y,ll mod)
{
    ll res=1;
    while(y)
    {
        if(y&1)
            res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

signed main()
{
    IFN
    (
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    )

    string s,t;
    cin>>s>>t;
    if((s+s).find(t)!=string::npos)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    IFD(cout<<"\n\nTIME: "<<runtime<<" sec\n\n";)
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] fruits = new int[n];
      for(int i=0;i<n;i++){
        fruits[i] = sc.nextInt();
      }
      Arrays.sort(fruits);
      int sum=0;
      for(int i=0;i<k;i++){
        sum+=fruits[i];
      }
        System.out.println(sum);
    }
}


Measured memory_bytes: 38788
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  int a[101];
  int b[101];
  rep(i,101) a[i]=b[i]=0;
  cin>>n;
  rep(i,n) cin>>a[i];
  rep(i,n){
    repn(j,n-1){
      if(a[j]>=a[j+1] && a[j]==j+1){
	b[i]=j+1;
	for(int k=j;k<n-i;k++) a[k]=a[k+1];
	break;
      }
      else if(j==0){cout<<-1<<endl;return 0;}
    }
  }
  repn(i,n-1) cout<<b[i]<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        int count=0;
        int maxHigh =0;
        int tmp;
        for(int i=0;i<number;i++){
            tmp = sc.nextInt();
            if(tmp >= maxHigh){
                maxHigh=tmp;
                count++;
            }
        }
        System.out.print(count);
    }
    
}


Measured memory_bytes: 22612
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(problem061a(a, b, c))
}

fun problem061a(a: Int, b: Int, c: Int): String {
    return if (c in a..b) {
        "Yes"
    } else {
        "No"
    }
}

Measured memory_bytes: 29472
# -*- coding: utf-8 -*-

n, k, q = map(int, input().split())


li = [0]*n
for i in range(q):
    a = int(input())
    li[a-1] += 1

for i in range(n):
    if li[i] > q-k:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 50904
#include <iostream>

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

using namespace std;

int main(){
	
	int a, b, c, x, y;
	long long int ans;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	
	if (2*c>=a+b){
		ans = a*x + b*y;
	}else{
		if (x>=y){
			if (a<=2*c){
				ans = c*2*y + a*(x-y);
			}else{
				ans = c*2*x;
			}
		}else if (y>=x){
			if (b<=2*c){
				ans = c*2*x + b*(y-x);
			}else{
				ans = c*2*y;
			}
		}
	}
	
	printf("%lld\n", ans);
	
}


Measured memory_bytes: 256
x = int(input())
if 400 <= x and x <= 599:
  print(8)
elif 600 <= x and x <= 799:
  print(7)
elif 800 <= x and x <= 999:
  print(6)
elif 1000 <= x and x <= 1199:
  print(5)
elif 1200 <= x and x <= 1399:
  print(4)
elif 1400 <= x and x <= 1599:
  print(3)
elif 1600 <= x and x <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int n, m;
array<array<int, 10>, 10> v{};
vector<int> wins;
int dfs(int i) {
    if(i == n) {
        return 1;
    }
    int ans = 0;
    vector<int> w;
    for (int j = 0; j < n; ++j) {
        if(i != j && !v[i][j]) w.emplace_back(j);
    }
    for (int mask = 0; mask < (1<<w.size()); ++mask) {
        if(wins[i] + __builtin_popcount(mask) != n/2) continue;
        for (int j = 0; j < w.size(); ++j) {
            v[i][w[j]] = ((mask>>j)&1)+1;
            v[w[j]][i] = 2-((mask>>j)&1);
            wins[((mask>>j)&1) ? i : w[j]]++;
        }
        ans += dfs(i+1);
        for (int j = 0; j < w.size(); ++j) {
            v[i][w[j]] = v[w[j]][i] = 0;
            wins[((mask>>j)&1) ? i : w[j]]--;
        }
    }
    return ans;
}

int main() {
    while(cin >> n, n){
        cin >> m;
        wins.resize(n);

        for (int i = 0; i < n; ++i) {
            wins[i] = 0;
            for (int j = 0; j < n; ++j) {
                v[i][j] = 0;
            }
        }
        for (int i = 0; i < m; ++i) {
            int x, y;
            cin >> x >> y;
            x--; y--;
            v[x][y] = 2;
            v[y][x] = 1;
            wins[x]++;
        }

        cout << dfs(0) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//LRのかたまり数で表示
//LRLRRL
//11121
//一続きに変換することが最大ともかぎ、、らない？かぎるならいけそう
//LかRか、どっちもやるのが正解かな
//もともとを加算しておく
//はじっこ以外ならどこかえても同じだけ増加するっぽいな
//数値化して、123番目を毎回くっつける感じ。
//sizeが2以下になったら終了か
//数値-1の総和がans
int main(){
  ll N,K; cin>>N>>K;
  string S; cin>>S;
  S+='X';
  queue<ll> Q;
  ll tmp=1, ssz=S.size();
  for(int i=0; i<ssz-1; i++){
    if(S[i]!=S[i+1]){
      Q.push(tmp);
      tmp=1;
    }
    else tmp++;
  }
  ll ans=Q.front()-1;
  Q.pop();
  while(!Q.empty() && K>0){
    ans+=Q.front();
    Q.pop();
    if(Q.empty()) break;
    ans+=Q.front();
    Q.pop();
    K--;
  }
  while(!Q.empty()){
    ans+=Q.front()-1;
    Q.pop();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1152
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    ans = 0
    x = int(input())
    while not(x < 500):
        ans += 1000
        x -= 500
    while not(x < 5):
        ans += 5
        x -= 5
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 22980
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int result = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    int tmp = 0;
		    while(a%2 == 0){
		        tmp++;
		        a /= 2;
		    }
		    result = min(result, tmp);
		}
		
		// 計算
		
		// 出力
		System.out.println(result);
	}
}



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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    long H[N];
    for(int i=0; i<N; i++) cin >> H[i];
    long A[M], B[M];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }    
    bool g[N]; fill(g, g + N, true);
    int ans = 0;
    for(int i=0; i<M; i++){
        if(H[A[i]] > H[B[i]]) g[B[i]] = false;
        else g[A[i]] = false;
        if(H[A[i]] == H[B[i]]) {
            g[A[i]] = false;
            g[B[i]] = false;
        }
    }
    for(int i=0; i<N; i++) {
        if(g[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 a,b,c; cin>>a>>b>>c;
    ll res=0;
    while(a%2==0 && b%2==0 && c%2==0){
        ll x=(b+c)/2, y=(a+c)/2, z=(a+b)/2;
        if(a==x && b==y && c==z){
            cout<<-1<<endl;
            return 0;
        }
        a=x; b=y; c=z;
        res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

template<typename T>
using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(322);

ll const mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    string s; cin >> s;
    ll ans = 1;
    for(ll i = 1;i<n;i++){
        if(s[i]!=s[i-1]) ans++;
    }
    cout << ans;
    return 0;
}
/*

*/

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back


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

    int N, R;
    cin >> N >> R;

    if (N<10){
        cout << R+100*(10-N) << endl;
    }else{
        cout << R << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vs = vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e9 + 7;
const int MAX_N = 2e5, MAX_M = 1e5, MAX_K = 1e9;

//qsortでの比較用の関数 cmp
//qsort(配列名,要素数,sizeof(要素型),cmp)
int cmp(const void *p, const void *q) {
	return *(int*)p - *(int*)q;
}

int  n;
int p[MAX_N];
int solve() {
	int ans = 1;
	int small = p[0];
	for (int i = 1;i < n;i++) {
		if (p[i] <= small) {
			ans += 1;
			small = p[i];
		}
}
	return ans;
}	
int main() {
	cin >> n;
	rep(i, n) cin >> p[i];
	cout << solve() << endl;
}


Measured memory_bytes: 1152
#include <stdio.h>

#define N 100

int main()
{
    int M[N][N];
    int n, u, k, v;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; j++) {
            scanf("%d", &v);
            M[u - 1][v - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0)
                printf(" ");
            printf("%d", M[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2084
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double r;
main() {
  file("threesum");
  ios;
  cin >> r;
  double ans = 2.0 * PI * r;
  cout << fixed << setprecision(12) << ans;
  return 0;
}
/**

*/


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

int main()
{
    int n;
    cin>>n;
    int ans=0;
    unordered_map<int,int> mp;
    for(int i=0;i<n;++i)
    {
        int temp;
        cin>>temp;
        mp[temp]++;
    }
    for(auto &a:mp)
    {
        if(a.second>a.first)
            ans+=a.second-a.first;
        else if(a.second<a.first)
            ans+=a.second;
    }
    cout<<ans;
    return 0;
}

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


def main():
    N, A, B = map(int, input().split())
    if (B - A) % 2 == 0:
        print(int((B - A) // 2))
    else:
        #     if A + B - 1 > N:
        #         print(int(N - (A + B - 1) / 2))
        #     else:
        #         print(int((A + B - 1) / 2))
        print(int(min(A - 1, N - B) + 1 + (B - A - 1) // 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){
   	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);}

 int func(vector<int> &v)
 {
     int cnt=0;
     for(int i=0;i<v.size;i++)
     {
         cnt=cnt+(v[i]*pow(10,v.size-i-1));
     }
     return cnt;
 }
int main(void)
{
  fast();
  int a,b;
  int m,n;
  cin>>n>>m;
  vector<int>v(n,-1);
  for(int i=0;i<m;i++){
      cin>>a>>b;
      if(v[a-1]==-1||v[a-1]==b){
          v[a-1]=b;
      }else{
          cout<<-1<<endl;
          return 0;
      }
  }
  if(n==1){
      if(v[0]==-1){
          v[0]=0;
          cout<<v[0]<<endl;
          return 0;
      }else{
          cout<<v[0]<<endl;
          return 0;
      }
  }
  if(v[0]==0){
      cout<<-1<<endl;
      return 0;
  }else{
      if(v[0]==-1){
          v[0]=1;
      }
      for(int i=1;i<n;i++){
          if(v[i]==-1){
              v[i]=0;
          }
      }
      int var=func(v);
      cout<<var<<endl;
      return 0;
  }
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

S = input()
K = int(input())

mozi = list(S)
num = 0

for i in range(1, len(S)):
	if mozi[i] == mozi[i - 1]:
		mozi[i] = "A"
		num += 1

if mozi[0] != mozi[-1]:
	print(num*K)
	exit()

mozi2 = list(S)
mozi2[0] = "A"
num2 = 1
for i in range(1, len(S)):
	if mozi2[i] == mozi2[i - 1]:
		mozi2[i] = "A"
		num2 += 1

if mozi[0] != mozi2[-1]:
	n2 = K//2
	n1 = K - n2
	print(num*n1 + num2*n2)
else:
	print(num + (K - 1)*num2)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

int n;
double ans = 1.0;

int main(){
	std::cin >> n;
	ans = n;

	if (n == 1){
		std::cout << 0 << std::endl;
		return 0;
	}

	int i = 2;
	while (n != 1){
		bool f = true;
		while(n % i == 0){
			n /= i;
			if (f)ans *= (1.0 - 1.0 / i);
			f = false;
		}
		++i;
	}

	std::cout << (int)ans << std::endl;

	return 0;
}

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

int main() {
    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        vector<int> v(N);
        for (auto& i : v) cin >> i;

        int x = 0, y = 0;
        for (int i = 1; i < N; i++) {
            if (v[i] - v[i-1] >= 0) x = max(x, v[i]-v[i-1]);
            else y = min(y, v[i]-v[i-1]);
        }

        cout << x << " " << abs(y) << endl;
    }

    return 0;
}

Measured memory_bytes: 3072
n=int(input())
txy=[input().split() for i in range(n)]
if n!=1:
  for i in range(n-1):
    subX=abs(int(txy[i+1][1])-int(txy[i][1]))
    subY=abs(int(txy[i+1][2])-int(txy[i][2]))
    subT=int(txy[i+1][0])-int(txy[i][0])
    t=[]
    p=subT-subX-subY
    t.append(p)
  for i in range(len(t)):
      if t[i]<0 or t[i]%2==1:
        print('No')
      else:
        print('Yes')
else:
  subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])
  if subby>=0 and subby%2==0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 32148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int m = scn.nextInt();

		int[] city = new int[n];

		for(int i=0;i<m;i++){
			int cityA = scn.nextInt() - 1;
			int cityB = scn.nextInt() - 1;
			city[cityA]++;
			city[cityB]++;
		}

		for(int i=0;i<city.length;i++){
			System.out.println(city[i]);
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    ll x;
    cin>>x;
    for(ll i=0;i<=3900;i++)
    {
        for(ll j=0;j<=3900;j++)
        {
            ll a=i*i*i*i*i;
            ll b=j*j*j*j*j;
            if((a-b)==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            
            if((a+b)==x)
            {
                cout<<i<<" "<<-j;
                return 0;
            }
        }
    }
}

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

# define ll long long
ll mod=pow(10,9)+7;

ll pw(ll n,ll mod){
    ll ans=1;

    ll x=2,y=n;
    while(y!=0){
        if(y%2)
            ans=((ans%mod)*(x%mod))%mod;
        x=((x%mod)*(x%mod))%mod;
        y/=2;
    }
    return ans;
}

ll cunt(ll n){
    ll cnt=0;
    while(n!=0){
        if(n%2)
            cnt++;
        n/=2;
    }
    return cnt;
}

void func(ll n){
    ll cnt=1;
    while(n!=0){
        ll temp=cunt(n);
        cnt++;
        n=n%temp;
    }
    cout<<cnt<<endl;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll mn=0,mx=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='1')
            mn++;
    }
    if(mn<n){
        mx=mn+1;
        mn--;
    }
    else{
        mn--;
        mx=mn;
    }

    if(mn==0 || mx==0){ for(ll i=0;i<n;i++){ if(s[i]=='1') cout<<0<<endl; else{ if(i==n-1) cout<<2<<endl; else cout<<1<<endl; } } return 0; }

    ll chota=0,bada=0;

    reverse(s.begin(),s.end());
    ll temp1=1,temp2=1;
    for(ll i=0;i<n;i++){
        if(s[i]=='1'){
        chota=((chota%mn)+(temp1%mn))%mn;
        bada=((bada%mx)+(temp2%mx))%mx;
        }
        temp1=((temp1%mn)*2)%mn;
        temp2=((temp2%mx)*2)%mx;
    }
    vector<ll> ans;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='1'){
            ll temp=chota - pw(i,mn);
            temp+=mn;
            temp=temp%mn;
            func(temp);
        }
        else{
            ll temp=bada + pw(i,mx);
            temp=temp%mx;
            func(temp);
        }
    }

}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less_equal<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 2E5+7;
const ll MOD = 1e9+123;
const ll M1 = 1e9+7;
const ll INF = 1E17;
const ld eps = 0.0000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
	static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution <int> (a, b)(rng);
}
const ll MAXN = 1E9;
ll A[DIM],dp[DIM];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>n;

    cin>>k;
    forn(i,n)cin>>A[i];

    for(ll i = 2;i<=n;++i){
        dp[i] = INF;
        for(ll j = max(1ll,i-k);j<i;++j)dp[i] = min(dp[i],dp[j]+abs(A[i]-A[j]));
    }

    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=1e9+7;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a,int b) {
  a+=b;
  return a>=mod?a-mod:a;
}
int sub(int a,int b) {
  a-=b;
  return a<0?a+mod:a;
}
int mul(int a,int b) {
  return (int)((long long)a*b%mod);
}
int dp[2][51][2501],n,k;

int main(){
    scanf("%d%d",&n,&k);
    dp[0][0][0]=1;
    int x=0;
    /**
    This is the most weird dp problem I've seen so far
    But require some good insight
    dp[i][j][k] is the number of ways to match 
    from 1,..i-th such that there is j elements pending to be matched with i+1 or later
    until it's paired with something it will increase the oddness 1 in each step
    One key is: the number of unmatched left side and right side is equal
    */
    for(int i=1;i<=n;i++){
        x^=1;
        memset(dp[x],0,sizeof(dp[x]));
        for(int j=0;j<=n;j++){
            for(int l=2*j;l<=k;l++){
                plusle(dp[x][j][l],mul(2*j+1,dp[x^1][j][l-2*j]));
                if(j<n)
                plusle(dp[x][j][l],mul((j+1)*(j+1),dp[x^1][j+1][l-2*j]));
                if(j>0)
                plusle(dp[x][j][l],dp[x^1][j-1][l-2*j]);
            }
        }
    }
    printf("%d\n",dp[x][0][k]);
/*
|i-p[i]|
*/
}
/*
    Good Luck
        -Lucina
*/



Measured memory_bytes: 1280
h1, m1, h2, m2, k = list(map(int, input().split()))

h3 = h2 - h1
m3 = m2 - m1
if m3 < 0:
    h3 = h3 - 1
    m3 = 60 - m1 + m2

a = h3 * 60 + m3
ans = a - k

print(ans)


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

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    if (x < a * a * b / 2)
        cout << fixed << setprecision(10) << atan(a * b * b / (2 * x)) * 180 / M_PI << endl;
    else
        cout << fixed << setprecision(10) << atan(2 / a * (b - x / (a * a))) * 180 / M_PI << endl;
    return 0;
}

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

int x[100000], w[100000], y[100000];
int main() {
	int n, l, t; scanf("%d%d%d", &n, &l, &t);
	rep(i, n) {
		scanf("%d%d", &x[i], &w[i]);
		if (w[i] == 1)y[i] = (x[i] + t) % l;
		else {
			if (x[i] >= t)y[i] = x[i] - t;
			else y[i] = (l - (t - x[i]) % l) % l;
		}
	}
	int X = y[0], cnt = 0;
	for (int i = 1; i < n; i++) {
		if (w[0] == 1 && w[i] == 2) {
			double d = (x[i] - x[0]) / 2.;
			if (t >= d)(cnt += (t - d) * 2 / l + 1) %= n;
		}
		if (w[0] == 2 && w[i] == 1) {
			double d = (l - (x[i] - x[0])) / 2.;
			if (t >= d)(cnt += ((t - d) * 2) / l + 1) %= n;
		}
	}
	if (w[0] == 2)cnt = (n - cnt) % n;
	sort(y, y + n);
	int a;
	if (w[0] == 1)a = (upper_bound(y, y + n, X) - y - 1 + n - cnt) % n;
	else a = (lower_bound(y, y + n, X) - y + n - cnt) % n;
	rep(i, n)printf("%d\n", y[(i + a) % n]);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long int n,ans=0;cin>>n;
  	vector<long long int> a(3*n);
  	for(int i=0;i<3*n;i++) cin>>a[i];
  	sort(a.begin(),a.end());
  	
  	for(int i=n;i<3*n;i=i+2){
    	ans+=a[i];
    }
  	cout<<ans<<endl;
  	
}

Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        HashSet<String> hashSet = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String[] sp = bf.readLine().split(" ");
            if (sp[0].equals("insert")){
                hashSet.add(sp[1]);
            }else {
                System.out.println(hashSet.contains(sp[1])?"yes":"no");
            }
        }

    }
}


Measured memory_bytes: 190164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int  
#define mod 1000000007
ll seg[1600011];
ll input[400011];
ll lazy[1600011];
ll intime[400001],outtime[400001],visited[400002];
ll tim=1;
ll k=0;
vector<ll>v[200001];
void dfs(ll s)
{
    visited[s]=1;
    intime[s]=tim++;
    input[k++]=s;
    for(ll i=0;i<v[s].size();i++)
    {
        if(!visited[v[s][i]])
        {
            dfs(v[s][i]);

        }
    }
    input[k++]=s;
    outtime[s]=tim++;
}

void update(ll qlow,ll qhigh,ll low,ll high,ll pos,ll val){
  if(low>high){
    return ;
  }
  if(lazy[pos]!=0){

    seg[pos] += lazy[pos];
    if(low!=high){
      lazy[2*pos + 1] += lazy[pos];
      
      lazy[2*pos+2] += lazy[pos];
      // lazy[2*pos + 2].y = lazy[pos].y;
    }
    lazy[pos] = 0;
    // lazy[pos].y = -1;
  }
  if(low>qhigh||high<qlow){
    return ;
  }
  if(low>=qlow&&high<=qhigh){
    // cout<<low<<" "<<high<<" ";
    seg[pos] += val;
    // seg[pos].y = yy;
    if(low!=high){
      // lazy[pos].x = xx;
      lazy[pos] += val;
    }
    return ;
  }
  ll mid = (low+high)>>1;
  update(qlow,qhigh,low,mid,2*pos+1,val);
  update(qlow,qhigh,mid+1,high,2*pos+2,val);
}

ll maxq(ll qlow,ll qhigh,ll low,ll high,ll pos)
{
    if(low>high)
            return 0;
    if(lazy[pos]!=0){

    seg[pos] += lazy[pos];
    if(low!=high){
      lazy[2*pos + 1] += lazy[pos];
      
      lazy[2*pos+2] += lazy[pos];
      // lazy[2*pos + 2].y = lazy[pos].y;
    }
    lazy[pos] = 0;
    // lazy[pos].y = -1;
  }
    if(qlow>high||qhigh<low)
        return 0;
    if(low>=qlow&&high<=qhigh)
        return seg[pos];
    ll mid=(low+high)/2;
    return (maxq(qlow,qhigh,low,mid,2*pos+1)+maxq(qlow,qhigh,mid+1,high,2*pos+2));
}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll t,i,j,l,m,n,q;
  cin>>n>>q;
  for(i=0;i<(n-1);i++)
  {
    ll r;
    cin>>l>>r;
    v[l].push_back(r);
    v[r].push_back(l);
  }
  dfs(1);
  
// segtree(0,k-1,0);
while(q--)
{
    // string qq;
    // cin>>qq;
    // if(qq=="get")
    // {
    //     cin>>l;
    //     ll low=intime[l]-1;
    //     ll high=outtime[l]-1;
    //    // cout<<low<<" "<<high<<" ";
    //     cout<<maxq(low,high,0,k-1,0)/2<<"\n";
    // }
    // else
    // {
	ll r;
        cin>>l>>r;
        ll low=intime[l]-1;
        ll high=outtime[l]-1;
        update(low,high,0,k-1,0,r);
    // }
}

for(ll i=1;i<=n;i++){
	ll low = intime[i]-1;
	ll high = outtime[i]-1;
	cout<<maxq(low, low, 0, k-1,0)<<" ";
}
return 0;
}

Measured memory_bytes: 54656
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if 0 in A:
        print(0)
        exit()
    for i in A:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
resolve()

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
  vector<bool> used(n);
  int now = 0;
  int c = 0;
  while (!used[now]) {
    used[now] = true;
    if (now == 1) {
      cout << c << endl;
      return 0;
    }
    c++;
    now = a[now];
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int i;
	int x;
	int m;
} T_DATA;
T_DATA a[200000] = {0};

int comp1(const void* p1, const void* p2)
{
	return ((T_DATA*)p1)->x - ((T_DATA*)p2)->x;
}
int comp2(const void* p1, const void* p2)
{
	return ((T_DATA*)p1)->i - ((T_DATA*)p2)->i;
}
int main(int argc, char** argv)
{
	int n;
	int i;
	int d;
	
	scanf("%d", &n);
	for(i=0;i<n;++i){
		int k;
		scanf("%d", &k);
		a[i].x = k;
		a[i].i = i;
	}
	//sort
	qsort(a, n, sizeof(*a), comp1);
	
	for(i=0; i<n/2; ++i){
		a[i].m = a[n/2].x;
	}
	for(i=n/2; i<n; ++i){
		a[i].m = a[n/2-1].x;
	}
	//sort
	qsort(a, n, sizeof(*a), comp2);
	
	for(i=0; i<n; ++i){
		printf("%d\n", a[i].m);
	}
	return 0;
}


Measured memory_bytes: 6740
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    int imos[30][101010];
    cin>>N>>C;
    rep(i,N){
        int  a,b,c;
        cin>>a>>b>>c;
        a--;c--;
        imos[c][a]++;
        imos[c][b]--;
    }
    rep(c,C) rep2(i,1,101010) imos[c][i] += imos[c][i-1];
    rep(c,C) rep(i,101010) if(imos[c][i]) imos[c][i]=1;
    int ans=0;
    rep(i,101010){
        int cnt=0;
        rep(c,C) cnt +=  imos[c][i];
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>
#include <cmath>
#include <iomanip>
#include <iterator>

using namespace std;

clock_t timeStart, timeFinish;

void timeBegin() {
    timeStart = clock();
}

void timeEnd() {
    timeFinish = clock();
}

void timeDuration() {
    double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC);
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " sec " << endl;
}

class InputReader {
public:
    InputReader() {
        input_file = stdin;
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    InputReader(const char *file_name) {
        input_file = fopen(file_name, "r");
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    inline InputReader &operator >>(int &n) {
        while((buffer[cursor] < '0' || buffer[cursor] > '9') && buffer[cursor] != '-') {
            advance();
        }
        int sign = 1;
        if (buffer[cursor] == '-') {
            sign = -1;
            advance();
        }
        n = 0;
        while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
            n = n * 10 + buffer[cursor] - '0';
            advance();
        }
        n *= sign;
        return *this;
    }
private:
    FILE *input_file;
    static const int SIZE = 1 << 17;
    int cursor;
    char buffer[SIZE];
    inline void advance() {
        ++ cursor;
        if(cursor == SIZE) {
            cursor = 0;
            fread(buffer, SIZE, 1, input_file);
        }
    }
};

const int MAXN = 200000;
const int SIGMA = 26;

struct Node {
    Node *son[SIGMA];
    int contains[SIGMA];
    Node *parent;

    Node(Node *_parent = nullptr) {
        for (int i = 0; i < SIGMA; i++) {
            son[i] = nullptr;
            contains[i] = 0;
        }
        parent = _parent;
    }
};

string s[1 + MAXN];
Node *where[1 + MAXN];

int main() {
    timeBegin();
    //ifstream cin("input.txt");
    //ofstream cout("papagali.out");
    int n;
    cin >> n;
    Node *root = new Node;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
        Node *node = root;
        for (auto ch : s[i]) {
            if (node->son[ch - 'a'] == nullptr) {
                node->son[ch - 'a'] = new Node(node);
            }
            node = node->son[ch - 'a'];
        }
        where[i] = node;
        vector<bool> seen(SIGMA, false);
        for (int j = s[i].size() - 1; j >= 0; j--) {
            seen[s[i][j] - 'a'] = true;
            node = node->parent;
            for (int k = 0; k < SIGMA; k++) {
                if (seen[k]) {
                    node->contains[k]++;
                }
            }
        }
    }
    long long answer = 0;
    for (int i = 1; i <= n; i++) {
        answer += where[i]->parent->contains[s[i].back() - 'a'] - 1;
    }
    cout << answer << "\n";
    //timeDuration();
    return 0;
}

Measured memory_bytes: 339052
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    ll n;; cin >> n;
    ll s = 0 , k = 1;
    while(n){
        s += k;
        k *= 2;
        n /= 2;
    }
    cout << s;
}

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


Measured memory_bytes: 256