akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {

    static void sieve(int nMax, boolean[] isPrime, int[] spf) {
        Arrays.fill(isPrime, true);
        isPrime[0] = false;
        isPrime[1] = false;
        for (int n = 2; n <= nMax; n++) {
            if (isPrime[n]) {
                spf[n] = n;
                int i = 2;
                while (i * n <= nMax) {
                    isPrime[i * n] = false;
                    spf[i * n] = n;
                    ++i;
                }
            }
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());

        boolean[] isPrime = new boolean[n + 1];
        int[] spf = new int[n + 1];
        sieve(n, isPrime, spf);
        long ans = 0;

        for (int k = 1; k <= n; k++) {
            long c = 1;
            int a = k;
            long l = 0;
            long prev = -1;
            while (a > 1) {
                int b = a / spf[a];
                if (prev == -1) {
                    ++l;
                } else {
                    if (prev == spf[a]) {
                        l++;
                    } else {
                        c *= (l+1);
                        l = 1;
                    }
                }
                prev = spf[a];
                a=b;
            }
            if (l > 0) c *= (l+1);
            ans += c * k;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 82092
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

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

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    vector<int> counts = vector<int>(S.length(), 0);
    int repeat = 1;
    char last = 'R';
    int last_R_index = 0;
    for (int i = 1; i <= S.length(); i++) {
        if (i < S.length() && S[i] == last) {
            repeat++;
        } else {
            if (last == 'R') {
                counts[i-1] += (repeat + 1) / 2;
                counts[i] += repeat / 2;
                last_R_index = i-1;
//                cout << i-1 << ", " << i << ": R(" << ((repeat + 1) / 2) << ") -> L(" << repeat / 2 << ")" << endl;
            } else {
                counts[last_R_index] += repeat / 2;
                counts[last_R_index + 1] += (repeat + 1) / 2;
//                cout << last_R_index << ", " << last_R_index + 1 << ": R(" << (repeat / 2) << ") -> L(" << (repeat + 1 ) / 2 << ")" << endl;
            }
            
            repeat = 1;
            last = S[i];
        }
    }
    for (int i = 0; i < S.length(); i++) {
        cout << counts[i];
        if (i < S.length() - 1) {
            cout << " ";
        }
    }
    return 0;
}


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

using namespace std;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));

    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            cin >> s.at(r).at(c);
        }
    }


    vector<vector<int>> cost(h, vector<int>(w));
    cost[0][0] = s[0][0] == '#';
    for (int c = 0; c + 1 < w; c++)
        cost[0][c + 1] = cost[0][c] + (s[0][c] == '.' && s[0][c + 1] == '#');
    for (int r = 0; r + 1 < h; r++)
        cost[r + 1][0] = cost[r][0] + (s[r][0] == '.' && s[r + 1][0] == '#');

    for (int r = 1; r < h; r++) {
        for (int c = 1; c < w; c++) {
            cost[r][c] = min(
                cost[r][c - 1] + (s[r][c - 1] == '.' && s[r][c] == '#'),
                cost[r - 1][c] + (s[r - 1][c] == '.' && s[r][c] == '#')
            );
        }
    }

    cout << cost[h - 1][w - 1] << endl;

    return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    set<int> stacks;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        stacks.insert(x);
    }
    cout << stacks.size();
}

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

