akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a,b;
void solve()
{
    int x=b,len=0;
    while(x) {x/=10;len++;}
    x=a*pow(10,len)+b;
    if (sqrt(1.0*x)==(int)sqrt(1.0*x)) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include <algorithm>
#include <regex>

using namespace std;

int main() {
    string s;
    cin >> s;

    regex re1(".*?keyence");
    regex re2("k.*?eyence");
    regex re3("ke.*?yence");
    regex re4("key.*?ence");
    regex re5("keye.*?nce");
    regex re6("keyen.*?ce");
    regex re7("keyenc.*?e");
    regex re8("keyence.*?");

    if (
        regex_match(s, re1) ||
        regex_match(s, re2) ||
        regex_match(s, re3) ||
        regex_match(s, re4) ||
        regex_match(s, re5) ||
        regex_match(s, re6) ||
        regex_match(s, re7) ||
        regex_match(s, re8)
    ) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;

    return 0;
}

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

int main() {
  int N,Q,a;
  long int ans=0;
  int i,j;
  cin>>N;
  vector<int> A(100001);
  for(i=0;i<N;i++){
    cin>>a;
    A[a]++;
    ans+=a;
  }
  cin>>Q;
  int B,C;
  for(i=0;i<Q;i++){
    cin>>B>>C;
    A[C]+=A[B];
    ans+=(C-B)*A[B];
    A[B]=0;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3768
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String n=sc.next();
		for(int i=0;i<n.length();i++) {
			if(n.charAt(i)=='A') {
				if(i!=0) {
					n=n.substring(i);
				}
				break;
			}
		}
		for(int j=0;j<n.length();j++) {
			if(n.charAt(n.length()-1-j)=='Z') {
				n=n.substring(0,n.length()-j);
				break;
			}
		}
		System.out.println(n.length());
		sc.close();
	}
}

Measured memory_bytes: 30000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int taroPoint = 0;
		int hanakoPoint = 0;

		String taro;
		String hanako;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);
			int gameCount = sc.nextInt();

			for (int i = 0; i < gameCount; i++) {
				taro = sc.next();

				hanako = sc.next();

				int judge = taro.compareTo(hanako);

				//?????????????????????
				if (judge > 0) {
					taroPoint += 3;
				}else if(judge < 0){
					hanakoPoint += 3;
				}else{
					taroPoint += 1;
					hanakoPoint += 1;
				}

			}
			System.out.println(taroPoint + " " + hanakoPoint);
		} finally {
			sc.close();
		}
	}

}

Measured memory_bytes: 30172
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	h := make([]int, n)

	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	dp := make([]int, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		mincost := math.MaxInt64
		for j := max(i-k, 0); j < i; j++ {
			costnow := dp[j] + abs(h[i]-h[j])
			//fmt.Println("i,j=", i, j, " dp[j]=", dp[j], " abs=", abs(h[i]-h[j]))
			mincost = min(mincost, costnow)
		}
		dp[i] = mincost

	}

	fmt.Println(dp[n-1])

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4124
#include <stdio.h>
int main(){
    
  int n,i,a[101];
  
  n <= 100;
  0 <= a[101] < 1000;
  
  scanf("%d", &n);
  for( i = 1; i <= n; i++){
    scanf("%d", &a[i]);
  }
  for( i = n; i > 0; i--){
    printf("%d", a[i]);
    if(i != 1){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}


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

int main(){

   long long i,n;
   cin>>n;
   
   for(i=sqrt(n);i>=1;i--)
       if(n%i==0) break;
	 
	long long x,y;
	x=n/i;
	y=i;
	
	if(x>y) swap(x,y);
	long long u,v;
	u=x; v=1;
	cout<<x-1+y-1<<endl;
	

    return 0;
}


Measured memory_bytes: 256
x,n=map(int,input().split())
p=list(map(int,input().split()))
num1=0
num2=0
if(n==0):
    print(x)
    exit()
for i in range(100):
    num1=x-i
    num2=x+i
    if(not num1 in p and not num2 in p):
        print(num1)
        exit()
    elif(not num2 in p):
        print(num2)
        exit()
    elif(not num1 in p):
        print(num1)
        exit()

Measured memory_bytes: 9104
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

import numpy as np

def get_time(i):
    return int(np.ceil(i / 10) * 10)

total1 = get_time(a) + get_time(b) + get_time(c) + get_time(d) + e
total2 = a + get_time(b) + get_time(c) + get_time(d) + get_time(e)
total3 = get_time(a) + b + get_time(c) + get_time(d) + get_time(e)
total4 = get_time(a) + get_time(b) + c + get_time(d) + get_time(e)
total5 = get_time(a) + get_time(b) + get_time(c) + d + get_time(e)
print(min([total1, total2, total3, total4, total5]))


Measured memory_bytes: 21648
N, M = map(int, input().split())
H = list(map(int, input().split()))
array = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    if H[a - 1] > H[b - 1]:
        array[b - 1] += 1
    elif H[a - 1] < H[b - 1]:
        array[a - 1] += 1
    else:
        array[a - 1] += 1
        array[b - 1] += 1

print(array.count(0))

Measured memory_bytes: 20148
using System;
using System.Collections.Generic;

namespace _5_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = new List<int>();
            for (var i = 1; i <= n; i++)
            {
                if (i % 3 == 0 || i.ToString().Contains("3"))
                {
                    num.Add(i);
                }
            }
            Console.WriteLine(" " + string.Join(" ", num));
        }
    }
}



