akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

int D;
vector<int> c(26);
vector<vector<int>> s;

struct Data{
	vector<int> t;
	vector<vector<int>> penalty;
	int score;
	
	Data(){
		t.resize(D,0);
		penalty.resize(D+1,vector<int>(26,0));
		score = 0;
	}
};

void init(){
	cin>>D;
	for(int i=0;i<26;i++)scanf("%d",&c[i]);
	
	s.resize(D,vector<int>(26));
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++)scanf("%d",&s[i][j]);
	}
}

void Print(Data &d){
	for(int i=0;i<D;i++)printf("%d\n",d.t[i]+1);
}

Data generate(vector<int> t){
	Data ret;
	ret.t = t;
	vector<int> last(26,0);
	for(int i=0;i<t.size();i++){
		int temp = t[i];
		ret.score += s[i][temp];
		last[temp] = i+1;
		
		for(int j=0;j<26;j++){
			ret.penalty[i+1][j] = ret.penalty[i][j] + c[j];
			if(temp==j)ret.penalty[i+1][j] = 0;
			ret.score -= ret.penalty[i+1][j];
		}
	}
	return ret;
}

int change(Data &d,int ind,int nv){
	int o_score = d.score;
	int ov = d.t[ind];
	d.score += s[ind][nv];
	d.score -= s[ind][ov];
	d.t[ind] = nv;
	for(int i=ind+1;i<=D;i++){
		d.score += d.penalty[i][nv];
		d.score += d.penalty[i][ov];
		if(i==ind+1){
			d.penalty[i][nv] = 0;
			d.penalty[i][ov] = d.penalty[i-1][ov] + c[ov];
		}
		else{
			if(d.penalty[i][nv]!=0){
				d.penalty[i][nv] = d.penalty[i-1][nv]+c[nv];
			}
			if(d.penalty[i][ov]!=0){
				d.penalty[i][ov] = d.penalty[i-1][ov]+c[ov];
			}
		}
		d.score -= d.penalty[i][nv];
		d.score -= d.penalty[i][ov];
	}
	
	return d.score - o_score;
}

int main(){
	
	init();
	
	vector<int> t(D);
	for(int i=0;i<D;i++){
		int maxi = -1;
		int ind = 0;
		for(int j=0;j<26;j++){
			if(maxi < s[i][j]){
				maxi = s[i][j];
				ind = j;
			}
		}
		t[i] = i%26;//ind;
	}
	Data d = generate(t);

	auto start = chrono::system_clock::now();
	while(true){
		if(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() > 1950){
			break;
		}
		for(int i=0;i<D;i++){
			for(int j=0;j<26;j++){
				int temp = d.t[i];
				if(temp==j)continue;
				int ts = d.score;
				if(change(d,i,j)<0)change(d,i,temp);
				/*
				Data d2 = generate(d.t);
				if(d.score!=d2.score){
					cout<<d.score<<','<<d2.score<<','<<i<<','<<j<<endl;
					return 0;
				}
				*/
			}
		}
	}
	
	//cout<<d.score<<endl;

   //return 0;
	
	
	Print(d);
	
	return 0;
}

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

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] != b[i]) ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll dp[1005][1005];

int main()
{
    string S, T;
    cin >> S >> T;
    REP(i, S.length() + 1)
    {
        dp[i][0] = i;
    }
    REP(i, T.length() + 1)
    {
        dp[0][i] = i;
    }

    REP(i, S.length())
    {
        REP(j, T.length())
        {
            if (S[i] == T[j])
                dp[i + 1][j + 1] = dp[i][j];
            else
                dp[i + 1][j + 1] = std::min(dp[i][j], std::min(dp[i + 1][j], dp[i][j + 1])) + 1;
        }
    }
    cout << dp[S.length()][T.length()] << endl;
    return 0;
}


Measured memory_bytes: 11072
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll A;
string B;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> A;
    cin >> B;
    solve();
}

// 0 <= A <= 10^{15}
// 0 <= B < 10
// A は整数
// B は小数第 2 位まで与えられる

// ll A, long double B
// 答えを整数として出力せよ。
void solve(){
    string s={B[0],B[2],B[3]};
    ll b=stoll(s);
    cout<<A*b/100<<endl;
}


Measured memory_bytes: 3616
from math import sin, cos, atan2

def sgn(x, eps=1e-10):
    if x < -eps: return -1
    if -eps <= x <= eps: return 0
    if eps < x: return 1

