akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;
 cin >>n>>m;
  vector<long long>data(n);
  priority_queue<long long>qe;
  for (long long i=0;i<n;i++){
    long long a;
  cin >> a;
    qe.push(a);
  }
  long long s=0;
  for (long long i=m;i>0;i--){
  s=qe.top();
  s/=2;
  qe.pop();
  qe.push(s);
  }
  long long p;
 while (!qe.empty()){
 p+=qe.top();
   qe.pop();
 } 
  
  cout <<p<<endl;
  
}

Measured memory_bytes: 2168
s = input()
a = ''
for i in range(len(s)):
    if i%2 == 0:
        a += '0'
    else:
        a += '1'
cnt = 0
for i in range(len(s)):
    if s[i] == a[i]:
        cnt += 1
print(min(cnt, len(s)-cnt))


Measured memory_bytes: 3188
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    relations[s] += [t]
    relations[t] += [s]
friend_id = [None] * n
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = s
            queue += relations[k]
            relations[k] = []

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] != None and friend_id[s] == friend_id[t] else'no')

Measured memory_bytes: 27472
// finish date: 2018/07/25
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string S;
    cin >> S;
    map<int, int> trans;
    trans[0] = 0;
    trans[1] = 4;
    trans[2] = 6;
    trans[3] = 8;
    vb use = {false, true, true, true, false, true, false, true, false};
    string akihabara = "AKIHABARA";
    rep(i, 1 << 4) {
        vb nowuse = use;
        rep(j, 4) {
            if (i >> j & 1) {
                nowuse[trans[j]] = true;
            }
        }
        string check = "";
        rep(j, 9) {
            if (nowuse[j]) check += akihabara[j];
        }
        if (check == S) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            Array.Sort(ai);
            var query = new Tuple<long, long>[nm[1]];
            for (var i = 0; i < nm[1]; i++)
            {
                var bc = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
                query[i] = new Tuple<long, long>(bc[0], bc[1]);
            }
            query = query.OrderByDescending(x => x.Item2).ThenByDescending(x => x.Item1).ToArray();
            var aiIndex = 0;
            var queryIndex = 0;
            while (aiIndex < ai.Length && queryIndex < query.Length)
            {
                if (ai[aiIndex] < query[queryIndex].Item2)
                {
                    for (var i = 0; i < query[queryIndex].Item1; i++)
                    {
                        if (ai[aiIndex] >= query[queryIndex].Item2) break;
                        ai[aiIndex] = query[queryIndex].Item2;
                        if (++aiIndex >= ai.Length) break;
                    }
                }
                queryIndex++;
            }
            Console.WriteLine(ai.Sum());
        }
    }
}


Measured memory_bytes: 32572
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 25;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

char matrix[NMAX][NMAX];
int matrixFill[NMAX][NMAX];
int sol = 0;
int n,m;

bool check(int x,int y)
{
	if(x < 0 || x >= n)
		return false;
	if(y < 0 || y >= m)
		return false;
	if(matrix[x][y] == '#')
		return false;
	return true;
}

void BFS(int a, int b)
{
	queue<pair<int,int>> coada;
	coada.push({a,b});


	while(!coada.empty())
	{
		int x = coada.front().first;
		int y = coada.front().second;
		coada.pop();
	
		for(int i =0; i < 4; ++i)
		{
			int next_x = x + dx[i];
			int next_y = y + dy[i];


			if(check(next_x,next_y) && matrixFill[next_x][next_y] == 0)
			{
				matrixFill[next_x][next_y] = matrixFill[x][y] + 1;
				sol = max(sol, matrixFill[next_x][next_y]);
				coada.push({next_x,next_y});
			}		
		}
	}
}


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


	cin >> n >> m;

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

	for(int i = 0; i< n; ++i)
	{
		for(int j = 0; j< m; ++j)
		{
			if(matrix[i][j] == '.')
			{
				for(int i =0; i< n; ++i)
				{
					for(int j =0; j< m; ++j)
					{
						matrixFill[i][j] = 0;
					}
				}
				matrixFill[i][j] = 1;
				BFS(i,j);
			}
		}
	}
	cout << sol-1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	string s;
	string t;
	int count = 0;
	cin >> s;
	cin >> t;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] < t[j]) {
				cout << "Yes" << endl;
				return 0;
			}
			else if (s[i] == t[j]) {
				count++;
			}
		}
	}

	if (count == s.size()*t.size()) {
		if (s.size() < t.size()) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}
	
	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a, b, c, i;