int main() {
    int n, x;
    while(true){
        cin>>n>>x;
        if(n==0 & x==0)break;
        int a, b, c;
        int ans = 0;
        for(int i=1;i<=n;++i){
            for(int j=i+1;j<=n;++j){
                a = i;
                b = j;
                c = x-i-j;
                if(c>b & c<=n)ans++;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3076
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    if a == 0 and b == 0:
                        break
                    if (100*A)*a + (100*B)*b + C*c + D*d > F:
                        break
                    if  ((100*A)*a + (100*B)*b)/100 *E < C*c + D*d:
                        break
                    density = 100 * (C*c+D*d) / ( (100*A)*a + (100*B)*b + C*c + D*d )
                    memo[a,b,c,d] = density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 39660
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

		long ans = 0;
		long ans2 = 0;
//		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);


		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();

//		int n = sc.nextInt();
//		int m = sc.nextInt();
//		int k = sc.nextInt();
//		int v = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);
//		String string2 = sc.next();
//		StringBuilder s2 = new StringBuilder(string);

		boolean f = false;

//		String[] s = new String[n];
//		int[] a = new int[n];
//		long[] a = new long[n];

//		int[][] a = new int[n][m];


//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}

//		for (int i = 0; i < n; i++) {
//			a[i] = sc.nextLong();
//		}


//		if() {
//
//		} else {
//
//		}

		long temp = k - n;


		if(k >= n + m) {
			ans = 0;
			ans2 = 0;
		} else {
			if(k <= n) {
				ans = n - k;
				ans2 = m;
			} else {
				ans = 0;
				ans2 = m - (k - n);
			}
		}

		System.out.println(ans);
		System.out.println(ans2);

		sc.close();
	}


}

Measured memory_bytes: 23380
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>

typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
//四方向への移動ベクトル
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

//入力
int H, W;
vector<string> field;

//探索
bool seen[510][510];	// seen[h][w] := マス(h,w)が検知済みかどうか

void dfs(int h, int w)
{
	seen[h][w] = true;

	//四方向を検索
	for (int dir = 0; dir < 4; dir++)
	{
		int nh = h + dx[dir];
		int nw = w + dy[dir];

		//場外アウトしたり、移動先が壁の場合はスルー
		if (nh < 0 || nh >= H || nw < 0 || nw <= W)continue;
		if (field[nh][nw] == '#')continue;

		//移動先が探索済みの場合
		if (seen[nh][nw])continue;

		//再帰的に探索
		dfs(nh, nw);
	}
}

/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}




int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
/*
vector<bool> seen;
void dfs(const Graph & G, int v)
{
	seen[v] = true;	//v を訪問済みにする

	// vから行ける各頂点 next_vについて
	for (auto next_v : G[v])
	{
		if (seen[next_v])continue;	//next_vが探索済みだったらスルー
		dfs(G, next_v);//再帰的に探索
	}
}
*/
/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


void init(int n)
{
	for (int i = 0; i < n; i++) par[i] = i;
	for (int i = 0; i < n; i++) r[i] = 0;
}

int find(int x)
{
	if (par[x] == x)return x;
	else return find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);

	if (r[x] < r[y])
	{
		par[x] = y;
	}
	else
	{
		par[y] = x;
		if (r[x] == r[y])
		{
			r[x]++;
		}
	}
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

};

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

	int R, G;
	cin >> R >> G;
	cout << 2 * G - R << endl;
	

	return 0;

}



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

const int MOD = 1e9 + 7;

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

ll N, last;
map<Pl, ll> MAP;

ll func(ll S, ll X) {
  if (MAP[Pl(S, X)] > 0) return MAP[Pl(S, X)];
  if (X == 0 && S == 0) {MAP[Pl(S, X)] = 1; return MAP[Pl(S, X)];}
  ll ans = 0;
  ans = (ans + func(S / 2, X / 2)) % MOD;
  if (X >= 1 && S >= 1) {ans = (ans + func((S - 1) / 2, (X - 1) / 2)) % MOD;}
  if (S >= 2) ans = (ans + func((S - 2) / 2, X / 2)) % MOD;
  MAP[Pl(S, X)] = ans;
  return ans;
}

