akhauriyash/Code-Regression huggingface dataset:
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;

    cin>>n>>k;
    l(i,0,n)
    {
        cin>>a;
        v.pb(a);
    }
    lw(v);
    l(i,0,k)
    {
        d=d+v[i];
    }
    cout<<d<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IL inline
using namespace std;
typedef long long LL;
typedef unsigned int U;
typedef unsigned long long LLU;
typedef pair<int,int> PII;
typedef long double LD;
IL LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
#define io read()
int x,y,cnt[10];
int main()
{
	for(int i=1;i<=3;++i){
		x=io;y=io;
		++cnt[x];++cnt[y];	
	}
	for(int i=1;i<=4;++i){
		if(cnt[i]>2){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	long long x,ans;
	cin>>x;
	ans=0;
	ans=x/11*2;
	if(x%11==0) cout<<ans<<endl;
	else if(x%11<=6) cout<<ans+1<<endl;
	else cout<<ans+2<<endl;
	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	string s[114];
	for (int i = 0; i < n; i++)cin >> s[i];
	sort(s, s + n);
	for (int i = 0; i < n; i++)cout << s[i];
	cout << endl;
	return 0;
}

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

const int MAXN = 1e6 + 10;

class no_solution: std::exception
{
public:
	const char * what() const noexcept
	{
		return "There is no solution under such constrains";
	}
};

int len;
char a[MAXN], b[MAXN];

auto findSolution() -> std::deque<int>::size_type
{
	std::deque<int>::size_type answer = 0;
	std::deque<int> DQ;
	DQ.push_back(len + 1);

	int k = len + 1, offset = 0;
	for (int i = len; i > 0; i--)
	{
		int t = k;
		k = std::min(i, k);
		while (k && a[k] != b[i])
			k--;
		if (k <= 0)
			throw no_solution();

		if (k == t)
		{
			while (!DQ.empty() && DQ.back() + offset >= i)
				DQ.pop_back();
			DQ.push_back(i - offset);
		}
		else
		{
			offset--;
			if (i != k)
				answer = std::max(answer, DQ.size()), DQ.push_front(k - offset);
		}
	}
	return answer;
}

int main()
{
	std::cin >> len >> (a+1) >> (b+1) ;

	try
	{
		std::cout << findSolution() << std::endl ;
	}
	catch(no_solution & x)
	{
		std::cout << "-1" << std::endl ;
		std::cerr << x.what() << std::endl ;
	}

	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
    cout << "GREATER" << '\n';
  } else if (a.size() < b.size()) {
    cout << "LESS" << '\n';
  } else {
    int type = -1;
    for (int i = 0; i < (int) a.size(); i++) {
      if (a[i] > b[i]) {
        type = 1;
        break;
      } else if (b[i] > a[i]) {
        type = 0;
        break;
      }
    }
    cout << (type == 1 ? "GREATER" : (type == 0 ? "LESS" : "EQUAL")) << '\n';
  }
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    a *= n;
    if(a > b)cout << b << endl;
    else cout << a << endl;
}

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

int main() {

	char a[3];

	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}

	if (a[0] == '7' || a[1] == '7' || a[2] == '7') {
		cout << "Yes" << "\n";
	}
	else {
		cout<<"No"<<"\n";
	}
}

Measured memory_bytes: 3616
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int len = str.length();
        
        Deque<Integer> downPos = new ArrayDeque<>();
        Deque<IntPair> downPosPool = new ArrayDeque<>();
        
        int totalPool = 0;
        for (int i = 0; i < len; i++) {
            char ch = str.charAt(i);
            if (ch == '\\') {
                downPos.push(i);
            } else if (ch == '/' && !downPos.isEmpty()) {
                int j = downPos.pop();
                int a = i - j;
                totalPool += a;
                while (!downPosPool.isEmpty() && downPosPool.peek().int1 > j) {
                    a += downPosPool.pop().int2;
                }
                downPosPool.push(new IntPair(j, a));
            }
        }
        System.out.println(totalPool);
        
        int size = downPosPool.size();
        System.out.print(size);
        for (int i = 0; i < size; i++) {
            System.out.print(" ");
            System.out.print(downPosPool.pollLast().int2);
        }
        System.out.println();
    }
    
    static class IntPair {
        int int1;
        int int2;
        IntPair(int i1, int i2) {
            int1 = i1;
            int2 = i2;
        }
    }
}



Measured memory_bytes: 28728
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    vector<int> v(5);  
    REP(i, 5){
        cin >> v[i];
    }
    int k;
    cin >> k;

    bool flag = true;
    REP(i, 5){
        Rep(j,i+1,5){
            if(abs(v[i]-v[j]) > k) flag=false;
        }
    }
    if(flag == false) pr(":(");
    else pr("Yay!");
}

Measured memory_bytes: 256
def fa(): #final answer
    global ans
    print(ans)
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
N = getN()

