akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main () 
    {
        long n  = long.Parse(Console.ReadLine());
        long ans = 1;
        String[] inline = Console.ReadLine().Split(' ');
        int flag = 1;
        for (int i = 0; i < n; i++)
        {
            try
            {
                checked
                {
                    ans *= long.Parse(inline[i]);
                }
            } 
            catch (OverflowException)
            {
                flag = -1;
            }
            
            if (ans == 0)
            {
                flag = 0;
                break;
            }
            if (ans > (long) Math.Pow(10,18))
            {
                flag = -1;
            }
        }

        switch(flag)
        {
            case 1:
                Console.WriteLine(ans);
                break;
            case 0:
                Console.WriteLine(0);
                break;
            case -1:
                Console.WriteLine(-1);
                break;
        }
    }
}

Measured memory_bytes: 54660
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	int ans = 1,upper = 1;
	int rest = N-1,need;

	while(true){

		if(upper%K == 0){

			need = upper/K;

		}else{

			need = (upper/K)+1;
		}

		if(need > rest){
			break;
		}

		rest -= need;
		upper += need;

		ans++;
	}

	printf("%d\n",ans);

	return 0;
}



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

void removeTarget(int *personmap, int *distancemap, int *flagmap, int x, int y, int index, int n);

void removeTargetSub(int *personmap, int *distancemap, int *flagmap, int x, int y, int index, int n, int dx, int dy)
{
    int t1 = x + n * y;
    int t2 = x + dx + n * (y + dy);
    if( flagmap[t2] < index)
    {
        if( ( distancemap[t1] + 1 == distancemap[t2] && personmap[t2] < index) || ( distancemap[t1] + 2 == distancemap[t2] && personmap[t2] > index) )
        {
            removeTarget(personmap, distancemap, flagmap, x + dx, y + dy, index, n);
        }
    }
}

void removeTarget(int *personmap, int *distancemap, int *flagmap, int x, int y, int index, int n)
{
    int t = x + n * y;
    distancemap[t]--;
    flagmap[t] = index;
    if( x > 0 ) removeTargetSub(personmap, distancemap, flagmap, x, y, index, n, -1, 0);
    if( x < n - 1 ) removeTargetSub(personmap, distancemap, flagmap, x, y, index, n, 1, 0);
    if( y > 0 ) removeTargetSub(personmap, distancemap, flagmap, x, y, index, n, 0, -1);
    if( y < n - 1 ) removeTargetSub(personmap, distancemap, flagmap, x, y, index, n, 0, 1);
}

int getShortest(int x, int y, int n)
{
    int ans = x;
    if( ans > n - 1 - x ) ans = n - 1 - x;
    if( ans > y ) ans = y;
    if( ans > n - 1 - y ) ans = n - 1 - y;
    return ans + 1;
}

int main(void)
{
    int n, n2;
    int ans = 0;
    cin >> n;
    n2 = n * n;
    int *seq = (int*)malloc(sizeof(int) * n2);
    int *personmap = (int*)malloc(sizeof(int) * n2);
    int *flagmap = (int*)malloc(sizeof(int) * n2);
    int *distancetable = (int*)malloc(sizeof(int) * n2);
    for( int i = 0; i < n2; i++)
    {
        cin >> seq[i];
        personmap[seq[i] - 1] = i;
        flagmap[i] = -1;
    }

    for( int x = 0; x < n; x++)
    {
        for( int y = 0; y < n; y++)
        {
            distancetable[x + y * n] = getShortest(x, y, n);
        }
    }

    for( int i = 0; i < n2; i++ )
    {
        ans = ans + distancetable[seq[i] - 1] - 1;
        int y = (seq[i] - 1) / n;
        int x = (seq[i] - 1) - y * n;
        removeTarget(personmap, distancetable, flagmap, x, y, i, n);
    }

    cout << ans;
}

Measured memory_bytes: 34420
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
bool prime[1000001];

