akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;


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

    int a, b, c;
    cin >> a >> b >> c;

    // a = b, c diff
    if (a == b && c != a) cout << "Yes";
    // a = c, b diff
    else if (a == c && b != a) cout << "Yes";
    // b = c, a diff
    else if (b == c && a != b) cout << "Yes";
    else cout << "No";

    return 0;
}

/*
file=a
g++ -W -Wall -pedantic --std=c++17 -ggdb3 -o ${file}.out ${file}.cpp && ./${file}.out

*/


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

int main(void){
    int n,b,i,j,v=0,a[100010],ans=0,bob=0,alice=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n,greater<int>());
    for(i=0;i<n;i++)
        if(i%2==0)
        {
            alice+=a[i];
        }
        else
        {
            bob+=a[i];
        }
    ans=alice-bob;
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3632
N = list(input())
n = len(N)
N = int(''.join(N))

if(n == 1):
  ans = N
  print(ans)
elif(n == 2):
  print(9)
elif(n == 3):
  ans = N-100+1
  print(9+ans)
elif(n == 4):
  print(9+900)
elif(n == 5):
  ans = N-10000+1
  print(9+900+ans)
elif(n == 6):
  print(9+900+90000)
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
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; }

struct UnionFind {
    vector<int> par;

    UnionFind(int sz) {
        par.assign(sz, -1);
    }

    bool merge(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return (false);
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return (true);
    }

    int root(int k) {
        if(par[k] < 0) return (k);
        return (par[k] = root(par[k]));
    }