ans = "No"
maxn = N//4 + 1

for i in range (maxn):
    if (N-4*i) % 7 == 0:
        ans = "Yes"

fa()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define maxn 100005
#define pii pair<int,int>
using namespace std;
int r,c,n;
int cal(int x,int y) {
	if(x == 0)
		return y;
	else if(x == r)
		return c + c + r - y;
	else if(y == 0)
		return c + c + r + r - x;
	else
		return c + x;
}
bool vis[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> r >> c >> n;
	vector<pii> arr;
	for(int i=1,x1,y1,x2,y2;i<=n;i++) {
		cin >> x1 >> y1 >> x2 >> y2;
		if((x1 % r == 0 || y1 % c == 0) && (x2 % r == 0 || y2 % c == 0)) {
			int a = cal(x1,y1) , b = cal(x2,y2);
			if(a > b)	swap(a,b);
			arr.push_back(pii{a,i});
			arr.push_back(pii{b,i});
		}
	}
	sort(arr.begin(),arr.end());
	stack<int> s;
	for(pii now : arr)
		if(vis[now.second]) {
			if(s.top() != now.second) {
				cout << "NO" << endl;
				return 0;
			}
			s.pop();
		}
		else {
			s.push(now.second);
			vis[now.second] = true;
		}
	cout << "YES" << endl;
	return 0;
}


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

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

vector<string> S(N);
for (int i = 0; i < N; i++) {
  cin >> S.at(i);
}
  
  sort(S.begin(), S.end()); 
  
for (int i = 0; i < N; i++) {
  cout << S.at(i);
}
  
  cout << endl;
  
}


Measured memory_bytes: 256
#17:51
a,b,x = map(int,input().split())
x /= a
import math
if a * b >= 2 * x:
  c = 2*x/b
  t = math.atan(b/c) * 360 / (2*math.pi)
  print(t)
else:
  #print(x)
  c = 2*b - 2*x/a
  #print(c)
  t = math.atan(c/a) * 360 / (2*math.pi)
  print(t)

Measured memory_bytes: 3188
import java.util.Scanner;

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

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

		boolean flag = true;
		int cnt = 0;
		int i = 0;
		while (flag) {
			flag = false;
			for (int j = n - 1; j >= i + 1; j--) {
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					cnt++;
					flag = true;
				}
			}
			i++;
		}

		StringBuilder sb = new StringBuilder();
		for (int num : a) {
			sb.append(num);
			sb.append(" ");
		}

		System.out.println(sb.toString().trim());
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26480
def cin():  return list(map(int,input().split()))

N = cin()[0]
INF = 10 ** 9 + 7
ans = pow(10, N, INF)
tmp = pow(9, N, INF)
ans -= tmp
ans %= INF
ans -= tmp
ans %= INF
ans += pow(8, N, INF)
ans %= INF
print(ans)

Measured memory_bytes: 61700
N, M = map(int, input().split())

stepper = 0
gate = []

for j in range(M):
    gate_1, gate_2 = map(int, input().split())
    gate.append([gate_1, gate_2])

gate_min = 0
gate_max = N

for m in range(M):
    if gate[m][0] > gate_min:
        gate_min = gate[m][0]

    if gate[m][1] < gate_max:
        gate_max = gate[m][1]

#print(gate_min, gate_max)
for k in range(N):
    k = k+1
    if gate_min <= k <= gate_max:
        stepper += 1

print(stepper)


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

int main(){
	int N, T, A;
	cin >> N >> T >> A;
	double dtmin = 1000;
	int imin = -1;
	rep(i,N) {
		int h;
		cin >> h;
		double dt = abs((double)T-(double)h*0.006-A);
		if (dt<dtmin) {
			dtmin = dt;
			imin = i+1;
		}
	}
	cout << imin << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
struct mzls
{
	int ti,ed;
	bool operator<(const mzls &a1)const
	{
		return ed<a1.ed;
	}
}a[500005];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].ti,&a[i].ed);
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=a[i].ti;
		if(ans>a[i].ed)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

vector<pair<ll, ll> > pairs;
int cnt[100005], flag[100005];
int main()
{
    int N, M, P, ans1 = 0, ans2 = 0;
    string S;
    cin >> N >> M;
    
    rep(i, M){
        cin >> P >> S;
        if (S == "AC"){
            if (flag[P] == 0){
                ans2 += cnt[P];
                ans1++;
                flag[P] = 1;
            }
        } else {
            cnt[P]++;
        }
    }
    cout << ans1 << " " << ans2;
    return 0;    
}


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

string tos(ll a){
  string res;
  while(a)res+=a%10,a/=10;
  reverse(res.begin(),res.end());
  return  res;
}

