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

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	}
}

Measured memory_bytes: 30168
n, m, l = map(int,input().split())

a = []
for _ in range(n):
    li = list(map(int,input().split()))
    a.append(li)

b = []
for _ in range(m):
    li = list(map(int,input().split()))
    b.append(li)

c=[[0 for i in range(l)] for j in range(n)]

for _n in range(n):
    for _l in range(l):
        s = 0
        for k in range(m):
            s += a[_n][k] * b[k][_l]
        c[_n][_l] = s


for _n in range(n):
    for _l in range(l):
        print(c[_n][_l], end='')
        if _l == l-1:
            print('')
        else:
            print(' ',end='')

    


Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  long long x=max(a,max(b,c));
  a-=x;
  for(int i=0;i<k;i++) x*=2;
  cout << a+b+c+x << endl;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int K;
  in >> K;
  vector<int> cost(K, numeric_limits<int>::max());
  cost[1] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> Q;
  Q.emplace(cost[1], 1);
  while (!Q.empty()) {
    int n, c;
    tie(c, n) = Q.top();
    Q.pop();
    if (c > cost[n]) continue;
    if (c < cost[10 * n % K]) {
      cost[10 * n % K] = c;
      Q.emplace(c, 10 * n % K);
    }
    if (c + 1 < cost[(n + 1) % K]) {
      cost[(n + 1) % K] = c + 1;
      Q.emplace(c + 1, (n + 1) % K);
    }
  }
  out << cost[0] + 1 << '\n';
}

Measured memory_bytes: 4292
package main

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

var mod int = 1e9 + 7
var maxMove int = 1e6
var fac = make([]int, maxMove)
var ifac = make([]int, maxMove)

func powMod(x, n int) int {
	if n == 0 {
		return 1
	}
	if n%2 == 0 {
		t := powMod(x, n>>1)
		return t * t % mod
	}
	return x * powMod(x, n-1) % mod
}

func preprocess() {
	fac[0] = 1
	for i := 1; i < maxMove; i++ {
		fac[i] = fac[i-1] * i % mod
	}

	for i := range ifac {
		ifac[i] = powMod(fac[i], mod-2)
	}
}

func main() {
	x, y := readInt(), readInt()

	preprocess()

	if (x+y)%3 != 0 || y > 2*x || 2*y < x {
		fmt.Println(0)
		return
	}

	totalMove := (x + y) / 3
	diff := abs(x - y)
	move := (totalMove - diff) / 2

	fmt.Println(fac[totalMove] * ifac[move] % mod * ifac[totalMove-move] % mod)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 17024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) {
        if(a[i] % 2 == 0) {
            b.push_back(a[i]);
        }
    }
    int num = 0;
    rep(i, 0, b.size()) {
        if(b[i] % 3 == 0 || b[i] % 5 == 0) {
             num++;
        }
    }
    if(num == b.size()) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    lint X, T, A;
    rep(i, n){
        lint t, a; cin >> t >> a;
        if(i == 0){
            X = t + a; T = t; A = a;
            continue;
        }
        lint l = 1, r = 1e18;
        while(r - l > 1){
            lint m = (l + r) / 2;
            lint y = m/(t+a)*(t+a);

            bool ok = true;
            if(y < X) ok = false;
            if(y/(t+a)*t < T) ok = false;
            if(y/(t+a)*a < A) ok = false;

            if(ok) r = m;
            else l = m;
        }
        X = r/(t+a)*(t+a);
        T = X/(t+a) * t;
        A = X/(t+a) * a;
    }
    out(X);
}

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


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

   if(n>=1000){
      cout<<"ABD"<<endl;//<<setfill('0')<<right<<setw(3)<<1001-n<<endl;
   }
   else{
      cout<<"ABC"<<endl;//<<setfill('0')<<right<<setw(3)<<n<<endl;
   }
}



Measured memory_bytes: 256
C,G=map(int,input().split())
Lmax=0
Rmin=C+1
for i in range(G):
    L,R=map(int,input().split())
    if L > Lmax :
        Lmax = L
    else:
        pass
    
    if R < Rmin :
        Rmin = R
    else:
        pass
