akhauriyash/Code-Regression huggingface dataset:
A = list(map(int, input().split()))
if A[0] == A[1] and A[0] == A[2]:
  print("No")
elif A[0] == A[1]:
  print("Yes")
elif A[0] == A[2]:
  print("Yes")
elif A[1] == A[2]:
  print("Yes")
else:
  print("No")

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

using namespace std;

bool check(int n, long long k, long long m,
		   vector<int> & a, vector<int> & f){
	long long tot = 0;
	for(int i = 0; i < n; ++i){
		long long val = a[i] * 1LL * f[i] - m; 
		if(val > 0){
			tot += (val / f[i] + (val % f[i] != 0));
		}
	}
	return tot <= k;
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n;
	long long k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	vector<int> f(n);
	for(int i = 0; i < n; ++i){
		cin >> f[i];
	}

	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());

	long long left = 0;
	long long right = 1e12 + 3;
	while(left < right){
		long long mid = left + (right - left) / 2;
		if(check(n, k, mid, a, f)){
			right = mid;
		}else{
			left = mid + 1;
		}
	}

	cout << left;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m= sc.nextInt();
		int[] x = new int[n];int[] y = new int[n];
		int[] mx = new int[m];int[] my = new int[m];
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		for(int i = 0;i < m;i++) {
			mx[i] = sc.nextInt();
			my[i] = sc.nextInt();
		}
		int max, a, ans;
		for(int i = 0;i < n;i++) {
			max = Math.abs(x[i]-mx[0])+Math.abs(y[i]-my[0]);
			ans = 1;
			for(int k = 1;k < m;k++) {
				a = Math.abs(x[i]-mx[k])+Math.abs(y[i]-my[k]);
				if(max > a) {
					max = a;
					ans = k+1;
				}
			}
			System.out.println(ans);
		}
	}

}


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

using namespace std;

int main(){
	int n,suma=0; cin>>n;
	vector<int>a,b;
	a.resize(n);b.resize(n-1);
	for(int i=0; i<n-1; i++){
		cin>>b[i];
	}
	a[0] = b[0];
	a[n-1] = b[n-2];
	for(int i=1; i<n-1; i++){
		a[i] = min(b[i-1], b[i]);
	}
	for(int i=0; i<n; i++){
		suma+=a[i];
	}
	cout<<suma<<endl;
	return 0;
}

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

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

ll powermod(ll x,ll ex,ll md){ll ans=1ll;while(ex>0){if(ex&1ll) ans=(ans*x)%md; ex>>=1ll;x=(x*x)%md;}return ans;}
inline ll gcd(ll a,ll b) {if(b==0)return a;a%=b;return gcd(b,a);}
inline ll max(ll a,ll b) {return((a>b)?a:b);}
inline ll min(ll a,ll b) {return((a>b)?b:a);}