ll dp[100001][11];
int main(){
  ll a,b,p;
  while(cin>>a>>b>>p,a){
    vector<string> v;
    for(ll i=a;i<=b;i++)v.push_back(tos(i));
    sort(v.begin(),v.end());
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<v.size();i++)
      for(int j=0;j<11;j++){
	if(j<=v[i].size())dp[i+1][v[i].size()]=(dp[i+1][v[i].size()]+dp[i][j])%p;
	dp[i+1][j]=(dp[i+1][j]+dp[i][j])%p;
      }
    ll s=0;
    for(int i=1;i<11;i++)s+=dp[v.size()][i];
    cout<<s%p<<endl;
  }
  return 0;
}

Measured memory_bytes: 16988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 20002
struct Node{
	vector<int> adj;
};
int main(){
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// #endif

	int n,m;
	int a,b;
	bool p=false;
	vector<int> g1,gn;

	cin>>n>>m;
	
	for(int i=0;i<m;++i){
		
		cin>>a>>b;
		if(a==1)
			g1.push_back(b);
		if(b==n)
			gn.push_back(a);
		if(b==1)
			g1.push_back(a);
		if(a==n)
			gn.push_back(b);
	}
	
	sort(g1.begin(),g1.end());
	sort(gn.begin(),gn.end());
	
	for(int i=0,j=0;i<g1.size() && j<gn.size();){
		if(g1[i]==gn[j]){
			p = true;
			break;
		}else if(g1[i]>gn[j]){
			j++;
		}else{
			i++;
		}
	}
	
	if(p)
		cout<<"POSSIBLE";
	else
		cout<<"IMPOSSIBLE";
	return 0;
}

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
    int N; cin >> N;
    ll ans = 1LL;

    for(int i = 0; i < N; i++){
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 25;

const string tnames[] = { "root", "internal node", "leaf" };

/* typedef */

struct Node {
  int id, prt, sbl, nc, d, h;
  int lc, rc;
  Node(): prt(-1), sbl(-1), nc(0), d(0), h(0), lc(-1), rc(-1) {}
};

/* global variables */

Node nds[MAX_N];

/* subroutines */

inline int ntype(int u) {
  if (nds[u].prt < 0) return 0;
  if (nds[u].nc == 0) return 2;
  return 1;
}

int rec(int u, int ud) {
  Node &ndu = nds[u];
  ndu.d = ud;
  ndu.h = 0;

  if (ndu.lc >= 0) {
    int lh = rec(ndu.lc, ud + 1) + 1;
    if (ndu.h < lh) ndu.h = lh;
  }
  if (ndu.rc >= 0) {
    int rh = rec(ndu.rc, ud + 1) + 1;
    if (ndu.h < rh) ndu.h = rh;
  }

  return ndu.h;
}

/* main */

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

  for (int i = 0; i < n; i++) {
    int id, lc, rc;
    cin >> id >> lc >> rc;

    Node &ndi = nds[id];
    ndi.id = id;

    if (lc >= 0) {
      ndi.lc = lc;
      ndi.nc++;
      nds[lc].prt = id;
      nds[lc].sbl = rc;
    }
    if (rc >= 0) {
      ndi.rc = rc;
      ndi.nc++;
      nds[rc].prt = id;
      nds[rc].sbl = lc;
    }
  }

  int root = -1;
  for (int i = 0; i < n; i++)
    if (nds[i].prt < 0) {
      root = i;
      break;
    }

  rec(root, 0);

  for (int u = 0; u < n; u++) {
    Node &ndu = nds[u];

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, "
	   "height = %d, %s\n",
	   ndu.id, ndu.prt, ndu.sbl, ndu.nc, ndu.d, ndu.h,
	   tnames[ntype(u)].c_str());
  }

  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a - b >= 0) {
			System.out.println("delicious");
		} else if(b - a > 0 && b - a <= x) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}
}


Measured memory_bytes: 23124
package main

import (
	"fmt"
)

