akhauriyash/Code-Regression huggingface dataset:
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			BigDecimal result = BigDecimal.ZERO;
			for (int i = 0; i < n; i++) {
				result = result.add(BigDecimal.ONE.divide(sc.nextBigDecimal(), 10, BigDecimal.ROUND_HALF_UP));
			}
			System.out.println(BigDecimal.ONE.divide(result, 10, BigDecimal.ROUND_HALF_UP));
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll d ;cin>>d;
    vector<ll> c(26);rep(i,26)cin>>c[i];
    vector<vector<ll>> s(d,vector<ll>(26));
    vector<ll> x(365);//i回目のコンテストで選ばれた数字の保管
    vector<ll> bai(26); //何倍のcを追加するかのチェック
    ll ans = 0;

    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    vector<ll> t(d);rep(i,d)cin>>t[i];

    rep(i,d){
        ans+=s[i][t[i]-1];
        bai[t[i]-1]=i+1;


        rep(j,26){
            ans-=c[j]*(i+1-bai[j]);
        }
        cout<<ans<<endl;

    }

}

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

int n;
long long memo[104][105] = {0};

int main() {
  long long sum = 0;
  cin >> n;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) cin >> memo[i][j];
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      sum += min(memo[i][j], memo[j][i]);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> x(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    x[i] = make_pair(a, b);
  }
  sort(all(x));
  cout << x[n - 1].first + x[n - 1].second << endl;
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
#define int ll
#define N 100005
#define pb push_back
#define pv(x) cout<<#x<<": ";for(auto k:x){ cout<<k<<" "; }cout<<endl;
#define dbg(x) cout<<#x<<": "<<x<<endl;

int n,m,ni,mi;
// int num[N];
int ok=false;

void solve(){
	cin >> n;
	deque<int> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	map<int,int> M;
	int ans=0;
	int pos=1;
	for(auto k:v){
		ans+=M[pos-k];
		M[pos+k]++;
		pos++;

	}


	cout<<ans<<endl;
}