int main(){
        IOS;
        string s,t;
        cin>>s>>t;
        ll len1=(int)s.size() , len2=(int)t.size();
        ll ans=LLONG_MAX;
        for(ll i=0;i+len2-1<=len1-1;i++){
                ll change=0;
                for(ll j=0;j<len2;j++){
                        if(s[i+j] != t[j]) change++;
                }
                ans=min(ans,change);
        }
        cout<<ans<<"\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  int n,ans;
  double t, a;
  cin >> n >> t >> a;
  vector<double> h(n),d(n);
  REP(i,n){
    cin >> h.at(i);
    d.at(i) = abs(t - h.at(i) * 0.006 - a);
  }

  double mini = INF;
  REP(i, n)
  {
    if(mini>d.at(i)){
      mini = d.at(i);
      ans = i + 1;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
using namespace std;
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
const int N = 1e5+10;
typedef long long ll;
ll a[N];
ll b[N];

int main()
{
	ll m;
	cin>>m;
	ll s = 0;
	for(int i = 1;i<=m-1;i++)s+=i;
	cout<<s<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		if (N % 2 == 0) {
			System.out.println(N);
		} else {
			System.out.println(N * 2);
		}
	}
}


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

int main() {
	//code
   ll t;
   cin>>t;
   int a[4]={0};
   string s;
   while(t--){
    cin>>s;
    if(s=="AC") a[0]++;
    else if(s=="WA") a[1]++;
    else if(s=="TLE") a[2]++;
    else a[3]++;
   }
   cout<<"AC x "<<a[0]<<endl;
   cout<<"WA x "<<a[1]<<endl;
   cout<<"TLE x "<<a[2]<<endl;
   cout<<"RE x "<<a[3]<<endl;
	return 0;
}


Measured memory_bytes: 3628
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break

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

int main()
{
    int a,b=0,c=0;
    for (int i=0; i<3; i++)
	{
       cin>>a;
       if (a==5)
          b++;
       if (a==7)
          c++;
    }
    if (c==1 && b==2)
       cout<<"YES";
    else
     cout<<"NO";
    return 0; 
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

graph = Array.new(n+1){Array.new(n+1, false)}

edge = []

0.upto(m-1) do |i|
  edge[i] = gets.split.map(&:to_i)
end

#隣接行列
#頂点は0-index
0.upto(m-1) do |i|
  graph[edge[i][0]-1][edge[i][1]-1] = graph[edge[i][1]-1][edge[i][0]-1] = true
end

#bitDPで解く
#dp[S][v] = 頂点0から出発し，集合Sに含まれる頂点をすべて訪れるパスのうち，
#最後にv(in S)を訪れるものの数
dp = Array.new(1<<n) {Array.new(n,0)}
dp[1][0] = 1

1.upto((1<<n)-1) do |s|
  0.upto(n-1) do |v|
    #vがSに含まれるならskip
    next if (1 << v) & s > 0

    #vがSに含まれないなら，dp[S+v][v]=\sum_u dp[S][u]を計算する
    0.upto(n-1) do |u|
      #和をとる条件：uはSに含まれ，かつvに接続している
      if ((1<<u) & s) > 0 && graph[u][v]
        dp[s|(1<<v)][v] += dp[s][u]
      end
    end
  end
end

puts dp[(1<<n)-1].inject(:+)


Measured memory_bytes: 1788
while True:
    m,f,r = (int(x) for x in input().split())
    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50 or (m + f >= 30 and r >= 50):
        print("C")
    elif m + f >= 30:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int a = ia[0];
		int b = ia[1];
		int ans = 0;
		for (int i = a; i <= b; i++) {
			if (i / 10000 == i % 10) {
				if (i / 1000 % 10 == i / 10 % 10) {
					ans++;
				}
			}
		}
		pln(ans);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21972
n,k = map(int,input().split())
A = list(map(int,input().split()))
bi = ''
cur = 1
while cur <= k:
    t = k&cur
    if t != 0:
        bi = '1'+bi
    else:
        bi = '0'+bi
    cur *= 2
bit = [0]*len(bi)
for i in range(n):
    u = A[i]
    cur = 1
    s = ''
    times = 0
    for j in range(40):
        z = u&cur
        if z != 0:
            if times < len(bi):
                bit[len(bi)-times-1] += 1
        cur *= 2
        times += 1
ans = ''
flag = False #kを下回っているかどうか
l = len(A)
if l%2 != 0:
    for i in range(len(bi)):
        if l//2 < bit[i]:
            if flag:
                ans = ans+'0'
            else:
                if bi[i] == '1':
                    flag = True
                    ans = ans+'0'
                else:
                    ans = ans+'0'
        else:
            if flag:
                ans = ans+'1'
            else:
                if bi[i] == '1':
                    ans = ans+'1'
                else:
                    ans = ans+'0'
else:
    for i in range(len(bi)):
        if l//2 <= bit[i]:
            if flag:
                ans = ans+'0'
            else:
                if bi[i] == '1':
                    flag = True
                    ans = ans+'0'
                else:
                    ans = ans+'0'
        else:
            if flag:
                ans = ans+'1'
            else:
                if bi[i] == '1':
                    ans = ans+'1'
                else:
                    ans = ans+'0'
alt = 0
cur = 1
for i in range(len(ans)):
    if ans[len(ans)-i-1] == '1':
        alt += cur
    cur *= 2
S = 0
for i in range(n):
    S += A[i]^alt
print(S)


Measured memory_bytes: 68696
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(i=0;i<n;i++)
        ans+=(arr[i]-1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int A,B;
    cin >> A >> B;
    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) fin("Possible");
    else fin("Impossible");
    return 0;
}

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

Measured memory_bytes: 676
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
//typedef pair<int, int> P;

int main()
{
    int n; double L, s=0;
  cin>>n>>L;
  using P=pair<double, double>;
  deque<P> deq;
  for(int i=0; i<n; i++){
    double t, v; cin>>t>>v;
    double v1=v;
    while(!deq.empty()){
      P &p=deq.front();
      if(p.second>v1){
        p.second-=v1;
        s-=p.first*v1;
        break;
      }else{
        v1-=p.second;
        s-=p.first*p.second;
        deq.pop_front();
      }
    }
    while(!deq.empty()){
      P p=deq.back();
      if(p.first<t) break;
      double v2=v+p.second;
      t=(p.first*p.second+v*t)/v2;
      v=v2;
      s-=p.first*p.second;
      deq.pop_back();
    }
    s+=t*v;
    deq.push_back({t, v});
    printf("%.7lf\n", s/L);
  }
	return 0;
}


Measured memory_bytes: 17168
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=110;

string s="ACGT";
string sub="AGC";
set<string> st;

bool f(string str)
{
    if(str.substr(0,3)==sub)
        return 1;

    if(str.substr(1,3)==sub)
        return 1;

    for(int i=1;i<4;++i)
    {
        swap(str[i],str[i-1]);

        if(str.substr(0,3)==sub)
            return 1;

        if(str.substr(1,3)==sub)
            return 1;

        swap(str[i],str[i-1]);
    }

    return 0;
}

void init()
{
    string str="....";
    for(int i=0;i<4;++i)
    {
        str[0]=s[i];
        for(int j=0;j<4;++j)
        {
            str[1]=s[j];
            for(int k=0;k<4;++k)
            {
                str[2]=s[k];
                for(int l=0;l<4;++l)
                {
                    str[3]=s[l];
                    if(f(str))
                        st.ins(str);
                }
            }
        }
    }

    //cout<<st.size()<<"\n";
    //show(st);
}

int pw(int x,int n)
{
    int res=1;
    x%=M;
    for(;n;n/=2)
    {
        if(n%2)
            res=(res%M*x%M)%M;
        x=(x%M*x%M)%M;
    }

    return res;
}

int dp[110][4][4][4];

int rec(int n,int nt,int snt,int tnt)
{
    if(n==0)
        return 1;

    if(dp[n][nt][snt][tnt]!=-1)
        return dp[n][nt][snt][tnt];

    string str="?";
    str+=s[nt];
    str+=s[snt];
    str+=s[tnt];

    int res=0;
    for(int i=0;i<4;++i)
    {
        str[0]=s[i];
        if(st.find(str)!=st.end())
        {
            //cout<<str<<"..\n";
            continue;
        }
        res=(res%M+rec(n-1,i,nt,snt)%M)%M;
    }

    return dp[n][nt][snt][tnt]=res;
}

void solve()
{
    mem(dp,-1);

    int n;
    cin>>n;

    if(n==3)
    {
        cout<<61;
        return;
    }

    init();

    int ans=0;

    for(int i=0;i<4;++i)
    {
        for(int j=0;j<4;++j)
        {
            for(int k=0;k<4;++k)
                ans=(ans+rec(n-3,i,j,k))%M;
        }
    }

    cout<<ans;
}

int32_t main()
{
    //fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

int main() {
  vector<int> nums(3);
  for (int i = 0; i < 3; i++) cin >> nums[i];
  
  sort(nums.begin(), nums.end());
  
  int diff = nums[2] * 2 - nums[1] - nums[0];
  
  if (diff % 2 == 0) {
    cout << (diff / 2) << endl;
  } else {
    cout << (diff / 2 + 2) << endl;
  }
}

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

int main(){
    int n;
    char str[10],com[13];

    map<string,int> T;

    cin>>n;

    rep(i,n){
        scanf("%s%s",com,str);
        if(com[0]=='i') T[string(str)]=true;
        else{
            if (T[string(str)]) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 47500
H, N = map(int, input().split())

AB = []
for i in range(N):
    tmp = list(map(int, input().split()))
    AB.append(tmp)
    
dp = [10**9] * (H+1)
dp[0] = 0
    
for i in range(N):
    for j in range(H+1):
        a, b = AB[i]
        if j < a:
            dp[j] = min(dp[0]+b, dp[j])
        else:
            dp[j] = min(dp[j-a]+b, dp[j])
    
print(dp[H])


Measured memory_bytes: 42988
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
typedef long double ld;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define pb 				push_back
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 55;
ll modpow(ll a,ll b,int mod = LLONG_MAX) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}

signed main(){
	FLASH
	int a, b;
	cin >> a >> b;
	if (a >= 13) cout << b;
	else if (a >= 6 and a <= 12) cout << b/2;
	else cout << 0;

	return 0;
}


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




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll mod = 998244353;
    ll n,k;
    cin>>n>>k;

    vector<vector<ll>> vec(k,vector<ll> (2));
    for(ll i=0;i<k;i++)cin>>vec[i][0]>>vec[i][1];
    vector<ll> arr(n+5,0);
    ll curr = 0;
    arr[1]=1;
    for(ll i=1;i<=n;i++)
    {
        curr = (curr+arr[i])%mod;
        for(ll j=0;j<k;j++)
        {
            // cout<<i+vec[j][0]<<' '<<i+vec[j][1]+1<<endl;
            if(i+vec[j][0]<=n)arr[i+vec[j][0]]=(curr+arr[i+vec[j][0]])%mod;
            ll k = (mod + (arr[i+vec[j][1]+1]-curr)%mod)%mod;
            if(i+vec[j][1]+1<=n)arr[i+vec[j][1]+1]=k;
        }
        // for(auto j:arr)cout<<j<<' ';cout<<curr<<endl;
        if(i==1)curr=0;
    }
    cout<<curr<<endl;
    return 0;
}



Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
int main(){
    int N; SCD(N);
    vector<int> a;
    vector<int> U;	
    int count = 1;

    REP(i,N){
        int x; SCD(x);
        a.PB(x);
    }
    REP(i,a.size()-1){
        if (a[i] == a[i+1]){
            count++;
        }else{
            U.PB(count);
            count = 1;
        }
    }
    U.PB(count);
    int ans = 0;
    
    REP(i,U.size()){
        if (U[i] == 2) ans++;
        else ans += U[i]/2;
    }

    PRINTD(ans);

}

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

int main(){
	int n;
	cin >> n;
	vector<double> a(n);
	rep(i, n) cin >> a.at(i);

	double num = 0;
	rep(i, n) num += (double)1/a.at(i);

	cout << fixed << setprecision(10) << (double)1/num << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int p[3]={0},j[2]={0},m,pmin,jmin;
	
	for(int i=0;i<3;i++){
		cin>>p[i];
	}
	pmin=p[0];
	for(int i=0;i<2;i++){
		cin>>j[i];
	}
	jmin=j[0];
	
	for(int i=0;i<2;i++){
		if(pmin>p[i+1]){
			pmin=p[i+1];
		}
		if(jmin>j[1]){
			jmin=j[1];
		}
	}
	cout<<pmin+jmin-50<<endl;
	
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
 
int n;
long long x;
long long a[55],p[55];
 
long long dfs(int i,long long sum){
  if(sum<=0)
    return 0;
  else if(i==0)
    return 1;
  else if(sum<=1+a[i-1])
    return dfs(i-1,sum-1);
  else if(sum==2+a[i-1])
    return p[i-1]+1;
  else if(sum<=2+2*a[i-1])
    return p[i-1]+1+dfs(i-1,sum-1-a[i-1]-1);
  else if(sum==3+2*a[i-1])
    return 2*p[i-1]+1;
}
 
int main(){
  std::cin>>n>>x;
  a[0]=1;
  p[0]=1;
  for(int i=1;i<=n;++i){
    a[i]=2*a[i-1]+3;
    p[i]=2*p[i-1]+1;
  }
  std::cout<<dfs(n,x)<<std::endl;
  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    vi t(n);
    vec<string> s(n);
    rep(i,n) cin >> s[i] >> t[i];
    string x; cin >> x;
    ll cnt = 0;
    bool can = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i]==x) {
            can = 1;
            continue;
        }

        if(can) cnt += t[i];
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 256
h,w = map(int,input().split())
area =[input() for i in range(h)]

xy=[(1,0),(-1,0),(0,1),(0,-1)]

for i in range(h):
  for j in range(w):
    if area[i][j] == '#':
      flag=0
      for x, y in xy:
        #斜めに黒が存在しないか確認（存在してしまったらそれは塗ることができないのでfalse）
        if 0 <= i + y < h and 0 <= j + x < w and area[i+y][j+x]=="#":
          flag=1
      if not flag:
        print('No')
        exit()
print('Yes')



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<int> uset;

int main( int argc, char* argv[] ){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if( K % 2 == 0 ){
    cout << (A-B) << endl;
  } else {
    cout << (B-A) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <map>
typedef uint64_t u64;
typedef std::pair<int, int> PII;

int main() {
	int N, A;
	scanf("%d%d", &N, &A);
	std::map<PII, u64> M0;
	M0.emplace(PII(0, 0), 1);
	auto M1 = M0;
	for(; N > 0; N--) {
		int x;
		scanf("%d", &x);
		for(const auto &p : M0) {
			M1[PII(p.first.first + 1, p.first.second + x)] += p.second;
		}
		M0 = M1;
	}
	u64 a = 0;
	for(const auto &p : M0) {
		if(A * p.first.first == p.first.second) a += p.second;
	}
	std::cout << a - 1 << std::endl;
	return 0;
}

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

#define mod 1000000007
#define modd 998244353
#define PI 3.1415926
#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
#define couts(ans) cout<< ans <<" "
#define coutss(a,b) cout<< a <<" "<< b << "\n"
#define coutsm(a,b,c) cout<< a <<" "<< b <<" "<< c << "\n"
#define maxx *max_element
#define minn *min_element


void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}



ld dp[3005][3005];
ld p[3005];

void solve()
{      
    int n;cin>>n;
    // ld p[n+1];
    forn(i,1,n+1)
    {
        cin>>p[i];
    }
    // ld dp[n+1][n+1];
    // memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    // dp[1][0]=1-p[0];
    // dp[1][1]=p[0];
    // coutss(dp[0][1],"DJJ");
    forn(i,1,n+1)
    {
        forn(j,0,i+1)
        {
            // coutsm(dp[0][1],i,j); 

            // if(j)
            {
                dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
                // if(i==2 && j==1)
                // coutsm(dp[i][j],dp[i-1][j]*(1-p[i-1]),dp[i-1][j-1]*p[i-1]);
            }
            // else
            // {
            //     dp[i][j]=dp[i-1][j]*(1-p[j-1]);
            // }

            // coutsm(dp[1][1],i,j); 

        }
    }
    // forn(i,1,n+1)
    // {
    //     forn(j,0,i+1)
    //     {
    //        coutsm(dp[i][j],i,j);
    //     }
    //     // cout<<endl;
    // }


    ld ans=0;
    forn(i,1,n+1)
    {
        if(i>(n-i))
        {
            ans+=dp[n][i];
        }
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;

}


int main()
{   
    speed();
    int tc=1;
    // cin>>tc;
    while(tc--)
    {
        solve();
    }
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; //00右,01下,10左,11上

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

const int mask=(1<<12)-1;
int h,w,k,memo[50][50][4][1<<12];
char fld[50][50];

bool Check(int y,int x){
	return 0<=y&&y<h&&0<=x&&x<w&&fld[y][x]!='#';
}

int Max(int y,int x,int c,int bit){
	int &res=memo[y][x][c][bit];
	if(res!=-1) return res;
	if(y==h-1&&x==w-1&&c==0) return res=0;

	bool done=false;
	int py=y,px=x;
	rep(i,0,6){
		py-=dy[(bit>>(i*2))&3];
		px-=dx[(bit>>(i*2))&3];
		if(y==py&&x==px){
			done=true;
			break;
		}
	}
	int gift=0;
	if(!done&&fld[y][x]!='.') gift=fld[y][x]-'0';

	res=-INF;
	rep(i,0,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(!Check(ny,nx)) continue;
		if(i<2){
			res=max(res,Max(ny,nx,c,((bit<<2)&mask)|i)+gift);
		}else if(c>=1){
			res=max(res,Max(ny,nx,c-1,((bit<<2)&mask)|i)+gift);
		}
	}

	return res;
}

void Solve(){
	fill_n((int*)memo,50*50*4*(1<<12),-1);
	cin >> h >> w >> k;
	rep(i,0,h) rep(j,0,w) cin >> fld[i][j];

	cout << Max(0,0,k,0) << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 161200
d, n = map(int, input().split())
 
if d==0:
	if n<100:
		print(n)
	else:
		print(101)    
elif d==1:
	if n<100:
		print(n*100)
	else:
		print(10100)
elif d==2:
	if n<100:
		print(n*10000)
	else:
		print(n*10000+10000)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	forn(i,n) cin >> a[i];
	stack<int> S;
	vi leftsmall(n, -1);
	// S.push(0);
	for(int i = n - 1; i >= 0; i--){
		while(!S.empty() && a[S.top()] > a[i]){
			int id = S.top();
			leftsmall[id] = i;
			S.pop();		
		}
		S.push(i);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(leftsmall[i] == -1){
			ans++;
		}
	}
	cout << ans << endl;
}		


Measured memory_bytes: 2688
import qualified Data.Vector as V (Vector, fromList, length, (!))
import Control.Applicative


binarySearch :: V.Vector Int -> Int -> Bool
binarySearch vec a = loop (0, V.length vec - 1)
  where
    loop (start, end)
      | v == a       = True
      | start >= end = False
      | v > a        = loop (start, n - 1)
      | v < a        = loop (n + 1, end)
      where
        (n, v) = (div (start + end) 2, vec V.! n)

main :: IO ()
main = do
  _ <- getLine
  s <- map read . words <$> getLine
  _ <- getLine
  t <- map read . words <$> getLine
  print $ length $ filter (binarySearch $ V.fromList s) t



Measured memory_bytes: 109428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[1010];
int main() {
	int n, q;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> q;
	while (q--) {
		int Q, x, y;
		cin >> Q >> x >> y;
		if (Q == 0) {
			int ans = 1145141919;
			for (int i = x; i < y; i++)ans = min(ans, a[i]);
			cout << ans << endl;
		}
		else {
			int ans = -1145141919;
			for (int i = x; i < y; i++)ans = max(ans, a[i]);
			cout << ans << endl;
		}
	}
	return 0;
}


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

#define endl '\n'

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

    int a,b; cin >> a >> b;
    if (a*500 >= b) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using ld = long double;

pii isec(pii a, pii b) {
	return { max(a.first, b.first), min(a.second, b.second) };
}

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	vector<pii> a(n);
	pii s1 = { 1e9 + 100, 1e9 + 100 };
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		s1 = min(s1, { a[i].second, a[i].first });
	}
	swap(s1.first, s1.second);
	vector<pii> pref(n), suff(n);
	pref[0] = a[0];
	for (int i = 1; i < n; i++) {
		pref[i] = isec(pref[i - 1], a[i]);
	}
	suff[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		suff[i] = isec(suff[i + 1], a[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		pii u = (i ? pref[i - 1] : pii(-1e9 - 100, 1e9 + 100) );
		u = isec(u, i < n - 1 ? suff[i + 1] : pii(-1e9 - 100, 1e9 + 100) );
		ans = max(ans, (a[i].second - a[i].first + 1) + max(u.second - u.first + 1, 0));
	}

	sort(all(a));
	pii s2 = a.back();
	a.pop_back();
	ans = max(ans, s2.second - s2.first);
	int rb2 = 1e9 + 100;
	for (int i = sz(a) - 1; i >= 0; i--) {
		rb2 = min(rb2, a[i].second);
		ans = max(ans, max(0, s1.second - (i ? a[i - 1].first : s1.first) + 1) + max(0, rb2 - s2.first + 1));
	}
	cout << ans;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
	string S,T;
	cin>>S>>T;
	for(int i=0;i<S.size();++i){
		if(S[i]==T[0]){
			string temp1=S.substr(i);
			string temp2=S.substr(0,i);
			temp1+=temp2;
			if(temp1==T){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    count = 0
    for i in range(N):
        while A[i] % 2 == 0:
            A[i] //= 2
            count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 4084
using System;

namespace AtCoder{
    class Program{
        static void Main(string[] args){
            Int64 n = Int64.Parse(Console.ReadLine());
            Int64 ans = sum(10,n) - sum(9,n) - sum(9,n) + sum(8,n);
            ans %= 1000000007;
            ans += 1000000007;
            ans %= 1000000007;
            Console.WriteLine(ans);
        }
        static Int64 sum(Int64 a, Int64 b){
            Int64 c = 1;
            for(Int64 i = 0; i < b; i++){
                c = (c * a) % 1000000007;
                c %= 1000000007;
            }
            return c;
        }
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> v(n+1);REP(i, n)cin >> v[i+1];
	vector<ll> ans(n+1);

	REV(i, n+1){
		if(!i)continue;
		ll cou = 0;
		for(int j = i;j <= n;j += i)cou += ans[j];
		if(cou % 2 != v[i])ans[i]++;
	}

	vector<ll> out;
	REP(i, n+1)if(ans[i])out.PB(i);
	cout << out.size() << endl;
	REP(i, out.size())cout << out[i] << '\n';
	return 0;
}


Measured memory_bytes: 5108
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  string S;
  cin >> S;
  map<char, int> M;
  while(S.size() > 3){
    if(!(S.size()%2)){
      cout << "No" << endl;
      return 0;
    }
    for(char c = 'A'; c < 'D'; ++c)
      M[c] = 0;
    int abc = 0;
    int l = S.size();
    for(int i = 0; i < l; ++i){
      M[S[i]] += 1;
      if(S[i] == 'A' && i < l-2 && S[i+1] == 'B' && S[i+2] == 'C')
	abc += 1;
    }

    char s = 'A';
    bool f = true;
    for(; s < 'D'; ++s){
      if(!(M[s]-abc)){
	f = false;
	break;
      }
    }
    if(f){
      cout << "No" << endl;
      return 0;
    }
    string T = S;
    S = "";
    for(int i = 0; i < l; ++i){
      if(i < l-2 && T[i] == 'A' && T[i+1] == 'B' && T[i+2] == 'C'){
	S += s;
	i += 2;
      }else S += T[i];
    }
  }
  if(S == "ABC") cout << "Yes" << endl;
  else cout << "No" << endl;;
  return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <limits.h>

#define N 100
#define MY_NIL -2
#define INF INT_MAX

void prim(int);

int n;
int a[N][N];

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d",&a[i][j]);
    }
  }

  prim(0);
  
  return 0;
}
// ,a,0
void prim(int r){
  int i,u,min;
  int d[N],pi[N];
  char color[N];

  /*int j;
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      printf(" %d",a[i][j]);
    }
    printf("\n");
    }*/
  
  for(u=0; u<n; u++){
    d[u]=INF;
    pi[u]=MY_NIL;
    color[u]='W';
  }
  d[r]=0;
  while(1){
    min=INF;
    for(i=0; i<n; i++){
      if(color[i]!='B' && d[i]<min){
	min=d[i];
	u=i;
      }
    }
    if(min==INF){
      break;
    }
    color[u]='B';
    for(i=0; i<n; i++){
      if(color[i]!='B' && a[u][i]<d[i] && a[u][i]!=-1){
	pi[i]=u;
	d[i]=a[u][i];
      }
    }
  }
  int ans=0;
  for(i=0; i<n; i++){
    ans+=d[i];
  }
  printf("%d\n",ans);
}



Measured memory_bytes: 2048
s = input()
if s[0] == "A":
  if "C" in s[2:-1]:
    p = s.lstrip("A").split("C")
    if len(p) == 2:
      if p[0].lower() == p[0]:
        if p[1].lower() == p[1]:
          print("AC")
          quit()
print("WA")

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    int a,b,c;
    cin>>a>>b>>c;

    if((a==b&&b!=c)||(b==c&&c!=a)||(a==c&&c!=b)){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

for i in range(1,N+1):
    ans1 = 0
    ans2 = 0
    ans3 = 0
    
    for x in range(1,101):
        if x**2>i:
            break
        for y in range(1,x):
            if x**2+y**2+x*y>i:
                break
            for z in range(1,y):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    ans1 += 1

                if x**2+y**2+z**2+x*y+y*z+z*x>i:
                    break

    for x in range(1,101):
        if x**2>i:
            break
        for y in range(1,x):
            if x**2+y**2>i:
                break
            if x**2+3*y**2+2*x*y==i:
                ans2 += 1
    
    for x in range(1,101):
        if x**2>i:
            break
        for y in range(1,x):
            if x**2+y**2>i:
                break
            if 3*x**2+y**2+2*x*y==i:
                ans2 += 1
                
    for x in range(1,101):
        if 6*x**2==i:
            ans3+=1

    print(ans1*6+ans2*3+ans3)

Measured memory_bytes: 76412
#include <stdio.h>

int main() {
	int x, a, b, i, j;
	scanf("%d %d %d", &x, &a, &b);
	i = x-a;
	j = x-b;
	if (i<0) {
		i *= -1;
	} 
	if (j<0) {
		j *= -1;
	}
	
	if (i>j) {
		printf("B");
		return 0;
	} else {
		printf("A");
	}
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int h, w;
vector<string> s;
vector<int> hp;
bool ans = false;

bool isMatch(int a, int b){
    for(int i = 0; i < h; i++){
        if(s[i][a] != s[hp[i]][b]) return false;
    }
    return true;
}

void check(){
    int wOdd = w % 2;
    vector<int> used(w, 0);
    for(int i = 0; i < w; i++){
        if(used[i]) continue;
        for(int j = i + 1; j < w; j++){
            if(used[j]) continue;
            if(isMatch(i, j)){
                used[i] = 1; used[j] = 1;
                break;
            }
        }
    }
    if(count(used.begin(), used.end(), 0) > 1) return;
    if(wOdd){
        for(int i = 0; i < w; i++){
            if(used[i]) continue;
            if(isMatch(i, i)){
                break;
            }else{
                return;
            }
        }
    }
    ans = true;
}

void dfs(int y, bool hOdd){
    if(ans) return;
    if(y >= h){
        check();
        return;
    }
    if(hp[y] != -1){
        dfs(y + 1, hOdd);
        return;
    }
    if(hOdd){
        hp[y] = y;
        dfs(y + 1, false);
        hp[y] = -1;
    }
    for(int i = y + 1; i < h; i++){
        if(hp[i] != -1) continue;
        hp[y] = i; hp[i] = y;
        dfs(y + 1, hOdd);
        hp[y] = -1; hp[i] = -1; 
    }
    hp[y] = -1;
}

int main(){
    
    cin >> h >> w;
    s.resize(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    hp = vector<int>(h, -1);
    if(h % 2){
        dfs(0, true);
    }else{
        dfs(0, false);
    }
    if(ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort()
ans = 0
cnt = 0
for a, b in AB:
  if cnt == M:
    break
  
  if cnt + b <= M:
    ans += a * b
    cnt += b
  else:
    ans += a * (M - cnt)
    cnt += M - cnt

print(ans)

Measured memory_bytes: 27316
#include <stdio.h>

int main(void){
    int a,b,i,j;
    scanf("%d %d",&a,&b);
    if(a<0&&b>0){
        printf("Zero\n");
        return 0;
    }
    else if(0<a){
        printf("Positive\n");
        return 0;
    }
    else {
        for(i=a;i<=b;i++){
            j++;
        }
        if(j%2==0){
            printf("Positive\n");
            return 0;
        }
    }
    printf("Negative\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vll a(n);
  ll cu=0;
  rep(i,n) {
    cin>>a[i];
    cu+=a[i];
  }
  sort(rall(a));
  rep(i,m){
    if(a[i]*4*m<cu){
      COUT("No");
      return 0;
    }
  }
  COUT("Yes");
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <limits>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int N;
    vector<int> A;
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        int v;
        cin >> v;
        A.push_back(v);
    }
    const int max = accumulate(A.begin(), A.end(), 0);
    cout << max - N << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import collections
import copy
input = sys.stdin.readline
N = input()
P= list(int(i) for i in input().split())
chk = 0
col = []
for i in range (len(P)):
	if P[i] != i+1 :
		chk +=1
if chk ==2 or chk ==0:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll a;
        cin >> a;
        cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3620
// ITP1_10_C Standard_Deviation
import java.io.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         while (true) {
            int n = Integer.parseInt(br.readLine());
            if (n == 0) break;

            double sum = 0;
            double sumx = 0;
            double ave = 0;

            String[] input = br.readLine().split(" ");
            double[] s = new double[n];

            for (int i = 0; i < n; i++) {
               s[i] = Double.parseDouble(input[i]);
               sum += s[i];
            }

            ave = sum / n;

            for (int i = 0; i < n; i++) {
               sumx += Math.pow((s[i] - ave), 2) / n;
            }

            System.out.println(Math.sqrt(sumx));
         }
      }

      catch (Exception e) {
         e.printStackTrace();
      }
   }
}

Measured memory_bytes: 19376
n, k = map(int, input().split())
d_list = []
a_list = []

for i in range(k):
    d_list.append(int(input()))
    a_list.append(list(map(int, input().split())))
nonhave_list = []

for j in range(n):
    for l in range(k):
        exist = False
        if j+1 in a_list[l]:
            exist = True
            break
    if not exist:
        nonhave_list.append(j)

print(len(nonhave_list))



Measured memory_bytes: 9284