typedef long long LL;
int main(){
        REP(i,1000001){
            prime[i]=true;
        }
        prime[0]=false;
        prime[1]=false;
        REP(i,1000001){
            if(prime[i]==false)continue;
            for(int j=2*i;j<1000001;j+=i){
                prime[j]=false;
            }
        }
        LL a;
        while(cin>>a){
           LL c=0;
           REP(i,a+1){
               if(prime[i]==true){
                  c++;
               }
           }
           cout<<c<<endl;
        }
	return(0);
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '[';
  for (auto &&e : v) os << e << ' ';
  return os << ']';
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << '[';
  for (auto &&e : v) os << e << ' ';
  return os << ']';
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  V<tuple<i64, int>> sushi(N);
  REP(i, N) {
    int t, d;
    cin >> t >> d;
    --t;
    sushi[i] = {(i64)d, t};
  }
  sort(sushi.rbegin(), sushi.rend());

  MinHeap<i64> heap;
  V<optional<i64>> maxp(N);
  i64 score = 0;
  i64 count = 0;
  REP(i, K) {
    auto [d, t] = sushi[i];
    score += d;
    if (not maxp[t].has_value()) {
      maxp[t] = d;
      ++count;
    } else {
      heap.push(d);
    }
  }
  i64 ans = score + count * count;

  for (int i = K; i < N; ++i) {
    auto [d, t] = sushi[i];
    if (heap.empty()) break;
    if (maxp[t].has_value()) continue;
    score += d;
    maxp[t] = d;
    ++count;

    auto v = heap.top();
    heap.pop();
    score -= v;

    ans = max(ans, score + count * count);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6892
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N, W = map(int, readline().split())
    INF = int(1e5)+100
    weight = [0 for _ in range(110)]
    value = [0 for _ in range(110)] 
    for i in range(N):
        w, v = map(int, readline().split())
        weight[i] = w
        value[i] = v
    dp = [[0 for _ in range(INF)] for _ in range(110)]
    for i in range(N):
        for sum_w in range(W+1):
            if sum_w - weight[i] >= 0:
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-weight[i]] + value[i]) 
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
    print(dp[N][W])
if __name__ == '__main__':
    main()


Measured memory_bytes: 181512
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  bool yes = false;
  int cnt = 0;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x==y){
      cnt++;
    } else cnt = 0;
    if(cnt>=3)yes = 1;
  }
  cout<<(yes?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
    char s[10];
    scanf("%s", s);
    sort(s, s + 4);
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	char a[8][9];
	int i,j,flag;

	while(scanf("%s",a[0])!=EOF){
		for(i=1;i<8;i++)
			scanf("%s",a[i]);
		
		flag=1;
		for(i=0;i<8&&flag;i++)
			for(j=0;j<8&&flag;j++)
				if(a[i][j]=='1'){
					if(i+1<8&&j+1<8&&a[i+1][j]=='1'&&a[i][j+1]=='1'&&a[i+1][j+1]=='1')
						printf("A\n");
					else if(i+3<8&&a[i+1][j]=='1'&&a[i+2][j]=='1'&&a[i+3][j]=='1')
						printf("B\n");
					else if(j+3<8&&a[i][j+1]=='1'&&a[i][j+2]=='1'&&a[i][j+3]=='1')
						printf("C\n");
					else if(i+2<8&&j-1>=0&&a[i+1][j-1]=='1'&&a[i+1][j]=='1'&&a[i+2][j-1]=='1')
						printf("D\n");
					else if(i+1<8&&j+2<8&&a[i][j+1]=='1'&&a[i+1][j+1]=='1'&&a[i+1][j+2]=='1')
						printf("E\n");
					else if(i+2<8&&j+1<8&&a[i+1][j]=='1'&&a[i+1][j+1]=='1'&&a[i+2][j+1]=='1')
						printf("F\n");
					else
						printf("G\n");
					flag=0;
				}
	}	
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9;
int n,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();
	for(int i=1;i<=9;++i)
		for(int j=1;j<=9;++j)
			if(i*j==n)
				return puts("Yes"),0;
	return puts("No"),0;
}

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