int main(void){
    // Here your code !
    scanf("%lld", &N);
    last = func(N, N);
    printf("%lld\n", last);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;


void solve()
{
	int N;
	cin >> N;
	vector<int> C(N);
	vector<int> V(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> V[i];
	}
	for (int i = 0; i < N; ++i)
	{
		cin >> C[i];
	}
	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		ans += max(V[i] - C[i], 0);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
import sys
A,B,K=map(int,input().split())
if((B-A) < K):
    for i in range(A,B+1):
        print(i)
    sys.exit()
ansmin=[i for i in range(A,A+K,1)]
ansmax=[i for i in range(B,B-K,-1)]

ans=ansmin+ansmax
ans=set(ans)
ans=sorted(ans)
for a in ans:
    print(a)


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

int main() {
  string s;
  int n;
  int ans;

  cin >> n;
  cin >> s;

  for(int i=0;i<s.length();i++) {
    s[i] += n;
    if(s[i] > (int)'Z') {s[i] = s[i]-('Z'-'A'+1);}
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

vector<lint> prime_factorization(lint N) {
	//素因数分解して配列で返す
	vector<lint> R;
	if (N < 2)return R;
	for (lint i = 2; i * i <= N; i++) {
		while (N % i == 0) {
			R.push_back(i);
			N /= i;
		}
	}
	if (N != 1) {
		R.push_back(N);
	}
	return R;
}

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	for (lint i = 1; i <= N; i++) {
		vector<lint>V = prime_factorization(i);
		rep(j, V.size()) {
			A[V[j] - 1]++;
		}
	}
	lint ans = 1;
	lint MOD = pow(10, 9) + 7;
	rep(i, A.size()) {
		ans *= A[i] + 1;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#!/usr/bin/env python

n=int(raw_input().strip())
arr=map(int,raw_input().split())

b=0
cnt=0

for i in xrange(n-1):
    diff=arr[i+1]-arr[i]
    if b*diff<0:
        cnt+=1
        b=0
    elif b==0:
        b=diff
print cnt+1

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e17+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int x;
    cin >> x;
    int curr = 100;
    int cnt = 0;
    while(x > curr){
        curr = (curr+curr/100);
        cnt++;
    }
    cout << cnt;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,m;
double dp[maxn],tt[maxn],ans,q[maxn],tmp2;
vector <int> p[maxn];

inline void sol(int x)
{
	per(i,(x-1),1)
	{
		double tmp=0;
		for(int j=0;j<p[i].size();j++) tmp+=dp[p[i][j]];
		tt[i]=tmp; tmp/=p[i].size(); dp[i]=tmp+1;
	}
}

int main()
{
	n=read(); m=read();
	rep(i,1,m)
	{
		int u=read(),v=read();
		p[u].pb(v);
	}
	sol(n); ans=dp[1];
	per(i,(n-1),1)
	{
		if(p[i].size()==1) continue; double mx=0;
		for(int j=0;j<p[i].size();j++) mx=max(mx,dp[p[i][j]]);
		tt[i]-=mx; q[i]=tt[i]/(p[i].size()-1)+1;
		rep(k,1,(n-1)) if(k!=i) q[k]=dp[k];
		
		per(k,(i-1),1)
		{
			double tmp=0;
			for(int w=0;w<p[k].size();w++) tmp+=q[p[k][w]];
			tmp/=p[k].size(); q[k]=tmp+1;
		}
		ans=min(ans,q[1]);
	}
	printf("%.6lf\n",ans);
	return 0;
}

Measured memory_bytes: 30080
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define fir fisrt
#define sec second

int n, m;

int main(){
	scanf(" %d %d", &n, &m);
	int pos;
	for(int i = m / n; i >= 1; i --){
		if(m % i == 0){
			if(m / i >= n){
				pos = i;
				break;
			}
		}
	}
	printf("%d\n", pos);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n[5];
	scanf("%d%d%d%d%d", n+0, n+1, n+2, n+3, n+4);
	sort(n, n+5);
	printf("%d %d %d %d %d\n", n[4], n[3], n[2], n[1], n[0]);
	return 0;
}

Measured memory_bytes: 0
// Hopcroft-Karp Algorithm
// O(|E| * |V|^(1/2))
// http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm
// aoj 1163

#include <vector>
#include <queue>
#include <iostream>
using namespace std;

int NIL;
const int inf = 1<<29;

typedef vector<int> vi;
typedef vector<vector<int> > Graph;

bool bfs(const Graph &g,vi &dist,const vi &pair,int m) {
    queue<int> q;

    for(int i=0; i<m; ++i)
        if(pair[i] == NIL) {
            dist[i] = 0;
            q.push(i);
        }else
            dist[i] = inf;
    dist[NIL] = inf;

    while(!q.empty()) {
        int v = q.front(); q.pop();
        if(v == NIL) continue;
        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i];
            if(dist[pair[u]] == inf) {
                dist[pair[u]] = dist[v]+1;
                q.push(pair[u]);
            }
        }
    }
    return dist[NIL] != inf;
}

bool dfs(int v,const Graph &g,vi &dist,vi &pair) {
    if(v != NIL) {
        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i];
            if(dist[pair[u]] == dist[v]+1) {
                if(dfs(pair[u],g,dist,pair)) {
                    pair[u] = v, pair[v] = u;
                    return true;
                }
            }
        }
        dist[v] = inf;
        return false;
    }
    return true;
}

// 0ツつゥツづァm-1ツづ慊づづ個静淞点ツづツつゥツづァn-1ツづ慊づづ個静淞点ツづづ個催妥・ツマツッツチツδ督グツづーツ仰づ淞づゥ
int hopcroft_karp(Graph &graph,int m) {
    const int n = graph.size();
    NIL = n;
    vi pair(n+1, NIL), dist(n+1, 0);
    int ret = 0;
    while(bfs(graph,dist,pair,m)) {
        for(int i=0; i<m; ++i)
            if(pair[i] == NIL)
                if(i == NIL || dfs(i,graph,dist,pair)) ret++;
    }
    return ret;
}

int gcd(int x,int y) {
    if(y == 0) return x;
    return gcd(y,x%y);
}

int main() {
    ios::sync_with_stdio(false);
    int m,n;
    while(cin>>m>>n, m|n) {
        Graph g(m+n);
        vector<int> b(m), r(n);
        for(int i=0; i<m; ++i) cin>>b[i];
        for(int i=0; i<n; ++i) cin>>r[i];

        for(int i=0; i<m; ++i)
            for(int j=0; j<n; ++j)
                if(gcd(b[i],r[j]) > 1)
                    g[i].push_back(j+m);
        cout<<hopcroft_karp(g,m)<<endl;
    }
}

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

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

		int N = Integer.parseInt(sc.nextLine());
		int[] H = Arrays.stream(sc.nextLine().split(" ")).mapToInt(r -> Integer.parseInt(r)).toArray();

		int max_cnt = 0;
		int[] memo = new int[H.length];
		Arrays.fill(memo, -1);
		for (int i = H.length - 2; i >= 0; i--) {
			int cnt = (H[i] >= H[i + 1] ? 1 : 0);
			if (cnt > 0 && memo[i + 1] >= 0) {
				memo[i] = memo[i + 1] + cnt;
			}
			else {
				memo[i] = cnt;
			}
			max_cnt = Math.max(max_cnt, memo[i]);
		}
		System.out.println(max_cnt);
	}
}

