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

namespace y.miyoshi
{

    public class Queen8
    {
        static int Max = 8;
        static bool[] vertical;
        static bool[] diagonal1;
        static bool[] diagonal2;
        static Dictionary<byte, byte> queenDic;
        static byte[] skip;
        static bool finish;

        public static void Main()
        {
            var n = byte.Parse(Console.ReadLine());
            skip = new byte[n];
            queenDic = Enumerable.Range(0, n).Select(_ =>
            {
                var line = Console.ReadLine().Split();
                skip[_] = byte.Parse(line[0]);
                return new Queen{ x = byte.Parse(line[0]), y = byte.Parse(line[1])};
            }).ToDictionary(e => e.x, e=>e.y);

            Initialize();
            queenDic.ToList().ForEach(q => MarkBoad(q.Key, q.Value, true));

            Search8Queens(0);

        }

        public static void Search8Queens(byte x)
        {
            if (finish) return;

            if (x == Max)
            {
                Display();
                finish = true;
                return;
            }

            if (!skip.Contains(x))
            {
                for (byte i = 0; i < Max; i++)
                {
                    //????????????????
                    if (queenDic.ContainsKey(x)
                        || vertical[i] == true
                        || diagonal1[x + i] == true
                        || diagonal2[x - i + Max - 1] == true)
                        continue;

                    //??????
                    MarkBoad(x, i, true);
                    Search8Queens((byte)(x + 1));
                    MarkBoad(x, i, false);
                }
            }
            else
            {
                Search8Queens((byte)(x + 1));
            }

        }

        public static void Display()
        {
            for (byte i = 0; i < Max; i++)
            {
                for (byte j = 0; j < Max; j++)
                {
                    if (queenDic[i] == j)
                        Console.Write('Q');
                    else
                        Console.Write('.');
                }
                Console.WriteLine();
            }
        }

        public static void MarkBoad(byte x, byte y, bool mark)
        {
            vertical[y] = mark;
            diagonal1[x + y] = mark;
            diagonal2[x - y + Max - 1] = mark;
            if (mark) queenDic[x] = y;
            else queenDic.Remove(x);
        }

        public static void Initialize()
        {
            vertical = new bool[Max];
            diagonal1 = new bool[2 * Max - 1];
            diagonal2 = new bool[2 * Max - 1];
        }

        public struct Queen
        {
            public byte x;
            public byte y;
        }
    }
}

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

int main()
{
    long long int n ;
    cin>>n ;
   string st ;
   cin>>st ;
   int i=0;
   int j=st.length()-1 ;
   long long c=0 ;
   while(i<j && i<n && j>=0)
   {
       while(i<n && i<j && st[i]=='R')
            i++ ;
        while(j>=0 && i<j && st[j]=='W')
            j-- ;
        if(i>=n  || j<0 ||i>=j) break ;
        char t=st[i] ;
        st[i]=st[j] ;
        st[j] = t ;
        c++ ;
   }
   cout<<c<<endl ;
}


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