int main(){
    int N = 0,M = 0;
    int counter = 0;
    int ans = 0;

    
    


    cin >> N;
    vector<string> blue(N);
    rep(i,N){
        cin >> blue.at(i);
    }

    cin >> M;
    vector<string> red(M);

    rep(i,M){
        cin>>red.at(i);  
    }

    rep(i,blue.size()){

        counter =0;

        rep(j,blue.size()){
            if(blue.at(j) == blue.at(i)) counter++;
        }
        rep(k,red.size()){
            if(red.at(k) == blue.at(i)) counter--;
        }
       
        if(counter>ans) ans=counter;

    }
    cout << ans << endl;

    
}

Measured memory_bytes: 256
o,f,i=998244353,[1],1
while i<o/399:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
while-~m<min(w,n):m+=2;a-=c(n,m)*c((w-m)//2+u,u)
print(a%o)

Measured memory_bytes: 115300
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
    cout << (n / 3) << endl;
    return;
}

int main() {
    cin >> n;
    solve();
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int count = 0;
		for ( int i = 0; i < n; i++) {
			if ( sc.nextInt()== sc.nextInt()) {
				count++;
			} else {
				count = 0;
			}

			if ( count == 3) {
				System.out.println("Yes");
				return;
			}

		}
		System.out.println("No");

	}

}


Measured memory_bytes: 35964
{-
    sqrt(a) + sqrt(b) < sqrt(c)
    a + b + 2 * sqrt(a * b) < c
    4 * a * b < (c - a - b) ^ 2

    If c - a - b < 0,
    a + b + 2 * sqrt(a * b) > c
-}