int32_t main(){cin.tie(0);ios_base::sync_with_stdio(NULL);
	int t=1;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 27960
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int cnt = 0;
    for (int p = 0; p <= n; ++p) {
        for (int q = 0; q <= m; ++q) {
            cnt = p * m - p * q + q * n - p * q;
            if (cnt == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
const int inf=(1ll<<31)-1;
struct Info{//相当于存的是边及其后端点
    int to,cost;
    Info(int _to,int _cost){
        to=_to,cost=_cost;
    }
    bool operator< (const Info& arg) const {
        return cost>arg.cost;
    }
};
vector<Info> Edges[maxn];
int inq[maxn],d[maxn];
int E,V,o;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   
    cin>>V>>E>>o;
     fill(d+0,d+V,inf);
    rep(i,1,E){
        int s,t,d0;
        cin>>s>>t>>d0;
        Edges[s].push_back(Info(t,d0));
    }
    queue<int> Q;
    Q.push(o);
    d[o]=0;
    inq[o]=1;
    int cnt=0;
    while(!Q.empty()){
        cnt++;
        if(cnt==2e6)break;
        int now=Q.front();
        Q.pop();
        inq[now]=0;
        for(auto e:Edges[now]){
            if(d[e.to]>d[now]+e.cost){
                d[e.to]=d[now]+e.cost;
                if(!inq[e.to])Q.push(e.to);
                inq[e.to]=1;
            }
        }
    }
    if(cnt==2e6)cout<<"NEGATIVE CYCLE"<<endl;
    else{
         rep(i,0,V-1){
            if(d[i]==inf)cout<<"INF\n";
            else cout<<d[i]<<endl;
        }
    }
    
}
/* 
1 ≤ |V| ≤ 1000
0 ≤ |E| ≤ 2000
-10000 ≤ di ≤ 10000
There are no parallel edges
There are no self-loops

4 5 0
0 1 2
0 2 3
1 2 -5
1 3 1
2 3 2
用dis数组记录源点到有向图上任意一点距离，其中源点到自身距离为0，到其他点距离为INF。将源点入队，并重复以下步骤：

1队首x出队

2遍历所有以队首为起点的有向边(x,i)，若dis[x]+w(x,i)<dis[i]，则更新dis[i]

3如果点i不在队列中，则i入队

4若队列为空，跳出循环；否则执行1
 */
/* 
//循环
	for(int i = 0; i < V; i++){
		updated = false;
		for(int k = 0; k < E; k++){
			tmp = Edges[k];
			if(min_dist[tmp.from] != BIG_NUM && min_dist[tmp.to] > min_dist[tmp.from] + tmp.cost){
				min_dist[tmp.to] = min_dist[tmp.from] + tmp.cost;

				updated = true;
				if(i == V-1){
					FLG = false;
					break;
				}
			}
		}
		if(!updated)break;
		if(!FLG)break;
	}
    if(!FLG){
		printf("NEGATIVE CYCLE\n");
		return 0;
	}
 */


Measured memory_bytes: 26676
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N,M;
int value_add=0;
int value_dec=0;
int ans=0;

int main(int argc, char const *argv[])
{
    cin>>N;
vector<string> s(N);
for(int i=0;i<s.size();i++){
    cin>>s[i];
}
cin>>M;
vector<string> t(M);
for(int i=0;i<t.size();i++){
    cin>>t[i];
}

for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
        if(s[i]==s[j]){
            value_add++;
        }
    }
    for(int k=0;k<t.size();k++){
        if(s[i]==t[k]){
            value_dec++;
        }
    }
    if(ans<value_add-value_dec) ans=value_add-value_dec;
    value_add=0;
    value_dec=0;
}

cout<<ans<<endl;

return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;

    double ans = 0;
    REP(i, n)
    {
        double sum = 1.0 / n;
        int cnt = i+1;
        while(k > cnt)
        {
            cnt *= 2;
            sum /= 2;
        }

        ans += sum;
    }
    printf("%.12f\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            var D = c2i(RL());
            var cnlst = RL2IE().ToList();
            var snlst = new List<List<int>>();
            for (int i = 0; i < D; i++)
            {
                snlst.Add(RL2IE().ToList());
            }
            var tnlst = new List<int>();
            for (int i = 0; i < D; i++)
            {
                tnlst.Add((int)c2i(RL()));
            }
            long score=0;
            var lastd = new List<int>();
            for (int i = 0; i < 26; i++) lastd.Add(0);
            for (int i = 1; i <= D; i++)
            {
                var contest=(tnlst[i-1]-1);
                score += snlst[i-1][contest];
                lastd[contest] = i;
                //score += cnlst[contest];

                for (int cn = 0; cn < cnlst.Count; cn++)
                {
                    score-=cnlst[cn]*(i-lastd[cn]);
                }

                    Console.WriteLine(score);
            }




                //Console.WriteLine(cnt);
            Console.ReadLine();

        }

        static IEnumerable<int> RL2IE() { return spr(RL()).Select(x => (int)c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 28844
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  for(int i=1;i<50001;i++){
    if(int(i*1.08) == n){
      cout<< i <<endl;
      return 0;
    }
  }
  cout<< ":(" <<endl;
}


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

int main(){
    int n;
    cin >> n;
    
    set<string> st;
    int number_over_3200 = 0;
    
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        
        if (1 <= a && a <= 399) st.insert("gray");
        else if (a <= 799) st.insert("brown");
        else if (a <= 1199) st.insert("green");
        else if (a <= 1599) st.insert("lightBlue");
        else if (a <= 1999) st.insert("blue");
        else if (a <= 2399) st.insert("yellow");
        else if (a <= 2799) st.insert("orange");
        else if (a <= 3199) st.insert("red");
        else number_over_3200++;
    }
    
    int numberOfMinimumColor = st.size();
    if (numberOfMinimumColor == 0) numberOfMinimumColor = 1;
    int numberOfMaximumColor = st.size() + number_over_3200;
    
    cout << numberOfMinimumColor << " " << numberOfMaximumColor << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    db n,ans=0;cin>>n;
    vector<pair<db,db> > v(n+2,{0,0});//time,velocity
    for(int i=1;i < n+1;i++)
    {
        cin>>v[i].fi;
        v[i].fi+=v[i-1].fi;
    }
    for(int i=1;i < n+1;i++)
    {
        cin>>v[i].se;
    }
    
    v[n+1].fi=v[n].fi;

    db prev=0;
    for(db t=0.5;t <= v[n+1].fi;t+=0.5)
    {
        db nowv=INF;
        for(int i=n+1;1 <= i;i--)
        {
            if(t<=v[i].fi)nowv=v.at(i).se;//制限速度
        }

        for(int i=0;i < n+1;i++)
        {
            if(t>v[i].fi)nowv=min(nowv,t-v[i].fi+v.at(i).se);
            else nowv=min(nowv,v[i].fi -t +v.at(i+1).se);//バグらせた
        }
        ans+=(prev+nowv)/4; //cout<<t<<":"<<nowv<<endl;
        prev=nowv;
    }

    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int y(int x) {
    return x * x;
}

int main() {
    int d, i, x, max, sum = 0;
    while(cin >> d){
        max = (600-d) / d;
        sum = 0;
        for(i = 1, x = d; i <= max; ++i, x = i*d) {
            sum += d * y(x);
        }

        cout << sum << endl;
    }
}


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

int main() {
  int N,sum=0;
  cin >> N;
  
  for (int i=0; i<N; i++) {
    int l,r;
    cin >> l >> r;
    sum += (r-l+1);
  }
  
  cout << sum << endl;
}

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

signed main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  
  vector<int> add(3);
  int mp = 0;
  int ans = 1000000000;
  for (int i = 0; i < pow(4, N); i++) {
    int act = i;
    mp = -30;
    add[0] = 0;
    add[1] = 0;
    add[2] = 0;
    for (int j = 0; j < N; j++) {
      if (act%4 == 1) {
        add[0] += l[j];
        mp += 10;
      }
      if (act%4 == 2) {
        add[1] += l[j];
        mp += 10;
      }
      if (act%4 == 3) {
        add[2] += l[j];
        mp += 10;
      }
      act /= 4;
    }
    if (add[0] == 0||add[1] == 0||add[2] == 0) continue;
    mp += abs(add[0] - A);
    mp += abs(add[1] - B);
    mp += abs(add[2] - C);
    ans = min(mp, ans);
  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );
 
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 2e5 + 12; //check the limits, dummy

int main() {
 
    ios_base::sync_with_stdio (0);
    cin.tie (0);
 
    ll a, b, m;
    cin >> a >> b >> m;
    vl va(a), vb(b);
    ll mva = 1e18L, mvb = 1e18L;
    FOR(i,0,a) cin >> va[i], mva = min(mva,va[i]);
    FOR(i,0,b) cin >> vb[i], mvb = min(mvb,vb[i]);
    ll ans = mva + mvb;
    FOR(i,0,m) {
        ll x, y, c;
        cin >> x >> y >> c;
        ll curAns = -c;
        curAns += va[x-1];
        curAns += vb[y-1];
        ans = min(ans, curAns);
    }
    cout << ans << '\n';
    return  0;
}

Measured memory_bytes: 1792
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if a[i] > x:
        ans += a[i]-x
        a[i] = x
for i in range(1,n):
    if a[i-1] + a[i] > x:
        ans += a[i-1]+a[i] - x
        a[i] = x-a[i-1]
print(ans)



Measured memory_bytes: 19872
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 998244353;
const double PI = acos(-1);

struct Point {
    double x, y;
};

bool check(long long a, long long b, long long s) {
    while (a) {
        s -= a % b;
        a /= b;
    }
    return s == 0;
}

void solve() {
    long long n, s; cin >> n >> s;
    long long d = n - s;
    long long res = LINF;
    if (d == 0) {
        cout << n + 1 << endl;
        return;
    }
    for (long long i = 1; i * i <= d; i++) {
        if (d % i == 0) {
            if (check(n, i + 1, s)) res = min(res, i + 1);
            if (check(n, d / i + 1, s)) res = min(res, d / i + 1);
        }
    }
    if (res == LINF) cout << -1 << endl;
    else cout << res << endl;
} 

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

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

#define ll long long int 
#define pii pair<int, int>
#define INF 0x3f3f3f3f
#define fi first
#define se second
#define f(n) for(int i = 0; i < n; i++)
#define f2(n) for(int i = 1; i <= n; i++)
#define debug(x) if(on)cout << x << endl
#define on true
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back


int main(){

	vector<int> v;

	int aux;
	f(5){
		cin >> aux;
		v.pb(aux);
	}


	int total = 0;
	int dif = 0;
	for(auto x : v){
		if(x % 10 != 0){
			if(10 - (x%10) > dif)
				dif = 10 - (x % 10);
			total += 10 + (x - (x%10));
		}else{
	
			
			total += x;
		}
	}

	total -= dif;

	cout << total << endl;

return 0;

}


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

const int Maxn = 55;
int n, c[Maxn];
long long ans;
string str[Maxn], now;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		cin >> str[i] >> c[i];
	cin >> now;
	for (int i = 1; i <= n; i++)
	{
		if (str[i] == now)
		{
			for (int j = i + 1; j <= n; j++)
				ans += c[j];
			printf("%lld", ans);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int w,n;
    cin>>w>>n;
    int na[31];
    for(int i=1;i<=w;++i){
        na[i]=i;
    }
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a;
        cin.ignore();
        cin>>b;
        swap(na[a],na[b]);
    }
    for(int i=1;i<=w;++i){
        cout<<na[i]<<endl;
    }
    return 0;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m;
	cin >> n >> m;
	ll a[n];
	ll res = 0;
	for (ll i = 0; i < m; i++) {
		cin >> a[i];
		res += a[i];
	} 
	if (res > n) cout << -1 << "\n";
	else cout << (n - res) << "\n";
 	return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;



int main ()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i=0;
    while (i<s.length()-1)
    {
        if (s[i]==s[i+1])
        {
            s.erase(i,1);
            i--;
        }
        i++;
    }
    cout<<s.length()<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    char c[10]; cin >> c;
    int A, B, C, D;
    A = c[0] - '0';
    B = c[1] - '0';
    C = c[2] - '0';
    D = c[3] - '0';

    int sum;
    string op1 = "";
    string op2 = "";
    string op3 = "";

    // bit 全探索 2 の 3乗通り
    rep(i, 1 << 3) {
        sum = A;
        if (i >> 0 & 1) {
            // 0 ビット目が立っている場合
            op1 = "+";
            sum += B;
        } else {
            // 0 ビット目が立っていない場合
            op1 = "-";
            sum -= B;
        }

        if (i >> 1 & 1) {
            // 1 ビット目が立っている場合
            op2 = "+";
            sum += C;
        } else {
            // 1 ビット目が立っていない場合
            op2 = "-";
            sum -= C;
        }

        if (i >> 2 & 1) {
            // 2 ビット目が立っている場合
            op3 = "+";
            sum += D;
        } else {
            // 2 ビット目が立っていない場合
            op3 = "-";
            sum -= D;
        }

        if (sum == 7) break;
    }

    cout << to_string(A) + op1 + to_string(B) + op2 + to_string(C) + op3 + to_string(D) + "=7" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;
int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  if (k < abs(x / d)) {
    if (x < 0) {
      x += d * k;
    } else {
      x -= d * k;
    }
  } else {
    if (x >= 0) {
      k -= x / d;
      x %= d;
      if (k % 2) {
        x -= d;
      }
    } else {
      k -= abs(x) / d;
      x %= d;
      if (k % 2) {
        x += d;
      }
    }
  }
  cout << abs(x) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;

int main(){
  ll n,W,ans=0;cin>>n>>W;
  vll v(n),w(n);
  vvll dp(n+1,vll(W+1,0));
  rep(i,0,n){
    cin>>v[i]>>w[i];
  }
  rep(i,0,n){
    rep(j,0,W+1){
      if(j<w[i]){dp[i+1][j]=dp[i][j];}
      else{
        dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      }
    }
  }
  
  cout<<dp[n][W]<<endl;
}



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

int main()
{
	string n;
	cin >> n;
	
	for(int i = 0; i < 3; i++){
		if(n[i] == '9'){
			n[i] = '1';
		}else{
			n[i] = '9';
		}
	}

	cout << n << "\n";

	return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, t, a;
    cin>> n>> t>> a;

    long double h[n], mi= 10000, ind= 0;

    for(int i=0; i<n; i++)
    {
        cin>> h[i];

        if( (abs( a -(t - (h[i] * 0.006) ) )) <mi)
        {
            mi= abs ( a-(t- (h[i] * 0.006) ) );
            ind= i+1;
        }


    }


cout << ind;
 nl;



    return 0;
}




Measured memory_bytes: 3796
#include<stdio.h>
#include<string.h> 

	long long int GameCube(long long int a, long long int b) {
  if(a < b) return GameCube(b, a);
  long long int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main()
{
	long long int X;
	long long int Y;
	scanf("%ld %ld", &X, &Y);
	printf("%ld", X*Y/GameCube(X, Y));
	
	return 0;
}

Measured memory_bytes: 128
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

   if(a>9 || b>9) cout<<-1<<endl;
   else cout<<a*b<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<long long, int> PF;
void primeF(long long n) {
    long long tmp = n;
    for (int i = 2; (long long)i*i <= tmp; i++) {
        while (tmp%i == 0) {
            PF[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1) PF[tmp]++;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long A, B;
    cin >> A >> B;
    long long G = __gcd(A, B);
    primeF(G);
    printf("%ld\n", PF.size()+1);
    return 0;
}


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

int n,k;
double ans=0,cur;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		double prob=1.0;
		int cnt=i;
		while(cnt<k)
		{
			cnt*=2;
			prob/=2;
		}
		ans+=prob*1.0/n;
	}
	printf("%.12lf",ans);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int>A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	double ans=0;
	for (size_t i = 0; i < N; i++)
	{
		ans += 1.0 / A.at(i);
	}
	cout << 1.0/ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int x,y,s,i,j,max;	
		Scanner in = new Scanner(System.in);
		
		x = in.nextInt(); //??§?¨????
		y = in.nextInt(); //??°?¨????
		s = in.nextInt(); //??§????¨???????
		
		while(x != 0){
			max = 0;

			for(i=1; i<s; i++){
				for(j=1; j<s; j++){
					if(TotalPrice.calcTotalPrice(x, i, j) == s){
						max = Math.max(TotalPrice.calcTotalPrice(y, i, j), max);
					}
				}
			}
			
			System.out.println(max);
			
			x = in.nextInt();
			y = in.nextInt();
			s = in.nextInt();
		}
		
		in.close();
	}
}


//??§?¨??????§????????????????¨???????????¨??????????????????????
class TotalPrice{
	public static int calcTotalPrice(int x, int i, int j){
		return i*(100+x)/100 + j*(100+x)/100;
		//double rate = (double)(100+x)/100;
		//return (rate*i)+ (rate*j);
	}
}

Measured memory_bytes: 20900
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    s = input()
    
    leng = len(s)
    
    for i in range(leng-1, -1, -1):
        testtest = s[0:i]
        
        tmp = is_run(testtest)
        if tmp == True:
            print(len(testtest))
            sys.exit()
            
    print(0)
    
    
    
def is_run(s):
    leng = len(s)
    if leng % 2 == 1:
        return False
        
    bese = int(leng/2)
    tmp1 = s[:bese]
    tmp2 = s[bese:]
    
    #print("{} {}".format(tmp1,tmp2))
    
    if tmp1 == tmp2:
        return True
    else:
        return False
        
if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#!/usr/bin/env ruby

require 'bigdecimal'

class Line
  # initialize with coordinates of 2 points which the line includes
  def initialize(x1, y1, x2, y2)
    @x1 = x1
    @y1 = y1
    @x2 = x2
    @y2 = y2
  end

  def slope
    # this is the 'a' from y=ax+b (we know 2 points)
    (@y1 - @y2) / (@x1 - @x2)
  end

  attr_reader :x1, :y1, :x2, :y2

  def parallel_to?(other)
    slope == other.slope
  end
end

lines_enum = $stdin.each_line
n = lines_enum.next.chop.to_i

n.times do
  line = lines_enum.next.chop
  ax, ay, bx, by, cx, cy, dx, dy = line.split(' ').map { |s| BigDecimal.new(s) }
  ab = Line.new(ax, ay, bx, by)
  cd = Line.new(cx, cy, dx, dy)
  puts ab.parallel_to?(cd) ? 'YES' : 'NO'
end

Measured memory_bytes: 8972
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(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 sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int store[3001][3001];
int  dp(string &a, string &b, int n , int m){
    if(n==0 || m==0) {
        store[n][m]=0;
        return 0;
    }
    int ans=store[n][m];
    if(ans!=-1) return ans;
    if(a[n-1]==b[m-1]){
        store[n][m]=dp(a,b,n-1,m-1)+1;
    }
    else{
        store[n][m]= max(dp(a,b,n-1,m),dp(a,b,n,m-1));
    }
    return store[n][m];
}


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

        string a,b;
        cin >> a>> b;
        int n=a.size();
        int m=b.size();
        int i,j,k;
        memset(store, -1, sizeof(store));
         int r=dp(a,b,n,m);
         trace(r);
        i=n; j=m;
        string ans="";
        while(i!=0 && j!=0){
                if(a[i-1]==b[j-1]){
                    ans+=a[i-1];
                    i--;
                    j--;
                }
                else if(store[i][j-1]>=store[i-1][j]){
                    j--;
                }
                else{
                    i--;
                }
            }
            reverse(ans.begin(),ans.end());
            cout << ans << '\n';

        

}

Measured memory_bytes: 71040
#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 int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

//重み付きUF
struct UnionFind_w {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> diff_weight;
    UnionFind_w(int n){ //最初は全てが根であるとして初期化
        init(n);
    }
    void init(int n) {
        par.resize(n);
        diff_weight.resize(n);
        REP(i,n){
            par[i] = i;
            diff_weight[i] = 0;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        int r = root(par[x]);
        if(par[par[x]] != par[x]) diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }

    int weight(int x){
        root(x);
        return diff_weight[x];
    }

    void unite(int x, int y,int w) { // xとyの木を併合
        w -= weight(x);
        w += weight(y);
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        diff_weight[rx] = w;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int diff(int x,int y){
        return weight(x) - weight(y);
    }
};

int a[4][3][10];

signed main(){
    int n;
    cin >> n;
    REP(i,n){
        int w,x,y,z;
        cin >> w >> x >> y >> z;
        w--;
        x--;
        y--;
        a[w][x][y] += z;
    }
    REP(i,4){
        REP(j,3){
            REP(k,10){
                cout << " " << a[i][j][k];
            }
            cout << endl;
        }
        if(i!= 3){
            cout << "####################" << endl;
        }
    }


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)
#define print(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1> void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << '\n';
}

template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int32_t main(){
		
		fast;

		int n; cin >> n;
		int len = to_string(n).size();

		int ans = 0;

		int i;
		for(i=1;i<=len-1;i+=2){
			ans=ans+(9*pow(10,i-1));
		}
		
		int k = n-pow(10,i-1);
		if(k>=0){
			ans=ans+k+1;
		}
		
		cout << ans << '\n';
 
		return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

ll n, a, b, h[MAXN];

bool check(ll x){
	ll t = 0;
	for(int i = 0; i < n; i++){
		ll y = x * b;
		if(y / x != b) continue;
		if(h[i] <= x * b) continue;
		t += (h[i] - x * b + (a - b) - 1) / (a - b);
	}
	return t <= x;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
    	cin >> h[i];
    }
    ll l = 1, r = 1e18;
    while(l < r){
    	ll mid = (l + r) / 2;
    	if(check(mid)) r = mid;
    	else l = mid + 1;
    }
    cout << l;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,k,a[200001];

void nhap()
{
    scanf("%d %d",&n,&k);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n,greater<int>());
    if (k>n) k=n;
}

void process()
{
    long long s=0;
    for (int i=k+1;i<=n;++i)
        s+=a[i];
    cout<<s;
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){
	
	string abc="abcdefghijklmnopqrstuvwxyz";
	int n, ans=0;
	string s;
	cin >> n;
	cin >> s;
	bool flag[26];
	for(int i=0; i<26; i++){
		flag[i]=false;
	}

	for(int i=0; i<n; i++){
		int x=0;
		for(int j=0; j<i; j++){
			for(int k=0; k<26; k++){
				if(s[j]==abc[k] && !flag[k]){
					flag[k]=true;
				}
			}
		}
		for(int j=i; j<n; j++){
			for(int k=0; k<26; k++){
				if(s[j]==abc[k] && flag[k]){
					x++;
					flag[k]=false;
				}
			}
		}
		for(int j=0; j<26; j++){
			flag[j]=false;
		}
		ans=max(ans, x);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int n,sum=0;
    cin>>n;
    long long int arr[3*n+1];
    for(long long int i=0;i<3*n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+3*n,greater<long long>());
    for(long long int i=1;i<=2*n;i=i+2)
    {
        sum=sum+arr[i];

    }
    cout<<sum<<endl;

}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    for (ll i = 1; i * i <= m; i++)
    {
        if (m % i == 0)
        {
            if (n * i <= m)
                ans = max(ans, i);
            if (n * (m / i) <= m)
                ans = max(ans, (m / i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MAXN = 105;

int n, m, sum;
int arr[MAXN];

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
        sum += arr[i];
    }
    std::sort(arr + 1, arr + n + 1, cmp);
    if (arr[m] * 4 * m >= sum) {
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

int		main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	map<int, ll> add, sub;
	for (int i = 0; i < n; i++)
	{
		add[i + a[i]]++;
		sub[i - a[i]]++;
	}
	ll count = 0;
	for (auto it = add.begin(); it != add.end(); it++)
		count += it->second * sub[it->first];
	cout << count << endl;
}


Measured memory_bytes: 38204
#include <iostream>

using namespace std;

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    int x,y,a;
    int xl=0,xr=W,yl=0,yh=H;
    for (int i=0;i<N;i++){
	cin >> x >> y >> a;
	if (a == 1) xl=max(xl,min(xr,x));
	else if (a == 2) xr=min(xr,max(xl,x));
	else if (a == 3) yl=max(yl,min(yh,y));
	else if (a == 4) yh=min(yh,max(yl,y));
    }

    cout << (xr-xl)*(yh-yl) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String ans = "Yes";
		if (str.compareTo("AAA") == 0 || str.compareTo("BBB") == 0 ) {
			ans = "No";
		}

		System.out.println(ans);
	}
}


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

int main()
{
    int x1,x2,x3,x4,x5;
    scanf("%d",&x1);
    scanf("%d",&x2);
    scanf("%d",&x3);
    scanf("%d",&x4);
    scanf("%d",&x5);

    if(x1==0)
    {
        printf("1");
    }
    else if(x2==0)
    {
        printf("2");
    }
    else if(x3==0)
    {
        printf("3");
    }
    else if(x4==0)
    {
        printf("4");
    }
    else if(x5==0)
    {
        printf("5");
    }
    else
    {
        printf("error");
    }
    return 0;
}


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

int main() {
    const int N = 1001;
    const int M = 2001;
    const ll INF = 1LL << 50;

    int n, m;
    cin >> n >> m;
    int a[M], b[M], c[M];

    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        c[i] *= -1;
    }

    ll dist[N];
    rep(i, n) dist[i] = INF;

    dist[0] = 0;

    for (int i=0; i<n-1; ++i) {
        for (int j=0; j<m; ++j) {
            if (dist[a[j]] != INF and dist[b[j]] > dist[a[j]] + c[j]) {
                dist[b[j]] = dist[a[j]] + c[j];
            }
        }
    }

    ll ans = dist[n-1];

    bool nega[N];
    rep(i, n) nega[i] = 0;

    for (int i=0; i<n; ++i) {
        for (int j=0; j<m; ++j) {
            if (dist[a[j]] != INF and dist[b[j]] > dist[a[j]] + c[j]) {
                dist[b[j]] = dist[a[j]] + c[j];
                nega[b[j]] = 1;
            }

            if (nega[a[j]]) nega[b[j]] = 1;
        }
    }

    if (nega[n-1]) cout << "inf" << endl;
    else cout << -ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, m, k;
double mod;

double solve(int i, int sum)
{
	if (i == n)
	{
		if (sum <= k) return 1 / mod;
		return (sum-k) / mod;
	}
	double res = 0;
	FOR(j, 1, m + 1)
	{
		res += solve(i + 1, sum + j);
	}
	return res;
}
int main()
{
	while (cin >> n >> m >> k, n)
	{
		mod = pow(m, n);
		cout << D10 << solve(0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define LL long long
#define INF 1e18
using namespace std;
LL n,p,p2,p3,p5;map<LL,LL> f;
I LL dfs(Con LL& x)
{
	#define Fdiv(x,y) ((p##y<=(x)/y*(y-1)||p##y<=p*(x)/y*(y-1))?p##y:p*(x)/y*(y-1))
	#define DFS(x,v) (t=dfs(x)+v,res>t&&(res=t))
	#define Work(y) ((m=x%y)?(x>=y&&DFS(x/y,Fdiv(x-m,y)+p*m),DFS(x/y+1,Fdiv(x+y-m,y)+p*(y-m))):DFS(x/y,Fdiv(x,y)))
	if(!x) return 0;if(x==1) return p;if(f.count(x)) return f[x];
	RI m;LL t,res=INF;return Work(2),Work(3),Work(5),f[x]=res;
}
int main()
{
	RI Tt;scanf("%d",&Tt);W(Tt--) f.clear(),
		scanf("%lld%lld%lld%lld%lld",&n,&p2,&p3,&p5,&p),printf("%lld\n",dfs(n));
	return 0;
}

Measured memory_bytes: 4556
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    a1 =0
    a2=0
    a3=0
    a4=0
    for i in a:
        if i == 1:
            a1+=1
        if i == 9:
            a2+=1
        if i == 7:
            a3+=1
        if i == 4:
            a4+=1
    if a1 == a2==a3==a4 ==1:
        print("YES")
    else:
        print("NO")

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

int main()
{
    int N, M, C;

    std::cin >> N >> M >> C;

    int B[20];
    int A[20][20];

    for (int i = 0; i < M; ++i)
    {
        std::cin >> B[i];
    }

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < M; ++j)
        {
            std::cin >> A[i][j];
        }
    }

    long long int sum;
    int cnt = 0;

    for (int i = 0; i < N; ++i)
    {
        sum = 0;
        for (int j = 0; j < M; ++j)
        {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0)
        {
            cnt++;
        }
    }

    std::cout << cnt << std::endl;
    return 0;
}


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

int main(){

    long long a, b;

    cin >> a >> b;

    if((a*b) % 2 ==0){
        printf("Even\n");
    }
    else{
        printf("Odd\n");
    }

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, m; cin >> n >> m;
    vi pat(m);
    rep(i, m){
        int k; cin >> k;
        rep(j, k){
            int s; cin >> s; s--;
            pat[i] |= (1 << s);
        }
    }
    vi p(m); for(auto& e : p) cin >> e;

    int res = 0;
    rep(i, 1 << n){
        [&](){
            rep(j, m){
                if(__builtin_popcount(i & pat[j]) % 2 != p[j]){
                    return;
                }
            }
            res++;
        }();
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1001001001;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct P
{
	int x, y;
	P(int x=0, int y=0) : x(x), y(y) {}
};

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int white = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') white++;
		}
	}
	queue<P> q;
	vector<vector<int>> d(h, vector<int>(w, INF));
	q.push({0, 0});
	d[0][0] = 0;
	while (!q.empty()) {
		P p = q.front(); q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.x + dx[i];
			int ny = p.y + dy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if (s[nx][ny] == '#') continue;
			if (d[nx][ny] < INF) continue;
			d[nx][ny] = d[p.x][p.y] + 1;
			q.push({nx, ny});
		}
	}
	if (d[h-1][w-1] >= INF) {
		cout << -1 << endl;
		return 0;
	}
	int ans = white - (d[h-1][w-1] + 1);
	cout << ans << endl;
	return 0;
}

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

int main()
{
  i64 N;
  cin >> N;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  double ans = 0;
  for (i64 i = 0; i < N; i++)
    ans += 1.0 / A[i];
  cout << fixed << setprecision(6) << 1.0 / ans << endl;
  return 0;
}


Measured memory_bytes: 256