Measured memory_bytes: 52952
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
        ce("Yes");
    else
        ce("No");
}

Measured memory_bytes: 3596
s = input()
n = len(s)
p = 10 ** 9 + 7

# i = 0, ..., nについて
# dp[i][0] = i文字目まででありうる文字列の数（ABCなら1、AB?なら3）
# dp[i][1] = i文字目までに含まれるAの数
# dp[i][2] = i文字目までに含まれるABのパターン数
# dp[i][3] = i文字目までに含まれるABCのパターン数
dp = [[0 for j in range(4)] for i in range(n + 1)]
dp[0][0] = 1 # ''空の文字列は1パターン
for j in range(1, 4):
    dp[0][j] = 0  # 空の文字列にはAもABもABCも入っていない

for i in range(1, n + 1):
    m = 3 if s[i - 1] == '?' else 1

    for j in range(4):
        dp[i][j] = dp[i - 1][j] * m % p

    if s[i - 1] == 'A' or s[i - 1] == '?':
        dp[i][1] =  (dp[i][1] + dp[i - 1][0]) % p
    if s[i - 1] == 'B' or s[i - 1] == '?':
        dp[i][2] = (dp[i][2] + dp[i - 1][1]) % p
    if s[i - 1] == 'C' or s[i - 1] == '?':
        dp[i][3] = (dp[i][3] + dp[i - 1][2]) % p

print(dp[n][3])

Measured memory_bytes: 27608
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let r = get!(i32);
    let g = get!(i32);
    println!("{}", 2*g - r);
}

Measured memory_bytes: 2108
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  int n; cin >> n;
  vector<int> q(n);
  vector<int> p(n);
  rep(i,n){
    cin >> q[i];
    q[i]--;
  }
  rep(i,n) p[q[i]]=i;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n) a[i]=i+1;
  rep(i,n) b[i]=n-i;
  vector<int> lazya=p;
  vector<int> lazyb=p;
  rep(i,n-1) lazya[i+1]+=lazya[i];
  for(itn i=n-1;i>0;i--) lazyb[i-1]+=lazyb[i];
  rep(i,n){
    a[i]+=lazya[i];
    b[i]+=lazyb[i];
  }
  rep(i,n){
    cout << a[i] << " ";
  }cout << endl;
  rep(i,n){
    cout << b[i] << " ";
  }cout << endl;
}

Measured memory_bytes: 4072
import sys

n=int(input())
V=list(map(int,input().split()))

check=0
for i in range(n):
    if V[i]!=V[i-1]:
        check=1
        break

if check==0:
    print(n//2)
    sys.exit()


G=[]
K=[]
for i in range(n):
    if i%2==0:
        G.append(V[i])
    else:
        K.append(V[i])

G.sort()
K.sort()

GV=[]
count=1

for i in range(1,len(G)):
    if G[i]==G[i-1]:
        count+=1
    else:
        GV.append((count,G[i-1]))
        count=1

GV.append((count,G[i-1]))

count=1
KV=[]
for i in range(1,len(K)):
    if K[i]==K[i-1]:
        count+=1
    else:
        KV.append((count,K[i-1]))
        count=1

KV.append((count,K[i-1]))

GV.sort(reverse=True)
KV.sort(reverse=True)

if GV[0][1]!=KV[0][1]:
    ANS=len(G)+len(K)-GV[0][0]-KV[0][0]

else:
    ANS=min(len(G)+len(K)-GV[1][0]-KV[0][0],len(G)+len(K)-GV[0][0]-KV[1][0])

print(ANS)


    
    
    


Measured memory_bytes: 15104
#!/usr/bin/env python3
import sys
import math

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

def solve(N: int, A: "List[int]"):
    res = A[0]
    B = A[1:]
    for a in B:
        res = gcd(res,a)

    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int vis[N];
int ar[N];
bool ok(int x,int y,int z){
	if((x+y<=z)|| (y+z<=x)||(z+x<=y))return 0;
	return 1;
}
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cin >> ar[i];
		}
		int ans=0;
		int m = n;
		// sort(ar,ar+n);
		fn{
			for(int j=i+1;j<n;j++){
				for(int k =j+1;k<n;k++){
					if(ar[i]!=ar[j] && ar[k]!=ar[i]&&ar[k]!=ar[j]){
						if(ok(ar[i],ar[j],ar[k])){
							// trace(i+1,j+1,k+1);
							ans++;
						}
					}
				}
			}
		}
		cout<<ans;

	
	
	}
	return 0;
}