ans=Rmin-Lmax+1
if ans >= 0 :
    print(ans)
else :
    print(0)

Measured memory_bytes: 3060
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    ll a,b;cin>>a>>b;
    if(abs(b-a)%2)
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    else
    {
        cout<<((a+b)>>1)<<endl;
    }
}
signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  int a[6][3]={{60,2,600},{80,5,800},{100,10,1000},
               {120,15,1200},{140,20,1400},{160,25,1600}};
  while(1){
    cin>>n;
    if(n==0)break;
    int sum=0;
    rep(i,n){
      int x,y,h,w;
      cin>>x>>y>>h>>w;
      rep(j,6)
        if(x+y+h<=a[j][0] && w<=a[j][1]){
          sum+=a[j][2];
          break;
        }
    }
    cout<<sum<<endl;
  }
}

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

string S, T;

int main() {
    cin >> S >> T;

    string ans = "No";
    for (int i = 0; i < S.length(); i++) {
        if (S == T) {
            ans = "Yes";
            break;
        }
        else {
            S = S.substr(1) + S[0];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
int  pow(int x,int n) {int res=1; while(n){if(n&1) res=(res*x);x=(x*x);n>>=1;}return res;}
 
 int min_cost(int arr[], int n){
 	int dp[n+1]={0};

 	for(int i=2;i<=n;i++){

 		int op1= abs(arr[i]-arr[i-1])+dp[i-1];
 		int op2= (i==2) ? inf : abs(arr[i]-arr[i-2]) + dp[i-2];

 		 dp[i]=min(op1, op2);
 	}
 	return dp[n];
 }
int32_t main()
{
// #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
// #endif
	//paawan9s
	FIO;
	int n; cin>>n;
	mk(arr, n+1, int);
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	cout<< min_cost(arr, n);
	return 0;
}

Measured memory_bytes: 1792
/**
  Let a simple polygon (i.e. without self intersection, not necessarily convex) be given. It is required to calculate its area given its vertices.
  Time : O (n)
**/


#include <bits/stdc++.h>
using namespace std;

using ftype = double;


//..method 1- using signed area of triangles
struct point2d {
    ftype x, y;
    point2d() {}
    point2d(ftype x, ftype y): x(x), y(y) {}
    point2d& operator+=(const point2d &t) {
        x += t.x;
        y += t.y;
        return *this;
    }
    point2d& operator-=(const point2d &t) {
        x -= t.x;
        y -= t.y;
        return *this;
    }
    point2d& operator*=(ftype t) {
        x *= t;
        y *= t;
        return *this;
    }
    point2d& operator/=(ftype t) {
        x /= t;
        y /= t;
        return *this;
    }
    point2d operator+(const point2d &t) const {
        return point2d(*this) += t;
    }
    point2d operator-(const point2d &t) const {
        return point2d(*this) -= t;
    }
    point2d operator*(ftype t) const {
        return point2d(*this) *= t;
    }
    point2d operator/(ftype t) const {
        return point2d(*this) /= t;
    }
};
point2d operator*(ftype a, point2d b) {
    return b * a;
}

//2 d cross product
ftype cross(point2d a, point2d b) {
  return a.x * b.y - a.y * b.x;
}

//..using signed area
int signed_area_parallelogram(point2d p1, point2d p2, point2d p3) {
  return cross(p2 - p1, p3 - p2);
}


//..method 2 : we go through all edges and add trapezoid areas bounded by each edge and x-axis.
double area(const vector<point2d>& fig) {
  double res = 0;
  for (unsigned i = 0; i < fig.size(); i++) {
    point2d p = i ? fig[i - 1] : fig.back();
    point2d q = fig[i];
    res += (p.x - q.x) * (p.y + q.y);
  }
  return fabs(res) / 2;
}

int main() {
  cout << fixed;
  cout << setprecision(1);
  int n;
  cin >> n;
  int x, y;
  vector <point2d> fig;
  for (int i = 0; i < n; i++) {
      cin >> x >> y;
      point2d point(x, y);
      fig.push_back(point);
  }
  reverse(fig.begin(), fig.end());
  double ans = area(fig);
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 3268
S = input()

days = {'SUN': 0, 'MON': 1, 'TUE': 2, 'WED': 3, 'THU': 4, 'FRI': 5, 'SAT': 6}

if S == 'SUN':
    print(7)
else:
    print((7 - days[S]) % 7)

Measured memory_bytes: 8880
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)


Measured memory_bytes: 207224
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    s = ns()
    Q = ni()

    T1 = 0
    FrontS = ""
    BackS = ""
    for _ in range(Q):
        T = stdin.readline().split()
        if T[0] == "1":
            FrontS, BackS = BackS, FrontS
            T1 += 1
        else:
            if T[1] == "1":
                FrontS += T[2]
            else:
                BackS += T[2]
                
    FrontS = FrontS[::-1]

    if T1 % 2 == 0:
        print(FrontS + s + BackS)
    else:
        print(FrontS + s[::-1] + BackS)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

const int MOD = 1000000007;
int main() {
    ll n, x, t; cin >> n >> x >> t;
    ll ans = (n%x == 0) ? t * n/x : t * (n/x + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> b;
  REP(i, n) REP(j, a[i]) b.emplace_back(i+1);
  vector<vector<int>> ans(h, vector<int>(w));
  REP(i, h){
    REP(j, w) ans[i][j] = b[i*w+j];
    if(i%2) reverse(ALL(ans[i]));
  }
  REP(i, h){
    REP(j, w) printf("%d ", ans[i][j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data
{
public:
    int a, b, id;
    Data(int a0, int b0, int id0){
        a = a0;
        b = b0;
        id = id0;
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        list<Data> x;
        x.push_back(Data(-1,-1, -1));
        x.push_back(Data(1000000001, 1000000001, -1));

        while(--n >= 0){
            char c;
            cin >> c;

            if(c == 'W'){
                int id, s;
                cin >> id >> s;
                list<Data>::iterator it = x.begin();
                while(s > 0){
                    list<Data>::iterator it2 = it;
                    ++ it2;
                    int len = it2->a - it->b - 1;
                    if(len > 0){
                        x.insert(it2, Data(it->b+1, it->b+min(s,len), id));
                        s -= min(s, len);
                    }
                    it = it2;
                }
            }else if(c == 'D'){
                int id;
                cin >> id;
                list<Data>::iterator it = x.begin();
                while(it != x.end()){
                    if(it->id == id)
                        it = x.erase(it);
                    else
                        ++ it;
                }
            }else{
                int p;
                cin >> p;
                list<Data>::iterator it = x.begin();
                while(p > it->b)
                    ++ it;

                if(p >= it->a)
                    cout << it->id << endl;
                else
                    cout << -1 << endl;
            }
        }

        cout << endl;
    }
}

Measured memory_bytes: 1352
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  ll n, k;
  cin >> n >> k;
  ll arr[n];
  ll sum = 0;
  for (ll i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);

  for (ll i = 0; i < n - k; i++) {
    sum += arr[i];
  }

  // cout << sum << endl;

  cout << sum << '\n';
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    dp = [0 for _ in range(N + 1)]
    dp[0] = 1000
    for i in range(N):
        dp[i + 1] = max(dp[i], dp[i - 1])
        for j in range(0, i):
            a = dp[j] // A[j] * A[i] + dp[j] % A[j]
            dp[i + 1] = max(dp[i + 1], a)
    print(dp[N])


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

lli n, l, r, tot, a[3005], dp[3005][3005][2] ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    cin>> n ;
    for(int i=1 ; i<=n ; i++) cin>> a[i], dp[i][i][0]=a[i], tot+=a[i] ;
    for(int i=1 ; i<=n ; i++)
      for(int j=1 ; j+i<=n ; j++)
        {
          l=j ; r=j+i ;
          dp[l][r][0]=max(dp[l+1][r][1]+a[l], dp[l][r-1][1]+a[r]) ;
          dp[l][r][1]=min(dp[l+1][r][0], dp[l][r-1][0]) ;
        }
    cout<< 2*dp[1][n][0]-tot ;
  }


Measured memory_bytes: 139648
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl mons(n+1), hero(n+1);
        rep(i, n+1) cin>>mons[i];
        rep(i, n)   cin>>hero[i];
        ll ans = 0;
        ll x = 0, carry = 0;
        rep(i, n+1){
            ans += min(hero[i]+carry, mons[i]);
            if(carry >= mons[i])    carry = hero[i];
            else carry = max(hero[i]+carry-mons[i], x);
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;
using llint = long long;
using pint = pair<int,int>;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

const int INF = 1<<28;
const llint LLINF = 1LL<<60;

int n, a, b, ans;

int main() {
    // Input
    cin >> n >> a >> b;
    // Output
    ans = min(a*n, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    M, K = map(int, input().split())
    if M == 1:
        if K == 0:
            print('0 0 1 1')
        else:
            print('-1')
        return
    if K >= 2 ** M:
        print(-1)
        return
    r = []
    for i in range(2 ** M):
        if i != K:
            r.append(i)
    r.append(K)
    for i in reversed(range(2 ** M)):
        if i != K:
            r.append(i)
    r.append(K)
    print(' '.join(str(i) for i in r))
main()


Measured memory_bytes: 31640
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int S, W;
    cin >> S >> W;

    string ans;
    if (S <= W)
    {
        ans = "unsafe";
    }
    else
    {
        ans = "safe";
    }

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

Measured memory_bytes: 3628
// インクルード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

// 名前空間省略
using namespace std;

// メイン
int main()
{
	// 入出力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// 表示精度変更
	cout << fixed << setprecision(16);

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];

    int ans=(1<<30);
    for(int i=-100;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans,sum);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static final BigDecimal BTC_TO_JPY_CONVERT_RATIO = new BigDecimal("380000.0");

    public static String process(TestCase testCase) {
        int N = testCase.N;
        BigDecimal sum = BigDecimal.ZERO;

        final List<BigDecimal> x = testCase.x;
        final List<String> u = testCase.u;
        for (int i = 0; i < N; ++i) {
            final String currency = u.get(i);
            final BigDecimal value = x.get(i);
            BigDecimal valueInJPY = Currency.fromString(currency).asJPY(value);
            sum = sum.add(valueInJPY);
        }

        return sum.toPlainString();
    }

    private static enum Currency {
        JPY(BigDecimal.ONE), BTC(BTC_TO_JPY_CONVERT_RATIO);

        private final BigDecimal toJpyConvertRatio;

        Currency(BigDecimal toJpyConvertRatio) {
            this.toJpyConvertRatio = toJpyConvertRatio;
        }

        public BigDecimal asJPY(BigDecimal value) {
            return value.multiply(toJpyConvertRatio);
        }

        public static Currency fromString(String possibleCurrency) {
            return Arrays.stream(values())
                    .filter(currency -> currency.name().equals(possibleCurrency))
                    .findFirst()
                    .orElseThrow(() -> new IllegalArgumentException("Unknown Currency: " + possibleCurrency));
        }
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        List<BigDecimal> x = new ArrayList<>();
        List<String> u = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            x.add(new BigDecimal(sc.next()));
            u.add(sc.next());
        }

        sc.close();
        return new TestCase(N, x, u);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final List<BigDecimal> x;
        final List<String> u;

        public TestCase(int N, final List<BigDecimal> x, final List<String> u) {
            this.N = N;
            this.x = x;
            this.u = u;
        }
    }
}


Measured memory_bytes: 26832
S = input()
n = len(S)
flag = 0
if S[:1] == "k" and S[n-6:] == "eyence":
    flag = 1
elif S[:2] == "ke" and S[n-5:] == "yence":
    flag = 1
elif S[:3] == "key" and S[n-4:] == "ence":
    flag = 1
elif S[:4] == "keye" and S[n-3:] == "nce":
    flag = 1
elif S[:5] == "keyen" and S[n-2:] == "ce":
    flag = 1
elif S[:6] == "keyenc" and S[n-1:] == "e":
    flag = 1
if flag:
    print("YES")
else:
    print("NO")

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

int main() {
	int N, K;
	cin >> N >> K;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h >= K)
			sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int M;

struct Graph {
    struct Sub {
        Sub() : r(1) {}
        Sub &operator+=(const Sub &s) {
            r = (ll)r * s.r % M;
            return *this;
        }
        Sub &add_root() {
            r++;
            return *this;
        }
        int r;
    };
    struct Vertex { int n; Sub s; };
    struct Edge { int i, n; Sub s; };
    Graph(int n, int m) : v(n, { -1, {} }), e(m), r(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n, {} };
        v[i].n = m;
        m++;
    }
    Sub dfs0(int i, int p) {
        Sub s;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;

            s += o.s = dfs0(o.i, i);
        }
        return s.add_root();
    }
    void dfs1(int i, int p, Sub *r, Sub s0) {
        int l = 0;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) o.s = s0;
            r[l++] = o.s;
        }
        for (int k = l - 1; k > 0; k--) {
            r[k - 1] += r[k];
        }
        v[i].s = r[0].add_root();

        Sub s;
        int k = 0;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            k++;
            if (o.i != p) {
                Sub t = s;
                if (k < l) t += r[k];
                dfs1(o.i, i, r + l, t.add_root());
            }
            s += o.s;
        }
    }
    void solve() {
        if (n == 1) {
            v[0].s = Sub().add_root();
        } else {
            dfs0(0, -1);
            dfs1(0, -1, &r[0], {});
        }

        for (int i = 0; i < n; i++) {
            cout << (v[i].s.r - 1 + M) % M << '\n';
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    vector<Sub> r;
    int n, m;
};

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

    int n;
    cin >> n >> M;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    g.solve();

    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define INT long long
#define MOD 1000000007
using namespace std;
INT l, r, ans = MOD;
map<INT, INT> s;
int main(void)
{
    ios::sync_with_stdio(false);
    cin>>l>>r;
    if( r-l+1 >= 2019 ) cout<<0<<endl;
    else
    {
        for(INT i = l ; i < r ; i++ )
            for(int j = i+1 ; j <= r ; j++ )
                ans = min(ans, (i*j)%2019 );
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
const ll INF=pow(10,15);
ll N;
//35
int main()
{
ll a,b,x;
 scanf("%lld %lld %lld",&a,&b,&x);
 ll anx=a/x,bnx=b/x;
 if(a%x!=0){anx++;}
 ll ans=bnx-anx+1;
 printf("%lld\n",ans);
} 

Measured memory_bytes: 3832
#include<stdio.h>

int main()
{
	long long n;
	long long ctr = 1;
	scanf("%lld", &n);
	long long num[n];
	
	for(int i = 0; i < n; i++){
		scanf("%lld", &num[i]);
	}
	
	for(int i = 0; i < n; i++){
		if(num[i] == 0){
			printf("0\n");
			return 0;
		}
	}
	for(int i = 0; i < n; i++){
		if(num[i] <= 1000000000000000000/ctr){
			ctr *= num[i];
		}else{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ctr);
}

Measured memory_bytes: 2508
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int num=0;
    int flag=0;

    cin >> a >> b;

    for(int i=1;i<=b;i++){
        num=b/i;
        if(num==a)flag=1;
    }

    if(flag==1)cout << a+b << endl;
    else cout << b-a << endl;

    return 0;
}

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

int main() {
  stack<int> S;
  stack<pair<int, int>> S2;
  char ch;
  int sum = 0;
  for ( int i = 0; cin >> ch; i++ )  {
    if (ch == '\\') {
      S.push(i);
    } else if (ch == '/' && S.size() > 0) {
      int j = S.top(); S.pop();
      sum += i - j;
      int a = i - j;
      while (S2.size() > 0 && S2.top().first > j) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " " << ans[i];
  }
  cout << endl;

  return 0;
}



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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    bool a[3] = {true, true, true};
    a[x-1] = false, a[y-1] = false;
    for(int i=0;i<3;i++){
        if(a[i]){
            cout << (i + 1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    // 整数の入力

    // スペース区切りの整数の入力
    string[] input = Console.ReadLine().Split(' ');
    int k = int.Parse(input[0]);
		int x = int.Parse(input[1]);

    string result;
    
    if(500*k >= x){
      result = "Yes";
    } else {
      result = "No";
    }
  
    //出力
    Console.WriteLine(result);
  }
}


Measured memory_bytes: 11092
n=int(input())
l=[]
b=0
for j in range(1,200):
    for i in range(1,j+1):
        if j%i==0:
            b+=1
    if b==8:
        l.append(j)
    b=0
L=[]
for k in range(len(l)):
    if l[k]%2==1 and l[k]<=n:
        L.append(l[k])
print(len(L))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int path[n];
  vector<int> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];

  double sum=0;
  rep(i,n) path[i]=i;

  do{
    rep(i,n-1){
      sum+=hypot((x[path[i+1]]-x[path[i]]),(y[path[i+1]]-y[path[i]]));
    }
  }while(next_permutation(path,path+n));
  for(int i=1; i<=n; i++) sum/=i;
  printf("%.9f\n",sum);
  return 0;
}


Measured memory_bytes: 256
def main():
    sum, leg = map(int, input().split())
    
    if leg / sum == 2:
        print('Yes')
        return
    elif leg / sum == 4:
        print('Yes')
        return

    for i in range(sum + 1):

        x = sum - i

        crane = i * 2
        turtle = x * 4
        total = crane + turtle
        if total == leg:
            print('Yes')
            return
    print('No')
    
main()

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<=b){
    for(int i=0;i<b;i++)
      cout<<a;
    cout<<endl;
    }
    else{
      for(int i=0;i<a;i++)
      cout<<b;
      cout<<endl;
    }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b-a << endl;
	}
}



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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0;i<N;i++){
    cin >> d.at(i);
  }
  int ans=0;
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      if(i==j){
        continue;
      }
      else{
        ans+=d.at(i)*d.at(j);
      }
    }
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
 
public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
 
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
String s[]=line.split(" ",0);
int i=Integer.parseInt(s[0]);
int j=Integer.parseInt(s[1]);
if(i*j==15)
        System.out.println("*");
else if(i+j==15)System.out.println("+");
else System.out.println("x");
    }
}