func main() {
	var w, h, n int
	fmt.Scan(&w, &h, &n)

	z := make([][]int, h)
	for i := 0; i < h; i++ {
		z[i] = make([]int, w)
	}

	for i := 0; i < n; i++ {
		var x, y, a, yi, xi int
		fmt.Scan(&x, &y, &a)

		switch a {
		case 1:
			for yi=0; yi<h; yi++ {
				for xi=0; xi<x; xi++ {
					z[yi][xi] = 1
				}
			}
		case 2:
			for yi=0; yi<h; yi++ {
				for xi=x; xi<w; xi++ {
					z[yi][xi] = 1
				}
			}
		case 3:
			for yi=0; yi<y; yi++ {
				for xi=0; xi<w; xi++ {
					z[yi][xi] = 1
				}
			}
		case 4:
			for yi=y; yi<h; yi++ {
				for xi=0; xi<w; xi++ {
					z[yi][xi] = 1
				}
			}
		}
	}

	cnt := 0
	for yi:=0; yi<h; yi++ {
		for xi:=0; xi<w; xi++ {
			if z[yi][xi] == 0 {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 640
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, c = sc.nextInt

  var num = 1
  var ans = false
  while (num <= b) {
    if (a * num % b == c) ans = true
    num += 1
  }
  println(if (ans) "YES" else "NO")
}


Measured memory_bytes: 27348
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BCommonRaccoonVsMonster {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    ll h;
	    int n;
	    in >> h >> n;
	    vector<int> a(n);
	    ll sum = 0;
	    for(int i=0; i<n; i++){
	        in >> a[i];
	        sum += a[i];
	    }

	    sort(a.begin(), a.end());

	    ans(sum >= h, out);
	}
};


int main() {
	BCommonRaccoonVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
import itertools as it
def caln(an):
    maxa = int(an)
    mina = int(an)
    con = it.permutations(an)
    for x in con:
        temp = int(''.join(x))
        if temp > maxa:maxa = temp
        elif mina > temp: mina = temp
    return str(maxa - mina)
    
while 1:
    a=[]
    a0,n=list(input().split())
    if a0 == n == '0' :break
    if len(a0) < int(n):
        a0 = ''.join(['0' for _ in range(int(n) -len(a0))]) + a0
    a.append(a0)
    count =0
    an = a0
    while 1:
        count +=1
        an= caln(an)
        if len(an) < int(n):
            an = ''.join(['0' for _ in range(int(n) -len(an))]) + an
        if an in a:
            print("{} {} {}".format(a.index(an),int(an),count-a.index(an)))
            break
        a.append(an)





Measured memory_bytes: 5660
from collections import defaultdict
def main():
    N, M = map( int, input().split())
    d = defaultdict(lambda : -1)
    md = -1
    mn = -1
    G = [-1]*N
    for _ in range(M):
        s, c = map( int, input().split())
        if G[s-1] == -1:
            G[s-1] = c
        else:
            if G[s-1] != c:
                print(-1)
                return
    if M == 0:
        if N == 1:
            print(0)
            return
    if G[0] == -1:
        G[0] = 1
    if G[0] == 0:
        if N == 1:
            print(0)
        else:
            print(-1)
        return
    ans = 0
    for i in range(N):
        if G[i] == -1:
            G[i] = 0
        ans += G[i]*10**(N-1-i)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, min, max;
  scanf("%lld", &n);
  pair<ll, ll> c[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &c[i].first, &c[i].second);
  sort(c, c + n, greater< pair<ll, ll> >());
  stack< pair<ll, ll> > sta;
  pair<ll, ll> p1, p2;
  sta.push(c[0]);
  min = c[0].first - c[0].second, max = c[0].first + c[0].second;
  for(i = 1; i < n; ++i) {
    if(c[i].first - c[i].second <= min && c[i].first + c[i].second >= max) continue;
    if(c[i].first - c[i].second >= min && c[i].first + c[i].second <= max) {
      while(!sta.empty()) sta.pop();
      sta.push(c[i]);
      min = c[i].first - c[i].second, max = c[i].first + c[i].second;
      continue;
    }
    while(sta.size() > 1) {
      p1 = sta.top(), sta.pop();
      p2 = sta.top(), sta.pop();
      double x1 = (double)(p1.first * p1.first - c[i].first * c[i].first - p1.second * p1.second + c[i].second * c[i].second) / (double)(2 * (p1.first - c[i].first));
      double x2 = (double)(p2.first * p2.first - p1.first * p1.first - p2.second * p2.second + p1.second * p1.second) / (double)(2 * (p2.first - p1.first));
      if(x1 > x2) {
        sta.push(p2), sta.push(p1);
        break;
      }
      sta.push(p2);
    }
    sta.push(c[i]);
    max = c[i].first + c[i].second;
  }
  pair<ll, ll> vec[sta.size()];
  double m[sta.size()];
  int tn = sta.size();
  while(!sta.empty()) vec[sta.size() - 1] = sta.top(), sta.pop();
  m[0] = (double)min;
  double t = (double)max, h = (double)min;
  for(i = 1; i < tn; ++i) m[i] = (double)(vec[i].first * vec[i].first - vec[i - 1].first * vec[i - 1].first - vec[i].second * vec[i].second + vec[i - 1].second * vec[i - 1].second) / (double)(2 * (vec[i].first - vec[i - 1].first));
  for(i = 0; i < 100000; ++i) {
    double t1 = (t + h * 2) / 3.0, t2 = (t * 2 + h) / 3.0;
    ll a = upper_bound(m, m + tn, t1) - m - 1, b = upper_bound(m, m + tn, t2) - m - 1;
    if(vec[a].second * vec[a].second - (t1 - vec[a].first) * (t1 - vec[a].first) < vec[b].second * vec[b].second - (t2 - vec[b].first) * (t2 - vec[b].first)) h = t1;
    else t = t2;
  }
  ll a = upper_bound(m, m + tn, t) - m - 1;
  printf("%lf\n", sqrt(vec[a].second * vec[a].second - (t - vec[a].first) * (t - vec[a].first)));
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll h,n,sum=0;
    cin >> h >> n;
    rep(i,n){
        ll a;
        cin >> a;
        sum += a;
    }

    if(sum >= h)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {

  string O,E;
  cin>>O>>E;
  int N=O.size(), M=E.size();

  for(int i=0;i<M;i++){
    cout<<O[i];
    cout<<E[i];
  }
  if(N>M){
    cout<<O[N-1];
  }
  cout<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

class self_made_pq {
private:
	vi heap;
	int n, inf;
	bool ord; //true????????§??????????????????pop
	bool comp(int a, int b){
		if (ord) return a > b;
		else return a < b;
	}
public:
	self_made_pq(int N, bool b) {
		heap.resize(N * 2 - 1);
		ord = b;
		if (ord) inf = INT_MIN;
		else inf = INT_MAX;
		fill(heap.begin(), heap.end(), inf);
		n = 0;
	}
	void ins(int a) {
		heap[n] = a;
		n++;
		int k1 = n - 1, k2 = n - 1;
		while (k2 > 0) {
			k2 = (k1 - 1) / 2;
			if (comp(heap[k1], heap[k2])) swap(heap[k1], heap[k2]);
			else break;
			k1 = k2;
		}
	}
	int pop() {
		if (n == 0) return inf;
		int ret = heap[0];
		heap[0] = heap[n - 1];
		heap[n - 1] = inf;
		n--;
		int k1 = 0, k2 = 0;
		while (true) {
			k2 = k1 * 2 + 1;
			if (comp(heap[k2], heap[k1])) {
				if (comp(heap[k2 + 1], heap[k2])) {
					swap(heap[k2 + 1], heap[k1]);
					k1 = k2 + 1;
				}
				else {
					swap(heap[k2], heap[k1]);
					k1 = k2;
				}
			}
			else if (comp(heap[k2 + 1], heap[k1])) {
				swap(heap[k2 + 1], heap[k1]);
				k1 = k2 + 1;
			}
			else break;
		}
		return ret;
	}
};



int main() {
	self_made_pq pq(2e6, true);
	while (true) {
		string s; cin >> s;
		if (s == "end") break;
		else if (s == "extract") cout << pq.pop() << endl;
		else {
			int x; cin >> x;
			pq.ins(x);
		}
		int t = 1;
	}
	return 0;
}

Measured memory_bytes: 18224
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int x, y;
    cin >> x >> y;

    if(x % y == 0){
        cout << - 1 << endl;
    } else {
        cout << x << endl;
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		final int INF = Integer.MAX_VALUE;
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		ArrayList<Integer> coins = new ArrayList<Integer>();
		coins.add(1);
		for(int i = 1; ;i++) {
			int buf = (int)Math.pow(6, i);
			if(buf > N)break;
			coins.add(buf);
		}
		for(int i = 1; ;i++) {
			int buf = (int)Math.pow(9, i);
			if(buf > N)break;
			coins.add(buf);
		}
		int[] DP = new int[N+1];
		DP[0] = 0;
		for(int i = 1;i <= N;i++) {
			DP[i] = INF;
		}

		int length = coins.size();
		for(int i = 1;i <=N;i++) {
			for(int j = 0;j < length;j++) {
				int coin = coins.get(j);
				if(i >= coin) {
					DP[i] = Math.min(DP[i], DP[i-coin]+1);
				}
			}
		}
		System.out.println(DP[N]);
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

using DVector = vector<double>;

double Average(DVector& vec) {
   double sumVal{0};
   for (auto element : vec) {
      sumVal += element;
   }
   return sumVal / vec.size();
}

double Variance(DVector& vec) {
   double sumVal{0}, average{Average(vec)};
   for (auto element : vec) {
      sumVal += pow(average - element, 2);
   }
   return sumVal / vec.size();
}

double StdDev(DVector& vec) {
   return sqrt(Variance(vec));
}

int main() {

   int n{};

   while (cin >> n, n > 0) {
      
      DVector s(n, 0);
      
      while (n--) {
         cin >> s[n];
      }
      
      cout << fixed << StdDev(s) << endl;
   }

   return 0;

}

Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int[][] card = {{-1,-1,-1},{-1,-1,-1},{-1,-1,-1}};
        boolean[][] called = {{false,false,false},{false,false,false},{false,false,false}};
        
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                card[i][j] = Integer.parseInt(sc.next());
            }
        }
        
        int n = Integer.parseInt(sc.next());
        
        int b = 0;
        for(int t = 0; t < n; t++) {
            b = Integer.parseInt(sc.next());
            for(int i = 0; i < 3; i++) {
                for(int j = 0; j < 3; j++) {
                    if(card[i][j] == b) {
                        called[i][j] = true;
                    }
                }
            }
        }
        
        boolean ans = false;
        for(int i = 0; i < 3; i++) {
            if((called[i][0])&&(called[i][1])&&(called[i][2])) {
                ans = true;
            }
            if((called[0][i])&&(called[1][i])&&(called[2][i])) {
                ans = true;
            }
        }
        if((called[0][0])&&(called[1][1])&&(called[2][2])) {
            ans = true;
        }
        if((called[0][2])&&(called[1][1])&&(called[2][0])) {
            ans = true;
        }
        
        if(ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23508
#include <iostream>
using namespace std;
int sum[11][101];
void rec(int d, int index, int s){
	if(d > 10){
		return;
	}
	for(int i = index+1; i < 10 ; i++){
		sum[d+1][s+i]++;
		rec(d+1, i, s+i);
	}
}
int main(){
	rec(0, -1, 0);
	int n, s;
	while(cin >> n >> s, (n || s)){
		cout << sum[n][s] << endl;
	}
	return 0;
}

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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int c = sc.nextInt();
      int[][] colors = new int[c][c];
      for(int i = 0; i < c; i++)
        for(int j = 0; j < c; j++)
          colors[i][j] = sc.nextInt();

      long[][] sum = new long[3][c];
      int[][] grid = new int[n][n];
      for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
          grid[i][j] = sc.nextInt() - 1;
          for(int k = 0; k < c; k++)
            sum[(i + j) % 3][k] += colors[grid[i][j]][k]; 
        }
      }

      long res = Long.MAX_VALUE;
      for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++) {
          if(i == j) continue;
          for(int k = 0; k < c; k++) {
            if(k == j || k == i) continue;
            res = Math.min(res, sum[0][i] + sum[1][j] + sum[2][k]);
          }
        }
      }

      System.out.println(res);
  }
}