class Vector():
    def __init__(self, x=0.0, y=0.0):
        self.x = x
        self.y = y

    def arg(self):
        return atan2(self.y, self.x)

    def norm(self):
        return (self.x**2 + self.y**2)**0.5

    def rotate(self, t):
        nx = self.x * cos(t) - self.y * sin(t)
        ny = self.x * sin(t) + self.y * cos(t)
        return Vector(nx, ny)

    def counter(self):
        nx = -self.x
        ny = -self.y
        return Vector(nx, ny)

    def times(self, k):
        nx = self.x * k
        ny = self.y * k
        return Vector(nx, ny)

    def unit(self):
        norm = self.norm()
        nx = self.x / norm
        ny = self.y / norm
        return Vector(nx, ny)

    def normal(self):
        norm = self.norm()
        nx = -self.y / norm
        ny = self.x / norm
        return Vector(nx, ny)

    def add(self, other): #Vector, Vector -> Vector
        nx = self.x + other.x
        ny = self.y + other.y
        return Vector(nx, ny)

    def sub(self, other):
        nx = self.x - other.x
        ny = self.y - other.y
        return Vector(nx, ny)

    def dot(self, other): #Vector, Vector -> int
        return self.x * other.x + self.y * other.y

    def cross(self, other): #Vector, Vector -> int
        return self.x * other.y - self.y * other.x

    def __str__(self):
        return '{:.9f}'.format(self.x) + ' ' + '{:.9f}'.format(self.y)

class Line():
    def __init__(self, bgn=Vector(), end=Vector()):
        self.bgn = bgn
        self.end = end

    def build(self, a, b, c): #ax + by == 1
        assert sgn(a) != 0 or sgn(b) != 0
        if sgn(b) == 0:
            self.bgn = Vector(-c / a, 0.0)
            self.end = Vector(-c / a, 1.0)
        else:
            self.v = Vector(0, -c / b)
            self.u = Vector(1.0, -(a + b) / b)

    def vec(self):
        return self.end.sub(self.bgn)

    def projection(self, point):
        v = self.vec()
        u = point.sub(self.bgn)
        k = v.dot(u) / v.norm()
        h = v.unit().times(k)
        return self.bgn.add(h)

    def refrection(self, point):
        proj = self.projection(point)
        return proj.sub(point).times(2).add(point)

    def is_orthogonal(self, other):
        v = self.vec()
        u = other.vec()
        if sgn(v.dot(u)) == 0:
            return True
        else:
            return False

    def is_parallel(self, other):
        v = self.vec()
        u = other.vec()
        if sgn(v.cross(u)) == 0:
            return True
        else:
            return False

q = int(input())
for _ in range(q):
    xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3 = map(int, input().split())
    p0 = Vector(xp0, yp0)
    p1 = Vector(xp1, yp1)
    p2 = Vector(xp2, yp2)
    p3 = Vector(xp3, yp3)
    s1 = Line(p0, p1)
    s2 = Line(p2, p3)
    if s1.is_parallel(s2):
        print(2)
    elif s1.is_orthogonal(s2):
        print(1)
    else:
        print(0)


Measured memory_bytes: 5712
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=100,M=(1<<18)+5;
int n,m,a[N],C[N][N],k,S,T,ans,cnt[M],pos[20];
bool v[M];

signed main(){
	read(n,k,S,T);
	if((S&T)!=S) return write(0),0;
	for(int i=1;i<=n;i++){
		read(a[i]);
		if((S&a[i])==S&&(a[i]&T)==a[i]) a[++m]=a[i];
	}
	n=m;m=0;
	for(int i=0;i<18;i++) if((S>>i&1)!=(T>>i&1)) pos[m++]=i;
	for(int i=1;i<=n;i++){
		int x=0;
		for(int j=0;j<m;j++) x|=(a[i]>>pos[j]&1)<<j;
		a[i]=x;
	}
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	for(int s=0;s<(1<<m);s++){
		long long cur=0;
		for(int i=1;i<=n;i++) cnt[a[i]&s]++;
		for(int i=1;i<=n;i++) if(!v[a[i]&s]){
			v[a[i]&s]=1;
			for(int j=1;j<=k;j++) cur+=C[cnt[a[i]&s]][j];
		}
		for(int i=1;i<=n;i++) v[a[i]&s]=cnt[a[i]&s]=0;
		ans+=__builtin_popcount(s)&1?-cur:cur;
	}
	write(ans);
}

Measured memory_bytes: 5988
def main():
  N=int(input())
  A=[int(a) for a in input().split()]
  Acnt, Aprob={}, {}
  for a in A:
    Acnt[a] = Acnt.get(a, 0) + 1
  sumA=0
  for k, a in Acnt.items():
    Aprob[k]=a*(a-1)//2
    sumA+=Aprob[k]
  #Acnt=[A.count(n) for n in range(N+1)]
  #Aprob=[Acnt[n]*(Acnt[n]-1)//2 for n in range(N+1)]
  #sumA=sum(Aprob)

  for a in A:
    ans=(Acnt[a]-1)*(Acnt[a]-2)//2
    print(ans+sumA-Aprob[a])
  
main()



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

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

  int x = a + b;
  int y = a - b;
  int z = a * b;
  cout << max(x, max(y, z)) << endl;
}