main = do
    [a, b, c] <- map read . words <$> getLine :: IO [Int]
    putStrLn $ if a + b <= c && 4 * a * b < (c - a - b) ^ 2 then "Yes" else "No"


Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    ans += 'x';
  }

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



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  
  for(int i=N; i>=0; --i){
    bool CAN=true;
    for(int j=0; j<i; ++j){
      if(S.at(N-i+j)!=T.at(j)) CAN=false;
    }
    if(CAN){
      cout<<2*N-i<<endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
using namespace atcoder;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  //using namespace std;
  
  int n, m;
  cin>>n>>m;
  int a[m], b[m];
  REP(i, m){
    cin>>a[i]>>b[i];
    a[i]--; b[i]--;
  }
  
  UnionFind uf(n);
  REP(i, m) uf.connect(a[i], b[i]);
  vector<bool> seen(n, false);
  int sz = 0;
  REP(i, n){
    int rt = uf.root(i);
    if(seen[rt]) continue;
    seen[rt] = true;
    sz++;
  }
  int ans = sz - 1;
  cout << ans << endl;
  return 0;
}

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


class Lowlink{
public:
  // {v_from, v_to}
  vector<pair<int,int>> bridge;
  // [v]
  vector<int> articulation_point;
  void construct(const vector<vector<int>>& g){
    const int n = g.size();
    bridge = vector<pair<int, int>>{};
    articulation_point = vector<int>{};

    vector<int> ord(n, -1);
    vector<int> low(n);
    for(int i=0; i<n; i++){
      dfs(g, ord, low, i);
    }
  }

private:
  void dfs(
    const vector<vector<int>>& g, vector<int>& ord, vector<int>& low,
    int cur, int par = -1)
  {
    ord[cur] = par==-1 ? 0 : ord[par] + 1;
    low[cur] = ord[cur];
    int num_children = 0;
    bool is_articulation = false;
    for(auto& nex: g[cur]){
      if(ord[nex] == -1){
        ++num_children;
        dfs(g, ord, low, nex, cur);
        low[cur] = min(low[cur], low[nex]);
        if(ord[cur] <= low[nex] && par!=-1)
          is_articulation = true;
        if(ord[cur] < low[nex])
          bridge.emplace_back(min(cur, nex), max(cur, nex));
      }else if(nex != par){ // back edge
        low[cur] = min(low[cur], ord[nex]);
      }
    }
    if(par == -1 && num_children >= 2)
      is_articulation = true;
    if(is_articulation)
      articulation_point.push_back(cur);
  }

};

// 2020/05/15
// verified bridge
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B
// int main(){
//   int n,e;
//   cin >> n >> e;
//   vector<vector<int>> g(n);
//   for(int i=0; i<e; i++){
//     int u,v;
//     cin >> u >> v;
//     g[u].push_back(v);
//     g[v].push_back(u);
//   }

//   Lowlink lowlink;
//   lowlink.construct(g);
//   auto b = lowlink.bridge;
//   sort(begin(b), end(b));
//   for(auto e : b){
//     cout << e.first << " " << e.second << endl;
//   }
//   return 0;
// }


int main(){
  int n,e;
  cin >> n >> e;
  vector<vector<int>> g(n);
  for(int i=0; i<e; i++){
    int u,v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  Lowlink lowlink;
  lowlink.construct(g);
  auto a = lowlink.articulation_point;
  sort(begin(a), end(a));
  for(auto v: a) cout << v << endl;
  return 0;
}


Measured memory_bytes: 4344
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

ll mod = 1e9 + 7;
map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

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

  int n;
  cin >> n;
  map<ll, ll>m;
  rep(i, 1, n + 1){
    map<int, int> tmp = prime_factor(i);
    for(auto it = tmp.begin(); it != tmp.end(); ++it) {
      m[it->first] += it->second;
    }
  }
  ll rsl = 1;
  for(auto it = m.begin(); it != m.end(); ++it) {
    if(it->first == 1) continue;
    (rsl *= (it->second + 1)) %= mod;
  }
  cout << rsl << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <stack>
#include <set>
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a[310][310], dis[310][310];
	bool f[310][310] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			dis[i][j] = a[i][j];
		}
		dis[i][i] = 0;
	}
	for (int k = 0; k < n; k++)for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) {
		if (a[i][j] != dis[i][j]) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)for (int k = 0; k < n; k++) {
		if (i == j || i == k || j == k)continue;
		if (dis[i][j] == dis[i][k] + dis[k][j])f[i][j] = 1;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) {
		if (!f[i][j])ans += dis[i][j];
	}
	cout << ans / 2 << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;


// a new data structure defined. Please refer below
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;


#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/



int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}
























Measured memory_bytes: 3632
N, M = map(int, input().split())
WA = [0] * (N+1)
AC = [0] * (N+1)
Q = [list(input().split()) for _ in range(M)]
for p, s in Q:
  p = int(p)
  if AC[p] == 1:
    continue
  if s == "WA":
    WA[p] += 1
  else:
    AC[p] = 1
ans = 0
for w, a in zip(WA, AC):
  if a:
    ans += w
print(sum(AC), ans)

Measured memory_bytes: 31860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e3 + 5;
const int M = 1e4 + 5;

int h, n;
int a[N], b[N];
int dp[N][M];

int f(int idx, int hp) {
    if(hp <= 0) return 0;
    if(idx > n) return INF;
    int &sol = dp[idx][hp];
    if(sol != -1) return sol;
    return sol = min(f(idx + 1, hp), f(idx, hp - a[idx]) + b[idx]);
}

void solve() {
    cin >> h >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, h) << "\n";
}

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

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

#define      ll      long long int

int main( )
{
    ll k;
    string s;
    int i, j, ans, l;
    cin >> s >> k;
    l = (int) s.size();
    for (i = 0; i < l; i++) {
        if (s[i] != '1') { ans = s[i] - '0'; break; }
    }
    if (k - 1 < i) {
        cout << "1\n";
    }
    else {
        cout << ans << '\n';
    }
    return 0;
}


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

using namespace std;

#define int long long

int n,x,dem;

