akhauriyash/Code-Regression huggingface dataset:
// not solved by myself

import java.util.*;
import java.util.Map.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        ArrayList<String> Ss = new ArrayList<>();
        if (N == 0){
            System.out.println(0);
            return;
        }

        while(N != 1){
            if (Math.abs(N) % 2 == 1){
                Ss.add("1");
                N = (N - 1) / (-2);
            }else{
                Ss.add("0");
                N /= (-2);
            }
        }
        Ss.add("1");

        ArrayList<String> Ss_list = new ArrayList<>();
        for(int i = 0; i < Ss.size();i++)
            Ss_list.add(Ss.get(i));
        Collections.reverse(Ss_list);


        StringJoiner sj = new StringJoiner("");
        Arrays.stream(Ss_list.toArray()).forEach(s -> sj.add(String.valueOf(s)));

        System.out.println(sj.toString());


    }

    // nCr を求める
    // 第1引数: 列挙対象の配列 n
    // 第2引数: r
    // 第3引数: 答えの組み合わせ配列を保持するための set
    public static <T> void combination(ArrayList<T> n,Integer r,HashSet<ArrayList<T>> ans){
        if (n.size() == r){
            ans.add(n);
            return;
        }

        for(int i = 0; i < n.size(); i++){
            ArrayList<T> N = new ArrayList<>(n);
            N.remove(i);
            combination(N,r,ans);
        }
    }

    public static List<Entry<Integer,Integer>> SortMapByValue(HashMap<Integer,Integer> maps,boolean is_reverse){
        List<Entry<Integer,Integer>> entries = new ArrayList<>(maps.entrySet());

        Collections.sort(entries, new Comparator<Entry<Integer, Integer>>() {
            @Override
            public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
                return (is_reverse ? -1 : 1) * o1.getValue().compareTo(o2.getValue());
            }
        });

       return entries;
    }

     public static long max(int[] ar,int size){
        long max = 0;
        for(int i = 0; i< size;i++)
            if(max < ar[i])
                max = ar[i];
        return max;
    }


    public static long max(List<Long> ar){
        long max = 0;
        for(int i = 0; i< ar.size();i++)
            if(max < ar.get(i))
                max = ar.get(i);
        return max;
    }

    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }


    public static long gcd(long m, long n) {
        if(m == 0)
            return n;
        if(n == 0)
            return m;
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 26956
#include <iostream>

using namespace std;

int main()
{
    int n;
    float c[25],v[25];
    float v_c[25];
    float total_c=0,total_v=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        v_c[i]=v[i]/c[i];
    }
    for(int i=0;i<n;i++)
    {
        //cout<<v_c[i]<<" ";
        if(v_c[i]>1)
        {
            //cout<<"www";
            total_c+=c[i];
            total_v+=v[i];
        }
    }
    cout<<total_v-total_c;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;

signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0)ans+=i;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
  int H,N,sum=0;
  cin>>H>>N;
  int arr[N];
  for(int i=0;i<N;i++){
        cin>>arr[N];
        sum+=arr[N];
    }
    if((H-sum)>0){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }

    return 0;
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

a, b, c, x, y = map(int, input().split())

itr = max(x, y)*2+1