Measured memory_bytes: 17980
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    string S;
    cin>>S;
    int N=S.size(),ans=0;
    for(int i=0;i<N;++i){
        for(int j=i;j<N;++j){
            bool b=true;
            for(int k=i;k<=j;++k){
                if(!(S[k]=='A'||S[k]=='T'||S[k]=='C'||S[k]=='G'))b=false;
            }
            if(b)ans=max(ans,j-i+1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
//int g(int x){
//	x=modpow(x,MOD-2);
//	return x;
//}
int n,a[2010],ans;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	rep(i,n){
		for(int j=i+1;j<n;j++){
			int x=a[i]+a[j];
			ans+=lower_bound(a,a+n,x)-a-1-j;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n >> t;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vector<vector<int>> dp(n+1, vector<int>(t));
  for (int i = 1; i <= n; i++) {
    rep(j, t) {
      dp[i][j] = dp[i-1][j];
      if (j-a[i-1] >= 0)
        chmax(dp[i][j], dp[i-1][j-a[i-1]]+b[i-1]);
    }
  }
  set<int> st;
  int j = t-1;
  for (int i = n; i > 0; i--) {
    if (j-a[i-1] >= 0 && dp[i-1][j-a[i-1]]+b[i-1] == dp[i][j]) {
      st.insert(i-1);
      j -= a[i-1];
    }
  }
  priority_queue<int> que;
  rep(i, n) {
    if (st.find(i) == st.end())
      que.push(b[i]);
  }
  int ans = dp[n][t-1];
  if (!que.empty())
    ans += que.top();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int x = tx - sx;
  int y = ty - sy;

  rep(i, y) cout << "U";
  rep(i, x) cout << "R";

  rep(i, y) cout << "D";
  rep(i, x) cout << "L";

  cout << "LU";
  rep(i, y) cout << "U";
  rep(i, x) cout << "R";
  cout << "RD";

  cout << "RD";
  rep(i, y) cout << "D";
  rep(i, x) cout << "L";
  cout << "LU";

  cout << endl;

  return 0;
}


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

int main(void)
{
    int x,y,z;
    cin>>x>>y>>z;
    for(int i=0;;++i)
    {
        if(y*i+z*(i+1)>x)
        {
            if(i==0)
            {
                cout <<0<<endl;
                return 0;
            }
            cout<<i-1<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("prob.in"));
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("prob.out")));
		
		StringTokenizer st = new StringTokenizer(in.readLine());
		
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		
		int e = a + b;
		int f = c + d;
		
		if(e == f){
			out.println("Balanced");
		}
		else if(e < f){
			out.println("Right");
		}
		else{
			out.println("Left");
		}
		
		
		
		in.close();
		out.close();
		
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

struct Point2D { 
	double x, y;
	Point2D (double a=0, double b=0) { x=a; y=b; }
};

typedef Point2D Vector2D;

double dist2D(const Point2D& a, const Point2D& b) { return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); }

Vector2D sub_vector2D(const Vector2D& a, const Vector2D& b) {
	Vector2D ret;
	ret.x = a.x - b.x; ret.y = a.y - b.y;
	return ret;
}

double cross_product(const Vector2D& a, const Vector2D& b) { return a.x*b.y - a.y*b.x; }

double inner_product(const Vector2D& a, const Vector2D& b) { return a.x*b.x + a.y*b.y; }

bool point_in_triangle_2D(const Point2D& a, const Point2D& b, const Point2D& c, const Point2D& p) {
	Vector2D ab = sub_vector2D(b, a); Vector2D bp = sub_vector2D(p, b);
	Vector2D bc = sub_vector2D(c, b); Vector2D cp = sub_vector2D(p, c);
	Vector2D ca = sub_vector2D(a, c); Vector2D ap = sub_vector2D(p, a);
	double c1 = cross_product(ab, bp), c2 = cross_product(bc, cp), c3 = cross_product(ca, ap);
	return ( (c1>0 && c2>0 && c3>0) || (c1<0 && c2<0 && c3<0) );
}

struct Circle {
	Point2D c; 
	double r;
	Circle (double a=0, double b=0, double rr=0) { c.x=a; c.y=b; r=rr; }
};

bool point_in_circle(const Point2D& p, const Circle& t) {
	double dist = dist2D(p, t.c);
	return (dist<t.r);
}

int circle_intersect(const Circle& a, const Circle& b) {
	double dist = dist2D(a.c, b.c);
	if (a.r + b.r < dist) return 0;
	if (dist + b.r < a.r) return 2;
	if (dist + a.r < b.r) return -2;
	return 1;
}

int main() {
	int n; cin >> n;
	Circle a, b;
	
	for_(i, 0, n) {
		cin >> a.c.x >> a.c.y >> a.r >> b.c.x >> b.c.y >> b.r;
		
		cout << circle_intersect(a, b) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a[3];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&a[0],&a[1],&a[2]);
		std::sort(a,a+3);
		
		if(a[0]==3 && a[1]==4 && a[2]==5)puts("YES");
		else if(a[0]==6 && a[1]==8 && a[2]==10)puts("YES");
		else puts("NO");
	}
}

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

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

    long long n;
    cin >> n;

    long long ans = n - 1;
    for(long long i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            ans = min(ans, i + (n / i) - 2);
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	const double hight[] = { 0.0, 165.0, 170.0, 175.0, 180.0, 185.0, DBL_MAX };
//	cut here before submit 
//	freopen("testcase.hist", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	vector <int> hist (sizeof(hight)/sizeof(hight[0]) - 1, 0);
	int i,j;

	for (i = 0; i < n; ++i){

		getline (cin, str );
		double h;

		stringstream ss(str);
		ss >> h;

		for (j = 0; j < hist.size(); ++j){
			if (h >= hight[j] && h < hight[j+1] ){
				++hist[j];		
			} // end if
		} // end for

	} // end loop

	for (i = 0; i < hist.size(); ++i){
		cout << (i+1) << ':';
		for (j = 0; j < hist[i]; ++j){
			cout << '*';
		} // end for
		cout << endl;
	} // end for
		
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7

ans = 0
count=[0]*60
for a in A:
  for i in range(60):
    count[i] += a & 1
    a >>= 1
    
for i in range(60):
  ans += count[i] * (N - count[i]) * (2 ** i)
  ans %= mod
print(ans)


Measured memory_bytes: 124188
#include <bits/stdc++.h>
#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 SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 1000000007;
// const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


int n;

string s[2];


signed main(){

    cin >> n;
    cin >> s[0];
    cin >> s[1];

    int ans;
    bool beforeState;
    bool nowState;

    int start;

    for(int i = 0;i < 1;i++){
        if(s[0][0]!=s[0][1]){
            ans = 3;
            beforeState = 0;
            start = 1;
        }else{
            ans = 6;
            beforeState = 1;
            start = 2;
        }
    }

    for(int i = start;i < n;i++){
        if(i == n-1){
            nowState = 0;
        }else if(s[0][i] == s[0][i+1]){
            nowState = 1;
            i++;
        }else{
            nowState = 0;
        }

        int revarage;

        if(beforeState == 0){
            revarage = 2;
        }else{
            if(nowState == 0){
                revarage = 1;
            }else{
                revarage = 3;
            }
        }

        ans=(ans*revarage)%MOD;
        beforeState = nowState;
    }

    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a, b, c = 3.times.map{gets.split.map(&:to_i).sort_by{|x|-x} << 0}

bb = [0]
j = 0
n.times{|i|
  j += 1 while b[i]<c[j]
  bb << bb[-1] + j
}
ct = 0
j = 0
n.times{|i|
  j += 1 while a[i]<b[j]
  ct += bb[j]
}
p ct

Measured memory_bytes: 27100
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265

void koch(int d,double p1x,double p1y,double p2x,double p2y){
    if(d==0) return;
    double sx,sy,ux,uy,tx,ty;
    sx=(p1x*2+p2x)/3;
    sy=(p1y*2+p2y)/3;
    tx=(p1x+p2x*2)/3;
    ty=(p1y+p2y*2)/3;
    ux=(tx-sx)*cos(PI/3)-(ty-sy)*sin(PI/3)+sx;
    uy=(tx-sx)*sin(PI/3)+(ty-sy)*cos(PI/3)+sy;
    koch(d-1,p1x,p1y,sx,sy);
    printf("%.8lf %.8lf\n",sx,sy);
    koch(d-1,sx,sy,ux,uy);
    printf("%.8lf %.8lf\n",ux,uy);
    koch(d-1,ux,uy,tx,ty);
    printf("%.8lf %.8lf\n",tx,ty);
    koch(d-1,tx,ty,p2x,p2y);
}

int main(){
    int n;
    cin>>n;
    double x=0,y=100;
    printf("%.8lf %.8lf\n",x,x);
    koch(n,x,x,y,x);
    printf("%.8lf %.8lf\n",y,x);
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

const int N=2e5+100;

int32_t main(){
    ll a,b;
    cin >> a >> b;
    cout << (b-1+a-2)/(a-1);
}


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

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, p: "List[int]"):
    for i in range(N):
        if p[i] != i + 1:
            j = p[i] - 1
            p[i], p[j] = p[j], p[i]
            break
    for i in range(N):
        if p[i] != i + 1:
            print(NO)
            return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int c=1;
    for(int i=0;i<4;i++){
        if(i!=0 && s[i]==s[i-1]){     
            c++;
            if(c>=3){
                cout<<"Yes"<<endl;
                return 0;
            } 
        }
        else c=1;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();

		if (A == B && B == C) {
			System.out.println("No");
		} else if (A != B && B != C && C != A) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int A, B;
    cin >> A >> B;
    if (A % 2 == 0 || B % 2 == 0) {
        cout << "No" << endl;

    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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



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

int main() {
    
    int X;
    cin >> X;
    
    FOR(a, 0, 20) FOR(b, 0, 25) FOR(c, 0, 100) FOR(d, 0, 50) {
        int tmp = X - a*105 - b*104 - c*103 - d*102 ;
        if (tmp >= 0) {
            int e = tmp % 10;
            int r = tmp - 101*e;
            if (r >= 0 && r % 100 == 0) {
                //printf("%d %d %d %d %d %d %d\n", a, b ,c ,d ,e, r % 100);
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    cout << (N / 2) * (N - (N / 2)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
bool used[103];
int cmp[103];
vector<int> g[103], gr[103];
vector<int> vs;
void init(){
	for(int i=0; i<2*n+2; i++) g[i].clear(), gr[i].clear();
}
void add(int x, int y){
	g[x].push_back(y); gr[y].push_back(x);
}
void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}
 
void rdfs(int v, int k){
	used[v]=1;
	cmp[v]=k;
	for(auto y:gr[v]){
		if(!used[y]) rdfs(y, k);
	}
}
 
int scc(){
	fill(used, used+2*n+2, 0);
	vs.clear();
	for(int i=0; i<2*n+2; i++){
		if(!used[i]) dfs(i);
	}
	fill(used, used+2*n+2, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int main()
{
	cin>>n;
	int d[51]; d[0]=0;
	for(int i=1; i<=n; i++) cin>>d[i];
	for(int s=12; s>=0; s--){
		init();
		for(int i=0; i<=n; i++){
			for(int j=0; j<=n; j++){
				if(i==j) continue;
				if(abs(d[i]-d[j])<s){
					add(i, j+n+1);
					add(i+n+1, j);
				}
				int x=abs((24-d[i])%24-d[j]);
				if(min(x, 24-x)<s){
					add(i, j);
					add(i+n+1, j+n+1);
				}
			}
		}
		scc();
		bool ok=1;
		for(int i=0; i<=n; i++){
			if(cmp[i]==cmp[i+n+1]){
				ok=0; break;
			}
		}
		if(ok){
			cout<<s<<endl;
			return 0;
		}
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long H, W, K;
    cin >> H >> W >> K;
    unsigned long sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    vector mp(H + 2, vector(W + 2, 1UL));
    for(unsigned long i{1}; i <= H; ++i){
        string s;
        cin >> s;
        transform(begin(s), end(s), begin(mp[i]) + 1, [](char c){return c / 64;});
    }
    vector dist(H + 2, vector(W + 2, numeric_limits<unsigned long>::max()));
    queue<pair<pair<unsigned long, unsigned long>, unsigned long>> q;
    q.emplace(pair<unsigned long, unsigned long>(sx, sy), 0);
    dist[sx][sy] = 0;
    while(!q.empty()){
        const auto [p, d] = q.front();
        q.pop();
        const auto [x, y] = p;
        if(dist[x][y] > d)continue;
        if(x == gx && y == gy){
            cout << d << endl;
            return 0;
        }
        for(unsigned long i{1}; i <= K; ++i){if(mp[x + i][y] || dist[x + i][y] <= d)break;if(dist[x + i][y] > d + 1)q.emplace(pair<unsigned long, unsigned long>{x + i, y}, dist[x + i][y] = d + 1);}
        for(unsigned long i{1}; i <= K; ++i){if(mp[x - i][y] || dist[x - i][y] <= d)break;if(dist[x - i][y] > d + 1)q.emplace(pair<unsigned long, unsigned long>{x - i, y}, dist[x - i][y] = d + 1);}
        for(unsigned long i{1}; i <= K; ++i){if(mp[x][y + i] || dist[x][y + i] <= d)break;if(dist[x][y + i] > d + 1)q.emplace(pair<unsigned long, unsigned long>{x, y + i}, dist[x][y + i] = d + 1);}
        for(unsigned long i{1}; i <= K; ++i){if(mp[x][y - i] || dist[x][y - i] <= d)break;if(dist[x][y - i] > d + 1)q.emplace(pair<unsigned long, unsigned long>{x, y - i}, dist[x][y - i] = d + 1);}
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 58008
#!/usr/bin/env python3

bridges = 0

def visit(i, cnt, frm):
    global bridges

    cnt += 1

    pre[i] = cnt
    low[i] = cnt

    for n in e[i]:
        if pre[n] == -1:
            low[i] = min(low[i], visit(n, cnt, i))
            if low[n] == pre[n]:
                bridges += 1
        elif n != frm:
            low[i] = min(low[i], low[n])

    return low[i]

n, m = [int(x) for x in input().split()]
e = [set() for _ in range(n)]
for _ in range(m):
    p, q = [int(x) - 1 for x in input().split()]
    e[p].add(q)
    e[q].add(p)

pre = [-1 for _ in range(n)]
low = [-1 for _ in range(n)]

visit(0, 0, -1)
print(bridges)


Measured memory_bytes: 3064
#include<stdio.h>
    int main(void){
    int a,b,c;
    int w;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a>b){
    w=a;
    a=b;
    b=w;
    }
    if(a>c){
    w=a;
    a=c;
    c=w;
    }
    if(b>c){
    w=b;
    b=c;
    c=w;
    }
    printf("%d %d %d\n",a,b,c);
    
    return 0;
    }



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int count[11] = {};
  REP(i, 4) count[ nextInt() ]++;

  if (count[1] == 1 && count[9] == 1 && count[7] == 1 && count[4] == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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


int main() {

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

	int num;
	cin >> num;

	vector<int> vals;
	for( int i = 0; i < num; ++i ) {
		int input;
		cin >> input;
		vals.emplace_back( input );
	}

	int INF = -1;
	for( int i = 0; i < num - 1; ++i ) {
		for( int j = 1; j < num; ++j ) {
			if( INF < abs( vals[ i ] - vals[ j ] ) ) {
				INF = abs( vals[ i ] - vals[ j ] );
			}
		}
	}

	cout << INF << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Node{
    int p,y,id;
}node[100005];
bool cmp(Node a,Node b){
    return a.y<b.y;
}
vector<int> g[100005];
ll ind[100005];
ll bel[100005];
int n,m;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>node[i].p>>node[i].y;
        node[i].id = i;
        bel[i] = node[i].p;
    }
    sort(node+1,node+1+m,cmp);
    for(int i=1;i<=m;i++){
        Node tmp = node[i];
        g[tmp.p].push_back(tmp.id);
        ind[tmp.id] = g[tmp.p].size();
    }
    for(int i=1;i<=m;i++){
        string s="";
        int cnt = 0;
        while (cnt++<6){
            s+=(bel[i]%10+'0');
            bel[i]/=10;
        }
        reverse(s.begin(),s.end());
        cout<<s;

        s = "";
        cnt = 0;
        while (cnt++<6){
            s+=(ind[i]%10+'0');
            ind[i]/=10;
        }
        reverse(s.begin(),s.end());
        cout<<s;
        cout<<endl;
    }
}


Measured memory_bytes: 9728
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vector<multiset<ll>> vs(1 << n);
    for(int i = 0; i < (1 << n); ++i) {
        ll a;
        cin >> a;
        vs[i].insert(a);
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < (1 << n); ++j) {
            if(!(j & (1 << i))) continue;
            multiset<ll>& _vs = vs[j ^ (1 << i)];
            for(auto it = _vs.begin(); it != _vs.end(); ++it) vs[j].insert(*it);
            while(vs[j].size() > 2) vs[j].erase(vs[j].begin());
        }
    }
    vll ans(1 << n);
    for(int i = 1; i < (1 << n); ++i) {
        ans[i] = *vs[i].begin() + *vs[i].rbegin();
        chmax(ans[i], ans[i - 1]);
        cout << ans[i] << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 42320
#include <iostream>
#include <algorithm>
using namespace std;
const int oo = 1e6;
int arr[107];
int main(){
int n;cin >> n;
for(int i = 0; i < n; i++)
cin >> arr[i];

sort(arr, arr+ n);
int res = arr[n-1] - arr[0];
cout << res << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<int> E[110000];

int pin[110000] = {};
int ans[110000] = {};

int main(){
	
	int N, M;
	cin >> N >> M;
	
	for(int i = 0; i < N - 1 + M; i++){
		int A, B;
		cin >> A >> B;
		E[A].push_back(B);
		pin[B] += 1;
	}
	
	queue<int> que;
	
	for(int i = 1; i <= N; i++){
		if(pin[i] == 0){
			que.push(i);
		}
	}
	
	while(!que.empty()){
		int pos = que.front();
		que.pop();
		for(int i = 0; i < E[pos].size(); i++){
			pin[E[pos][i]] -= 1;
			if(pin[E[pos][i]] == 0){
				ans[E[pos][i]] = pos;
				que.push(E[pos][i]);
			}
		}
	}
	
	for(int i = 1; i <= N; i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int cnt[26] = {};
    for(auto c:S){
        cnt[c - 'a']++;
    }
    for(int i:cnt){
        if(i & 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

def factorization(n):
    arr = []
    if n == 1:
        return arr
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i== 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

f_list = factorization(n)
ans = 0

for i in range(len(f_list)):
    tmp = f_list[i][1]
    j = 1
    while tmp >= 0:
        tmp -= j
        j += 1
    ans += j-2

print(ans)

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

template <class T>
inline T Max(const T &a, const T &b) {return a > b ? a : b;}

const int N = 23, C = (1 << 20) + 5;

int n, k, fi[N][C][2], ansl, anss;
bool start[N][C];
char s[C];

std::vector<int> f[N][N];

int main()
{
	std::cin >> n >> k;
	for (int i = 0; i <= n; i++)
	{
		scanf("%s", s);
		for (int S = 0; S < (1 << i); S++)
			start[i][S] = s[S] - '0';
	}
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= i; j++)
			for (int S = 0; S < (1 << i); S++)
				f[i][j].push_back(!j && start[i][S] ? 1 : 0);
	for (int i = 1; i <= n; i++)
		for (int S = 0; S < (1 << i); S++)
			if (S < (1 << i - 1)) fi[i][S][0] = 1, fi[i][S][1] =
				S ? fi[i - 1][S][1] + 1 : 0;
			else fi[i][S][1] = 1, fi[i][S][0] = S < (1 << i) - 1
				? fi[i - 1][S ^ (1 << i - 1)][0] + 1 : 0;
	for (int i = n; i >= 0; i--)
		for (int j = 0; j < i; j++)
			for (int S = 0; S < (1 << i); S++)
			{
				f[j][j][S >> i - j] += f[i][j][S];
				int S1 = S >> i - j, S2 = S & (1 << i - j) - 1,
					p0 = fi[i - j][S2][0], p1 = fi[i - j][S2][1];
				if (p0) f[i - p0 + 1][j + 1][(S1 << i - j - p0 + 1) |
					(S2 & (1 << i - j - p0) - 1)] += f[i][j][S];
				if (p1) f[i - p1 + 1][j + 1][(S1 << i - j - p1 + 1) |
					(S2 & (1 << i - j - p1) - 1) | (1 << i - j - p1)] += f[i][j][S];
			}
	for (int i = 1; i <= n; i++)
		for (int S = 0; S < (1 << i); S++)
			if (f[i][i][S] >= k && i > ansl) ansl = i, anss = S;
	for (int i = ansl; i >= 1; i--) printf("%d", (anss >> i - 1) & 1);
	return puts(""), 0;
}

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

#define lli long long int

int main() {
	lli n, ans = LLONG_MAX;
	cin >> n;
    int raiz = sqrt(n), is = 1;
    for (int divi = 2; divi <= raiz; divi ++)
    {
      if (n % divi == 0)
      {
        is = 0;
        break;
      }
  	}
    if(is) {
    	printf("%Ld\n", n - 1);
    	return 0;
    }
	for(lli i = 1; i <= raiz; i++) {
		if(n % i == 0) {
			ans = min(ans, (i-1) + ((n/i)-1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    int A,B;

int main(){
    cin>>A>>B;
    cout<<(A+B)%24;
    cout<<endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   string s;cin >>s;
   ll n=s.size();
   string ans="";
    for (int i = 0; i < n; ++i) {
        if(i%2==0){
            ans+=s[i];
        }
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int i,x;
	i = 1;

	while (1) {
		scanf("%d", &x);
		if(x==0){
		break;
		}
		printf("Case %d: %d\n",i,x);
		i++;
	}
	return 0;
}


Measured memory_bytes: 1980
N, Q = map(int, input().split())
S = input()
AC = [0] * (N + 1)
for i in range(2, N + 1):
  AC[i] = AC[i - 1]
  if S[i - 2:i] == 'AC':
    AC[i] += 1
for q in range(Q):
  l, r = map(int, input().split())
  print(AC[r] - AC[l])

Measured memory_bytes: 6060
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);
    int c[n], a[n][m];
    rep(i, n){
        scanf("%d", &c[i]);
        rep(j, m) scanf("%d", &a[i][j]);
    }

    int ans = mod;
    rep(S, 1<<n){
        int t[m], sum = 0;;
        memset(t, 0, sizeof(t));
        rep(i, n)if(S>>i & 1){
            rep(j, m) t[j] += a[i][j];
            sum += c[i];
        }
        bool flag = true;
        rep(i, m)if(t[i] < x){
            flag = false;
            break;
        }
        if(flag) chmin(ans, sum);
    }
    printf("%d\n", ans < mod ? ans : -1);
}

Measured memory_bytes: 3828
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

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

int main() 
{
    string s; cin >> s; 
    char p = '+';
    int ans = 0;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == p) { 
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;

    return 0;
}




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

const ll MAXV = 100005;
const ll MAXW = 1e12;

int main()
{
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, 0, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N+1, vector<ll>(MAXV, MAXW));

    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < MAXV; j++) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if (j - v[i] >= 0) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < MAXV; i++) {
        if (dp[N][i] <= W) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    a-=b;
    c-=a;
    cout<<max(0ll,c);
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Map<Integer, Integer[]> map = new HashMap<Integer, Integer[]>();

		Scanner sc = new Scanner(System.in);
		int length = Integer.parseInt(sc.nextLine());

		for (int count = 0; count < length; count++) {
			String point[] = sc.nextLine().split(" ");
		    Integer points[] = new Integer[]{Integer.parseInt(point[0]),Integer.parseInt(point[1])};
            map.put(count, points);
		}

        List<Entry<Integer, Integer[]>> list_entries = new ArrayList<Entry<Integer, Integer[]>>(map.entrySet());
        Collections.sort(list_entries, new Comparator<Entry<Integer, Integer[]>>() {
            public int compare(Entry<Integer, Integer[]> obj1, Entry<Integer, Integer[]> obj2) {
                // 4. 昇順
            	Integer sum1 = obj1.getValue()[0] + obj1.getValue()[1];
            	Integer sum2 = obj2.getValue()[0] + obj2.getValue()[1];
                return sum1.compareTo(sum2) * -1;
            }
        });

        int idx = 0;
        BigDecimal sum1 = BigDecimal.ZERO;
        BigDecimal sum2 = BigDecimal.ZERO;
        for (Entry<Integer, Integer[]> entry : list_entries) {
        	if (idx % 2 == 0) {
        		sum1 = sum1.add(new BigDecimal(entry.getValue()[0]));
        	} else {
        		sum2 = sum2.add(new BigDecimal(entry.getValue()[1]));
        	}
        	idx++;
        }

		System.out.println(sum1.subtract(sum2));
	}

}

Measured memory_bytes: 169380
slst = []
while True:
    try:
        slst.append(input())
    except:
        break
sen = ' '.join(slst)
sen = sen.lower()
alf = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(26):
    print(f'{alf[i]} : {sen.count(alf[i])}')


Measured memory_bytes: 5572
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#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++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem1179 : Millennium **/
int day[10] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19};

int main()
{
	int n, y, m, d;
	
	cin>>n;
	
	rep(k, n) {
		cin >> y >> m >> d;
		int ans=0;
		int i=m-1;
		while (1) {
			if (y%3==0)
				ans += 20;
			else
				ans+=day[i];
			
			i++; if (i>=10){ y++; i=0; }
			if (y==1000) {
				ans++;
				break;
			}
		}
		cout << ans-d << endl;
	}
}

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

int main(){
    string S , T , U ;
    cin >> S >> T ;
    int N , M ;
    cin >> N >> M ;
    cin >> U ;
    if( S == U ){
        cout << N - 1 << endl;
        cout << M << endl;
    }
    else{
        cout << N  << endl;
        cout << M - 1  << endl;
    }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        r: i64,
        d: i64,
        x2000: i64,
    );
    let mut x : i64 = x2000;
    for _ in 0..10 {
        x = r * x -d;
        println!("{}", x);
    }
}


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

int main() {
    double w, h, x, y, ans;
    char s;
    cin >> w >> h >> x >> y;
    ans=w*h/2;
    if(w/2==x && h/2==y) s='1';
    else s='0';
    cout << fixed << setprecision(10);
    cout << ans << " " << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
using namespace std;
bool fl=		0				;
bool mtest=		0			;

//

//

void solve()
{
	ld r;	cin>>r;
	cout<<2*3.14159*r<<endl;
}


int main()
{
	
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 3796