int main(){
    scanf("%d %d %d", &a, &b, &c);
    for(i=1; i<=b; i++)
      if((a*i)%b==c){printf("YES\n"); return 0;}
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W, N,K;
int sx, sy;
typedef long long ll;
typedef pair<int, int> P;
int main(){
    cin >> N ;
    vector<P> data;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        data.push_back(P(tmp-1,i));
    }
    sort(data.begin(),data.end());
    for(int i=0;i<N;i++){
        cout << data[i].second+1 << " ";
    }
    cout << endl;
}

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   ll N,K;
   cin>>N>>K;
   ll ans = 0;
   if(K==0){
      cout<<N*N<<endl;
      return 0;
   }
   for(ll i=K+1;i<=N;i++){
      ans += (N/i)*(i-K);
      ans += max((ll)0,(N%i)-K+1);
   }
   cout<<ans<<endl;
   return 0; 
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll n,W;
  cin >> n >> W;
  VLL w(n);
  VLL v(n);
  rep(i,n) cin >> w[i] >> v[i];

  VVLL dp(n+1,VLL(100010,(ll)(1e10)));
  rep(i,n) dp[i][0] = 0;
  rep(i,n){
    rep(j,100010){
      if(dp[i][j] + w[i] <= W) dp[i+1][j+v[i]] = min(dp[i][j] + w[i] ,dp[i+1][j+v[i]] );
      dp[i+1][j] = min(dp[i][j] ,dp[i+1][j] );
    }
  }
  for(int i = 100000; i >= 0; i--){
    if(dp[n][i] !=  (ll)(1e10) ){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

ll f(ll num){
	string str = to_string(num);
	ll re = 0;
	for(char c : str){
		re += c - '0';
	}
	return re;
}

int main(){
	ll N;
	cin >> N;
	
	ll a = 1, b = N - 1, min = 999999999999;
	for(; a < b; ++a, --b){
		ll sum_a = f(a);
		ll sum_b = f(b);
		min = MIN(min, (sum_a + sum_b));
	}
	if(N == 2) min = N;
	cout << min << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, j;
	int H, W;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H==0 && W==0){
			break;
		}
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 572
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();

		sc.close();

		if (A > B) {
			out.println(0);
			return;
		}

		if (N == 1 && A != B) {
			out.println(0);
			return;
		} else if (N == 1 && A == B) {
			out.println(1);
			return;
		}

		long max = Math.max(A, B) * (N - 1) + Math.min(A, B);
		long min = Math.min(A, B) * (N - 1) + Math.max(A, B);

		out.println(max - min + 1);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
typedef long long ll;


using namespace std;
int main()
{
	
       string s;
       cin >> s;
       if(s == "Sunny")
       		cout << "Cloudy" << endl;
       	else if(s == "Cloudy")
       		cout << "Rainy" << endl;
       	else
       		cout << "Sunny" << endl;
    
    return 0;
}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

int num[4];

int main() {
	rep(i, 3) {
		int a, b; cin >> a >> b;
		--a; --b;
		++num[a]; ++num[b];
	}
	sort(num, num + 4);

	bool ok = (num[0] == 1 && num[1] == 1 && num[2] == 2 && num[3] == 2);
	puts(ok ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.nextLine();
        s = 'S' + s + 'S';
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R') {
                int j = i;
                while (j < s.length() && s.charAt(j) == 'R') {
                    j++;
                }
                res = Math.max(res, j - i);
                i = j;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 38568
#include <iostream>
using namespace std;
#define MAX_N 100005
int dp[MAX_N];
int alp[27];
int main(){
  int N;cin>>N;
  string s,t;cin>>s>>t;
  dp[0]=1;
  for(int i = 0; N > i; i++){
    dp[i] = (dp[i]+alp[t[i]-'a'])%1000000007;
    alp[s[i]-'a']=(alp[s[i]-'a']+dp[i])%1000000007;
  }
  cout << dp[N-1] << endl;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  cin >> n;
  ll result;
  if(n % 2 == 0) result = n;
  else result = n * 2;

  cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.math;

T read_num(T)() { return readln.chomp.to!T; }
T[] read_nums(T)() { return readln.chomp.split.to!(T[]); }

enum INF = 1L << 30;

T max(T)(T a, T b) { return a < b ? b : a; }

void main() {
  long N = read_num!long;
  long[] A = read_nums!long;
  long[2][] dp;
  dp.length = N + 1;

  dp[0][0] = 0;
  dp[0][1] = -INF;

  for (size_t i = 0; i < N; i++) {
    long a = A[i];
    dp[i + 1][0] = max(dp[i][0] + a, dp[i][1] - a);
    dp[i + 1][1] = max(dp[i][0] - a, dp[i][1] + a);
  }

  writeln(dp[N][0]);
}

Measured memory_bytes: 7320
from collections import Counter
from math import factorial
n, a, b = map(int, input().split())
v = sorted(list(map(int, input().split())), reverse = True)
max_value = sum(v[:a])/a
cnt1 = Counter(v)[v[a-1]]
cnt2 = Counter(v[:a])[v[a-1]]
comb = factorial(cnt1)//factorial(cnt2)//factorial(cnt1-cnt2)
if v[a-1]==v[0]:
    comb=0
    for i in range(a, min(cnt1, b)+1):
        comb += factorial(cnt1)//factorial(i)//factorial(cnt1-i)
print(max_value)
print(comb)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
long long m=1000000007;
long long dp[1000][1000];
int a[1000][1000];
int h,w;
long long func(int i,int j)
{
    if(i==h-1 && j==w-1)
    {
        return 1;
    }
    else if(i>=h || j>=w)
    {
        return 0;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    else
    {
        if(a[i][j]==0)
        {
        dp[i][j]=0;
        dp[i][j]=(dp[i][j]+func(i,j+1)%m)%m;
        dp[i][j]=(dp[i][j]+func(i+1,j)%m)%m;
        }
        else
        {
            dp[i][j]=0;
        }
        return dp[i][j];
    }
}
int main()
{
    int i,j;
    char ch;
    cin>>h>>w;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            cin>>ch;
            if(ch=='.')
                a[i][j]=0;
            else
                a[i][j]=1;
        }
    }
    cout<<func(0,0);
    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    string s;
    cin >> s;
    bool flag1=true;
    bool flag2=true;
    bool flag3=true;
    bool flag4=true;
    rep(i,s.size()){
        if(s.at(i)=='N')flag1=false;
        if(s.at(i)=='W')flag2=false;
        if(s.at(i)=='S')flag3=false;
        if(s.at(i)=='E')flag4=false;
    }
    if(!flag1&&!flag3){
        flag1=true;
        flag3=true;
    }
    if(!flag2&&!flag4){
        flag2=true;
        flag4=true;
    }
    if(flag1&&flag2&&flag3&&flag4) cout << "Yes" << endl;
    else cout << "No" << endl;
}
   


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e6 + 5;
const long long int MINN = 2e5 + 5;
const long long int inf = 1e6;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 10050;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}

int main(){
    FAST
    int k;
    cin>>k;
    ll ans = 0;
    for(int a = 1;a<=k;a++){
        for(int b = 1;b<=k;b++){
            for(int c = 1;c<=k;c++){
                ans += __gcd(c,__gcd(a,b));
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3692
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

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

  cout << n + n * n + n * n * n;
  return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> x(N), y(N), X(N), Y(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        X[i] = x[i] + y[i];
        Y[i] = x[i] - y[i];
    }

    int64_t max_X = *max_element(X.begin(), X.end());
    int64_t min_X = *min_element(X.begin(), X.end());
    int64_t max_Y = *max_element(Y.begin(), Y.end());
    int64_t min_Y = *min_element(Y.begin(), Y.end());

    int64_t ans = LLONG_MIN;
    ans = max(ans, max_X - min_X);
    ans = max(ans, -min_Y + max_Y);
    ans = max(ans, max_Y - min_Y);
    ans = max(ans, -min_X + max_X);
    cout << ans << endl;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
const ll INF=99999999999999999;
ll a,b,c,d,e,f,g,ans=0;
int main(){
    ll H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
}





    

Measured memory_bytes: 256
#include <stdio.h>


int main(){
	int n, s=0;
	scanf("%i", &n);
	if(n%2==0){
		if(n%10==2){
			while(n!=0){
				s=s+n%10;
				n=n/10;
			}
		}
		else{
			n=n/2;
			while(n!=0){
				s=s+n%10;
				n=n/10;
			}
			s=s*2;
		}
	printf("%i\n", s);
	}
	else{
		n--;
		while(n!=0){
			s=s+n%10;
			n=n/10;
		}
		s++;
		printf("%i\n", s);		
	}
}


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

edges = []
toE = [[] for _ in range(N)]
frE = [[] for _ in range(N)]
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges.append((fr, to, -(c - P)))
    toE[fr].append(to)
    frE[to].append(fr)

def getVisitedList(s, edges):
    visited = [False] * N
    st = [s]
    visited[s] = True
    while st:
        now = st.pop()
        for to in edges[now]:
            if not visited[to]:
                visited[to] = True
                st.append(to)
    return visited

canGo = getVisitedList(0, toE)
canBack = getVisitedList(N - 1, frE)

def sol():
    minDist = [10**18] * N
    minDist[0] = 0
    for i in range(N + 1):
        for fr, to, c in edges:
            d = minDist[fr] + c
            if minDist[to] > d:
                if i == N and canGo[fr] and canBack[to]:
                    return -1
                minDist[to] = d
    return max(0, -minDist[N - 1])

print(sol())


Measured memory_bytes: 51564
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int M,D;
	cin >> M >> D;
	int ans = 0;
	eFOR(i, 1, M) {
		eFOR(j, 1, D) {
			int a = i;
			int b = j / 10;
			int c = j % 10;
			if (b >= 2 && c >= 2) {
				if (a == b * c)ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	public static long maxProfit(int weivalue[][],int capacity,int maxValue){
		//System.out.println(maxValue);
		long dp[][]=new long[weivalue.length+1][maxValue+1];
		
		for(int i=0;i<=weivalue.length;i++){
			Arrays.fill(dp[i],Integer.MAX_VALUE);
			dp[i][0]=0;
		}
		
		for(int i=1;i<=weivalue.length;i++){
			for(int j=0;j<=maxValue;j++){
				if(j>=weivalue[i-1][1]){
					dp[i][j]=Math.min(dp[i-1][j],weivalue[i-1][0]+dp[i-1][j-weivalue[i-1][1]]);
				}else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		long ans=0;
		for(int i=0;i<=maxValue;i++){
			if(dp[weivalue.length][i]<=capacity)
				ans=i;
		}
		return ans;
			
	}
	
	public static void main(String []args){
		
		int n=sc.nextInt();
		int w=sc.nextInt();
		long sum=0;
		int weivalue[][]=new int[n][2];
		for(int i=0;i<n;i++){
			weivalue[i][0]=sc.nextInt();
			weivalue[i][1]=sc.nextInt();
			sum+=weivalue[i][1];
		}
		
		
		System.out.println(maxProfit(weivalue,w,(int)sum));
		
	}
}

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

#define fastio1 ios_base::sync_with_stdio(false)
#define fastio2 cin.tie(NULL)
#define LL long long
#define MOD 1000000007
using namespace std;

int main(){
    fastio1; fastio2;
	LL n, m; cin >> n >> m;
	vector<LL> x(n);
	for (int i = 0; i < n; i++){
		cin >> x[i];
	}
	vector<LL> y(m);
	for (int i = 0; i < m; i++){
		cin >> y[i];
	}
	
	LL total_x = 0;
	for (int i = 1; i< n; i++){
		total_x += (x[i]-x[i-1])*i*(n-i);
		total_x %= MOD;
	}
	LL total_y = 0;
	for (int i = 1; i < m; i++){
		total_y += (y[i]-y[i-1])*i*(m-i);
		total_y %= MOD;
	}
	
	LL total = total_x*total_y;
	total %= MOD;
	
	cout << total << endl;
}


Measured memory_bytes: 1792
//Transformation
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	string str, t, cc;
	int q, a, b;
	cin >> str >> q;
	for(int i = 0; i < q; i++){
		cin >> t >> a >> b;
		if(t == "print"){
			cout << str.substr(a,b-a+1) << endl;
		}else if(t == "replace"){
			cin >> cc;
			str.replace(a, b-a+1, cc);
	}else if(t == "reverse"){
			reverse(str.begin(), str.end());
			cc = str.substr(str.size()-b-1, b-a+1);
			reverse(str.begin(), str.end());
			str.replace(a, b-a+1, cc);
		}
		
	}
	return 0;
}


Measured memory_bytes: 3200
using System;

class quiz
{
    public float solve(int N, float[] x, string[] u)
    {
        float ans = 0;

        for (int i = 0; i < N; i++)
        {
            if (u[i] == "JPY")
                ans += x[i];
            else
                ans += x[i] * (float)380000.0;
        }

        return ans;
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();

        //while (true)
        //{
        int N = int.Parse(Console.ReadLine());

        float[] x = new float[N];
        string[] u = new string[N];

        for (int i = 0; i < N; i++)
        {
            string str = Console.ReadLine();

            x[i] = float.Parse(str.Split(' ')[0]);
            u[i] = str.Split(' ')[1];
        }

        Console.WriteLine(ex.solve(N, x, u));
        //}
    }
}

Measured memory_bytes: 13140
while 1:
    n,x=map(int, input().split())
    if n==0:break
    ans=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    ans+=1
    print(ans)


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

using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        mp[s[i]] += 1;
    }

    int m = 0;
    for (auto i = mp.begin(); i != mp.end(); i++) {
        if (i->second >= m) {
            m = i->second;
        }
    }

    vector<string> str;
    for (auto i = mp.begin(); i != mp.end(); i++) {
        if (i->second == m) {
            str.push_back(i->first);
        }
    }

    sort(str.begin(), str.end());    
    for (int i = 0; i < str.size() ; i++) {
        cout << str[i] << endl;
    }
}


Measured memory_bytes: 28528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
typedef struct hoge{
	hoge *previous=NULL;
	hoge *next=NULL;
	ll value;
}hoge;
int main(){
	ll n;
	cin>>n;
	hoge *P=(hoge*)malloc(sizeof(hoge));
	hoge *head =P,*tail=P;
	cin>>P->value;
	for(int i=1;i<n;i++){
		hoge *now=(hoge*)malloc(sizeof(hoge));
		cin>>now->value;
		if(i%2==1){//headに追加
			head->previous=now;
			now->next=head;
			head=now;
		}
		else{//tailに追加
			tail->next=now;
			now->previous=tail;
			tail=now;
		}
	}
	if(n%2==1){//tailが先頭
		while(tail!=NULL){
			cout<<tail->value;
			if(tail->previous!=NULL)cout<<" ";
			hoge *del=tail;
			tail=tail->previous;
			free(del);
		}
	}
	else{
		while(head!=NULL){
			cout<<head->value;
			if(head->next!=NULL)cout<<" ";
			hoge *del=head;
			head=head->next;
			free(del);
		}
	}
	cout<<endl;
}

Measured memory_bytes: 8448
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;
void solve(ll n, ll base)
{
    int dig = (int)(floor( log(n) /  log(base)) + 1);
    cout<<dig<<endl;
}
int main(){
        _ios;
        ll n,k;
        cin>>n>>k;
        solve(n,k);




return 0;
}







Measured memory_bytes: 640
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<Integer,List<Integer>> map = new HashMap<>();
		for(int i=0;i<n-1;i++) {
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			if(map.containsKey(a)) map.get(a).add(b);
			else {
				List<Integer> list = new ArrayList<>();
				list.add(b);
				map.put(a, list);
			}
			if(map.containsKey(b)) map.get(b).add(a);
			else {
				List<Integer> list = new ArrayList<>();
				list.add(a);
				map.put(b, list);
			}
		}
		int[] c = new int[n];
		for(int i=0;i<n;i++) {
			c[i] = in.nextInt();
		}
		Arrays.sort(c);
		int sum = 0;
		int[] ans = new int[n];
		Deque<Integer> que = new ArrayDeque<>();
		ans[0] = c[n-1];
		for(int tmp : map.get(0)) {
			que.add(tmp);
		}
		for(int i=n-2;i>=0;i--) {
			sum += c[i];
			int num = que.poll();
			ans[num] = c[i];
			for(int tmp : map.get(num)) {
				if(ans[tmp]==0) que.add(tmp);
			}
		}
		System.out.println(sum);
		StringBuilder sb = new StringBuilder();
		sb.append(ans[0]);
		for(int i=1;i<n;i++) {
			sb.append(" ");
			sb.append(ans[i]);
		}
		System.out.println(sb.toString());
		in.close();

	}

}


Measured memory_bytes: 46560
def main():
    N = int(input())
    ab = [list(map(int, input().split())) for i in range(N)]

    imos = [0]*(N+3)
    for a, b in ab:
        imos[min(a,N+2)] += 1
        imos[min(b+1,N+2)] -= 1
    for i in range(N+1):
        imos[i+1] += imos[i]
    #print(imos)

    ans = 0
    for i, imo in enumerate(imos):
        if (imo+1 >= i):
            ans = i-1
    print(ans)

main()


Measured memory_bytes: 26832
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: String,
        B: String,
    }
    println!("{}", if A==B{"H"}else{"D"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int INF = 1e9+5;
int main(){
    int N,k;
    scanf("%d%d",&N,&k);
    vector<int> h(N);
    for(int& x:h)
        scanf("%d",&x);
    vector<int> dp (N,INF);
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<N){
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    printf("%d",dp[N-1]);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    char s;
    cin >> s;
    if (isupper(s))
        cout << "A" << endl;
    else
        cout << "a" << endl;

    return 0;
}

Measured memory_bytes: 3532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int midterm_exam_score;
		int final_examination_score;
		int retest_score;
		int sum;

		while (true) {
			midterm_exam_score = sc.nextInt();
			final_examination_score = sc.nextInt();
			retest_score = sc.nextInt();
			//m,f,rがすべて-1のとき入力を終える
			if (midterm_exam_score == -1 && final_examination_score == -1 && retest_score == -1) {
				break;
			}

			if (midterm_exam_score == -1 || final_examination_score == -1) {
				System.out.println("F");
			} else {
				sum = midterm_exam_score + final_examination_score;
				if (sum >= 80) {
					System.out.println("A");
				} else if (sum >= 65) {
					System.out.println("B");
				} else if (sum >= 50) {
					System.out.println("C");
				} else if (sum >= 30) {
					if (retest_score >= 50) {
						System.out.println("C");
					} else {
						System.out.println("D");
					}
				} else {
					System.out.println("F");
				}
			}
		}
		sc.close();
	}
}



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

int main(){
  int n,m;cin>>n>>m;
  vector<int> h(n);
  vector<bool> good(n,true);
  int ans=0;
  rep(i,n) cin>>h.at(i);
  
  for(int i=0; i<m; i++){
    
    int a,b; cin>>a>>b;
    int low;
    if(h.at(a-1)<h.at(b-1)){
      good.at(a-1)=false;

    } else if(h.at(b-1)<h.at(a-1)){
      good.at(b-1)=false;
    } else {
      good.at(a-1)=false;
      good.at(b-1)=false;
    }
  }
  for(int i=0;i<n;i++){
    if(good.at(i)==true) {
      ans++;
      //cout << i+1<<endl;
    }
  }
  cout<< ans;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#define INF 100000000
using namespace std;

int n,m;
int edge[101][101];
int cnt[101];
int num[101];
int res=0;

void dfs(int v,int depth){
	num[depth]=v;
	int cntmin=15;
	for(int i=0;i<=depth;i++){
		cntmin=min(cntmin,cnt[num[i]]);
	}
	int score=0;
	for(int i=0;i<=depth;i++){
		int mini=INF;
		for(int j=0;j<=depth;j++){
			if(i==j)continue;
			mini=min(mini,edge[num[i]][num[j]]);
		}
		score+=mini;
	}
	if(depth>0)res=max(res,score);
	if(depth==cntmin)return;
	for(int i=v+1;i<n;i++){
		if(cnt[i]<=depth)continue;
		bool flag=true;
		for(int j=0;j<=depth;j++){
			if(edge[i][num[j]]==0)flag=false;
		}
		if(flag)dfs(i,depth+1);
	}
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;
		b--;
		cnt[a]++;
		cnt[b]++;
		edge[a][b]=c;
		edge[b][a]=c;
	}
	for(int i=0;i<n;i++){
		dfs(i,0);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1068
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n = I()
    a = list(IL())
    c = 0
    for i,item in enumerate(a):
        if (i+1)%2==1 and item%2==1:
            c+=1
    print(c)
    exit()

Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    char a[h][w];
    rep(i,h)rep(j,w) cin>>a[i][j];
    rep(i,w+2)cout<<'#';
    cout<<endl;
    rep(i,h){
        cout<<'#';
        rep(j,w)cout<<a[i][j];
        cout<<'#'<<endl;
    }
    rep(i,w+2)cout<<'#';
    cout<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>

#define N 100

using namespace std;

void insertion_sort(int A[], int n) {
  for(int i = 0; i < n-1; i++) cout << A[i] << " ";
  cout << A[n-1] << endl;
    
  for(int i = 1; i< n; i++) {
    int v = A[i];
    int j = i-1;
    
    while(j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

    for(int i = 0; i < n-1; i++) cout << A[i] << " ";
    cout << A[n-1] << endl;    
  }

  return;
}

int main(void)
{
  int n, A[N];
  cin >> n;

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

  insertion_sort(A, n);

  return 0;
}


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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    int n = Integer.parseInt(sl[0]);
    int a = Integer.parseInt(sl[1]);
    int b = Integer.parseInt(sl[2]);
    
    System.out.println(Integer.min(n * a, b));
  }

}


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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	// check 1
	if (!(X<Y)) {
		cout << "War" << endl;
		return 0;
	}
	/*
	vector<int> x(N,0);
	vector<int> y(M,0);
	*/
	int x_max;
	cin >> x_max;
	for (int i=1; i<N; ++i) {
	//	cin >> x[i];
		int temp;
		cin >> temp;
		x_max = temp > x_max ? temp : x_max; 
	}
	int y_min;
	cin >> y_min;
	for (int i=1; i<M; ++i) {
	//	cin >> y[i];
		int temp;
		cin >> temp;
		y_min = temp < y_min ? temp : y_min; 
	}
	
	// check 2
	if (!(x_max < y_min && x_max < Y && X < y_min)) {
		cout << "War" << endl;
		return 0;
	}
	cout << "No War" << endl;
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[4];
	int i,j,k;
	for(i=0;i<4;i++)scanf("%d",&a[i]);
	int temp,ans=0;
	for(i=0;i<=a[0];i++){
		for(j=0;j<=a[1];j++){
			for(k=0;k<=a[2];k++){
				temp = 500*i + 100*j + 50*k;
				if(temp==a[3])ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println(x*x*x);
		
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}
		
		

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

int main() {
	int n, c, k;
	cin >> n >> c >> k;
	vector<int> t(n);
	rep(i, n) cin >> t[i];
	sort(t.begin(), t.end());
	int now = t[0], cnt = 1;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (t[i] <= now + k && cnt < c) cnt++;
		else {
			ans++;
			now = t[i];
			cnt = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3708
import heapq

n,m = (int(x) for x in input().split())

a = [int(i)*(-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):

    b  = -(heapq.heappop(a))//2
    heapq.heappush(a,-b)


print(-sum(a))


Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
double N,M;
cin >> N >> M;
double gou = 0;
vector<double> vec(N);
for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
gou += vec.at(i);
}
int count = 0;
for (int i = 0;i < N;i++) {
    if (vec.at(i) / gou >= 1/(4*M)) count++;
}
if (count >= M) cout << "Yes" << endl;
else cout <<"No" << endl;


return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int v[10000];
int comparator(const void *p, const void *q)
{
    int l = *(const int *)p;
    int r = *(const int *)q;

    return (l - r);
}
int main()
{
    int k = 0, nr, x, i;
    scanf("%d", &x);
    v[k ++] = 1;
    if(sqrt(x) == (int)sqrt(x))
    {
        printf("%d", x);
        return 0;
    }
    if(x < 4)
    {
        printf("1");
        return 0;
    }
    if(x == 1000)
    {
        printf("1000");
        return 0;
    }
   for(i = 2; i <= 31; i ++)
   {
       nr = 1;
       while(nr <= x)
            nr = nr * i;
        if((nr / i) != i && (nr / i) != 1)
       v[k ++] = nr / i;
   }
   qsort((void*)v, k, sizeof(int), comparator);
   k --;
   while(v[k] > x)
        k --;
   printf("%d", v[k]);
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long k=c*d/(__gcd(c,d)); 
	long long ans=(b-a)+1-(b/c-(a-1)/c)-(b/d-(a-1)/d)+ (b/k-(a-1)/k);
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   if(s.size() == 1){
      cout << 0;
      return 0;
   }
   int ans = 0;
   for(int i=0;i<s.size()-1;i++){
      if(s[i] == s[i+1]){
         ans++;
         if(s[i+1] == '0')s[i+1] = '1';
         else s[i+1] = '0';
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    q, h, s, d = map(int, input().split())
    N = int(input())

    one = min([4*q, 2*h, s])
    print(min((N//2)*d+one*(N % 2), N*one))


resolve()

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	static void init_array ( int[][] array ) {

		for ( int i = 0 ; i < array.length ; i++ ) {
			for( int j = 0 ; j < array[i].length ; j++ ) {
				array[i][j] = 0;
			}
		}
	}

	static void set_card_num ( int[] card_num, String[] card_color, int[][] card ) {

		int color = 0;

		for ( int i = 0 ; i < card_num.length ; i++ ) {
			switch( card_color[i] ) {
			case"R":
				color = 0;
				break;
			case"G":
				color = 1;
				break;
			case"B":
				color = 2;
				break;
			}

			card[color][card_num[i]]++;
			card[color][0]++;
		}
	}

	static boolean judge ( int[][] card ) {

		boolean judge = true;

		for ( int i = 0 ; i < card.length ; i++ ) {
			if( ( card[i][0] ) != 0 && judge ) {
				if ( card[i][0] % 3 != 0 ) {
					judge = false;
				}
				if( judge ) {
					for( int j = 1 ; j <  card[i].length ; j++ ) {
						if ( judge ) {
							if( card[i][j] < 0 ) {
								judge = false;
							} else	if( card[i][j] > 0 ) {
								if( card[i][j] >= 3 ) {
									card[i][j] -= 3;
								}

								if ( card[i][j] != 0 ) {
									if( j == ( card[i].length - 1 ) || j == ( card[i].length - 2 ) ) {
										if ( ( card[i][j] % 3 ) != 0 ) {
											judge = false;
										}
									} else {
										card[i][j+2] -= card[i][j];
										card[i][j+1] -= card[i][j];
									}
								}
							}
						}
					}
				}
			}
		}
		return judge;
	}

	static void judge_output ( boolean judge ) {
		if ( judge ) {
			System.out.println( "1" );
		} else {
		System.out.println( "0" );
		}
	}

	public static void main(String[] args) {

		//勝敗判定 true 勝利 false 敗北
		boolean win_match;
		//データセット数
		int set_num = 0;
		//手持ちのカード数
		int num_of_onhand = 9;
		//カードの数字の最大値
		int card_num_max = 9;
		//色の種類の数
		//色に対応した数字 R=0,G=1,B=2
		int color_num = 3;

		//1つのデータセットのカードの数字 配列nは手持ちn枚目
		int[] input_card_num = new int [num_of_onhand];
		//1つのデータセットのカードの色 配列nは手持ちn枚目
		String[] input_card_color = new String [num_of_onhand];

		//ある色の数字のカード枚数 R1の枚数が1枚 card[0][1]=1;
		//ただし数字0は1つのデータセットの同色の合計数 Rの合計数3枚 card[0][0]=3;
		int[][] card = new int[color_num][card_num_max+1];

		Scanner sc= new Scanner( System.in );

		//データセット数読み込み
		set_num = sc.nextInt();

		//データセットの回数、処理実行
		for ( int i = 0 ; i < set_num ; i++ ) {

			//初期化
			win_match = true;
			init_array ( card );

			//データセット（数字）読み込み
			for ( int j = 0 ; j < num_of_onhand ; j++ ) {
				input_card_num[j] = sc.nextInt();
			}

			//データセット（色）読み込み
			for ( int j = 0 ; j < num_of_onhand ; j++ ) {
				input_card_color[j] = sc.next();
			}

			//データセットを元に色と数字に対応したカードの枚数をセット
			//同色の合計枚数をセット
			set_card_num( input_card_num, input_card_color, card );

			//勝敗判定 true 勝利 false 敗北
			//敗北条件を判定し、一つでも一致したら敗北とみなす
			win_match = judge( card );

			//結果出力
			judge_output ( win_match );

		}
		sc.close();
	}
}



Measured memory_bytes: 29748
def func(li, c):
    for i, n in enumerate(li):
      if n % 2 != 0:
        return c
      else:
        li[i] = n/2
    c+= 1
    return func(li, c)
    
input()
li = list(map(int, input().split()))
print(func(li, 0))

Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string s;
    cin >> s;

    // 岩が2個並んでる場合はNG
    rep(A, i, C)
    {
        if (s.at(i) == '#' && s.at(i + 1) == '#')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(B, i, D)
    {
        if (s.at(i) == '#' && s.at(i + 1) == '#')
        {
            cout << "No" << endl;
            return 0;
        }
    }

    // すぬけ君がふぬけ君を追い抜く時は3マス以上の空きスペースが必要
    if (C > D)
    {
        for (ll i = B - 1; i <= D - 1; i++)
        {
            string ss = s.substr(i - 1, 3);
            if (ss == "...")
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3728