main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2==1) dem=1;
    }
    if(dem==0) cout<<"second";
    else cout<<"first";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;

    vector<int> ql(q), qr(q), qi(q);
    rep(i, q) cin >> ql[i] >> qr[i], ql[i]--;
    iota(qi.begin(), qi.end(), 0);

    int width = sqrt(q);
    sort(qi.begin(), qi.end(), [&](int i, int j) {
        if (ql[i] / width != ql[j] / width) return ql[i] < ql[j];
        return qr[i] < qr[j];
    });

    vector<int> cnt(n), ans(q);
    int sum = 0;
    int l = 0, r = 0;

    auto add = [&](int i) { if (cnt[a[i]]++ == 0) sum++;};
    auto del = [&](int i) { if (--cnt[a[i]] == 0) --sum;};
    
    for (int i : qi) {
        while (ql[i] < l) add(--l);
        while (r < qr[i]) add(r++);
        while (l < ql[i]) del(l++);
        while (qr[i] < r) del(--r);
        ans[i] = sum;
    }
    
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 15472
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    int[] C = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();
    for (int i = 0; i < N; i++) B[i] = scanner.nextInt();
    for (int i = 0; i < N; i++) C[i] = scanner.nextInt();
    Arrays.sort(A);
    Arrays.sort(B);
    Arrays.sort(C);
    long res = 0;
    for (int i = 0; i < N; i++) {
      long a = upperBound(A, B[i]);
      long c = lowerBound(C, B[i]);
      res += (a + 1) * (N - c);
    }
    System.out.println(res);
  }

  public static int upperBound(int[] a, int k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a[mid] < k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }

  public static int lowerBound(int[] a, int k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (k < a[mid]) {
        right = mid;
      } else {
        left = mid;
      }
    }
    return right;
  }
}


Measured memory_bytes: 93724
#include<bits/stdc++.h>
#define MAX_N 301
#define inf 1<<30
using namespace std;

struct edge{ int to,cap,rev; };

int n,m;
vector<edge> G[MAX_N];
int level[MAX_N],iter[MAX_N];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,cap,G[from].size()-1});
}

void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> q;
  q.push(s);
  level[s]=0;
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int i=0;i<G[v].size();i++){
      edge &e=G[v][i];
      if(level[e.to]<0 and e.cap>0){
	level[e.to]=level[v]+1;
	q.push(e.to);
      }
    }
  }
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  for(int &i=iter[v];i<(int)G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0 && level[e.to]>level[v]){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,inf))>0)flow+=f;
  }
}

int main()
{
  int x[1001],y[1001],s,t;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>x[i]>>y[i];
    x[i]--;y[i]--;
    add_edge(x[i],y[i],1);
  }
  cin>>s>>t;
  s--;t--;
  int f=max_flow(s,t);
  cout<<f<<endl;

  vector<int> V;
  
  for(int i=0;i<m;i++){
    for(int j=0;j<G[y[i]].size();j++){
      edge e=G[y[i]][j];
      if(e.to==x[i]){
	if(e.cap<1)V.push_back(i+1);
      }
    }
  }
  cout<<V.size()<<endl;
  for(int i=0;i<V.size();i++)cout<<V[i]<<endl;
  return 0;
}

Measured memory_bytes: 1284
#! /usr/bin/python
# -*- coding: utf-8 -*-
# ALDS1_2_D: Shell Sort

import copy
import math

def insertionSort(A, N, g):
    global cnt
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A

def shellSort(A, N):
    # print("ShellSort")
    global cnt
    i = 0
    # m = int(math.ceil(N**1.5))
    # print("m is {}".format(m))
    G = [1]
    # for i in range(0, m):
    #     G.append(3*G[i] + 1)
    while 3*G[i] + 1 < len(A):
        G.append(3*G[i] + 1)
        i += 1
    m = len(G)
    print(m)
    G_AFTER = list(reversed(G))
    print(*G_AFTER)
    for i in range(0, m):
        # print("G[i] = {}".format(G_AFTER[i]))
        insertionSort(A, N, G_AFTER[i])
    return A