Measured memory_bytes: 94868
def ssort(L, n):
    L = L[:]
    for i in range(n):
        minj = i
        for j in range(i, n):
            if L[j][1] < L[minj][1]:
                minj = j
        L[i], L[minj] = L[minj], L[i]
    return L

def bsort(L, n):
    L = L[:]
    for _ in L:
        for j in range(n-1, 0, -1):
            if L[j][1] < L[j-1][1]:
                L[j], L[j-1] = L[j-1], L[j]
    return L

def is_stable(L_in, L_out):
    in_pair_list= []
    out_pair_list= []
    for i, e1 in enumerate(L_in):
        for j, e2 in enumerate(L_in[i+1:]):
            if e1[1] == e2[1]:
                in_pair_list.append((e1, e2))
    for i, e1 in enumerate(L_out):
        for j, e2 in enumerate(L_out[i+1:]):
            if e1[1] == e2[1]:
                out_pair_list.append((e1, e2))
    return not bool(set(in_pair_list) - set(out_pair_list))

def print_stable(b):
    print('Stable' if b else 'Not stable')

n = int(input())
L = input().split()

b = bsort(L, n)
print(*b)
print_stable(is_stable(L, b))
s = ssort(L, n)
print(*s)
print_stable(is_stable(L, s))

Measured memory_bytes: 7844
#include<cstdio>
#include<algorithm>
using namespace std;
int flg[100001]={0},cnt[100001]={0};
int main(void)
{
	int n,m,p,i,wa,ac;
	char s[3];
	scanf("%d %d",&n,&m);
	wa=0;
	ac=0;
	for(i=0;i<m;i++){
		scanf("%d %s",&p,s);
		if(flg[p]==0&&s[0]=='W'){
			cnt[p]++;
		}
		if(flg[p]==0&&s[0]=='A'){
			flg[p]=1;
			ac++;
			wa+=cnt[p];
		}
	}
	printf("%d %d\n",ac,wa);
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define maxn 100005
#define INF 1000000007
using namespace std;
int n,m,val[maxn],x=-2,l[maxn],r[maxn],ans[maxn];
bool vis[maxn];
vector<int> G[maxn];
void dfs1(int u,int fa,int dep)
{
	if(vis[u])
	{
		if(x==-2) x=(dep^(val[u]&1));
		else if(x!=(dep^(val[u]&1)))
		{
			printf("No\n"); exit(0);
		}
	}
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa) continue;
		dfs1(v,u,dep^1);
	}
}
void dfs2(int u,int fa)
{
	l[u]=-INF,r[u]=INF;
	if(vis[u]) l[u]=r[u]=val[u];
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa) continue;
		dfs2(v,u);
		if(l[v]-1>r[u]||r[v]+1<l[u])
		{
			printf("No\n"); exit(0);
		}
		l[u]=max(l[v]-1,l[u]);
		r[u]=min(r[v]+1,r[u]);
	}
}
void dfs3(int u,int fa,int t)
{
    if(t+1<=r[u]) ans[u]=t+1;
    else if(t-1>=l[u]) ans[u]=t-1;
    for(int i=0;i<G[u].size();i++)
	{
        int v=G[u][i];
        if(v==fa) continue;
        dfs3(v,u,ans[u]);
    }
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		vis[u]=true,val[u]=v;
	}
	dfs1(1,0,0);
	dfs2(1,0);
	dfs3(1,0,r[1]-1);
	printf("Yes\n");
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 15872
S = list(str(input())) 
ans = 0