int main() {
    int N;
    cin >> N;
    vector <int> L(N);
    for (int i=0; i<N; i++) cin >> L.at(i);
    int wa=0;
    sort(L.begin(), L.end());
    for (int i=0; i<N-1; i++) wa+=L.at(i);
    if (L.at(N-1)<wa) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    cin>>a>>b;
    c=(a*b)/__gcd(a,b);
    cout<<c<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    R, C, K = NMI()
    item = [[0] * (C + 1) for i in range(R + 1)]

    for i in range(K):
        r_, c_, v_, = NMI()
        item[r_ - 1][c_ - 1] = v_

    dp = [[[0 for _ in range(C + 2)] for _ in range(R + 2)] for _ in range(4)]

    for i in range(R + 1):
        for j in range(C + 1):
            for k in range(4):
                a = dp[k][i][j]
                v = item[i][j]

                if k == 3:
                    dp[0][i + 1][j] = max(a, dp[0][i + 1][j])
                    continue
                dp[0][i + 1][j] = max(a, a + v, dp[0][i + 1][j])
                dp[k][i][j + 1] = max(a, dp[k][i][j + 1])
                dp[k + 1][i][j + 1] = max(a + v, dp[k + 1][i][j + 1])

    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 460372
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

int prim(vector<vector<int>>& graph) {
    int n = graph.size() - 1;
    vector<bool> isInTree(n + 1);
    vector<int> weight(n + 1);
    for (int i = 1; i <= n; i++)
        weight[i] = INT_MAX;
    int v = 1;
    weight[v] = 0;
    while (true) {
        isInTree[v] = true;
        int minCost = INT_MAX;
        for (int i = 1; i <= n; i++) {
            if (!isInTree[i])
                continue;
            for (int j = 1; j <= n; j++) {
                int cost = graph[i][j];
                if (cost >= 0 && !isInTree[j] && cost <= minCost) {
                    v = j;
                    minCost = cost;
                }
            }
        }
        if (minCost == INT_MAX)
            break;
        weight[v] = minCost;
    }

    int result = 0;
    for (int i = 1; i <= n; i++)
        result += weight[i];
    return result;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> graph(n + 1, vector<int>(n + 1));
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> graph[i][j];

    int totalCost = prim(graph);
    cout << totalCost << endl;

    return 0;
}



Measured memory_bytes: 3168
N, M = gets.split.map &:to_i
A = gets.split.map &:to_i
c = [0,2,5,5,4,5,6,3,7,6]
dp=[0]
N.times{|i|
    A.each{|e|
        if dp[i] != nil
            dp[i + c[e]] = [dp[i + c[e]] || 0 ,  dp[i] * 10 + e].max
        end
    }
}
p dp[N]


Measured memory_bytes: 29180
N = int(input())
A = [1, 6, 6**2, 6**3, 6**4, 6**5, 6**6, 9, 9**2, 9**3, 9**4, 9**5]
dp = [1000000] * 300000
dp[0] = 0

for i in range(N):
    for a in A:
        d = dp[i] + 1
        dp[i + a] = min(dp[i + a], d)

print(dp[N])

Measured memory_bytes: 5364
#include<cstdio>
#include<algorithm>
using namespace std;const int N=1e5+10;
int a[N];int npos[N];int ppos[N];int k;int n;int res=0x3f3f3f3f;int tp1;int tp2;
int main()
{
	scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)if(a[i]>0)ppos[++tp1]=a[i];
	for(int i=n;i>=1;i--)if(a[i]<0)npos[++tp2]=-a[i];
	if(tp1+tp2<n)k--;if(k==0){printf("0");return 0;}
	for(int i=0;i<=tp1;i++)if(0<=k-i&&k-i<=tp2)res=min(res,2*ppos[i]+npos[k-i]);
	for(int i=0;i<=tp2;i++)if(0<=k-i&&k-i<=tp1)res=min(res,2*npos[i]+ppos[k-i]);
	printf("%d",res);return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod = 	1000000007;
int main() {
	int n, m; scanf("%d%d", &n, &m);
	bool ok[n + 1]{false};
	forn(i, m) {
		int bad; scanf("%d", &bad);
		ok[bad] = true;
	}
	ll dp[n + 1]{0};
	dp[0] = 1;
	if(!ok[1])
		dp[1] = 1;
	for(int i = 2; i <= n; i++) {
		if(!ok[i])
			dp[i] = dp[i - 1] + dp[i - 2];
		dp[i] %= mod;
	}
	printf("%lld", dp[n]);
	return 0;
}

Measured memory_bytes: 1152
import java.io.*;
import java.util.*;

public class Main {
	
	static int c,d,n,m;
	static int adj[][] = {{-1,0},{1,0},{0,-1},{0,1}};
	static int maj[][];
	static int board[][];
	
	static boolean legal(int x, int y) {
		if(x<0||y<0||x>=n||y>=m||board[x][y]==1) return false;
		else return true;
	}
	
	static void majGen() {
		int i=0;
		for(int x=-2;x<=2;x++) {
			for(int y=-2;y<=2;y++) {
				maj[i][0] = x; maj[i][1] = y; i++;
			}
		}
	}
	
	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        n = in.nextInt();m = in.nextInt();
        int a = in.nextInt()-1;int b = in.nextInt()-1;
        int c = in.nextInt()-1;int d = in.nextInt()-1;
        board = new int[n][m];
        maj = new int[25][2];
        majGen();
        for(int i=0;i<n;i++) {
        	char ch[] = in.next().toCharArray();
        	for(int j=0;j<m;j++) {
        		if(ch[j]=='#') board[i][j] = 1;
        	}
        }
        int dis[][] = new int[n][m];
        for(int x=0;x<n;x++) Arrays.fill(dis[x], 1_000_000_000);
        ArrayDeque<Integer> qx = new ArrayDeque<>();
        ArrayDeque<Integer> qy = new ArrayDeque<>();
        qx.add(a);qy.add(b);
        dis[a][b] = 0;
        while(!qx.isEmpty()) {
        	int curX = qx.removeFirst(), curY = qy.removeFirst();
        	for(int x[] : adj) {
        		int nx = curX+x[0], ny = curY+x[1];
        		if(legal(nx,ny)) {
        			if(dis[nx][ny]>dis[curX][curY]) {
        				dis[nx][ny] = dis[curX][curY];
        				qx.addFirst(nx);
        				qy.addFirst(ny);
        			}
        		}
        	}
        	for(int x[] : maj) {
        		int nx = curX+x[0], ny = curY+x[1];
        		if(legal(nx,ny)) {
        			if(dis[nx][ny]>dis[curX][curY]+1) {
        				dis[nx][ny] = dis[curX][curY]+1;
        				qx.addLast(nx);
        				qy.addLast(ny);
        			}
        		}
        	}
        }
        out.println((dis[c][d]==1e9)?"-1":dis[c][d]);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
}











Measured memory_bytes: 55816
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <cmath>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define is_in(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
using namespace std;
typedef long long ll;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
typedef pair<int, int> PII;

const int MAX_N = 100010;
const double THRESH_HOLD = 1e-15;

int main()
{
	int N;
	
	double prob[MAX_N], r_prob[MAX_N], tmp=1.0;
	prob[0] = r_prob[0] = 1.0;
	for (int i=1; i<MAX_N; i++) {
		tmp *= 0.5;
		prob[i] = prob[i-1] * tmp;
		r_prob[i] = prob[i-1] * (1.0 - tmp);
		// cerr << "r_prob[" << i << "] = " << r_prob[i] << endl;
	}
	
	while (cin >> N, N) {
		double dp[MAX_N] = {0.0};
		dp[0] = 1.0;

		for (int i=1; i<N; i++) {
			dp[i] += (i+1) * prob[i];
			dp[i] += i * r_prob[i];

			for (int j=i-2; j>=0; j--) {
				// cerr << "dp[i] += " << r_prob[i-j-1] * (dp[j] + i - j - 1) << endl;
				if (r_prob[i-j-1] < THRESH_HOLD) break;
				dp[i] += r_prob[i-j-1] * (dp[j] + i - j - 1);
			}
		}

		cout << fixed << setprecision(10);
		cout << dp[N-1] << endl;
	}
}

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void solve(int N) {
  if (N == 1) {
    printf("Hello World\n");
  } else {
    int A, B;
    cin >> A >> B;
    printf("%d\n", A + B);
  }
}

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


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

using namespace std;

bool valid(const vector<int> &w, int n, int k, int P) {
	int64_t groupSum = 0;
	int groups = 0;
	for (int i = 0; i < n; ++i) {
		if (groups >= k) return false;

		if (w[i] + groupSum > P) {
			groupSum = 0;
			--i;
			++groups;
		} else {
			groupSum += w[i];
		}
	}

	if (groupSum > P) return false;

	return true;
}

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

	int64_t total = 0;
	vector<int> w(n);
	for (auto &wi: w) {
		cin >> wi;
		total += wi;
	}

	auto l = (total / k) - 1;
	auto r = total + 1;
	int P = -1;
	while (l+1 < r) {
		auto m = (l + r) / 2;
		if (valid(w, n, k, m)) {
			r = m;
			P = m;
		} else {
			l = m;
		}

	}

	cout << P << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  cout << a*b/2 << endl;
    
}

Measured memory_bytes: 256
#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 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 IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	static int p[100002];
	
	ARSCD1(p,N);
	int ans = 0;
	
	bool edge = false;
	FORq(i,1,N-1){
		if (p[i] != i) continue;
		if ((p[i] == i) and (p[i+1] == i+1)){
			if (i==N-1) edge = true;
			ans++;
			i++;
			
		}else if (p[i] == i){
			ans++;
		}
	}
	
	if ((edge == false) and (p[N] == N)) ans++;
	
	PRINTD(ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
float distance(int x1, int y1, int x2, int y2) 
{ 
    // Calculating distance 
    return sqrt(pow(x2 - x1, 2) +  
                pow(y2 - y1, 2) * 1.0); 
} 
int factorial(int n) 
{ 
    // single line to find factorial 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
}

signed main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n%2==1)
	{
		cout<<"No";
		return 0;
	}
	else
	{
		int flag=0;
		for(int i=0;i<s.length()/2;i++)
		{
			if(s[i]!=s[i+s.length()/2])
				flag++;

		}
		if(flag)
			cout<<"No";
		else cout<<"Yes";

	}
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
static const LL INF = 1<<24;
static const LL LL_INF = 1<<60;
static const int mod = 1e+5;
static const int MAX_N = 101;
int dx[]={0,1};
int dy[]={1,0};
using namespace std;


int w,h;
LL mem[MAX_N][MAX_N][2][2][2][2];
LL cal(int x,int y,int px,int py,int ppx,int ppy){
    LL res=0;
    if(mem[x][y][px][py][ppx][ppy]!=0)return mem[x][y][px][py][ppx][ppy];
    if(x>=w||y>=h)return 0;
    if(x==w-1&&y==h-1)return 1;
    FOR(i,0,1){
        if(px!=ppx&&py!=ppy&&px!=dx[i]&&py!=dy[i])continue;
        res+=cal(x+dx[i],y+dy[i],dx[i],dy[i],px,py)%mod;
    }
    return mem[x][y][px][py][ppx][ppy]=res%mod;
}

int main(){
    while(1){
        cin>>w>>h;
        memset(mem,0,sizeof(mem));
        if(w==0&&h==0)break;
        cout<<cal(0,0,0,0,0,0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 2456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a > b) { a = b; return 1; } return 0; }
#include <chrono>

int fibonacci(int n) {
	if (n < 0)return -1;
	if (n == 0)return 0;
	if (n == 1)return 1;
	return fibonacci(n - 1) + fibonacci(n - 2);
}
int d_fibonacci(int n) {
	int a, b, c;
	a = 0;
	b = 1;
	if (n == 0)return a;
	if (n == 1)return b;
	rep(i, n) {
		c = a + b;
		a = b;
		b = c;
	}
	return c;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vi A(N);
	int sum = 0;
	rep(i, N) {
		cin >> A.at(i);
		sum += A.at(i);
	}
	sort(all(A), greater<int>());
	/*
	cout << sum << endl;
	cout << A.at(M - 1) << endl;
	*/
	if (sum <= 4 * M * A.at(M - 1)) {
		Yes;
	}
	else {
		No;
	}

	return 0;
}


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

int main() {
	string s,t,u;
	int a,b;
	cin >> s >> t >> a >> b >> u;
	if(s==u) cout << a-1 << " " << b << endl;
	else cout << a << " " << b-1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N = 3e5+1;
int n,a[N],b[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	int x=n,tmp=2;
	for(int i=1;i<=n;++i)
	{
		b[i]=a[x];
		x-=tmp;
		if(!x)x=1;
		if(n%2&&x==3&&tmp==-2)x=2;
		if(x==1)tmp*=-1;
	}
	for(int i=1;i<=n;++i)cout<<b[i]<<" ";
}

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

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

int main(){
  int n;
  cin>>n;
  int a[100000][2];
  int b[100000]={0};
  int c[100000]={0};
  rep(i,n){
    cin>>a[i][0]>>a[i][1];
    a[i][0]--;
    a[i][1]--;
    if(b[a[i][1]]!=0){cout<<-1<<endl;return 0;}
    if(c[a[i][0]]){cout<<-1<<endl;return 0;}
    b[a[i][1]]=a[i][0];
    c[a[i][0]]=1;
  }
  int ans=n;
  rep(i,n){
    if(c[i]){
      c[i]=0;
      int now=i;
      while(c[b[now]]){
	now=b[now];
	c[now]=0;
      }
      ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4664
use std::cmp::max;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc.chars();
    if s.len() == 1 {
        println!("1");
        return;
    }

    let ans1 = solve(true, &s);
    let ans2 = solve(false, &s);
    println!("{}", max(ans1, ans2));
}

fn solve(mut prev_two: bool, s: &Vec<char>) -> usize {
    let mut ans = 1;
    let n = s.len();
    let mut cur = if prev_two { 2 } else { 1 };
    while cur < n {
        if prev_two {
            prev_two = false;
            cur += 1;
            ans += 1;
        } else {
            if s[cur - 1] == s[cur] {
                if cur + 2 > n {
                    return ans;
                }
                cur += 2;
                ans += 1;
                prev_two = true;
            } else {
                cur += 1;
                ans += 1;
            }
        }
    }
    ans
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r); 
    if(r <= x && x <= (W - r) && r <= y && y <= (H - r)) printf("Yes\n");
    else printf("No\n");
    return (0);
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	ll x;
	cin>>x;
	ll k=0;
	for(ll i=-1000;i<=1000;i++)
	{
		for(ll j=-1000;j<=1000;j++)
		{
			if(pow(i,5)-pow(j,5)==x)
			{
				k=1;
				cout<<i<<" "<<j;break;
			}
			else if(pow(j,5)-pow(i,5)==x)
			{
				k=1;
				cout<<j<<" "<<i;break;
			}
		}
		if(k==1)break;
	}
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
long long int count1=0;
int main(){
	long long int aka,aoi,ans,n;
	cin>>n>>aka>>aoi;
	ans=aoi+aka;
	long long int l=n/ans,r=n%ans;
	count1+=l*aka;
	if(r<=aka)count1+=r;
	if(r>aka) count1+=aka;
	cout<<count1<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i

def judge(t,x,y)
    x.abs + y.abs <= t &&  (x+y)%2 == t%2
end

ans = "Yes"
s = 0
a = 0
b = 0
(1..n).each do |i|
    t,x,y = gets.chomp.split(" ").map(&:to_i)
    if judge(t-s,x-a,y-b)
        s = t
        a = x
        b = y
    else
        ans = "No"
        break
    end
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
int main()
{
/* 
https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5
ボール      箱	      入れ方に制限なし 箱の中身は1つ以下 箱の中身は1つ以上
区別できる   区別できる  1            2             3
区別できない  区別できる  4            5             6
区別できる   区別できない 7            8             9
区別できない  区別できない 10          11            12
*/
ll n , k ;
cin >> n >> k ;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
COMinit();
vector<ll> fac = factorial(100000);

ll t=0;
rep(i,k+1){
  t=mod(t+mypow(-1,k-i)*COM(k,i)*mypow(i,n));
}

//1
//cout << mypow(k,n) << endl;
//2
//cout << (COM(k,n)*fac[n])%mo << endl;
//3
//cout << t << endl;
//4
//cout << COM(n+k-1,n) << endl;
//5
//cout << COM(k,n) << endl;
//6
//cout << COM(n-1,k-1) << endl;
//7
//8,11
//cout << (n>k?0:1) << endl;
//9 漸化式でもできる
cout << mod(t*mypow(fac[k],mo-2)) << endl;
//10
//12
return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    long n;

    cin >> n;

    ll b[n];
    vector<ll> a(n), c(n);
    vector<ll>::iterator it;
    long index;
    ll ans = 0LL;

    long i;

    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) cin >> b[i];
    for (i = 0; i < n; i++) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b, b + n);
    sort(c.begin(), c.end());

    for (i = 0; i < n; i++) {
        it = std::upper_bound(c.begin(), c.end(), b[i]);

        if (it != c.end()) {
            index = it - c.begin();

            it = std::lower_bound(a.begin(), a.end(), b[i]);

            ans += (it - a.begin()) * (n - index);
        }
    }

    cout << ans << '\n';

    return 0;
}


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

C = 10**9+7
n = 5
num = max(N+1, 6)
L = [0 for i in range(num)]
X = [0 for i in range(num)]
Y = [0 for i in range(num)]
Z = [0 for i in range(num)]
W = [0 for i in range(num)]
G = [0 for i in range(num)]
L[3] = 61
L[4] = 230
X[3] = 3
X[4] = 12
Y[3] = 4
Y[4] = 16
Z[3] = 4
Z[4] = 15
W[3] = 3
W[4] = 12
W[5] = 48
G[3] = 15
G[4] = 58
while n <= N:
    L[n] = 4*L[n-1] - (X[n-1]+Y[n-1]+Z[n-1]+W[n-1])
    G[n] = L[n-1]-X[n-1]
    X[n] = L[n-2]-G[n-2]
    Y[n] = L[n-2]
    Z[n] = L[n-2]-X[n-2]
    if n > 5:
        W[n] = L[n-3]*3
    n += 1

print(L[N]%C)

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

using namespace std;

char str[100000 + 10];
int t[100000 + 10];
bool check;

int main() {
    int n;
    check = false;
    scanf("%d", &n);
    scanf("%s", str + 1);
    for(int x = 0; x <= 1; x++) {
        for(int y = 0; y <= 1; y++) {
            t[1] = x;
            t[2] = y;
            for(int i = 2; i < n; i++) {
                if(t[i] == 0) {
                    if(str[i] == 'o') t[i + 1] = t[i - 1];
                    else t[i + 1] = 1 - t[i - 1];
                } else {
                    if(str[i] == 'o') t[i + 1] = 1 - t[i - 1];
                    else t[i + 1] = t[i - 1];
                }
            }
            check = true;
            if(t[1] == 0) {
                if(str[1] == 'o' && t[2] != t[n]) check = false;
                if(str[1] == 'x' && t[2] != 1 - t[n]) check = false;
            } else {
                if(str[1] == 'o' && t[2] != 1 - t[n]) check = false;
                if(str[1] == 'x' && t[2] != t[n]) check = false;
            }
            if(t[n] == 0) {
                if(str[n] == 'o' && t[1] != t[n - 1]) check = false;
                if(str[n] == 'x' && t[1] != 1 - t[n - 1]) check = false;
            } else {
                if(str[n] == 'o' && t[1] != 1 - t[n - 1]) check = false;
                if(str[n] == 'x' && t[1] != t[n - 1]) check = false;
            }
            if(check) break;
        }
        if(check) break;
    }
    if(check) {
        for(int i = 1; i <= n; i++) {
            if(t[i] == 0) printf("S");
            else printf("W");
        }
        printf("\n");
    }
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 500005
#define PI 3.14159265358979323846264338327950
#define F first
#define S second
#define ll   long long int
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	ll a[n+3];
	for(ll i = 0; i < n; i ++){
		cin >> a[i];
	}
	ll ans = 0;
	for(ll i = 0; i < n-1; i ++){
		for(ll j = i + 1; j < n; j ++){
			ans += (a[i] * a[j]);
		}
	}
	cout << ans;
	
}

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

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

    cout << min(a, b) << " "<<  (max(0, a + b-n)) << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	int ans = 0;
	REP(i, 3) {
		if (S[i] == T[i])ans++;
	}
	print(ans);
}



Measured memory_bytes: 256
import sys
import math

a,b,h,m = (float(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(11):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break



if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit(0)

elif zi > hun: 
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif zi - hun == 180:
        print(a + b)
        sys.exit(0)
elif hun == zi:
    if b >= a:
        print(b - a)
        sys.exit(0)
    else:
        print(a-b)
        sys.exit(0)

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosain))


    

Measured memory_bytes: 9464
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,a[100005];
int par[100005],ran[100005];
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
P val[100005];
bool used[100005];
vector<int>zan;
ll ret;
int main(){
	init();
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m){
		int a,b;cin>>a>>b;
		unite(a,b);
	}
	rep(i,n){
		val[i] = mp(INF,INF);
	}
	rep(i,n){
		val[find(i)] = min(val[find(i)],mp(a[i],i));
	}
	int cnt = 0;
	rep(i,n){
		if(find(i) == i){
			cnt++;
			ret += val[i].fi;
			used[val[i].sc] = 1;
		}
	}
	if(cnt == 1){
		cout << 0 << endl;
		return 0;
	}
	rep(i,n) if(!used[i]) zan.pb(a[i]);
	SORT(zan);
	if(zan.size() < cnt-2){
		puts("Impossible");
		return 0;
	}
	for(int i=0;i<cnt-2;i++) ret += zan[i];
	cout << ret << endl;
}

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 1000005
char s[MAXN];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<=len-1;i++)
	{
		if(s[i]==s[i+1])
		{
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		if(s[i]==s[i+2])
		{
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,m,dp[300005],ans[300005],pr[300005];
vector<ll>v[300005],pre[300005],suf[300005];
void go(ll x,ll par){
    dp[x] = 1;
    for(int i=0; i<v[x].size(); i++){
            go(v[x][i] , x);
            dp[x] *= dp[v[x][i]] + 1;
            dp[x] %= m;
    }
    ll namr = 1;
    for(int i=0; i<v[x].size(); i++){
            namr *= dp[v[x][i]] + 1;
            namr %= m;
            pre[x].pb(namr);
    }
    namr = 1;
    for(int i=(int)v[x].size() - 1; i>=0; i--){
            namr *= dp[v[x][i]] + 1;
            namr %= m;
            suf[x].pb(namr);
    }
    reverse(suf[x].begin(),suf[x].end());
}

void solve(ll x,ll par,ll cur){
    ans[x] = (cur + 1) * dp[x];
    ans[x] %= m;
    int t = 0;
    for(int i=0; i<v[x].size(); i++){
            ll gas = 1;
            if(i - t)gas *= pre[x][i - 1];
            if(i < (int)v[x].size() - 1)gas *= suf[x][i + 1];
            gas %= m;
            solve(v[x][i],x,((gas * cur) % m + gas) % m);
    }
}
void dfs(ll x,ll par){
    pr[x] = par;
    for(int i=0; i<v[x].size(); i++){
        if(v[x][i] != par){
            dfs(v[x][i],x);
        }
    }
}
int main(){
    cin >> n >> m;

    for(int i=1; i<n; i++){
        int x,y;
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1,-1);

    for(int i=1; i<=n; i++)v[i].clear();

    for(int i=2; i<=n; i++){
        v[pr[i]].pb(i);
    }

    go(1,-1);

    solve(1,-1,0);

    for(int i=1; i<=n; i++){
        cout << ans[i] << endl;
    }





    return 0;
}


Measured memory_bytes: 43392
a=[]
for i in range(3):
    line=list(map(int,input().split()))
    a.append(line)
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
bingo=0
for i in range(3):
    sum_=0
    for j in range(3):
        sum_+=a[i][j]
    if sum_==0:
        bingo+=1
for i in range(3):
    sum_=0
    for j in range(3):
        sum_+=a[j][i]
    if sum_==0:
        bingo+=1
if a[0][0]+a[1][1]+a[2][2]==0:
    bingo+=1
if a[0][2]+a[1][1]+a[2][0]==0:
    bingo+=1
print("Yes" if 0<bingo else "No")

Measured memory_bytes: 38256
def check(idxs_):
    rikaido = [0 for i in range(m)]
    cost_ = 0
    for i in idxs_:
        for j in range(m):
            rikaido[j] += a[i][j]
        cost_ += c[i]
    for i in range(m):
        if rikaido[i] < x:
            cost_ = 9999999
    return cost_


n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    c.append(_[0])
    a.append(_[1:])

mini = 9999999

for i in range(2 ** n):
    _ = []
    for j in range(n):
        if ((i >> j) & 1):
            _.append(j)
    cost = check(_)
    if cost < mini:
        mini = cost
    # print(mini)

if mini == 9999999:
    mini = -1

print(mini)


Measured memory_bytes: 9240
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#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 ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int main()
{

    int n, x;
    cin >> n >> x;
    int sum = 0;
    rep(i, 0, n)
    {
        int l;
        cin >> l;
        sum += l;
        if (sum > x)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << n + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    vector<int> a(4);
    string input;
    cin>>input;
    rep(i,4) a.at(i) = input.at(i) - '0';

    rep(x,8){//000~111までの二進数探索するループ
        int sum = a.at(0);
        string s;
        s += (char)('0'+a.at(0));
        rep(i,3){
            if(x&(1<<i)){//i番目のビットが0か１かを見分ける(1なら+,0なら-を表す）
                sum += a.at(i+1);
                s += '+';
                s += (char)('0'+a.at(i+1));
            }
            else{
                sum -= a.at(i+1);
                s += '-';
                s += (char)('0'+ a[i+1]);
            }
        }
        if(sum==7){
            s += "=7";
            cout<<s<<endl;
            return 0;
        }
    }

    return 0;
}

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  vector<int> A(M, 0);
  vector<int> B(M, 0);

  for(int i = 0; i < M; ++i){
    cin >> A.at(i) >> B.at(i);
  }

  for(int i = 0; i < M; ++i){
    uf.merge(A.at(i)-1, B.at(i)-1);
  }

  ll cnt = 0;
  for(int i = 0; i < N; ++i){
    ll t = uf.size(i);
    cnt = max(cnt ,t);
  }

  cout << cnt << endl;   
}


Measured memory_bytes: 7956
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF (1e10+5)
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define FRL(i,a,n) for(i=a;i<n;i++)
#define FR(i,n) FRL(i,0,n)
#define RFRL(i,n) for(i=n;i>=0;i--)
#define MOD 1000000007
#define fill(a) memset(dp,a,sizeof(dp));

using namespace std;

typedef long long int  ll;

typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector< pair<ll,ll> > vpi;
typedef set<ll> st;
typedef map<ll,ll> mp;
typedef unordered_map<ll,ll> ump;

template< class T>
T minn(T a,T b)
{
	return (a>b)?b:a;
}
template< class T>
T maxx(T a,T b)
{
	return (a>b)?a:b;
}


void FILE_OP()
{
	#ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("output2.txt", "w", stdout);
    #endif
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void SOLVE()
{

	
	ll tt,m,i,j,k,a,b,c,d,l,r;
	//cin>>tt;
	tt=1;
	//fill(-1)
	ll n,W;
    
    //ll dp[100010];
	while(tt--)
	{
		cin>>a>>b;
		for(i=((a*100)/8);i<=1000;i++)
		{

			if(((i*8)/100)==a && (i/10)==b )
			{
				cout<<i<<"\n";
				return;
			}
		}
		cout<<-1<<"\n";
		
	}


		
}

int main()
{
	FAST_IO
	//FILE_OP();
	SOLVE();
	
	return 0;
}


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

typedef long long ll;

int const N = 200 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;
int const inf = 1000 * 1000 * 1000;

typedef pair<int,int> type;

int X;


int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> X;
  ll l = 1;
  ll r = 1e9;
  ll ans = 0;
  while(l <= r) {
    ll m = l + r >> 1;
    if(X <= m*(m+1)/2)
      r = m - 1, ans = m;
    else
      l = m + 1;
  }

  cout << ans << " ";
}

Measured memory_bytes: 256
// ベルマンフォード法(O(V*E))V:頂点、E:辺の数
// 単一始点最短路問題
// 負の辺を含む時はこっち
// 含まない時はdijkstraダイクストラ(O(ElogV))が良い。

#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

// 頂点fromから頂点toへのコストcostの辺
struct edge { ll from, to, cost; };
typedef pair<ll, ll> P;
const int N = 1e3+5;
const int M = 2e3+5;
const ll INF = 1e17+5;

edge es[M]; // 辺
ll d[N]; // 最短距離
ll V,E;  // Vは頂点数, Eは辺数
// vector<P> G[N];

// s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
  rep(i,V) d[i] = -INF;
  d[s] = 0;
  rep(i,2*V) {
    // cout << i << endl;
    bool update = false;
    rep(i,E) {
      edge e = es[i];
      if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        // cout << e.to << " :  " << d[e.to] << endl;
        update = true;
      }
    }
    if(!update) break;
  }
}

// trueなら負の閉路が存在する
bool find_negative_loop() {
  rep(i,V) d[i] = -INF;

  rep(i,2 * V) rep(j,E){
    edge e = es[j];
    if(d[e.to] < d[e.from] + e.cost) {
      d[e.to] = d[e.from] + e.cost;

      // n回目にも更新があるなら負の閉路が存在する
      // cout << i << " : " << e.to << endl;
      if(i >= V - 1 && e.to == V-1) return true;
    }
  }
  return false;
}
ll a,b,c;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> V >> E;
  rep(i,E) {
    cin >> a >> b >> c;
    a--;b--;
    es[i] = (edge) {a,b,c};
  }
  if(find_negative_loop()) {
    cout << "inf" << endl;
    return 0;
  }
  shortest_path(0);
  cout << d[V-1] << endl;
}


Measured memory_bytes: 256