Measured memory_bytes: 256
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new C().doIt();
    }
    class C{
    	int alf[] = new int [128];
    	void doIt(){
    		int n = sc.nextInt();
    		String str = sc.next();
    		char ctr[] = str.toCharArray();
    		for(int i = 0;i < n;i++){
    			if(i % 2 == 0)alf[ctr[i]]++;
    		}
    		int ans = 0;
    		for(int i = 1;i <= 9;i++){
    			int num = 0;
    			for(char c = 'a';c <= 'z';c++){
    				if(alf[c] == i)num++;
    			}
    			if(i == 1){
    				if(num > 0){
    					if(ans > 0)ans = ans + 1;
    					ans = ans + (num*2)-1;
    				}
    			}else{
    				if(num == 1){
    					if(ans > 0)ans = ans + 1;
    					ans = ans + 3;
    				}
    				else if(num > 1){
    					if(ans > 0)ans = ans + 1;
    					ans = ans + (2*num) + 3;
    				}
    			}
    		}
    		System.out.println(ans);
    	}
    }
}

Measured memory_bytes: 26364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000005;

int main()
{
	int n;
	cin >> n;
	//d[i][j]:i日目にjを選んだときの最大値
	int dp[100001][3];
	fill(dp[0],dp[n],0);
	rep(i,n)
	{
		int a,b,c;
		cin >> a >> b >> c;
		if(i==0)
		{
			dp[0][0]=a;
			dp[0][1]=b;
			dp[0][2]=c;
		}
		else
		{
			dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
			dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
		}
	}
	//cout<<dp[n-2][0]<<dp[n-2][1]<<dp[n-2][2]<<endl;
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}


  ll calc(ll a, ll b , ll d)
  {

       ll l= a/d;
       ll r= b/d;

       ll ans = r-l;
       if(a%d==0) ans++;

       return ans;
  }
  int main()
  {
     
         ll a,b,c,d;
         cin>>a>>b>>c>>d;

         ll total= b-a+1;

         ll lcm= (c*d)/(__gcd(c,d));


         ll ans = calc(a,b,c)+calc(a,b,d)-calc(a,b,lcm);

         ans= total-ans;

         cout<<ans<<endl;


  }



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