if __name__ == "__main__":
    # 数字入力　行数＋数字
    cnt = 0
    N=int(input()) #行数
    A=[int(input()) for i in range(N)]
    ANS = shellSort(A, N)
    print(cnt)
    for i in range(len(ANS)):
        print(ANS[i])


Measured memory_bytes: 46112
L = input()
mod = 10**9+7
dp = [[0,0] for i in range(len(L)+1)] #[0]が=,[1]が以下
dp[0][0] = 2
dp[0][1] = 1
for i in range(len(L)-1):
    if L[i+1] == '0':
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = (dp[i][1]*3)%mod
    else:
        dp[i+1][0] = (dp[i][0]*2)%mod
        dp[i+1][1] = (dp[i][1]*3+dp[i][0])%mod
print((dp[len(L)-1][0]+dp[len(L)-1][1])%mod)

Measured memory_bytes: 54000
#pragma comment(linker, "/stack:200000000")

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

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 1e5 + 123;
int n , k , h[N] , dp[N];
main(){
	scanf("%lld%lld" , &n , &k);
	for(int i = 1 ; i <= n ; i++){
		dp[i] = 1e18;
		scanf("%lld" , &h[i]);
	}
	dp[1] = 0;
	for(int i = 1 ; i <= n ; i++){
		for(int j = i + 1 ; j <= i + k ; j++)
		dp[j] = min(dp[i] + abs(h[i] - h[j]) , dp[j]);
	}
	printf("%lld" , dp[n]);
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		string N = GetString();
		int K = GetInt();
		
		int L = N.Length;
		if(L < K)
		{
			WriteLine(0);
			return;
		}

		int[] num = new int[L];
		for(int i = 0; i < L; i++)
			num[i] = (int)(N[i] - '0');

		long[,,] dp = new long[L, L - K + 1, 2];
		if(L - K > 0)
			dp[0, 1, 1] = 1;

		for(int i = 1; i < num[0]; i++)
			dp[0, 0, 1]++;

		dp[0, 0, 0] = 1;
		for(int i = 1; i < L; i++)
		{
			for(int j = 0; j <= L - K; j++)
			{
				if(j < L - K)
				{
					if(num[i] == 0)
					{
						dp[i, j + 1, 0] += dp[i - 1, j, 0];
						dp[i, j + 1, 1] += dp[i - 1, j, 1];
					}
					else
					{
						dp[i, j + 1, 1] += dp[i - 1, j, 0] + dp[i - 1, j, 1];
					}
				}

				for(int l = 1; l < 10; l++)
				{
					if(l < num[i])
					{
						dp[i, j, 1] += dp[i - 1, j, 0] + dp[i - 1, j, 1];
					}
					else if(l == num[i])
					{
						dp[i, j, 0] += dp[i - 1, j, 0];
						dp[i, j, 1] += dp[i - 1, j, 1];
					}
					else
					{
						dp[i, j, 1] += dp[i - 1, j, 1];						
					}
				}
			}
		}

		WriteLine(dp[L - 1, L - K, 0] + dp[L - 1, L - K, 1]);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11220
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll X,Y;
	cin >>X>>Y;
	
	// 解法

	//出力
	cout << X+Y/2 << endl;
}


Measured memory_bytes: 256
def solve():
  ans = 0
  N = int(input())
  stacks = [list(map(lambda x:int(x)-1, input().split()))[::-1] for _ in range(N)]
  lis = [0]*N
  cnt = 0
  now = 0
  flag = 0
  while cnt<N*(N-1)//2:
    while not stacks[now]:
      now = (now+1)%N
    a = stacks[now][-1]
    if not stacks[a]:
      return -1
    if stacks[a][-1] == now:
      lis[now] = max(lis[now],lis[a])+1
      lis[a] = lis[now]
      stacks[a].pop(-1)
      stacks[now].pop(-1)
      cnt += 1
      flag = 0
    else:
      now = a
      flag += 1
    if flag==N:
      return -1
  ans = max(lis)
  return ans
print(solve())