if len(S)%2 == 0:
    for i in range(len(S)//2):
       if S[i] != S[len(S)-i-1]:
           ans += 1
    print(ans)
    
else:
    for i in range((len(S)-1)//2):
       if S[i] != S[len(S)-i-1]:
           ans += 1
    print(ans)


Measured memory_bytes: 3060
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

extension Array {
    func dump(){
        for x in 0..<self.count-1{
            print(self[x], terminator: " ")
        }
        print(self.last!)
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func distance(p1:CGPoint, p2:CGPoint) -> Double {
    let diffp = CGPoint(x:p1.x - p2.x, y:p1.y - p2.y)
    return Double(sqrt(diffp.x*diffp.x + diffp.y * diffp.y))
}

func distance(p1:[Double], p2:[Double]) -> Double{
    let diff = [p1[0] - p2[0], p1[1] - p2[1]]
    return sqrt(diff[0] * diff[0] + diff[1] * diff[1])
    
}

func lotate(theta:Double, point:[Double]) -> [Double] {
    let matrix = [
        [cos(theta), -sin(theta)],
        [sin(theta), cos(theta)]
    ]
    let x = point[0]
    let y = point[1]
    
    let rx = matrix[0][0]*x + matrix[0][1]*y
    let ry = matrix[1][0]*x + matrix[1][1]*y
    
    return [rx, ry]
}


func abc133c(){
    let N = Int(readLine()!)!
    let A = readLine()!.toSepIntList()
    var X = Array(repeating: 0, count: N)
    let total = A.reduce(0, +)
    var sum = 0
    for i in stride(from: 1, to: N, by: 2){
        sum += A[i]
    }
    X[0] = total - 2*sum
    
    for i in 1..<N {
        X[i] = 2*A[i-1] - X[i-1]
    }
    X.dump()
}


abc133c()


Measured memory_bytes: 19352
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
d,g = readInts()
cl = [readInts() for _ in range(d)]
ans = float("inf")
def dfs(i,sum,count,nokori):
    global ans
    #まだ解いてない配点をnokori
    if i == d:
        # G点に満たなければ nokoriのうち1番大きい物を解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(cl[use - 1][0], -(-(g-sum) // (use * 100)))
            count += n
            sum += n * use * 100
        if sum >= g:
            ans = min(ans,count)
    else:
        dfs(i + 1, sum, count, nokori)
        #print(i+1,nokori,nokori - {i+1})
        dfs(i + 1, sum + cl[i][0] * (i + 1) * 100 + cl[i][1], count + cl[i][0], nokori - {i + 1})

def main():


    dfs(0,0,0,set(range(1,d+1)))
    print(ans)




if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int a,b,ans;
main()
{
	re(a),re(b);
	if(a==b)return puts("1"),0;
	for(int i=60;;--i)
		if((a^b)>>i&1)
		{
			int T=1ll<<i;
			ans=T+T-a;
			int k=-1;
			for(int j=i-1;~j;--j)
				if(b>>j&1)
				{
					k=j;
					break;
				}
			if((1ll<<k+1)<a)ans-=a-(1ll<<k+1);
			break;
		}
		else if(a>>i&1)
			a-=1ll<<i,b-=1ll<<i;
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  let ans = 0
  for (let i = 0; i < 3; i++) {
    if (inp[0][i] === inp[1][i]) ans++
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
# https://atcoder.jp/contests/abc171/tasks/abc171_d


N = int(input())

A_list = list(map(int, input().split()))    #整数列
Q = int(input())                            #操作の回数

B_list = []                                 #値がBである要素を
C_list = []                                 #全てCに置き換える

for i in range(Q):
    B, C = map(int, input().split())
    B_list.append(B)
    C_list.append(C)


curr_sum = 0
elements_num_dict = {}

for A in A_list:
    curr_sum += A

    if A in elements_num_dict:
        elements_num_dict[A] += 1
    else:
        elements_num_dict[A] = 1


for i, (B, C) in enumerate(zip(B_list, C_list)):

    if B in elements_num_dict:
        
        count = elements_num_dict[B]
        diff = C*count - B*count
        curr_sum += diff


        # 辞書配列を修正
        elements_num_dict[B] -= count

        if C in elements_num_dict:
            elements_num_dict[C] += count
        else:
            elements_num_dict[C] = count

    
    print(curr_sum)

Measured memory_bytes: 26036
s=input()
def kaibun(aa) :
  for i in range(len(aa)):
    if aa[i]!=aa[-i-1] :
      return False
    
  return True


b=int((len(s)-1)/2)
c=int((len(s)+3)/2)
mae=s[:b]
ato=s[c-1:]
if kaibun(s) and kaibun(mae) and kaibun(ato) :
  print ('Yes')
else :
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int main()
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    int t1,t2;
    if(c%b==0) t1=c/b;
    else t1=c/b+1;
    if(a%d==0) t2=a/d;
    else t2=a/d+1;
    if(t1<=t2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {
	int N;
	cin >> N;
	long L_1_before, L_2_before;
	long L_current;
	L_1_before = 1; // initialize i == 1
	L_2_before = 2; // initialize i == 0
	if (N == 1){
		cout << 1 << endl;
	}else{
		for (int i = 2; i <= N; i++){
			L_current = L_1_before + L_2_before;
          	L_2_before = L_1_before;
			L_1_before = L_current;
		}
		cout << L_current << endl;
	}
}

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

typedef long long ll;

vector<vector<int> > adjList;
int N, Q;
vector<int> ans, cnt, visited;

void dfs(int node, int counter){
    ans[node] = counter;
    visited[node] = true;
    for (auto child : adjList[node]){
        if (!visited[child])
            dfs(child, counter + cnt[child]);
    }
}

int main(){
    //freopen("in.txt", "r", stdin);
    cin>>N>>Q;
    int a, b;
    int p, x;

    adjList.assign(N+1, vector<int>());
    ans.resize(N+1);
    cnt.assign(N+1, 0);
    visited.assign(N+1, false);
    for (int i=0;i<N-1;++i){
        cin>>a>>b;

        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }

    while (Q--){
        cin>>p>>x;
        cnt[p] += x;
    }

    dfs(1, cnt[1]);
    for (int i=1;i<=N;++i) cout<<ans[i]<<" ";
    cout<<endl;
    
    return 0;
}

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

using namespace std;
int main(){
cin.tie(NULL);
ios::sync_with_stdio(false);
 int a,b,c,d,e;
 cin>>a>>b;
 c=a+b;
 d=a-b;
 e=a*b;
 if(c>=d && c>=e){
   cout<<c<<"\n";
 }
 else if(d>=c && d>=e){
   cout<<d<<"\n";
 }
 else if(e>=c && e>=d){
   cout<<e<<"\n";
 }

 return 0;
}


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

int main(){
	int a, b, c, ans, Yes, no;
	cin >> a >> b >> c;
	if (a < b&&b < c) {
		cout << "Yes";
	}
	if (a>b&&b>c) {
		cout << "No";

	}
	if (a>b&&b<c) {
		cout << "No";

	}
	
	if (a==b&&b==c){
		cout << "No";
	}
	if (a == b&&b>c) {
		cout << "NO";
	}
	if (a == b&&b < c)
	{
		cout << "No";
	}

	if (a>b&&b == c){
		cout << "No";
	}
	if (a<b&&b == c){
		cout << "No";
	}
	if (a< b&&b>c){
		cout << "No";
	}
			cin >> ans;
	cout << endl;
}


Measured memory_bytes: 3076
#include <iostream>
using namespace std;
  
int F[105][105];
int xg,yg,w,h;
  
  
void DFS(int Y,int X,int c){
  if(F[Y][X] != c){
    return;
  }
  
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
  
  
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j] = 10;
      }
    }
      
    cin >> xs >> ys >> xg >> yg >> n;
  
  
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;

      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
  DFS(xs,ys,F[xs][ys]);
  
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    string s;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    while(n!=0){
        if(n % 2 == 0){
            s+='0';
        }
        else{
            s+='1';
            n-=1;
        }
        n/=2;
        n=-n;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
using namespace std;
  
double cross(complex<double> a, complex<double> b){
    return (conj(a)*b).imag();
}
 
int main(){
    complex<double> V[3], P;
    while(true){
        double x, y;
        for(int i=0; i<3; i++){
            cin >> x >> y;
            V[i] = {x, y};
        }
        cin >> x >> y;
        P = {x, y};
         
        if(!cin)break;
         
        int sum = 0;
        for(int i=0; i<3; i++){
            sum += cross(V[(i+1)%3]-V[i], (P-V[i])) > 0;
        }
        cout << (sum==0 || sum==3? "YES": "NO") << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> ds(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> ds.at(i);
    }
    for(int i = 0; i < n; ++i){
        ll cost;
        cin >> cost;
        ds.at(i) -= cost;
    }
    sort(ds.begin(), ds.end());
    ll ans = 0;
    for(auto it = ds.rbegin(); it != ds.rend(); ++it){
        if(*it < 0){
            break;
        }else{
            ans += *it;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256