Measured memory_bytes: 21844
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	string s;
	cin>>s;

	bool cnt[26]={};
	for(int i=0;i<s.size();i++) cnt[s[i]-'A']=true;

	if((cnt['N'-'A']+cnt['S'-'A'])!=1 && (cnt['W'-'A']^cnt['E'-'A'])!=1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

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

int main(void){
    int n,k,i,sum;
    sum = 0;

    cin >> n >> k;
    vector<int> p(n);

    for(i=0; i<n; i++){
        cin >> p.at(i);
    }

    sort(p.begin(),p.end());
    for(i=0; i<k; i++){
        sum += p.at(i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

  public static void main(String [] args)throws IOException{
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int [] num = new int[51];
    for(int a = 0; a <= 9; a++)
      for(int b = 0; b <= 9; b++)
        for(int c = 0; c <= 9; c++)
          for(int d = 0; d <= 9; d++) 
             num[a+b+c+d]++;
    String ln ="";
    while((ln = br.readLine())!= null)
      System.out.println(num[Integer.parseInt(ln)]);    
       
    
    }
    
}  

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

struct node{
    unsigned int key;
    struct node *next;
    struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
    NodePointer cur = nil -> next;
    while(cur != nil && cur -> key != key ){
        cur = cur -> next;
    }
    return cur;
}

void init(){
    nil = (NodePointer)malloc(sizeof(struct node));
    nil -> next = nil;
    nil -> prev = nil;
}

void printList(){
    NodePointer cur = nil -> next;
    int isf = 1;
    while(1){
        if(cur == nil) break;
        if(isf == 0) printf(" ");
        printf("%d", cur -> key);
        cur = cur -> next;
        isf = 0;
    }
    printf("\n");
}
void deleteNode(NodePointer t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    NodePointer t = nil->next;
    if(t == nil) return;
    deleteNode(t);
}

void deleteLast(){
    NodePointer t = nil->prev;
    if(t == nil) return;
    deleteNode(t);
}

void Delete(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    NodePointer x;
    x = (NodePointer)malloc(sizeof(struct node));
    x -> key = key;
    x -> next = nil -> next;
    nil -> next ->prev = x;
    nil -> next = x;
    x -> prev = nil;
}

int main(void){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i = 0; i< n; i++){
        scanf("%s%d", com, &key);
        if(com[0] == 'i'){insert(key); np++; size++;}
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            }else{
                Delete(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
    
}



Measured memory_bytes: 34456
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int Q;
    cin>>Q;
    vector<int> l(Q),r(Q);
    rep(i,Q) cin>>l.at(i)>>r.at(i);
    vector<bool> prime(1e5+1);
    vector<int> p2(1e5+1);
    vector<int> ps(1e5+2,0);
    //普通に素数判定する、次に素数*2+1が素数か判定する、素数ならp2[素数*2+1]を+1する
    //p2を累積和する
    for(int i=2; i<=1e5; i++){
        int a=i;
        bool isprime=true;
        for(int j=2; j<=sqrt(i); j++){
            if(a%j==0){ isprime=false;break; }
        }
        if(isprime) prime[i]=true;
    }
    for(int i=2; i<=1e5/2; i++){
        if(prime[i]&&prime[i*2-1]) p2[i*2-1]++;
    }
    for(int i=0; i<1e5+2; i++){
        ps[i+1]=ps[i]+p2[i];
    }
    rep(i,Q){
        cout<<ps[r[i]+1]-ps[l[i]]<<endl;
    }
}

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

using Graph = vector<vector<int>>;

int main(){
    double a,b,h,m;
    cin >>a>>b>>h>>m;
    double angle;
    angle = (6*m) - (30*h+30*m/60);
    //angle = min(angle,360-angle);
    angle = angle * M_PI /180;
    
    double ans2 = a*a + b*b -2*a*b*cos(angle);
    double ans = pow(ans2,0.5);
    
    printf("%.18lf\n", ans);
    
    return 0;
}




Measured memory_bytes: 4336
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

maxes = Array.new(n+1)
cur = 1
0.upto(n) do |i|
  cur -= a[i]
  if cur < 0
    puts -1
    exit
  end
  maxes[i] = cur + a[i]
  cur *= 2
end

# p maxes

ans = 0
cur = 0
n.downto(0).each do |i|
  cur += a[i]
  cur = [cur, maxes[i]].min
  ans += cur
end

puts ans


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

int main() {
    int n,x,ans=0;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    rep(i,n) {
        if (i!=n-1&&a[i]<=x) {
            ans++;
            x-=a[i];
        } else if(i==n-1&&a[i]==x) {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char str[1001] ;
    int i , sum ;
    
    while(1){
        sum = 0;
        scanf("%s" , str);
        if(str[0] == '0'){break;}
        for(i = 0 ; str[i] != '\0' ; i++){
            sum += str[i] - '0';
        }
        printf("%d\n" , sum);
    }
    return 0;
}


Measured memory_bytes: 2048
S = input()

alpha = 'abcdefghijklmnopqrstuvwxyz'
ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

ans = True

if S[0] != 'A':
    ans = False

c_cnt = 0
for S_i in S[2:-1:]:
    if S_i == 'C':
        c_cnt += 1
if c_cnt != 1:
    ans = False

for S_i in S[1:]:
    if S_i in ALPHA and S_i != 'C':
        ans = False

if ans:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060