Measured memory_bytes: 84504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
ll cnt[300009][69];

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  ll a[300009];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    rep(j,60){
      cnt[i+1][j]=cnt[i][j]+((a[i]>>j)&1);
    }
  }

  mint ans=0;
  for(int i=n-1;i>=0;i--){
    rep(j,60){
      if((a[i]>>j)&1){
        ans+=((mint)i-cnt[i][j])*(1ll<<j);
      }
      else{
        ans+=(mint)cnt[i][j]*(1ll<<j);
      }
    }
  }

  cout<<ans.x<<endl;

  return(0);
}


Measured memory_bytes: 164352
#include <stdio.h>
#define bit(n,m)(((n)>>(m))&1)
#define minz(p,q)((p)&&(p)<(q)?(p):(q))

int dp[1<<12];//宝箱Sを開けるための最小費用+1

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	dp[0]=1;
	for(int _=0;_<m;_++){
		int a,k;
		scanf("%d%d",&a,&k);
		int s=0;
		for(int i=0;i<k;i++){
			int t;
			scanf("%d",&t);
			t--;
			s|=1<<t;
		}
		for(int i=(1<<n)-1;i>=0;i--)if(dp[i])dp[i|s]=minz(dp[i|s],dp[i]+a);
	}
	if(!dp[(1<<n)-1])puts("-1");
	else printf("%d",dp[(1<<n)-1]-1);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int d, n, ans = 0;
    cin >> d >> n;
    if(n != 100){
        if(d == 0) ans = n;
        else if(d == 1) ans = n * 100;
        else if(d == 2) ans = n * 10000;
    }
    else{
        if(d == 0) ans = 101;
        else if(d == 1) ans = 101 * 100;
        else if(d == 2) ans = 101 * 10000;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3504
#include <stdio.h>

int main(void){

  int n;
	scanf("%d", &n);
  long pre2 = 2;
  long pre = 1;
  long lucas = 1;
  for (int i = 2; i <= n; i++) {
    lucas = pre2 + pre;
    pre2 = pre;
    pre = lucas;
  }
  printf("%ld\n", lucas);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=0;i<1e9+1;i++){
    if(abs(a-i)==abs(b-i)){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
module b;

import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;

void main()
{
    auto buf = readln.chomp.split.to!(int[]);
    auto votes = readln.chomp.split.to!(int[]);
    auto s = votes.sum;
    auto popular = votes.count!(a => s <= a * 4 * buf[1]);
    ((buf[1] <= popular) ? "Yes" : "No").writeln;
}


Measured memory_bytes: 256
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

K, T = mi()
a = list(mi())

print(max(0, max(a)-1-(K-max(a))))

Measured memory_bytes: 9384
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b) {
		printf("a >");
	} else if (a < b) {
		printf("a <");
	} else {
		printf("a ==");
	}
	printf(" b\n");
	return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int n;
    cin>>n;
    vector<int> a(n+1);
    rep(i,n+1) cin >> a[i];
    
    if(n==0){
        if(a[0]==1) cout<<1<<endl;
        else cout<<-1<<endl;
        return;
    }

    vec b(n+1);
    b[0]=1;
    int ng=0;
    rep(i,n+1){
        if(i!=0){
            b[i]=b[i-1]*2;
            if(b[i]>1000000000000000) b[i]=1000000000000000;
        }
        b[i]-=a[i];
        if(b[i]<0) ng++;
    }
    
    if(ng>0){
        cout<<-1<<endl;
        return;
    }

    b[n]=0;
    
    for(int i=n-1;i>=0;i--){
        if(b[i]>a[i+1]+b[i+1]){
            b[i]=a[i+1]+b[i+1];
        }
    }

    for(int i=0;i<n;i++){
        if(b[i]*2<a[i+1]+b[i+1]) ng++;
    }

    if(ng>0){
        cout<<-1<<endl;
        return;
    }


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

    int ans=0;
    rep(i,n+1){
        ans+=a[i]+b[i];
    }
    cout<<ans<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 9536