Measured memory_bytes: 3664
/*
                       _oo0oo_
                      o8888888o         BE LIKE BUDDHA
                      88" . "88         KEEP CALM AND CODE HARD.
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  AVINASH PRASAD 
  DATE:/10/2019
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    int x = str.length();
    if(x%2)
    {
        cout << "No" << endl;
        return 0;
    }
    int l = 0, r = x/2;
    bool flag = true;
    while(l<x/2)
    {
        if(str[l]!=str[r])
        {
            flag = false;
            break;
        }
        l++;
        r++;
    }
    if(flag)
    cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

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;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  COMinit();

  ll minSum = 0;
  ll maxSum = 0;
  //最大値和
  rep(i,n) {
    maxSum += COM(i,k-1) * a[i];
    maxSum %= MOD;
  }

  reverse(a.begin(),a.end());

  //最小値和
  rep(i,n) {
    minSum += COM(i,k-1) * a[i];
    minSum %= MOD;
  }

  ll ans = (maxSum - minSum) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
void ng() {puts("No"), exit(0);}
int p[324000], n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {cin >> p[i]; if (i % 2 == p[i] % 2)ng();}
  for (int i = n - 3; i >= 0; i--)if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])swap(p[i], p[i + 2]);
  for (int i = n - 3; i >= 0; i--)if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])swap(p[i], p[i + 2]);
  for (int i = 1; i < n - 1; i++)if ((p[i - 1] > p[i + 1]) && (p[i - 1] < p[i] || p[i] < p[i + 1]))ng();
  // for (int i = 0; i < n; ++i) if (p[i] != i + 1) ng();
  puts("Yes");
  return 0;
}

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


Measured memory_bytes: 128
import sys
n=int(input())
s=str(input())
l=[0]*n
flag=1

if s[0]=='x':
  flag=0
  new_s=''
  for j in range(n):
    if s[j]=='x':
      new_s+='o'
    else:
      new_s+='x'
  s=new_s
  
def check(i,l):
  sys.setrecursionlimit(10000000)
  if i==0:
    l11=[0]*n
    l12=[0]*n
    l21=[0]*n
    l22=[0]*n
    l11[0]='S'
    l11[1]=l11[n-1]='S'
    l12[0]='S'
    l12[1]=l12[n-1]='W'
    tmp1=check(i+1,l11)
    tmp2=check(i+1,l12)
    l21[0]=l21[n-1]='W'
    l21[1]='S'
    l22[0]=l22[1]='W'
    l22[n-1]='S'
    tmp3=check(i+1,l21)
    tmp4=check(i+1,l22)
    if tmp1==tmp2==tmp3==tmp4==-1:
      return -1
    else:
      if tmp1!=-1:
        return tmp1
      if tmp2!=-1:
        return tmp2
      if tmp3!=-1:
        return tmp3
      if tmp4!=-1:
        return tmp4
  elif 1<=i<=n-2:
    if s[i]=='o':
      if l[i]=='S':
        l[i+1]=l[i-1]
        return check(i+1,l)
      else:
        if l[i-1]=='W':
          l[i+1]='S'
          return check(i+1,l)
        else:
          l[i+1]='W'
          return check(i+1,l)
    else:
      if l[i]=='W':
        l[i+1]=l[i-1]
        return check(i+1,l)
      else:
        if l[i-1]=='S':
          l[i+1]='W'
          return check(i+1,l)
        else:
          l[i+1]='S'
          return check(i+1,l)
  else:
    if s[i]=='o':
      if l[i]=='S':
        if l[i-1]==l[0]:
          if (l[0]=='W' and l[i]==l[1]) or (l[0]=='S' and l[i]!=l[1]):
            return -1
          else:
            return l
        else:
          return -1
      else:
        if l[i-1]!=l[0]:
          if (l[0]=='W' and l[i]==l[1]) or (l[0]=='S' and l[i]!=l[1]):
            return -1
          else:
            return l
        else:
          return -1
    else:
      if l[i]=='S':
        if l[i-1]!=l[0]:
          if (l[0]=='W' and l[i]==l[1]) or (l[0]=='S' and l[i]!=l[1]):
            return -1
          else:
            return l
        else:
          return -1
      else:
        if l[i-1]==l[0]:
          if (l[0]=='W' and l[i]==l[1]) or (l[0]=='S' and l[i]!=l[1]):
            return -1
          else:
            return l
        else:
          return -1      
ans=check(0,l)
if ans==-1:
  print(-1)
else:
  if flag:
    print(''.join(ans))
  else:
    for i in range(n):
      if ans[i]=='S':
        ans[i]='W'
      else:
        ans[i]='S'
    print(''.join(ans))

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }
  vector<vector<int>> cnt(h, vector<int>(w));
  for(int i = 0; i < h; i++){
    vector<bool> done(w, false);
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#') continue;
      if(done[j]) continue;
      int l = 0;
      while(j + l < w){
        if(s[i][j + l] == '#') break;
        l++;
      }
      for(int k = 0; k < l; k++){
        cnt[i][j + k] = l;
        done[j + k] = true;
      }
    }
  }
  for(int j = 0; j < w; j++){
    vector<bool> done(h, false);
    for(int i = 0; i < h; i++){
      if(s[i][j] == '#') continue;
      if(done[i]) continue;
      int l = 0;
      while(i + l < h){
        if(s[i + l][j] == '#') break;
        l++;
      }
      for(int k = 0; k < l; k++){
        cnt[i + k][j] += l-1;
        done[i + k] = true;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      ans = max(ans, cnt[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 20096
#include <iostream>
#include <string>

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

using namespace std;

int main(){
    int a,b; cin>>a>>b;
    int ans=0;
    int outlet=1;
    while(outlet<b){
        outlet--;
        outlet+=a;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = list(map(int, input().split()))
even = defaultdict(int)
odd = defaultdict(int)
for i in range(n):
    if i % 2 == 0:
        even[a[i]] += 1
    else:
        odd[a[i]] += 1
x = sorted(even.items(), reverse=True, key=lambda t:t[1])
y = sorted(odd.items(), reverse=True, key=lambda t:t[1])
even_index = 0
odd_index = 0
if x[0][0] == y[0][0]:
    if x[0][1] > y[0][1]:
        even_index = 0
        odd_index = 1
    elif x[0][1] < y[0][1]:
        odd_index = 0
        even_index = 1
    else:
        if len(x) > 1:
            print(n - x[0][1] - max(x[1][1], y[1][1]))
        else:
            print(n // 2)
        exit()
            
else:
    even_index = 0
    odd_index = 0
print(n - x[even_index][1] - y[odd_index][1])


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

int main() {
   int n;
   cin>>n;
   int x=n%10;
   if(x==2 or x==4 or x==5 or x==7 or x==9){
       cout<<"hon";
   }
   else if(x==0 or x==1 or x==6 or x==8){
       cout<<"pon";
   }
   else{
       cout<<"bon"<<endl;   }
   return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,i,k,x;
    cin>>n>>k;
    if(n<=8 && k<=8){
        cout<<"Yay!"<<endl;
    } else {
       cout<<":("<<endl;
    }
    return 0;
}


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

struct tree{
    size_t n,r,md;
    vector<vector<int>> e;
    vector<int> c,sz;
    vector<ll> ans,C;
    explicit tree(int n):n(n),e(n),c(n),C(n),ans(n, ll(n)*(n+1)/2){}
    void built(){
        static int a,b;
        for(auto&i:c) cin>>i,--i;
        for(int i{1};i<n;++i){
            cin>>a>>b;
            --a,--b;
            e[a].emplace_back(b);
            e[b].emplace_back(a);
        }
    }
    void dfs(int i=0,int p=-1){
        ll tmp = C[c[i]];
        for(auto j:e[i]) if(j!=p){
                C[c[i]]=0;
                dfs(j,i);
                sz[i]+=sz[j];
                ans[c[i]]-=(sz[j]-C[c[i]])*(sz[j]-C[c[i]]+1)/2;
            }
        C[c[i]] = tmp+sz[i];
    }
    void solve(){
        sz.assign(n,1);
        dfs();
        for(int i{};i<n;++i) cout<<ans[i]-(n-C[i])*(n-C[i]+1)/2<<'\n';
    }
};

int main(){
    int n;
    cin>>n;
    tree t(n);
    t.built();
    t.solve();
}

Measured memory_bytes: 37484
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n,a,b,i;
  cin >> n >> a >> b;
  int ans=0;
  for(i=1;i<=n;i++){
    if(digit(i)>=a && digit(i)<=b){
      ans+=i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
N = int(input())
H = list(map(int,input().split()))
dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])


Measured memory_bytes: 52208
#include<bits/stdc++.h>
using namespace std;
const int N = 5001;
const int P = 1e9+7;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

int f[N][N][2];
int n,fact[N],cat[N];
vector<int> edge[N];

inline int pow_mod(int x,int k){
   int res = 1,base = x;
   while(k){
      if(k&1)res = 1LL*res*base%P;
      k >>= 1; base = 1LL*base*base%P;
   }
   return res;
}

inline void add(int &x,int y){
   x += y; if(x >= P)x -= P;
}

void init(){
   fact[0] = 1;
   fr(i,1,N-1)fact[i] = 1LL*fact[i-1]*i%P;
   for(int i = 2;i < N;i += 2)cat[i] = 1LL*fact[i]*pow_mod(fact[i/2],P-2)%P*
      pow_mod(pow_mod(2,P-2),i/2)%P;
}

int siz[N];
void dfs(int x,int fa){
   siz[x] = 1;
   memset(f[x],0,sizeof f[x]);
   f[x][1][0] = 1;
   fr(i,0,(int)edge[x].size()-1){
      int y = edge[x][i];
      if(y == fa)continue ;
      dfs(y,x);
      nfr(j,siz[x],0){
         int cur[2] = {f[x][j][0],f[x][j][1]};
         f[x][j][0] = f[x][j][1] = 0;
         fr(w,0,1){
            fr(w1,0,1){
               fr(k,0,siz[y])
                  add(f[x][j+k][(w1+w)%2],1LL*cur[w]*f[y][k][w1]%P);
            }
         }
      }
      siz[x] += siz[y];
   }
   
   for(int j = 2;j <= siz[x];j += 2){
      add(f[x][0][0],1LL*f[x][j][1]*cat[j]%P);
      add(f[x][0][1],1LL*f[x][j][0]*cat[j]%P);
   }
}

int main(){
   init();
   scanf("%d",&n);
   fr(i,1,n-1){
      int u,v; scanf("%d%d",&u,&v);
      edge[u].pb(v); edge[v].pb(u);
   }
   dfs(1,0);

   int res = 0;
   add(res,f[1][0][1]);
   add(res,P-f[1][0][0]);
   printf("%d\n",res);
   return 0;
}


Measured memory_bytes: 196608
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func mulOverflows(a, b int) bool {
	if a <= 1 || b <= 1 {
		return false
	}
	c := a * b
	return c/b != a
}

func main() {
	var n int
	fmt.Scan(&n)

	sc.Split(bufio.ScanWords)
	A := make([]int, n)
	for i := 0; i < n; i++ {
		v := nextInt()
		if v == 0 {
			fmt.Println(0)
			return
		}
		A[i] = v
	}

	a := 1
	for i := 0; i < n; i++ {
		if mulOverflows(a, A[i]) {
			fmt.Println(-1)
			return
		}
		a *= A[i]
		if a > 1e18 {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(a)
}


Measured memory_bytes: 5920
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mp make_pair
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const unsigned ll l=1000000007;
const int MAX_=2000;
int T;
 
void print(string res, int i)
{
  printf("Case #%d: %s\n",T-i,res.c_str());
  // cout << res;
}
void print(ll res, int i)
{
  printf("Case #%d: %lld\n",T-i,res);
  // cout << res;
}

void solve(int t)
{
  ll a,b;
  cin >> a >> b;
  if(a == b)
  {
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}
 
int main()
{
  IOS
  int t,testCases;
  testCases=1;
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    cin >> testCases;
    cout << "Running " << testCases << " testcases" << endl;
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
  #endif
 
 
  while(testCases--)
  {
    t=1;
    // cin >> t; //comment this in case of singular test case
    T = t;
    while(t--)
    {
      solve(t);
    }
  }
  return 0;
 
}

Measured memory_bytes: 256
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

        

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

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

  std::vector<int> a(n+1), b(n);
  for(int i=0; i<n+1; ++i) cin >> a[i];
  for(int i=0; i<n; ++i) cin >> b[i];

  long long ans = 0;
  for(int i=0; i<n; ++i){
    ans += min(a[i], b[i]);
    int work = a[i];
    a[i] = max(0, a[i]-b[i]);
    b[i] -= work - a[i];

    ans += min(a[i+1], b[i]);
    a[i+1] = max(0, a[i+1] - b[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;
using boost::irange;

int main(){

    int N, M;
    cin >> N >> M;

    vector<ll> A(N);
    for (auto &a: A){
        cin >> a;
    }

    
    int rem = M;
    for (int i=0; rem>0; i++){
        sort(A.begin(), A.end());
        A[N-1] /= 2; rem--;
        auto it = upper_bound(A.begin(), A.end(), A[N-1]);
        for (int j = N-2 ; j >= it-A.begin() && rem > 0; j--){
            A[j] /= 2;
            rem--;
        }
    }

    ll ans = 0;
    for (auto &a: A){
        ans += a;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int N = 1e5 + 3;
typedef long long ll;
typedef pair<int, int> ii;
vector<int> g[N];
int n, m;

struct DSU {
  int* d, n, *sz;
  ll sub = 0;
  DSU(const int& _size) {
    n = _size;
    d = new int [n + 1];
    sz = new int[n + 1];
    for (int i = 0; i <= n; ++i) {
      d[i] = i;
      sz[i] = 1;
    }
  }
  int get(int u) {
    if (u == d[u]) return u;
    return d[u] = get(d[u]);
  }
  bool merge(int u, int v) {
    u = get(u);
    v = get(v);
    if (u == v) return false;
    sub -= 1ll * sz[u] * (sz[u] - 1) / 2;
    sub -= 1LL * sz[v] * (sz[v] - 1) / 2;
    sz[u] += sz[v];
    d[v] = u;
    sub += 1LL * sz[u] * (sz[u] - 1) / 2;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> n >> m;
  vector<ii> edge(m);
  for (int i = 0; i < m; ++i)
    cin >> edge[i].first >> edge[i].second;
  reverse(edge.begin(), edge.end());
  vector<ll> ans;
  ans.push_back(1LL * n * (n - 1) / 2);
  DSU dsu(n);
  for (int i = 1; i < m; ++i) {
    dsu.merge(edge[i - 1].first, edge[i - 1].second);
    ans.push_back(ans[0] - dsu.sub);
  }
  reverse(ans.begin(), ans.end());
  for (ll v : ans)
    cout << v << '\n';
	return 0;
}	

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

int selectionSort(int A[], int n)
{
    int sw = 0, minj;

    for (int i = 0; i != n-1; ++i)
    {
        minj = i;

        for (int j = i; j != n; ++j)
        {
            if (A[j] < A[minj])
            {
                minj = j;
            }
        }

        if (minj != i)
        {
            swap(A[i], A[minj]);
            ++sw;
        }
    }

    return sw;
}

int main()
{
    int A[100], n, sw;

    cin >> n;

    for (int i = 0; i != n; ++i)
    {
        cin >> A[i];
    }

    sw = selectionSort(A, n);

    for (int i = 0; i != n; ++i)
    {
       if (i > 0)
       {
           cout << " ";
       }

        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;

    return 0;
}


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

using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long aux;
    long long resto = 0;
    long long pairs = 0;
    while(n--)
    {
        cin >> aux;
	if(!aux)
        {
            resto = 0;
	    continue;
        }
        pairs += (aux + resto)/2;
        resto = (aux - resto) % 2;
    }
    cout << pairs << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int64_t ans=0;
  for(int i=1;i<N-1;i++){
  if((N-1)%i==0){
  int k=(N-1)/i; k-=1; k/=2;
    int64_t a=0;
    for(int j=0;j<=k;j++){
    a+=A.at(i*j)+A.at(N-1-i*j);
      if(ans<a)ans=a;
    }
      }else{
  int64_t a=0;
    for(int j=0;(1+j)*i<N-1;j++){
    a+=A.at(i*j)+A.at(N-1-i*j);
      if(ans<a)ans=a;
    }
  }
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4060
package main

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

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 200200)

	s := []byte(getString())

	cnt := 0
	pos := 0
	bcc := 0
	sum := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			out("A")
			cnt++
		} else if i < len(s)-1 && s[i] == 'B' && s[i+1] == 'C' {
			out("BC", cnt)
			i++
			pos += cnt - bcc
			cnt++
			bcc++
		} else {
			if bcc != 0 {
				sum += pos
			}
			out("sum", sum, "pos", pos, "cnt", cnt, bcc)
			cnt = 0
			bcc = 0
			pos = 0
		}
	}
	out("sum", sum, "pos", pos, "cnt", cnt)
	if bcc != 0 {
		sum += pos
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string S,T;
  cin >> S >> T;
  int n=S.size();
  bool flag=true;
  rep(i,n) {
    if(S[i]!=T[i])flag=false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int con = 0;
    if (A % 2 == 1) break;
    while (A % 2 == 0) {
      A /= 2;
      con++;
    }
    if (ans == 0) ans = con;
    else ans = min(ans, con);
    con = 0;
  }
  cout << ans << endl;
}

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

  double dp[3300][3300];


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

  double p[N];
  rep(i,N)cin>>p[i];
  dp[0][0] =1;


  for(int i=1;i<N+1;i++){
    for(int j = 0;j<=i;  j++){
      dp[i][j] += dp[i-1][j] *(1-p[i-1]);
      if(j-1>=0)dp[i][j] += dp[i-1][j-1]*p[i-1];
    }
  }


double ans = 0;
for(int i = 0;i<N+1;i++){
  if(i > N-i) ans += dp[N][i];
}

  cout<<fixed<<setprecision(10)<<ans;

}


Measured memory_bytes: 76416