ans = sys.maxsize
for i in range(itr):
    tmpa = max(0, a*(x-i//2))
    tmpb = max(0, b*(y-i//2))
    tmpc = c*i
    tmp_cost = tmpa+tmpb+tmpc
    ans = min(ans, tmp_cost)

print(ans)





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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;




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

    int n,k,d;
    cin >> n >> k;
    vector<bool> a(n,false);
    int s;
    rep(i,k){
        cin >> d;
        rep(j,d){
            cin >> s;
            a[s-1]=true;
        }
    }

    int sum=0;
    rep(i,n){
        if(a[i]==false) ++sum;
    }
    cout << sum << "\n";
}   




Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author P.Alizadeh
 */

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

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

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define trace(x)        cerr << #x << " = " << x << endl;
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 1e5 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7;
//const ld PI   = acos(-1);

ll N, W, w[MAXN], v[MAXN], dp[110][MAXN];

int main()
{
    fastio;
    //ld_io;

    cin >> N >> W;
    for (ll i = 1; i <= N ; i++) {
        cin >> w[i] >> v[i];
    }

    for (ll i = 1; i <= N; i++) {
        for (ll j = 0; j <= MAXN; j++) {
            if (i == 1 && j == 0)
                dp[i][j] = 0;
            else if (w[i] <= j)
                dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    ll ans = -1;
    for (ll i = 0; i <= W; i++) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 81408
import java.util.Scanner;

public class Main {

	private static final int N = 5;

	public static void main(String[] args) {

		int[] arr = new int[N];

		Scanner sc = new Scanner(System.in);

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

		int s = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				if (arr[i] < arr[j]) {
					s = arr[i];
					arr[i] = arr[j];
					arr[j] = s;
				}
			}
			System.out.print(arr[i] + (i < N - 1 ? " " : ""));
		}
		System.out.println(arr[N - 1]);

	}
}

Measured memory_bytes: 17168
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, m = MINF, mn, mi;

int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		if (m < abs(a)) {
			m = abs(a);
			mn = a;
			mi = i + 1;
		}
	}
	cout << 2 * n - 1<< endl;
	if (mn > 0) {
		REP(i, 3)cout << mi << " " << 2 << endl;
		FOR(i, 2, n) {
			REP(j, 2)cout << i << " " << i + 1 << endl;
		}
	}

	else {
		REP(i, 3)cout << mi << " " << n - 1 << endl;
		FORR(i, n - 1, 2) {
			REP(j, 2) cout << i << " " << i - 1 << endl;
		}
	}
}


Measured memory_bytes: 256
def main():
    N=int(input())
    A=[0 for i in range(0,N)]
    for i in range(0,N):
        A[i]=int(input())
    s=max(A)
    index=0
    value=[0 for i in range(0,s+1)]
    for i in range(0,N):
        value[A[i]]+=1
        if A[i]==s:
            index=i
    if value[s]>1:
        for i in range(0,N):
            print(s)
    else:
        for i in range(0,N):
            if i==index:
                A[index]=0
                print(max(A))
            else:
                print(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7 
 
set<int> adj[2005];
int n,k;

int main()
{
    int x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n-1;i++){
        int c,d;c=i;d=i+1;
        adj[c].insert(d);
        adj[d].insert(c);
    }
    adj[x].insert(y);adj[y].insert(x);
    k=n-1;
    int res[2005];
    int dist[2005]; mem(res,0);
    bool vis[2005];
    for(int i=1;i<=n;i++)
    {
    mem(dist,200000);
    mem(vis,0);
    //int temp=1;
    queue<int> q;
    dist[i]=0;
    q.push(i);vis[i]=1;
    while(!q.empty()){
        int node=q.front();
        q.pop();
        for(auto j:adj[node]){
            if(!vis[j] ){
                dist[j]=min(dist[j],dist[node]+1);
                q.push(j);vis[j]=1;
                res[dist[j]]++;
            }
        }
       // temp++;
    }
    }

    for(int i=1;i<=k;i++)
        cout<<res[i]/2<<nl;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    // /A[i] がわかれば3色の人数が決まる
    long long ans = 1;
    vector<int> C(3);  // R, G, B の帽子をかぶっている人の数
    REP(i, N){
        long long cnt = 0, id = -1;
        if(A[i] == C[0]){ ++cnt; id = 0;}
        if(A[i] == C[1]){ ++cnt; id = 1;}
        if(A[i] == C[2]){ ++cnt; id = 2;}
        if(id == -1){
            cout << 0 << endl;
            return 0;
        }
        ans *= cnt;
        ans %= MOD;
        ++C[id];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
int a[5];
for(int i=0;i<5;++i)cin >>a[i];
sort(a,a+5);
cout<<a[4];
for(int i=4-1;i>=0;--i)
cout<<" "<<a[i];
cout<<endl;
return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#define maxn 10000+10

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while ( A[i]  != key ) i++;
	return i != n;
}

int main() {
	int A[maxn], n, q, temp, sum = 0;
	scanf("%d", &n);
	for( int i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for( int i = 0; i < q; i++) {
		scanf("%d", &temp);
		if( search(A, n ,temp) ) sum++; 
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) x.begin(), x.end()
bool isPowerOfTwo(int n)
{
    return (ceil(log2(n)) == floor(log2(n)));
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(i%2!=0&&x%2!=0){
            ans++;
        }

    }
    cout<<ans<<endl;



    return 0;

}


Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

#include <numeric>
using namespace std;

bool check(long long Ind, vector<long long> &v){
	//前から順番に食っていく、食えなくなったらfalse
	long long nowSize = v[Ind];
	for (long long i = 0; i < v.size(); i++){
		if (v[i] <= nowSize * 2 ){
			//食えるなら食う
			if (i == Ind) continue;
			nowSize += v[i];
		}
		else return false;	//食えない奴がいたら一番にはなれない
	}
	return true;
}

int main(){
	long long N;
	vector<long long> A;
	cin >> N ;
	for (long long i = 0; i < N; i++){
		long long inp;
		cin >> inp;
		A.push_back(inp);
	}
	std::sort(A.begin(), A.end());
	//方針:そいつが一番になれるかは前から貪欲に食っていけばO(N)で判別可能、サイズSの奴が一番になれるなら自明にサイズSより大きい奴は一番になれるので、境界を二分探索。
	//binsearch
	long long left, right;
	left = 0;
	right = (long long)A.size()-1;
	while (right - left != 1){
		long long mid = (left + right) / 2;
		if (check(mid,A)) right = mid;
		else left = mid;
	}
	long long ans =  check(left,A) ? left : right;
	cout << A.size() - ans << endl;



	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n, time;
  cin >> n >> time;
  int c[n], t[n];
  for(int i = 0; i < n; i++){
    cin >> c[i] >> t[i];
  }

  int mi = INF_INT;
  for(int i = 0; i < n; i++){
    if(t[i] <= time) mi = min(mi, c[i]);
  }

  if(mi != INF_INT) cout << mi << endl;
  else cout << "TLE" << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
a = [0]*n
for i, youso in enumerate(b):
    a[i] = youso
    a[i+1] = youso
    if i == 0:
        pass
    elif b[i-1] < youso:
        a[i] = b[i-1]
print(sum(a))

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 300 + 10;
int h[N];
int64 dp[N][N][N];
int n;

int64 solve(int pos, int kill, int last) {
  if (pos == n + 1) return 0;
  int64& ret = dp[pos][kill][last];
  if (ret >= 0) return ret;
  ret = 1LL << 60;
  if (kill > 0) ret = min(ret, solve(pos + 1, kill - 1, last));
  if (h[pos] > h[last]) {
    ret = min(ret, solve(pos + 1, kill, pos) + h[pos] - h[last]);
  } else {
    ret = min(ret, solve(pos + 1, kill, pos));
  }
  return ret;
}

int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &h[i]);
  }
  memset(dp, 255, sizeof(dp));
  int64 ret = solve(1, m, 0);
  printf("%lld\n", ret);
  return 0;
}


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

int N,T;
int t[200005],s[200005];

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

for(int i=0; i<N; i++){
    scanf("%d",&t[i]);
    s[i]=t[i]+T;
}

int Sum=s[N-1];
for(int i=1; i<N; i++){
    if(s[i-1]<t[i]) Sum-=(t[i]-s[i-1]);
}

cout<<Sum<<endl;

}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 7;
const LL LINF = INF * INF;

const int mod = 1e9 + 7;

inline int add(int x, int y)
{
	if (x + y >= mod)
		return x + y - mod;
	return x + y;
}

inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

const int MAX = 1 << 10;
int n, m;
int dp[MAX][MAX];
string s[MAX];

bool ok(int x, int y)
{
	return x >= 0 && x < n && y >= 0 && y < m && s[x][y] == '.';
}

int get(int x, int y)
{
	if (!ok(x, y))
		return 0;
	
	if (x == n - 1 && y == m - 1)
		return 1;
	
	if (dp[x][y] != -1)
		return dp[x][y];
	
	return dp[x][y] = add(get(x + 1, y), get(x, y + 1));
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n >> m;
	FOR(i, 0, n)
		cin >> s[i];
	
	FILL(dp, -1);
	cout << get(0, 0) << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
static const int MAX = 2e5 + 6;

int main() {
  int n;
  cin >> n;
  double a[n];
  double ans = 0.0;

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

  for (int i = 0; i < n; i++) {
    ans = ans + (double)(1 / a[i]);
  }
  printf("%.10f", (double)(1/ans));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int desc(const void *a, const void *b)
{
    if(*(long*)a - *(long*)b < 0) 
     return 1; 
    if(*(long*)a - *(long*)b > 0) 
     return -1; 
}

int main()
{
    int i;
    int n, k;
    long h[200010] = {0};
    long long ans = 0;
    scanf("%d%d", &n, &k);
    for(i = 0; i < n; i++){
        scanf("%ld", &h[i]);
    }
    qsort(h, n, sizeof(long), desc);
    for(i = k; i < n; i++){
        ans += h[i];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3324
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    vector<int> v(4);
    for(int i=0; i<4; ++i){
        char c;
        cin >> c;
        v[i] = c - '0';
    }

    for(int i=0; ; ++i){
        bitset<3> bs(i);
        int a = v[0];
        for(int j=1; j<4; ++j){
            if(bs[j-1])
                a += v[j];
            else
                a -= v[j];
        }

        if(a == 7){
            cout << v[0];
            for(int j=1; j<4; ++j){
                if(bs[j-1])
                    cout << '+';
                else
                    cout << '-';
                cout << v[j];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
def input_list():
  return list(map(int, input().split()))


def main():
  s = list(input())
  k = int(input())
  if len(set(s)) == 1:
    print(int(len(s)*(k/2)))
    exit()
  
  sw = [s[0]]
  num = 0
  numbers = [num]
  for i in range(1, len(s)):
    if s[i-1] != s[i]:
      num += 1
    numbers.append(num)
    if num == 0 and sw[0] == s[i]:
      sw.append(s[i])

  num = 0
  end_w = s[-1]
  ew = []
  for i in range(len(s)-1, -1, -1):
    if end_w != s[i]:
      num += 1
    if num == 0 and end_w == s[i]:
      ew.append(s[i])
  nc = collections.Counter(numbers)
  
  a = 0
  for n,c in nc.items():
    if c == 1:
      continue
    if c % 2 == 0:
      a += c // 2
    else:
      a += (c-1)//2
  
  ans = a * k
  b = 0
  if ew[0] == sw[0]:
    haji = len(sw) + len(ew)
    if haji % 2 == 0:
      print(a * k + (k-1))
      exit()
  print(ans - b)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 63980
import math

N=int(input())
P=[list(map(int,input().split())) for i in range(N)]

def culc(L,R):
    return math.sqrt((L[0]-R[0])**2+(L[1]-R[1])**2)

sum=0
for j in range(1,N):
    for k in range(j):
        sum+=culc(P[j],P[k])


ans=2*sum/N
print(ans)






Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var m = cin.nextInt();
            var x = cin.nextInt();
            var a = cin.ArrayInt(m);

            var r = 0;
            var l = 0;
            for (int i = 0; i <= n; i++)
            {
                if (i < x)
                {
                    if (a.Contains(i)) l++;
                }
                else
                {
                    if (a.Contains(i)) r++;
                }
            }
            Console.WriteLine(Math.Min(r,l));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void print(T x){cout << x << endl;}
template<class T>void printvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    ll n; cin >> n;

    if(n==2) {print(1); return 0;}

    ll ans=2;
    ll sqn = (ll)sqrt(n);
    vector<bool> ismod1(sqn+1, false);

    ll next;
    for(ll i=2; i<=sqn; i++){
        // printf("\n%d: ",i);
        ll mod = n%i;
        if(mod==1){
            // printf("1: %lld %lld\n", i, (n-1)/i);
            if((n-1)/i == i) ans++;
            else ans+=2;
            ismod1[i]=true;
            continue;
        }

        if(mod==0){
            next = n;
            while(mod==0) {
                next /= i;
                mod = next%i;
            }
            if(mod==1) ans++;
        }

    }

    print(ans);
    return 0;
}

Measured memory_bytes: 3816
#include<cstdio>
#include<cctype>
#include<algorithm>
typedef long long int64;
inline int64 getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int64 x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
const int N=3e5+1,mod=998244353;
int fac[N],ifac[N];
void exgcd(const int &a,const int &b,int &x,int &y) {
	if(!b) {
		x=1,y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}
inline int inv(const int &x) {
	int ret,tmp;
	exgcd(x,mod,ret,tmp);
	return (ret%mod+mod)%mod;
}
inline int power(int a,int k) {
	int ret=1;
	for(;k;k>>=1) {
		if(k&1) ret=(int64)ret*a%mod;
		a=(int64)a*a%mod;
	}
	return ret;
}
inline int C(const int &n,const int &m) {
	return (int64)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
	int n=getint(),a=getint(),b=getint();
	int64 k=getint();
	for(register int i=fac[0]=1;i<=n;i++) {
		fac[i]=(int64)fac[i-1]*i%mod;
	}
	ifac[n]=inv(fac[n]);
	for(register int i=n;i>=1;i--) {
		ifac[i-1]=(int64)ifac[i]*i%mod;
	}
	if(a==0&&b==0) {
		if(k!=0) {
			puts("0");
			return 0;
		}
		printf("%d\n",power(4,n));
		return 0;
	}
	if(a==0||b==0) {
		if(a==0) std::swap(a,b);
		if(k%a!=0||k/a>n) {
			puts("0");
			return 0;
		}
		printf("%lld\n",(int64)C(n,k/a)*power(2,k/a)%mod*power(2,n-k/a)%mod);
		return 0;
	}
	int ans=0;
	for(register int i=0;i<=n&&(int64)a*i<=k;i++) {
		if((k-(int64)a*i)%b!=0) continue;
		const int64 j=(k-(int64)a*i)/b;
		if(j>n) continue;
		(ans+=(int64)C(n,i)*C(n,j)%mod)%=mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    char[] s = scanner.next().toCharArray();

    int max = 0;
    int j = 1;
    int numZeros = 0;
    for (int i = 0; i < N; i++) {
      if (i > 0 && s[i - 1] == '0' && s[i] == '1') numZeros--;
      while (numZeros < K && j < N) {
        if (s[j - 1] == '0' && s[j] == '1') numZeros++;
        j++;
      }
      while (j < N && s[j] == '1') j++;
      max = Math.max(max, j - i);
    }
    System.out.println(max);
  }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

vector<li> edge[100100];
li n, m;

int main() {
    cin >> n >> m;
    rep(i, m) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    puts("Yes");
    queue<pair<li, PI>> q;
    vector<li> dist(n, INF);
    q.push({0, {0, -1}});
    vector<li> res(n);
    while (!q.empty()) {
        li now = q.front().S.F;
        li prev = q.front().S.S;
        li now_dist = q.front().F;
        q.pop();
        if (dist[now] != INF) {
            continue;
        }
        dist[now] = now_dist;
        res[now] = prev + 1;
        for (auto next : edge[now]) {
            q.push({now_dist + 1, {next, now}});
        }
    }
    repp(i, 1, n) {
        cout << res[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 20232
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

	
int main(){
	ll q,h,s,d;
	ll n;
	cin>>q>>h>>s>>d;
	cin>>n;
	ll x=min(q*2,h);
	x=min(x*2,s);
	if(x*2<d)cout<<x*n<<endl;
	else cout<<((n/2)*d)+((n%2)*x)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
				using namespace std;
				#define ll long long
				#define mod 1000000007
				#define pll pair<long,long>
				#define se second
				#define fi first
				#define pb push_back
				#include <ext/pb_ds/assoc_container.hpp>
				#include <ext/pb_ds/tree_policy.hpp>
				using namespace __gnu_pbds;

				typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
				typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
				
			
				
				int main()
				{
					ios_base::sync_with_stdio(false);
					cin.tie(NULL);
					
					double l;
					cin>>l;
					double r1=l/3.0;
					double ans=r1*r1*r1;
					printf("%0.10f",ans);
				}
				


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

int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	int ci[5];
	ci[a]++;
	ci[b]++;
	ci[c]++;
	ci[d]++;
	ci[e]++;
	ci[f]++;
	int ans=0;
	for(int i=1;i<5;i++)
		if(ci[i]%2!=0)
			ans++;
	if(ans>2)
		cout<<"NO";
	else
		cout<<"YES";
}

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

 int main() {
   int y,m,d;
   char S,S1;
   cin >> y >> S >> m >> S1 >>d;
  // cout << y << S << m << S1 << d << endl;
   cout << (m <= 4 ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
N = gets.to_i
a = Array.new(N)
for i in 0..N-1
    a[i] = gets.to_i
end
b = a.clone
b.sort!
c = a.count(b[N-1])

if c == 1
    for i in 0..N-1
        if a[i] == b[N-1]
            puts b[N-2]
        else
            puts b[N-1]
        end
    end
else
    for i in 0..N-1
        puts b[N-1]
    end
end



    

Measured memory_bytes: 9820
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

import bisect

n = I()
a = LI()
q = I()

cnt = [0]*1000000
for i in a:
    cnt[i] += 1
sm = sum(a)

for i in range(q):
    b,c = LI()
    sm += (c-b)*cnt[b]
    if(c != b):
        cnt[c] += cnt[b]
        cnt[b] = 0
    print(sm)

Measured memory_bytes: 91024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

int main() {
	ll N;
  cin >> N;
  vector<ll> V(N);
  
  ll pre = 0;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    ll ai;
    cin >> ai;
    
    if (pre < ai) {
      ai--;
    }
    if (pre > ai) {ok = false;}
   	pre = ai;
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    double n;
    cin >> n;
    cout << setprecision(13) << pow(n / 3, 3);
}


Measured memory_bytes: 4152
sougou,heikin=[],[]
t=" "
while True:
  try:
    ans = raw_input()
    ans+=t
    for i in range(len(ans)):
      if ans[i] == ",":
        sougou.append(int(ans[:i]))
        heikin.append(int(ans[i+1:]))
  except EOFError:  break 
a,b=0,0
for i in range(len(heikin)):
  a+=heikin[i]*sougou[i]
  b+=heikin[i]
if float(b)/len(heikin)> int(float(b)/len(heikin)):
  c = int(float(b)/len(heikin))+1
else: c = int(b)
if __name__ == '__main__':
  print "%d\n%d"%(a,c)

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n, k;
int a[N], b[N], c[N];
int dp[N][5];

int f(int idx, int now) {
    if(idx > n) return 0;
    int &sol = dp[idx][now];
    if(sol != -1) return sol;
    if(!now) {
        sol = max(f(idx + 1, 1) + a[idx + 1], 
              max(f(idx + 1, 2) + b[idx + 1], 
                  f(idx + 1, 3) + c[idx + 1]));
    } else if(now == 1) {
        sol = max(f(idx + 1, 2) + b[idx + 1],
                  f(idx + 1, 3) + c[idx + 1]);
    } else if(now == 2) {
        sol = max(f(idx + 1, 1) + a[idx + 1],
                  f(idx + 1, 3) + c[idx + 1]);
    } else {
        sol = max(f(idx + 1, 1) + a[idx + 1],
                  f(idx + 1, 2) + b[idx + 1]);
    }
    return sol;
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(0, 0) << "\n";
}

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

Measured memory_bytes: 13020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int x = in.nextInt();
        int y = in.nextInt();
        int z = in.nextInt();
        out.println(z, x, y);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 24788
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        if(n<=k){
            System.out.println(n*x);
        }
        else if(n>k){
            System.out.println(k*x + (n-k)*y);
        }
    }
}

Measured memory_bytes: 23764
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.map!(to!size_t), r = rd[0], c = rd[1];
  auto tij = r.iota.map!(_ => readln.split.map!(to!int).array).array;

  auto sij = new int[][](r + 1, c + 1);
  foreach (i; 0..r) sij[i][] = tij[i][] ~ 0;

  foreach (i; 0..r) sij[i][$-1] = tij[i].sum;
  foreach (j; 0..c) sij[$-1][j] = tij.transversal(j).sum;
  sij[$-1][$-1] = sij[$-1][0..c].sum;

  sij.each!(si => si.map!(to!string).join(" ").writeln);
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int ans, sum, n, z;
 
void subsetsum(int x, int y)
{
  for(int i = x; i <= z; i++){
    if(y){
      sum += i*i;
      if(sum > n){
        sum -= i*i;
        return;
      }else if(sum == n){
        ans++;
        sum -= i*i;
        return;
      }
      subsetsum(i,y-1);
      sum -= i*i;
    }else{
      return;
    }
  }
}
 
int main()
{
  while(1){
    ans = sum = 0;
    scanf("%d", &n);
    if(n == 0) break;
    z = (int)sqrt(n);
    subsetsum(1,4);
    printf("%d\n", ans);
  }
}

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

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

  if((int)a==(int)b)
  	cout<<"="<<endl;
  else if((int)a>(int)b)
  	cout<<">"<<endl;
  else
  	cout<<"<"<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n;
  cin >> n;
  set<char> st;
  rep(i,n) {
    char c;
    cin >> c;
    st.insert(c);
  }
  cout << (st.size() == 3 ? "Three" : "Four") << endl;
  return 0;
} 

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

import sys
input=sys.stdin.readline

def judge(k):
    if k%2==0 or k%5==0:
        print(-1)
    else:
        tmp=0
        for i in range(10**6):
            tmp+=7
            tmp%=k
            if tmp==0:
                print(i+1)
                break
            else:
                tmp*=10

k=int(input())
judge(k)

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> vec(2*n);
  rep(i,2*n) cin >> vec[i];
  sort(ALL(vec));
  int ans = 0;
  rep(i,2*n) if( !( i & 1 ) ) ans += vec[i];
  cout << ans << endl;
  compute();
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		int[] arr = new int[6];
		for (int i = 0; i < 6; i++) {
			arr[i] = Integer.parseInt(strArr[i]);
		}
		Dice dice = new Dice(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
		int q = Integer.parseInt(br.readLine());
		for(int i = 0;i < q;i++){
			strArr = br.readLine().split(" ");
			int top = Integer.parseInt(strArr[0]);
			int front = Integer.parseInt(strArr[1]);
			dice.top(dice.getIndex(top));
			while(front != dice.getFront()){
				dice.turn();
			}
			System.out.println(dice.getRight());
		}
	}

}

class Dice {
	int[] num;

	{
		num = new int[6];
	}

	Dice(int a, int b, int c, int d, int e, int f) {
		super();
		num[0] = a;
		num[1] = b;
		num[2] = c;
		num[3] = d;
		num[4] = e;
		num[5] = f;
	}

	public int getTop() {
		return new Integer(num[0]);
	}

	public int getFront(){
		return new Integer(num[1]);
	}

	public int getRight(){
		return new Integer(num[2]);
	}


	public int getIndex(int n){
		for(int i = 0;i < num.length;i++){
			if(n == num[i])
				return i;
		}
		return -1;
	}

	void roll(String s) {
		for (int i = 0; i < s.length(); i++) {
			roll(s.charAt(i));
		}
	}

	void roll(char c) {
		int[] temp = new int[6];
		switch (c) {
		case 'N':
			temp[0] = num[1];
			temp[1] = num[5];
			temp[2] = num[2];
			temp[3] = num[3];
			temp[4] = num[0];
			temp[5] = num[4];
			break;
		case 'W':
			temp[0] = num[2];
			temp[1] = num[1];
			temp[2] = num[5];
			temp[3] = num[0];
			temp[4] = num[4];
			temp[5] = num[3];
			break;
		case 'E':
			temp[0] = num[3];
			temp[1] = num[1];
			temp[2] = num[0];
			temp[3] = num[5];
			temp[4] = num[4];
			temp[5] = num[2];
			break;
		case 'S':
			temp[0] = num[4];
			temp[1] = num[0];
			temp[2] = num[2];
			temp[3] = num[3];
			temp[4] = num[5];
			temp[5] = num[1];
			break;
		default:
		}
		num = temp;
	}

	void top(int index){
		switch(index){
		case 0:
			return;
		case 1:
			roll("N");
			return;
		case 2:
			roll("W");
			return;
		case 3:
			roll("E");
			return;
		case 4:
			roll("S");
			return;
		case 5:
			roll("NN");
			return;
		}
	}

	void turn(){
		roll("ESW");
	}

}

Measured memory_bytes: 16928
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg



int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string>s(h);
	REP(i, h) cin >> s[i];
	int ans = 0;

	REP(is, 1 << h) {
		REP(js, 1 << w) {
			int cnt = 0;
			REP(i, h) {
				REP(j, w) {
					if (is >> i & 1) continue;
					if (js >> j & 1) continue;
					if (s[i][j] == '#') cnt++;
				}
			}
			if (cnt == k) ans++;
		}
	}

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



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

if (n < 105):
   print(0)
   exit()

i = 105
ok = 0
while i <= n:
   x = [j for j in range(1, n+1) if i % j == 0]
   if (len(x) == 8):
      ok += 1
   i += 2
print(ok)


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    ans = N*(N+2)*(N+1)/6;
    for(int i=0;i<N-1;i++) {
        ll u, v;
        cin >> u >> v;
        if(u>v) swap(u,v);
        ans -= (N+1-v)*u;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616