    int size(int k) {
        return (-par[root(k)]);
    }

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

int main(){
    int n,m,k; cin >> n >> m >> k;
    vector<int> a(m), b(m), c(k), d(k);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    rep(i,k){
        cin >> c[i] >> d[i];
        c[i]--; d[i]--;
    }
    UnionFind uf(n);
    vector<int> gf[n], gb[n];
    rep(i,m){
        gf[a[i]].pb(b[i]);
        gf[b[i]].pb(a[i]);
        uf.merge(a[i], b[i]);
    }
    rep(i,k){
        if(uf.same(c[i], d[i])){
            gb[c[i]].pb(d[i]);
            gb[d[i]].pb(c[i]);
        }
    }
    rep(i,n){
        cout << uf.size(i) - gf[i].size() - gb[i].size() - 1;
        if(i != n-1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

int N, W, D;

int area(pii a) {
  return a.fi * a.se;
}

int main(void) {
  while(cin >> N >> W >> D, N || W || D) {
    vector<pii> piece;
    piece.pb(pii(W, D));

    REP(i, 0, N) {
      int p, s, w, d;
      cin >> p >> s;
      p--;
      w = piece[p].fi;
      d = piece[p].se;

      piece.erase(piece.begin() + p);

      s %= w + d;
      if(0 < s && s < w) {
        piece.pb(pii(s, d));
        piece.pb(pii(w - s, d));
      } else {
        s -= w;
        piece.pb(pii(w, s));
        piece.pb(pii(w, d - s));
      }
      if(area(piece[i]) > area(piece[i + 1])) swap(piece[i], piece[i + 1]);
    }

    vector<int> ans;
    REP(i, 0, piece.size()) ans.pb(area(piece[i]));
    sort(ans.begin(), ans.end());
    REP(i, 0, ans.size()) {
      cout << ans[i];
      if(i + 1 != ans.size()) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
#include <iomanip>
#define PI 3.14159265
using namespace std;

double a, b, x;
double eps = 1e-8;

double get_res(double max_lim){
    double l = 0;
    double r = 90 - eps;
    double mid;
    while(r - l > eps){
        mid = (l + r) / 2;
        if(tan(mid*PI/180.0) > max_lim) r = mid;
        else l = mid;
    }
    return l;
}

int main(){
    cin >> a >> b >> x;
    x /= a;
    double cons;
    if (x <= 0.5*a*b){
        cons = (x*2)/(b*b);
    } else {
        cons = a/(2*b - (x*2.0/a));
    }
    cout << setprecision(11)<<90 - get_res(cons) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int ret;
	int k;
	char s[101];
	char sbuf[200];
	char *pbuf;
	memset(s,0,sizeof(s));
	memset(sbuf, 0, sizeof(sbuf));
	int n;
	ret = scanf("%d", &k);
	ret = scanf(" %s", s);

	n = strlen(s);
	if (n <= k)
		printf("%s\n",s);
	else {
		pbuf = strncpy(sbuf, s, k);
		pbuf = strcat(pbuf, "...");
		printf("%s\n",pbuf);
	}
	fflush(stdout);
	return EXIT_SUCCESS;
}


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

class Main{
	public static void main(String[] arg) {
		Scanner sc=new Scanner(System.in);
		int ninzu=sc.nextInt();
		int[] teamscore=new int[ninzu+1];

		for(int i=0; i<ninzu; i++) {
			teamscore[i]=sc.nextInt();
		}
		teamscore[ninzu]=0;

		Arrays.sort(teamscore);

		int tmp=0;

		for(int h=100; h>=1; h--) {
			tmp=0;
			for(int i=1; i<=ninzu; i++) {
				if(teamscore[i]>=h) {
					tmp++;
				}
			}
			if(tmp>=h) {
				System.out.println(h);
				break;
			}
		}
	}
}


Measured memory_bytes: 26380
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    vl h1(n);
    rep(i, n) {
        cin >> h1[i];
    }

    // 判定問題「？」を二分探索で解く
    ll left = -1;
    ll right = INF;
    while(right - left > 1) {
        ll x = (left + right)/2;
        vl h2(n);
        rep(i, n) {
            h2[i] = h1[i] - b*x;
        }
        ll cnt = 0;
        rep(i, n) {
            if(h2[i] > 0) {
                cnt += ceil(h2[i], a-b);
            }
        }
        if(cnt <= x) {
            right = x;
        }
        else {
            left = x;
        }
    }

    out(right);
    re0;
}

Measured memory_bytes: 1792
N, X, Y = map(int, input().split())
d = Y-X+1
l = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1):
        m = min(j-i, abs(X-i)+1+abs(Y - j))
        l[m] += 1
print(*l[1:-1], sep="\n")


Measured memory_bytes: 74328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
int ans;

bool ok(int x) {
	int k = n;
	while (!(k%x))k /= x;
	return k % x == 1;
}

signed main() {
	cin >> n;
	for (int i = 2; i <= sqrt(n); i++) {
		if (!(n%i)) {
			if (ok(i))ans++;
			if (i*i != n && ok(n / i))ans++;
		}
	}
	n--;
	for (int i = 2; i <= sqrt(n); i++) {
		if (!(n%i)) {
			ans++;
			if (i*i != n)ans++;
		}
	}
	if (2 < n)ans += 2;
	else ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        String P = scanner.next().toLowerCase();
        char p[] = P.toCharArray();
 
        String tmp;
        int ans = 0;
        boolean FLG;
 
        while(!(tmp = scanner.next()).equals("END_OF_TEXT")){
 
            char line[] = tmp.toLowerCase().toCharArray();
 
            if(line.length != p.length)continue;
 
            FLG = true;
            for(int i = 0; i < P.length(); i++){
                if(p[i] != line[i]){
                    FLG = false;
                    break;
                }
            }
            if(FLG)ans++;
        }
 
        System.out.println(ans);
    }
}


Measured memory_bytes: 26164
mod=1000000007
a=0
ab=0
abc=0
Q=1
S=input()
for i in S:
    if i=="A":
        a+=Q
    elif i=="B":
        ab+=a
    elif i=="C":
        abc+=ab
    else:
        abc=abc*3+ab
        ab=ab*3+a
        a=a*3+Q
        Q=Q*3
    a=a%mod
    ab=ab%mod
    abc=abc%mod
    Q=Q%mod
print(abc)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;    cin >> a >> b;
    if(a < b){
        rep(i, b){
            cout << a;
        }
    }else{
        rep(i, a){
            cout << b;
        }
    }
    cout << endl;
}


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

int main() {
	int a,b,x;
	cin >> a >> b >> x;
	if(a+b >= x && a <= x) cout <<"YES"<<endl;
	else cout << "NO" << endl; 
	return 0;
}

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

int main() {
    
    int ans = 0;
    
    int N, M;
    cin >> N >> M;
    
    vector<ll> H(N);
    rep(i, N){
        cin >> H[i];
    }
    
    vector<int> good(N, 1);
    
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(H[a] > H[b]){
            good[b] = 0;
        }else if(H[a] < H[b]){
            good[a] = 0;
        }else{
            good[a] = 0;
            good[b] = 0;
        }
    }
    
    rep(i, N){
        ans += good[i];
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int A = V[0], B = V[1];
            Console.WriteLine(A >= 13 ? B : A >= 6 ? B / 2 : 0);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        for (int i = 1; i < s.length() / 2 + 1; i++) {
            String s1 = s.substring(0, i);
            String s2 = s.substring(i, i + i);
            if(s1.equals(s2)){
                if(!s.equals(s1 + s2)) {
                    ans = i * 2;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 39456
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int diff = a[n / 2] - a[n / 2 - 1];
	cout << diff;
}

Measured memory_bytes: 640
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int n,x;
map <int,int> mp;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>x;
		if(mp[x]>0)
		{
			puts("NO");
			return 0;
		}
		mp[x]=1;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
answer = op = 0
while true
	x = gets.chomp
	break if x == "="

	if index = "+-*/".index(x)
	    op = index
	else
		x = x.to_i
		case op
		when 0 then answer += x
		when 1 then answer -= x
		when 2 then answer *= x
		when 3 then answer /= x
		end
	end
end
puts answer


Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double A,B,P,Q,R;cin>>A>>B>>P>>Q>>R;
    
    cout<<setprecision(25)<<B+(B*P-(B-A)*Q)/(Q+R)<<endl;
}





Measured memory_bytes: 3304
n, m = map(int, input().split())
x = [int(i) for i in input().split()]
x.sort()

dif = []
for i in range(1,len(x)):
  dif.append(x[i] - x[i-1])
dif.sort()
dif.reverse()

print(sum(dif[n-1:]))

Measured memory_bytes: 13832
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


ll dx[2]={1,0};
ll dy[2]={0,1};
ll h,w;
bool valid(ll i,ll j){
    if(0<=i&&i<=h-1&&0<=j&&j<=w-1)return true;
    return false;
}
int main(){fastio
    cin>>h>>w;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll dp[h][w];rep(i,0,h-1)rep(j,0,w-1)dp[i][j]=inf;

    ll c=0;
    while(1){
        
        queue<l_l>q;
        if(c==0){
            q.push({0,0});
            dp[0][0]=0;
        }else{
            rep(i,0,h-1){
                rep(j,0,w-1){
                    if(dp[i][j]==c-1){
                        rep(z,0,1){
                            ll nx=i+dx[z];
                            ll ny=j+dy[z];
                            if(!valid(nx,ny))continue;
                            if(dp[nx][ny]!=inf)continue;
                            dp[nx][ny]=c;
                            q.push({nx,ny});
                        }
                    }
                }
            }
        }
        if(q.empty())break;
        
        while(!q.empty()){
            l_l t=q.front();q.pop();
            rep(z,0,1){
                ll nx=t.fi+dx[z];
                ll ny=t.se+dy[z];
                if(!valid(nx,ny))continue;
                if(dp[nx][ny]!=inf)continue;
                if(s[t.fi][t.se]==s[nx][ny]){
                    q.push({nx,ny});
                    dp[nx][ny]=dp[t.fi][t.se];
                }
            }
        }
        c++;
    }
    /*
    rep(i,0,h-1){
        rep(j,0,w-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }cout<<endl;
     */
    ll ans=(dp[h-1][w-1]+1)/2;
    if(s[0][0]=='#'&&s[h-1][w-1]=='#')ans++;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
n, m, l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(list(map(int, input().split())))
    
for i in range(n):
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += a[i][k]*b[k][j]
        if j == l-1:
            print(str(tmp))
        else:
            print(str(tmp) + ' ', end='')


Measured memory_bytes: 6576
#include<bits/stdc++.h>
using namespace std ;
int h , w , n ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    cin >> h >> w >> n ;
    h = max(h , w) ;
    cout << n / h + (n % h != 0) << '\n' ;
    return 0 ;
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
ans = [0]*n
for i in range(1,int(n**(1/2))+1):
    for j in range(1,int(n**(1/2))+1):
        for k in range(1,int(n**(1/2))+1):
            if (i**2 + j**2 + k**2 + i*j + j*k + k*i)%1 == 0 and i**2 + j**2 + k**2 + i*j + j*k + k*i <= n:
                ans[i**2 + j**2 + k**2 + i*j + j*k + k*i - 1] += 1
for i in range(n):
    print(ans[i]) 

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

int main()
{
    int k;
    cin>>k;
    int sum=0;
    for(int a=1;a<=k;a++)
	for(int b=1;b<=k;b++)
	    for(int c=1;c<=k;c++)
		sum+=__gcd(__gcd(a, c), b);
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

const int MAX_N=1e5;

int N,A[MAX_N];

vector<int> G[MAX_N];
int win[MAX_N];

int dfs(int v){
	vector<int> vec;
	REP(i,(int)G[v].size()){
		vec.push_back(dfs(G[v][i]));
	}
	sort(vec.begin(),vec.end());
	int res=G[v].size();
	REP(i,(int)vec.size()){
		res=max(res,vec[i]+(int)vec.size()-i);
	}
	return res;
}

int main(){
	scanf("%d",&N);
	REP(i,N-1){
		scanf("%d",&A[i+1]);
		A[i+1]--;
		G[A[i+1]].push_back(i+1);
	}
	/*
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		REP(i,(int)G[v].size()){
			int u=G[v][i];
			win[v]++;
			win[u]=win[v];
			que.push(u);
		}
	}
	*/
	printf("%d\n",dfs(0));
	return 0;
}


Measured memory_bytes: 15488
N, Y = map(int, input().split())
Payable = False
try:
    for i in range(N+1):
        for j in range(N+1-i):
            k = N-i-j
            if i*10000+j*5000+k*1000 == Y:
                print(i,j,k)
                Payable = True
                raise Exception
except Exception:
    pass

if not Payable:
    print(-1, -1, -1)

             


Measured memory_bytes: 40684
S = input()

l = []
r = []
tmp = 0
for s in S:
    if s == 'L':
        r.append(tmp)
        tmp = 0
    else:
        r.append(0)
        tmp += 1
tmp = 0
for s in S[::-1]:
    if s == 'R':
        l.append(tmp)
        tmp = 0
    else:
        l.append(0)
        tmp += 1
l = l[::-1]
ans = [0 for i in range(len(S))]
for i in range(len(S)-1):
    ans[i] += r[i+1] % 2 + r[i+1] // 2 + l[i] // 2
    ans[i+1] += r[i+1] // 2 + l[i] % 2 + l[i] // 2
print(*ans)


Measured memory_bytes: 8040
#include <bits/stdc++.h>
#define rep(i,n)for(unsigned long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<string>s(n);
  vector<int>t(n);
  rep(i,n) cin >> s[i] >> t[i];
  
  string x ;
  cin >> x;
  
  int start;
  rep(i,n){
    if(x==s[i]){
      start=i;
      break;
    }
  }
  int sum=0;
  for(int i=start+1;i<n;i++){
    sum+=t[i];
  }
  cout<<sum <<endl;
  
}

Measured memory_bytes: 256
s = set(input())

if 'N' in s:
    if not 'S' in s:
        print('No')
        exit()

if 'S' in s:
    if not 'N' in s:
        print('No')
        exit()

if 'W' in s:
    if not 'E' in s:
        print('No')
        exit()

if 'E' in s:
    if not 'W' in s:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define int long long int 

int32_t main()
{
    string str;
    getline(cin,str);

    stringstream  ss(str);
    string word;
    while(ss>>word)
    {
        transform(word.begin(),word.end(),word.begin(),::toupper);
        cout<<word[0];
    }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

#define Edge pair< i_i, int>
#define Graph vector< vp >

//???????§????????????????(???????????????)
//Dijkstra O((E+V)logV)
//dist: ?§????????????????????????§??????????????¢
//?????????: ??????????????¨????????????(??????-1)
vector<int> dijkstra(Graph &g, int s, vi &dist)
{
    int n = g.size();
    vi visited(n, 0); visited[s] = 1;
    vi prev(n, -1);
    dist.assign(n, INF); dist[s] = 0;
    priority_queue< Edge, vector< Edge >, greater< Edge > > pq;
    pq.push(Edge(i_i((int)0, s), (int)-1)); // ????????? ??? ???
    while (pq.size()) {
        int d = pq.top().ffir, v = pq.top().fsec, u = pq.top().second;
        pq.pop();
        if (dist[v] < d) continue; //?????§???????????§???????????°??????
        visited[v] = 2; prev[v] = u;
        for (i_i &e : g[v]) {
            if (visited[e.fir] == 2) continue;
            if (dist[e.fir] > dist[v] + e.sec) {
                dist[e.fir] = dist[v] + e.sec;
                pq.push(Edge(i_i(dist[e.fir], e.fir), v));
                visited[e.fir] = 1;
            }
        }
    }
    return prev;
}

 
signed main()
{
    int2(n, m);
    Int(st);
    Graph g(n, vp());
    vi ans(n);

    rep(i, m) {
        int2(s, t);
        Int(d);
        g[s].pb(i_i(t, d));
    }
    dijkstra(g, st, ans);
    rep(i, n) {
        if (ans[i] == INF) {
            cout << "INF" << endl;
        } else {
            cout << ans[i] << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 22004
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
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; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  reverse(all(s));
  int n = sz(s);
  int i = 0;
  int numw = 0, numb = 0;
  int ans = 0;
  while (i < n && s[i] == 'B') i++;
  while (i < n) {
    while (i < n && s[i] == 'W') i++, numw++;
    while (i < n && s[i] == 'B') i++, numb++;
    ans += numw * numb;
    numb = 0;
  }
  cout << ans << endl;

  return 0;
}

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

int main(){

    long long int N, A, B;
    cin >> N >> A >> B;

    long long int C, D;
    C = N/(A+B);
    D = N - C*(A+B);

    long long int ans = 0;
    ans = (N - C * (A + B) >= A) ? C*A + A : C*A + D;

    cout << ans << endl;  

    return 0;
}

Measured memory_bytes: 256
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

N,K = map(int,input().split())
def kitai(num):
    return (1+int(num))/2
P = list(map(kitai,input().split()))	  

S = [0]*(N+1)
ans = 0
for i in range(N):
    S[i+1]=S[i]+P[i]
for i in range(N-K+1):
    ans = max(ans,S[i+K]-S[i])
print(ans)





Measured memory_bytes: 23524
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	char ch;
	cin>>ch;
	cout<<char(ch+1)<<endl;
	return 0;
}

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

int main(){
  int X, A, B;
  cin >> X >> A >> B;
  if(B<=A){
    cout << "delicious" << endl;
  }
  else if(B>A && B-A<=X){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
    
        switch (a % 10) { 
        case 0: System.out.println ("pon"); break;
        case 1: System.out.println ("pon"); break;
        case 2: System.out.println ("hon"); break;
        case 3: System.out.println ("bon"); break;
        case 4: System.out.println ("hon"); break; 
        case 5: System.out.println ("hon"); break;
        case 6: System.out.println ("pon"); break;
        case 7: System.out.println ("hon"); break;
        case 8: System.out.println ("pon"); break;
        case 9: System.out.println ("hon"); break;
        default: break;
		}
	}
}


Measured memory_bytes: 35732
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    string a,b;
    cin >> a >> b;
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp

s_n = S.chars
t_n = T.chars
s_l = s_n.length
t_l = t_n.length
ans = t_l
(0..(s_l-t_l)).each do |i|
  count = 0
  (0..t_l-1).each do |j|
    count += 1 if s_n[i+j] != t_n[j]
  end
  ans = [ans, count].min
end

p ans

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

cities = []
d1 = {}
d2 = {}

for i in range(N):
    s, p = input().split()
    P = int(p)
    if s not in cities:
         cities.append(s)
    if s not in d1:
        l = [P]
        d1[s] = l
    else:
        d1[s].append(P)

    d2[P] = i + 1

newcity = sorted(cities)

for i in newcity:
    newlist = sorted(d1[i], reverse=True)
    for j in newlist:
        print(d2[j])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
vector<ll> test,raf;
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>m>>l>>k)
    {
        ll ara[n],bara[m],tara[l];
        for(i=0;i<n;i++) cin>>ara[i];
        for(i=0;i<m;i++) cin>>bara[i];
        for(i=0;i<l;i++) cin>>tara[i];
        test.clear();
        for(i=0;i<n;i++){
            for(j=0;j<m;j++) test.pb(ara[i]+bara[j]);
        }
 
        sort(test.begin(),test.end(),greater<ll>());
        sort(tara,tara+l);
        raf.clear();
        
        ll siz=test.size();
        for(i=0;i<min(k,siz);i++) {
            for(j=0;j<min(k,l);j++) raf.push_back(test[i]+tara[j]);
        }
 
        sort(raf.begin(),raf.end(),greater<ll>());
        siz=raf.size();
        for(i=0;i<siz && k;i++){
             cout<<raf[i]<<endl;
             --k;
        }
 
        
    }
 
 
 
 
 
}

Measured memory_bytes: 43236
import sys

input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    s=input()
    dic={"A":[0 for i in range(N)],"B":[0 for i in range(N)]}
    edge=[[] for i in range(N)]

    for i in range(M):
        a,b=map(int,input().split())
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
        dic[s[a]][b]+=1
        dic[s[b]][a]+=1

    que=set([])
    check=0
    for i in range(N):
        if dic["A"][i]==0 or dic["B"][i]==0:
            que.add(i)
            dic["A"][i]=float("inf")
            dic["B"][i]=float("inf")

    while que:
        v=que.pop()
        check+=v+1
        for nv in edge[v]:
            dic[s[v]][nv]-=1
            if dic["A"][nv]==0 or dic["B"][nv]==0:
                dic["A"][nv]=float("inf")
                dic["B"][nv]=float("inf")
                que.add(nv)

    if check==N*(N+1)//2:
        print("No")
    else:
        print("Yes")

if __name__=="__main__":
    main()


Measured memory_bytes: 97196
n=int(input())
arr1=[]
arr2=[]
for _ in range(n):
  a,b=map(int,input().split())
  arr1.append(a)
  arr2.append(b)
arr1=sorted(arr1)
arr2=sorted(arr2)
if n%2==1:
  l=arr1[n//2]
  r=arr2[n//2]
else:
  l=arr1[n//2-1]+arr1[n//2]
  r=arr2[n//2-1]+arr2[n//2]
print(r-l+1)

Measured memory_bytes: 26984
#include <stdio.h>

int main(){
	int A,B,C,D,P,sumx=0,sumy=0,E,result=0;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	scanf("%d",&P);
	sumx=P*A;
	if(P>C){
		E=P-C;
		sumy=B+E*D;
	} else {
		sumy=B;
	}
	if(sumx>sumy){
		result=sumy;
	}	else {
		result=sumx;
	}
	printf("%d\n",result);
	return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;


int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int ans = 0;
	if (A <= K) {
		ans += A;
		K -= A;
	}
	else {
		cout << K << endl;
		return 0;
	}
	if (B >= K) {
		cout << ans << endl;
		return 0;
	}
	K -= B;
	cout << ans - K << endl;
	return 0;
}



Measured memory_bytes: 3620
a,b,c,x,y = map(int,input().split())
cheap = min(a+b,c*2)

if x>y:
    result = min(x,y)*cheap+(x-y)*a
elif x<y:
    result = min(x,y)*cheap+(y-x)*b
else:
    result = min(x,y)*cheap
    
print(min(result,c*max(x,y)*2))

Measured memory_bytes: 3064
#!/usr/bin/env python3
def main():
    from itertools import combinations
    from math import sqrt

    N = int(input())
    xy = tuple(tuple(map(int, input().split())) for _ in range(N))

    ans = 0
    for can_move in combinations(xy, 2):
        xi, yi = can_move[0]
        xj, yj = can_move[1]
        ans += sqrt((xi - xj) ** 2 + (yi - yj) ** 2)
    print(f'{ans * 2 / N:.10f}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,y;cin >> n >> y;
    y/=1000;
    for(int i=0;i*10<=y;i++){
        for(int j=0;i*10+j*5<=y;j++){
            int t=y-10*i-5*j;
            if(i+j+t==n){
                cout << i << " " << j << " " << t << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3660
#include"bits/stdc++.h"
using namespace std;
 
int main(){
  int A, B;
  cin >> A >>B;
  if(A > B){
cout << 2*A-1 << endl;
  }
else if (B > A){
  cout  << 2*B-1 << endl;
}
  else {
   cout << A+B <<endl;
  }
}

Measured memory_bytes: 256
{
  const run = (input: string) => {
    const k = parseInt(input.trim());

    if (k % 2 === 0) return -1

    let result = 0
    for (let i = 1; i <= k; i++) {
      result = (result * 10 + 7) % k
      if (result === 0) return i
    }

    return -1
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


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

void fnInput(vector<int>& rvnDisk)
{
  int nDiskSiz;
  cin >> nDiskSiz;

  rvnDisk.resize(nDiskSiz);
  for (int i = 0; i < nDiskSiz; i++)
    cin >> rvnDisk[i];
}

int fnDiskCount(const vector<int>& cnrvnDisk)
{
  set<int> seDisk;

  for (int nDisk : cnrvnDisk)
    seDisk.insert(nDisk);

  return seDisk.size();
}

int main()
{
  vector<int> vnDisk;
  fnInput(vnDisk);
  cout << fnDiskCount(vnDisk) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>

int main(){
	std::string S;
	long long count = 0,sum;
	std::cin>>S;
	int n = S.size() - 1;
	
	for(int bit=0;bit <(1<<n);++bit){
//		std::cout<<"-------------------------------------\n";
		std::string temp = S;
		int start = 0;
		for(int i=0;i<n;++i){
			if(bit & (1<<i)){
				std::string strNum = temp.substr(start,i + 1 - start);
				start  = i + 1;
				long long num = std::stoll(strNum);
//				std::cout<<num<<std::endl;
				count += num;
			}
		}
		std::string strLast = temp.substr(start);
		long long last = std::stoll(strLast);
//		std::cout<<last<<std::endl;
		count += last;
	}
	std::cout<<count<<std::endl;
	return 0;
}


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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

vector<pair<char, int>> compress(const string &v){
    if(v.empty()) return {};
    vector<pair<char, int>> ret;
    ret.emplace_back(v[0], 0);
    for(const auto &x : v){
        if(x == ret.back().first) ret.back().second ++;
        else ret.emplace_back(x, 1);
    }
    return ret;
}

int main(void){
    Cin(int, n);
    Cin(string, s);
    auto v = compress(s);
    Cout(v.size());
}




Measured memory_bytes: 1528
#include <stdio.h>

int main(void)
{
  char b[4],c[4];
  int i;
  scanf("%s%s",b,c);
  int ans = 0;
  for (i=0;i<3;i++) {
    if (b[i] == c[i]) {
      ans+=1;
    }
  }
  printf("%d",ans);
  return 0;
}
      

Measured memory_bytes: 128
def main():
    n = int(input())
    a = list(map(int,input().split()))
    x = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        x *= i
        if x > 1000000000000000000:
            print(-1)
            return
    print(x)
main()

Measured memory_bytes: 21652
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
map<int,int>p; int n,m,x;
bool ac(){
	for(int i=0;i<m;++i){
		cin>>x;
		if(!p[x]) return 0;
		--p[x];
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    for(int i=0;i<n;++i) cin>>x,++p[x];
    cin>>m;
    if(ac()) cout<<"YES";
    else cout<<"NO";
	return cout<<endl,0;
}

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

int main() {
  int n, count;
  cin >> n;
  count = 1000;
  
  
  rep(j, n) {
    int a, pans;
    cin >> a;
    pans = 0;
    
    for (int i = 0; a % 2 == 0; i++) {
      a /= 2;
      pans++;
    }
    if (pans < count) {
      count = pans;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

bool IsSym(int n)
{
    if (n / 10000 == n % 10 && (n / 1000) % 10 == (n / 10) % 10)
        return true;
    return false;
}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    int cnt = 0;
    for (int i = a; i <= b; i++)
    {
        if (IsSym(i))
            cnt++;
    }
    printf("%d", cnt);
}


Measured memory_bytes: 128
const Release = function () {
    const fs = require('fs');
    const stdin = function (text) {
        if (text) console.log(text);
        return fs.readFileSync('/dev/stdin', 'utf8');
    }
    return stdin;
};


const debug = false;

const stdin = debug ? Debug() : Release();
const input = stdin().split('\n');

const N = parseInt(input[0]);
const A1 = input[1].split(' ').map(x => parseInt(x));
const A2 = input[2].split(' ').map(x => parseInt(x));

const result = [];
for(var i = 0; i<N; i++) {
    var n = 0;
    A1.filter((x, j) => j <= i).map(x => n += x);
    A2.filter((x, j) => j >= i).map(x => n += x);
    result.push(n);
}

console.log(Math.max.apply(null, result));

Measured memory_bytes: 8048
n = int(input())
a = [int(e) for e in input().split()]
ans = float("inf")
MIN, MAX = min(a), max(a)
for i in range(MIN, MAX+1):
    cost = 0
    for j in a:
        cost = cost + (i-j)**2
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,a[1200000],s[1200000][2],g[1200000],tmp[4];
inline void uni(int x,int y){
	tmp[0]=s[x][0];tmp[1]=s[x][1];tmp[2]=s[y][0];tmp[3]=s[y][1];
	sort(tmp,tmp+4);
	s[x][0]=tmp[3];s[x][1]=tmp[2];
}
int main(){
	scanf("%d",&n);
	fo(i,0,(1<<n)-1) scanf("%d",&a[i]);
	fo(i,0,(1<<n)-1){
		s[i][0]=a[i];
		s[i][1]=-1;
	} 
	fo(k,0,n-1)
		fo(i,0,(1<<n)-1)
			if (!(i&(1<<k))) uni(i^(1<<k),i);
	fo(i,1,(1<<n)-1) g[i]=s[i][0]+s[i][1];
	fo(i,1,(1<<n)-1){
		if (g[i]>g[i+1]) g[i+1]=g[i];
		printf("%d\n",g[i]);
	}
	return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	string s;
	cin >> n >> s;

	vector<int>w(n);
	vector<int>e(n);

	rep(i, n) {
		if (s[i] == 'W')w[i]++;
		if (s[i] == 'E')e[i]++;
	}

	//累積和を求める ^_^

	vector<int>wl(n);
	vector<int>el(n);
	wl[0] = w[0];
	el[0] = e[0];
	for (int i = 1; i < n; i++) {
		wl[i] = wl[i - 1] + w[i];
		el[i] = el[i - 1] + e[i];
	}
	int ans = INF;
	int now = 0;

	for (int i = 0; i < n; i++) {
		now = 0;
		if (i != 0 && i != n - 1) {
			now = wl[i - 1] + el[n - 1] - el[i];
		}
		else if(i == 0){
			now = el[n - 1] - el[0];
		}
		else {
			now = wl[n - 1] - w[n - 1];
		}
		ans = min(ans, now);
	}
	
	cout << ans << endl;
}

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

int main(void) {
	int data[3];
	cin >> data[0] >> data[1] >> data[2];

	sort(data, data + 3);

	cout << (data[2] * 10 + data[1]) + data[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
  int res = 0;
  for (int i = 0; i < n; i++) res += a[a[i]] == i;
  cout << res / 2 << '\n';
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

while True:
    q = int(input())
    if q < 1:
        break
    
    x = q / 2
    y = 0.00001 * q
    while True:
        x2 = x * x
        r = x2 * x - q
        if -y < r < y:
            break
        x = x - r / (3 * x2)
    print(x)


Measured memory_bytes: 5608
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int N, T, a[107], c[107], l[107], used[4][4], dp[10009]; string s[107], m[4];
int rec(int x, int y, int d, int v) {
	if (d == l[v]) return 1;
	int ret = 0;
	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			int tx = x + j, ty = y + i;
			if (0 <= tx && tx <= 3 && 0 <= ty && ty <= 3 && !used[ty][tx] && m[ty][tx] == s[v][d]) {
				used[ty][tx] = 1;
				ret += rec(tx, ty, d + 1, v);
				used[ty][tx] = 0;
			}
		}
	}
	return ret;
}
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> s[i] >> a[i], l[i] = s[i].size();
	for (int i = 0; i < 4; i++) cin >> m[i];
	cin >> T;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				if (m[j][k] == s[i][0]) {
					used[j][k] = 1;
					c[i] += rec(k, j, 1, i);
					used[j][k] = 0;
				}
			}
		}
	}
	for (int i = 0; i < N; i++) {
		int x = c[i];
		for (int j = 1; x > 0; j <<= 1) {
			int mul = min(j, x);
			for (int k = T; k >= l[i] * mul; k--) dp[k] = max(dp[k], dp[k - l[i] * mul] + a[i] * mul);
			x -= mul;
		}
	}
	cout << dp[T] << endl;
	return 0;
}

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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e5+5;

int n,L;
int a[N],b[N];
LL prea[N],preb[N];

int main(){
	L=get();n=get();
	fo(i,1,n)a[i]=get();
	fo(i,1,n)b[i]=L-a[n-i+1];
	fo(i,1,n)prea[i]=prea[i-1]+a[i];
	fo(i,1,n)preb[i]=preb[i-1]+b[i];
	LL ans=max(a[n],L-a[1]);
	fo(i,1,n-1){
		int t=min(i,n-i);
		LL va=prea[i]-prea[i-t],vb=preb[n-i]-preb[n-i-t];
		va=va*2,vb=vb*2;
		ans=max(ans,va+vb-a[i]);
		if (i>t){
			ans=max(ans,va+vb-a[i]+2ll*a[i-t]);
		}
		ans=max(ans,va+vb-b[n-i]);
		if (n-i>t){
			ans=max(ans,va+vb-b[n-i]+2ll*b[n-i-t]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992