int main(){
	
	int n;
	
	while(cin >> n,n){
		int i,aaa,ans=0;
		
		for(i=0;i<(n/4);i++){
			cin >> aaa;
			
			ans += aaa;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<stdio.h>

using namespace std;

map<pair<long long, long long>, long long> memo;

long long rec(long long W, long long weight[], long long value[], long long n){

	if (n < 0) {
		return 0;
	}

	pair<long long, long long> p = make_pair(W, n);

	if (memo.find(p) != memo.end()){
		return memo[p];
	}
	long long ret = 0;
	if (W < weight[n]){
		ret = rec(W, weight, value, n-1);
	} else {
		ret = max(
			value[n] + rec(W - weight[n], weight, value, n-1),
			rec(W, weight, value, n-1)
			);
	}

	memo[p] = ret;
	return ret;
}

int main(){

	// input
	long long int N, W;
	cin >> N >> W;

	long long int weight[N],value[N];

	for (int i=0; i<N; i++) {
		cin >> weight[i] >> value[i];
	}

	cout << rec(W,weight,value,N-1) << endl;

	//for(auto itr = memo.begin(); itr != memo.end(); ++itr) {
    //    printf("key (W=%lld,n=%lld), val %lld\n",itr->first.first,itr->first.second,itr->second);           // キーを表示
    //}
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 10;
using ll = long long;
int a[N];
ll f[N][N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	memset(f, 0x3f, sizeof(f));
	f[0][0] = 0;
	for (int i = 1; i <= n + 1; ++i)
	{
		for (int j = 0; j < i; ++j)
			for (int k = 0; k <= j; ++k)
				f[i][j] = min(f[i][j], f[i - k - 1][j - k] + max(a[i] - a[i - k - 1], 0));
	}
	cout << f[n + 1][m];
}


Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int main() {
  int k; cin >> k;
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> b(n);
  rep(i, n-1) b[i] = a[i+1] - a[i];
  b[n-1] = k + a[0] - a[n-1];
  sort(ALL(b));
  int ans = k - b[n-1];
  cout << ans << endl;
}


Measured memory_bytes: 4808
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int IMF = 1'000'000'000; //1e9
const int MIL = -1;
const long long LIMF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int M, K; std::cin >> M >> K;
    if(K >= (1<<M)){
        std::cout << -1 << std::endl;
        return 0;
    }
    if(!M){
        std::cout << "0 0\n";
        return 0;
    }
    if(M == 1){
        if(K){
            std::cout << -1 << std::endl;
            return 0;
        }
        std::cout << "0 0 1 1\n";
        return 0;
    }
    std::vector<int> b;
    for(int i(0), i_len(1 << M); i < i_len; ++i){
        if(i == K) continue;
        b.push_back(i);
    }
    for(int i(0), i_len(b.size()); i < i_len; ++i){
        if(i) std::cout << " ";
        std::cout << b[i];
    }
    std::cout << " " << K;
    for(int i(b.size() - 1); i >= 0; --i){
        std::cout << " " << b[i];
    }
    std::cout << " " << K << std::endl;
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
	cout << "Left" << endl;
  }
  else if (a + b == c + d) {
	cout << "Balanced" << endl;
  }
  else {
	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<cstring>
#include<cmath>
using namespace std;

typedef long long LL;
typedef double DL;

const int INF = 2147483647;
const int maxn = 100010;

int n,now;
char s[maxn];

inline LL getint()
{
	LL ret = 0,f = 1;
	char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
		ret = ret * 10 + c - '0',c = getchar();
	return ret * f;
}

int main()
{
	#ifdef AMC
		freopen("AMC1.txt","r",stdin);
	#endif
	now = 1;
	scanf("%s",s + 1);
	n = strlen(s + 1);
	if (s[1] != '1' || s[n] != '0') {puts("-1"); return 0;}
	for (int i = 1; i <= n - 1; i++)
		if (s[i] != s[n - i]) {puts("-1"); return 0;}
	
	for (int i = 1; i <= n - 1; i++)
	{
		if (s[i] == '1')
		{
			printf("%d %d\n",i + 1,now);
			now = i + 1;
		}
		else printf("%d %d\n",now,i + 1);
	}
	return 0;
}

Measured memory_bytes: 1408
import numpy as np
import math
A, B, H, M = map(int, input().split())
T = 60 * H + M
rad_A = T / 2
rad_B = M * 6
rad = abs(rad_A - rad_B)
if rad > 180:
  rad = 360 - rad
length = np.sqrt(A*A + B*B - 2*A*B*np.cos(math.radians(rad)))
print(length)

Measured memory_bytes: 27200
NK = list(map(int, input().split()))



points = NK[0]//NK[1]
value = NK[1]*points
v1 = NK[0] - value
v2 = abs(v1-NK[1])

# print(value)
# print(v1)

if v1 > v2:
    print(v2)
else:
    print(v1)

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


int main(){
	int n,m;
	cin >> n >> m;
	
	
	map<int,int> mp;
	
	rep(i,n){
		int k;
		cin >> k;
		
		rep(j,k){
			int a;
			cin >> a;
			mp[a]++;
		}
	}
	
	int res = 0;
	rep(i,m){
		if(mp[i+1] == n) res++;
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
		int k,a,b;
		cin>>k>>a>>b;
		for(int i=a;i<=b;i++)
		{
			if(i%k==0)
			{
				cout<<"OK"<<endl;
				return 0;
			}
		}
		cout<<"NG"<<endl;
 } 

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  int i,n,k,p,l,r;
  scanf("%d",&n);
  int T[n+1];
  for(i=1;i<n+1;i++){
    scanf("%d",&k);
    T[i]=k;
  }
  for(i=1;i<n+1;i++){
    p=i/2;
    l=i*2;
    r=i*2+1;
    printf("node %d: key = %d, ",i,T[i]);
    if(p>0)printf("parent key = %d, ",T[p]);
    if(l<n+1)printf("left key = %d, ",T[l]);
    if(r<n+1)printf("right key = %d, ",T[r]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
import java.io.*;

/**
 * Created by Ayushi on 01/09/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int a = Integer.parseInt(temp[0]);
        int b = Integer.parseInt(temp[1]);
        r.close();
        int c = a;
        a--;

        int i;
        for (i = 1; true; i++) {
            if (c >= b) break;

            c += a;
        }

        if (b == 1) System.out.println(0);
        else System.out.println(i);
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
long long ceil(long long x,long long y){
  if(x%y) return x/y+1;
  else return x/y;
}
int main(){
  cin.tie(0);ios::sync_with_stdio(0);
  long long n,t,a,x = 1,y = 1,h;cin >> n;
  while(cin >> t >> a){
    h = max(ceil(x,t),ceil(y,a));
    x = t*h;y = a*h;
  }
  cout << x+y << "\n";
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))

ans = 0

i = 0
count = 0
ans = 0
while i != n-1:
    if lst[i]>=lst[i+1]:
        count += 1
        ans = max(ans, count)
    else:
        count = 0
    i += 1

print(ans)


Measured memory_bytes: 14224
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

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

#pragma endregion

int main() {
  int n = in();
  ll ans;
  ll ad = 0;
  ll as = 0;
  rep(i, n) {
    int tmp = in();
    ad += tmp * tmp;
    as += tmp;
  }

  int c = (as / n);
  ans = min(c * c * n - 2 * c * as, (c + 1) * (c + 1) * n - 2 * (c + 1) * as);
  ans += ad;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b;
    char op;
    int ans;

    int i = 0;
for (; i<20000; i++){
    scanf("%d %c %d", &a, &op, &b);
    
    
    if(op == '+'){
        ans = a +b;
    }
    else if (op == '-'){
        ans = a -b;
    }
    else if (op == '*'){
        ans = a * b;
    }
    else if (op == '/'){
        ans = a / b;
    }
    else if (op == '?'){
        break;
    }
   

    printf("%d\n",ans);
}
    
    return 0;
}


Measured memory_bytes: 2124
c,p[1<<17],P[1<<17],i;f(a){return a-p[a]?p[a]=f(p[a]):a;}main(x,y){for(scanf("%d%*d",&x);i++<x;p[i]=i)scanf("%d",P+i);for(;~scanf("%d%d",&x,&y);)p[x=f(x)]=x-f(y)?f(y):x;for(;--i;)c+=f(P[i])==f(i);printf("%d",c);}

Measured memory_bytes: 896
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    string s=stin();
    rep(i,3){
        if(s[i]==s[i+1]){
          cout<<"Bad"<<endl;
        return 0;
        }
    }
    cout<<"Good"<<endl;
}


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

struct point1 {
	int x, y, id;
	point1() {}
	point1(int x, int y, int id):x(x), y(y), id(id) {}
	friend bool operator < (const point1 &p, const point1 & q) {
		return p.x < q.x;
	}
};

struct point2 {
	int x, y, id;
	point2() {}
	point2(int x, int y, int id):x(x), y(y), id(id) {}
	friend bool operator < (const point2 &p, const point2 & q) {
		return p.y > q.y;
	}
};

priority_queue<point1> a;
priority_queue<point2> b;

const int N = 100010;
bool visit[N];

int reach(int x, int y, int &pos) {
	if (pos >= x && pos <= y) return 0;
	if (y <= pos) {
		int ans = pos - y;
		pos = y;
		return ans;
	} else {
		int ans = x - pos;
		pos = x;
		return ans;
	}
}

int X[N], Y[N];
int main()
{
	int n, x, y;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
	    scanf("%d%d", &X[i], &Y[i]);
		a.push(point1(X[i], Y[i], i));
		b.push(point2(X[i], Y[i], i));
	}

	int pos = 0;
	long long ans = 0, flag = 0;
	while (true) {
		while (!a.empty() && visit[a.top().id]) a.pop();
		while (!b.empty() && visit[b.top().id]) b.pop();
		if (a.empty()) break;
		int posa = pos, posb = pos;
	    int x = reach(a.top().x, a.top().y, posa);
		int y = reach(b.top().x, b.top().y, posb);
		if (flag) {
			visit[a.top().id] = true;
		    ans += x;
			pos = posa;
		} else {
			ans += y;
			visit[b.top().id] = true;
			pos = posb;
		}
		flag ^= 1;
	}
    ans += abs(pos);
	pos = 0;
	long long tmp = ans;
	ans = 0;

	memset(visit, false, sizeof(visit));
	for (int i = 1; i <= n; i++) a.push(point1(X[i], Y[i], i)), b.push(point2(X[i], Y[i], i));
    flag = 1;
	while (true) {
		while (!a.empty() && visit[a.top().id]) a.pop();
		while (!b.empty() && visit[b.top().id]) b.pop();
		if (a.empty()) break;
		int posa = pos, posb = pos;
	    int x = reach(a.top().x, a.top().y, posa);
		int y = reach(b.top().x, b.top().y, posb);
		if (flag) {
			visit[a.top().id] = true;
		    ans += x;
			pos = posa;
		} else {
			ans += y;
			visit[b.top().id] = true;
			pos = posb;
		}
		flag ^= 1;
	}
	cout << max(ans + abs(pos), tmp) << endl;
	return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int cmpr(string s1, string s2){
    int l1 = s1.length(), l2 = s2.length();
    if(l1 > l2)
        return 1;
    else if(l1 < l2)
        return -1;
    else{
        for(int i = 0; i < l1; i++){
            if(s1[i] > s2[i])   return 1;
            else if(s1[i] < s2[i])  return -1;
        }
    }
    return 0;

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

    string s1, s2;
    cin >> s1 >> s2;
    int t = cmpr(s1,s2);
    cout << ( t == 0? "EQUAL": t > 0?"GREATER":"LESS");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
string s;
int main()
{
	int n;
	scanf("%d", &n);
	cin >> s;
	int ans = 1;
	for(int i = 1; i < n; i++){
		if(s[i] != s[i - 1]){
			ans++;
		}
	}
	printf("%d", ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
int X1[100005], Y1[100005], X2[100005], Y2[100005];

struct Point{
    int x, y, i;
};
ll cross(const Point &O, const Point &A, const Point &B){
    return (A.x - O.x) *1ll* (B.y - O.y) - (A.y - O.y) *1ll* (B.x - O.x);
}

Point O;
bool cmp(Point a, Point b){
    if(cross(O, a, b) == 0){
        if(a.x == b.x) return a.y < b.y;
        return a.x > b.x;
    }
    return cross(O, a, b) < 0;
}

vector<Point> p;
bool add[100005];

int main(){
    O = {0, 0};
    int r, c, n;
    scanf("%d%d%d", &r, &c, &n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);

        if( ((X1[i] == 0 || X1[i] == r) || (Y1[i] == 0 || Y1[i] == c)) && ((X2[i] == 0 || X2[i] == r) || (Y2[i] == 0 || Y2[i] == c)) ){
            p.eb(Point{X1[i], Y1[i], i});
            p.eb(Point{X2[i], Y2[i], i});
        }
    }   
    sort(all(p), cmp);
    bool ok = 1;
    stack<int> st;
    for(int i=0;i<sz(p);i++){
        int j = p[i].i;
        if(add[j]){
            if(st.empty()){
                ok = 0;
                break;
            }
            else if(!st.empty() && st.top() != j){
                ok = 0;
                break;
            }
            st.pop();
        }
        else{
            add[j] = 1;
            st.push(j);
        }
    }
    if(ok) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 6004
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = sc.nextLong();
    int count = 0;
    long i = x;
    while(i <= y){
      count++;
      i *= 2;
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0); program();}
#define int long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

#define N 3007
#define M 1000000007
int dp[N][N];

void program(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    dp[0][0] = 1;
    for(int i=1;i<n;i++) {
        int sm = 0;
        if (s[i-1] == '<') {
            for(int j=0;j<=i;j++) {
                dp[i][j] = sm;
                sm = (sm + dp[i-1][j]) % M;
            }
        } else {
            for(int j=i;j>=0;j--) {
                sm = (sm + dp[i-1][j]) % M;
                dp[i][j] = sm;
            }
        }
    }

    int res = 0;
    for(int i=0;i<n;i++) res = (res + dp[n-1][i]) % M;
    cout << res << endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-bruteforce?
-reduce dimensionality with problem contraints?
*/


Measured memory_bytes: 69120
fun main(args: Array<String>) {
    abc153b()
}

fun abc153b() {
    val (h, n) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toInt() }

    val answer = if (aList.sum() >= h) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 48312
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}



int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		a[i] = x;
	}
	int node = 0;
	vector<bool>seen(n, false);
	vector<int>visited;
	visited.push_back(node);
	while (seen[node]==false) {
		seen[node] = true;
		visited.push_back(a[node]);
		node = a[node];
	}
	ll roop = 0;
	int fa = -1;
	for (int i = 0; i < visited.size() - 1; i++) {
		if (roop)roop++;
		if (visited[i] == node) {
			roop = 1;
			fa = i;
		}
		
	}
	int ans;
	if (k < visited.size())ans = visited[k];
	else {
		k -= fa;
		k %= roop;
		ans = visited[k + fa];
	}
	cout << ans+1 << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using ld = long double;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;
const ld eps = 1e-11;
int sgn(const ld &r) {return (r > eps) - (r < eps);}


struct UnionFind { // UnionFindTree

    vector<int> d;
    UnionFind(int n): d(n,-1) {}

    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(-d[x] < -d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main(){

    int n, m;
    cin >> n >> m;
    UnionFind uf(n);

    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }

    int ans = 0;
    int r = 0;
    for(int i = 1; i < n; i++) {
        if(uf.same(r,i)) continue;
        uf.unite(r,i);
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3788
#include<cstdio>
inline int getit(int x){
	int t=x&-x,res=0;
	while(t){t>>=1;++res;}
	return res;
}
int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<n;++i){
		for(j=i+1;j<=n;++j)printf("%d ",getit(j-i));
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] a = new long[n];
		long sum =0;
		for(int i=0;i<n;i++) {
			a[i] = scan.nextLong();
			sum+=a[i];
		}
		
		if(n==1){
           System.out.println(0);
           }else {
        	   Arrays.sort(a);
        	long[] r = new long[n];
        	 for(int i=0;i<a.length;i++)
        		 r[i]=a[n-i-1];
           long ans=r[0],ct=1;
           for(int i=1;i<n;i++){
            if(ct>=(n-1)) break;
            ans+=r[i]; ct++;
            if(ct>=(n-1)) break;
            ans+=r[i]; ct++;
           }
           System.out.println(ans);
           }
		
	}

}


Measured memory_bytes: 51904
S = str(input())

#print(S)
#print(S[0])

def check_Palindrome(S):
#    N = len(S)
#    S_1 = S[:int((N-1)/2)] #9文字なら前半は1～4文字⇒0:4
#    S_2 = ''.join(list(reversed(S[int((N+1)/2):]))) #後半は6～9⇒5:
#    if S_1 == S_2:
#        return 1
#    else:
#        return 0
    return S == S[::-1]

#print(check_Palindrome(S))
N = len(S)
# Sの1文字目から（N-1)/2文字目まで⇒Sが9文字なら1～4⇒S[:4]
S_check2 = S[:int((N-1)/2)]
# Sの(N+3)/2文字目からN文字目まで⇒Sが9文字なら6～9⇒S[5:]
S_check3 = S[int((N+3)/2-1):]

if (check_Palindrome(S) == 1) & (check_Palindrome(S_check2) == 1) & (check_Palindrome(S_check3) == 1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int n;
	n = readln.chomp.to!int;

	while (n) {
		auto a = new int[9][9],
		b = new int[9][9],
		c = new int[9][9],
		ans = new bool[9][9];

		foreach (i; 0..9) {
			a[i] = readln.split.map!(to!int).array;
			foreach (j; 0..3) {
				c[i/3*3+j][(i%3)*3..(i%3)*3+3] = a[i][j*3..(j+1)*3];
			}
			foreach (j; 0..9) {
				b[j][i] = a[i][j];
			}
		}

		foreach (i; 0..9) {
			foreach (j; 0..9) {
				foreach (k; 0..9) {
					if (j == k) continue;
					if (a[i][j] == a[i][k]) ans[i][j] = ans[i][k] = 1;
					if (b[i][j] == b[i][k]) ans[j][i] = ans[k][i] = 1;
					if (c[i][j] == c[i][k]) ans[i/3*3 + j/3][(i%3)*3 + (j%3)] = ans[i/3*3 + k/3][(i%3)*3 + (k%3)] = 1;
				}
			}
		}

		foreach (i; 0..9) {
			foreach (j; 0..9) {
				write(ans[i][j] ? "*" : " ", a[i][j]);
			}
			writeln("");
		}
		if (--n) writeln("");
	}
}

Measured memory_bytes: 1080
n=input()

if n[-1]=="2" or n[-1]=="4" or n[-1]=="5" or n[-1]=="7" or n[-1]=="9": 
    print("hon")
elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8" : 
    print("pon")
elif n[-1]=="3":
    print("bon")



Measured memory_bytes: 9060
#include<stdio.h>
 
int main()
{
  int a, b, n;
  int i, cnt = 0;
  int s[ 1010 ], f[ 1010 ];
 
  scanf( "%d %d %d", &a, &b, &n );
 
  for( i = 0; i < n; i++ ){
    scanf( "%d %d", &s[ i ], &f[ i ] );
 
    if( s[ i ] <= a && a < f[ i ] || s[ i ] < b && b <= f[ i ] || a <= s[ i ] && f[ i ] <= b ){
      cnt = 1;
    }
  }
 
  if( cnt == 0 ) printf( "0\n" );
  else printf( "1\n" );
 
  return 0;
 
}

Measured memory_bytes: 1812
package main

import "fmt"

func main() {
	var (
		n int
		f float32
	)

	fmt.Scan(&n)
	ns := make([]float32, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&ns[i])
		f += 1.0 / ns[i]
	}

	fmt.Println(1.0 / f)
}


Measured memory_bytes: 512
#N=int(input())
#N,M=map(int, input().split())
#L=list(map(int, input().split()))
S=str(input())

for i in range(len(S)):
  #print(S[i])
  if i%2==0:
    if S[i]!='R' and S[i]!='U' and S[i]!='D':
      print('No')
      exit()
    
  else:
    if S[i]!='L' and S[i]!='U' and S[i]!='D':
      print('No')
      exit()
      
print('Yes')

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

int main() {
	char S[200];
	int i, j, k;
	scanf("%s", S);
	for (j = 0;S[j] != '\0';j++);
	j--;
	while (j>=0) {
		if (j % 2 == 0) {
			k = 0;
			for (i = 0; i < j / 2; i++) {
				if (S[i] != S[i + j / 2]) {
					k = 1;
				}
			}
			if (k == 0) {
				printf("%d", j);
				break;
			}
			else j--;
		} else
			j--;
	}
	return 0;
}

Measured memory_bytes: 128
A, B, C, X = [int(input()) for i in range(4)]
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (i * 500) + (j * 100) + (k * 50) == X:
                count += 1
print(count)

Measured memory_bytes: 3060
/**********************************************************
* @Author: 			   Kirito
* @Date:   			   2020-07-25 20:00:36
* @Last Modified by:   Kirito
* @Last Modified time: 2020-07-25 20:06:25
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=111111;


int main()
{
	int x;
	cin>>x;
	if(x<600) cout<<"8"<<endl;
	else if(x<800) cout<<"7"<<endl;
	else if(x<1000) cout<<"6"<<endl;
	else if(x<1200) cout<<"5"<<endl;
	else if(x<1400) cout<<"4"<<endl;
	else if(x<1600) cout<<"3"<<endl;
	else if(x<1800) cout<<"2"<<endl;
	else
		cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,v,b,w,t,d,e;
  cin>>a>>v>>b>>w>>t;
  bool c=false;
  d=a,e=b;
   if(d<e){
     for (int i = 0; i < t; i++) {
     a=a+v;
     b=b+w;
      }
   if(a==b ||a>b){
       c=true;
   }
   }
  if(d>e){
     for (int i = 0; i < t; i++) {
     a=a-v;
     b=b-w;
     }
    if(a==b ||a<b){
       c=true;
       }
   }
    if(c){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    vector<string> S(3);
    REP(i,3) cin >> S[i];
    int turn = 0;
    while(1) {
        if(S[turn] == "") {
            cout << (char)('A'+turn)<< endl;
            return 0; 
        }
        char next = S[turn][0];
        S[turn].erase(S[turn].begin());
        turn = next-'a';
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)


int compare(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2) return 1;
	else if (*(long *)n1 < *(long *)n2) return -1;
	else return 0;
}

int main(){
    int n;
    scanf("%d",&n);
    long sum[n+1];
    sum[0]=0;
    long tmp;
    F(i,0,n){
        scanf("%ld",&tmp);
        sum[i+1]=sum[i]+tmp;
    }
    qsort(sum,n+1,sizeof(long),compare);

    long count=1,s=0;
    F(j,0,n){
        if(sum[j]==sum[j+1]){
            count++;
            continue;
        }
        s+=count*(count-1)/2;
        count=1;
    }
    s+=count*(count-1)/2;

    printf("%ld",s);
    return 0;
}


Measured memory_bytes: 3324
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
B = list(range(N))
def Temp(x):
  Temp = T-0.006*x
  return(Temp)
for i in range(N):
  B[i] = abs(Temp(H[i])-A)
ans = min(B)
print(B.index(ans)+1)

Measured memory_bytes: 3064
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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 run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize1, usize, i64); m],
    }
    let mut g = vec![vec![]; n];
    for (l, r, c) in e {
        g[l].push((r, c));
    }
    let inf = 1_000_000_000_000_000i64;
    let mut dp = vec![inf; n];
    dp[0] = 0;
    let mut h = std::collections::BinaryHeap::new();
    h.push((0, 1));
    for i in 0..n {
        while let Some((d, r)) = h.pop() {
            if r > i {
                h.push((d, r));
                break;
            }
        }
        if h.is_empty() {
            println!("-1");
            return;
        }
        let (d, _) = *h.peek().unwrap();
        dp[i] = -d;
        for &(r, c) in &g[i] {
            h.push((d - c, r));
        }
    }
    println!("{}", dp[n - 1]);
}

fn main() {
    run();
}


Measured memory_bytes: 20732
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

int main(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(B/A > C) printf("%d",C);
    else printf("%d",B/A);
    return 0;   
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL N;
	LL A, B, C, D;
	string S;

	cin >> N >> A >> B >> C >> D;
	cin >> S;

	--A;
	--B;
	--C;
	--D;

	// B -> D
	int blockCount = 0;
	bool canSkip = false;
	for (int i = B + 1; i < D; ++i) {
		if (S[i] == '#') {
			++blockCount;

			if (blockCount >= 2) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			blockCount = 0;
		}
	}


	// A -> C
	blockCount = 0;
	bool canSkipB = false;
	for (int i = A + 1; i < C; ++i) {
		if (S[i] == '#') {
			++blockCount;
			if (blockCount >= 2) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			blockCount = 0;
		}
	}

	if (C > D) {
		int blankCount = 0;
		for (int i = B - 1; i <= D + 1; ++i) {
			if (S[i] == '.') {
				++blankCount;

				if (blankCount >= 3) {
					cout << "Yes" << endl;
					return 0;
				}
			}
			else {
				blankCount = 0;
			}
		}

		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 640
a, b = map(int, input().split())
c = 10 ** 9
for i in range(a, b + 1):
    for j in range(i + 1, b + 1):
        c = min(c, (i * j) % 2019)
        if c == 0:
            print(c)
            exit()
print(c)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> p_fac(int n)
{
    vector<vector<int>> arr;
    int tmp = n;
    for (int i = 2; i * i <= n; i++)
    {
        if (tmp % i == 0)
        {
            int cnt = 0;
            while (tmp % i == 0)
            {
                cnt++;
                tmp /= i;
            }
            arr.push_back({i, cnt});
        }
    }
    if (tmp != 1)
        arr.push_back({tmp, 1});
    if (arr.size() == 0)
        arr.push_back({n, 1});
    return arr;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    long long ans = 0;
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    int mod = 1000000007;
    map<int, int> lcma{};
    for (int i = 0; i < N; i++)
    {
        vector<vector<int>> f = p_fac(A.at(i));
        for (int j = 0; j < f.size(); j++)
        {
            lcma[f.at(j).at(0)] = max(lcma[f.at(j).at(0)], f.at(j).at(1));
        }
    }
    long long l = 1;
    for (auto x : lcma)
    {
        l = l * modpow(x.first, x.second, mod) % mod;
    }
    for (int i = 0; i < N; i++)
    {
        ans = (ans + (l * modpow(A.at(i), mod - 2, mod) % mod)) % mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    
    if( a < b )
    {
        printf("%d\n", 0);
    }
    else
    {
        printf("%d\n", 10);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define p_b push_back
#define pl pair<ll,ll>

ll MOD = 1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t= 1;
	//cin >> t;
	while(t--)
	{
		ll r;
		cin >> r ;
		cout << r*r << endl;
		
	}
	return 0;
}

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

int decision_palindrome(int );

int main()
{
    int cnt = 0, a, b;
    cin >> a >> b;

    for(int i = a; i <= b; i++)
    {
        if(decision_palindrome(i)) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

int decision_palindrome(int x){
    string str;
    
    str = to_string(x);

    if((str[0] == str[4]) && (str[1] == str[3])) return 1;
    else return 0;
}


Measured memory_bytes: 256