akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

typedef unsigned long long ull;
const int INFTY = 1 << 30;


int main()
{
    int D, G;
    cin >> D >> G;

    vector< pair<int, int> > cp(D);
    for(int i=0;i<D;i++){
        cin >> cp.at(i).first >> cp.at(i).second;
    }

    ull value;
    int num, ans = INFTY, n;
    for(int i=0;i<(1<<D);i++){
        value = num = 0;
        for(int j=0;j<D;j++){
            if((i >> j) & 1){
                value += cp.at(j).first * 100 * (j+1);
                value += cp.at(j).second;
                num += cp.at(j).first;
            }
        }
        if(ans <= num) continue;
        if(G <= value){
            ans = num < ans ? num : ans;
            continue;
        }
        for(int j=D-1;j>-1;j--){
            if((i >> j) & 1) continue;
            n = (G - value - 1) / (100 * (j+1)) + 1;
            if(n <= (cp.at(j).first-1)){
                value += n * 100 * (j+1);
                num += n;
                break;
            }
            else{
                value += 100 * (j+1) * (cp.at(j).first - 1);
                num += cp.at(j).first - 1;
            }
        }
        if(value >= G){
            ans = num < ans ? num : ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys,math
input=sys.stdin.readline
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(360):
    x=math.cos(2*math.pi*i/360)
    y=math.sin(2*math.pi*i/360)
    ax=0
    ay=0
    for dx,dy in xy:
        if x*dx+y*dy>=0:
            ax+=dx
            ay+=dy
    ans=max(ans,(ax**2+ay**2)**0.5)
print(ans)


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

int main(){
    int N;
    cin >> N;
    int arrival_time;
    int leave_time;
    vector<int> C(N-1);
    vector<int> S(N-1);
    vector<int> F(N-1);
    for (int i = 0; i < N - 1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 0; i < N; i++){
        if (i == N - 1){
            cout << 0 << endl;
            break;
        }
        for (int j = i; j < N - 1; j++){
            if (j == i){
                arrival_time = S[j] + C[j];
            }else{
                leave_time = S[j];
                while(leave_time < arrival_time){
                    leave_time += F[j];
                }
                arrival_time = leave_time + C[j];
            }
        }
        cout << arrival_time << endl;
    }
}


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

using namespace std;

int solve(string &s, string &t, vector<vector<int>> &pos, vector<vector<int>> &dp, int m, int n){
    if(m < 0 || n < 0){
        return 0;
    }
    if(dp[m][n] != -1){
        return dp[m][n];
    }
    if(s[m] == t[n]){
        pos[m][n] = 0;
        return dp[m][n] = 1 + solve(s, t, pos, dp, m-1, n-1);
    }
    else{
        if(solve(s, t, pos, dp, m-1, n) > solve(s, t, pos, dp, m, n-1)){
            pos[m][n] = 1;
            return dp[m][n] = solve(s, t, pos, dp, m-1, n);
        }
        else{
            pos[m][n] = 2;
            return dp[m][n] = solve(s, t, pos, dp, m, n-1);
        }
    }

}

string print(string &s, string &t, int m, int n, vector<vector<int>> &pos){
    if(m < 0 || n < 0){
        return "";
    }
    if(pos[m][n] == 0){
        string temp = print(s, t, m-1, n-1, pos);
        temp.push_back(s[m]);
        return temp;
    }
    else if (pos[m][n] == 1){
        return print(s, t, m-1, n, pos);
    }
    else{
        return print(s, t, m, n-1, pos);
    }
}

int main(){
    string s, t;
    cin>>s>>t;
    vector<vector<int>> pos(s.length(), vector<int> (t.length(), -1));
    vector<vector<int>> dp(s.length(), vector<int> (t.length(), -1));
    solve(s, t, pos, dp, s.size()-1, t.size()-1);
    cout<<print(s, t, s.size()-1, t.size()-1, pos);
    return 0;
}

Measured memory_bytes: 74536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define line_buf 1024
#define ll long long

int main(){

    ll int i,j,k;
    ll int A,B,C,X,Y,N,count;
    char line[line_buf];
    int flag = 0;

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%lld %lld %lld %lld %lld",&A,&B,&C,&X,&Y);

    ll int ans = 0;
    ll int tmp,tmp_c;

    if(X<Y){    /* X > Yとして進める */
        tmp = X;
        tmp_c = A;
        X = Y;
        A = B;
        Y = tmp;
        B = tmp_c;
        flag  = 1;
    }

    if(A+B < 2*C){      /*ABピザの方がたかい*/
        ans = Y*(A+B);
    }

    else{
        ans = Y*2*C;
    }

    /*残りX-Yまい*/

    if(A<2*C){
        printf("%lld",ans+(X-Y)*A);
        return 0;
    }

    else{
        printf("%lld",ans+(X-Y)*2*C);
        return 0;
    }

}


Measured memory_bytes: 128
use std::str::FromStr;

fn main() {
    let xs = read_vec_i32();

    if solve(xs) {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn solve(xs : Vec<i32>) -> bool {
    let mut ys = xs;
    ys.sort();
    if ys == [5, 5, 7] {
        return true;
    } else {
        return false;
    }
}

fn read_vec_i32() -> Vec<i32> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().split(' ').map(|s| i32::from_str(s).unwrap()).collect()
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 300007;

void failure(){cout<<"No"<<lf;exit(0);}

struct tla
{
#define lb(a) ((a)&(-(a)))
	lint t[_];
	void add(int x,lint d){while(x)t[x]+=d,x-=lb(x);}
	lint sum(int x){lint d=0;while(x<_)d+=t[x],x+=lb(x);return d;}
	void cls(){memset(t,0,sizeof(t));}
#undef lb
}t;

int n,val[_],ps[_],lps;

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();

	for(int i=1;i<=n;i++)if((val[i]&1)!=(i&1))failure();

	lint ce=0,co=0,cc=0;
	t.cls();
	for(int i=1;i<=n;i+=2)co+=t.sum(val[i]),t.add(val[i],1);
	t.cls();
	for(int i=2;i<=n;i+=2)ce+=t.sum(val[i]),t.add(val[i],1);
	t.cls();
	for(int i=1;i<=n;i++)cc+=t.sum(val[i]),t.add(val[i],1);
	
	if(cc!=3*(ce+co))failure();

	cout<<"Yes"<<lf;

	return 0;
}


Measured memory_bytes: 3840
time = 0
dishes = [int(input()) for _ in range(5)]
lead_times = [0] * 5
long_time = 0
last_dish = 0

for i in range(5):
    lead_times[i] = (10 - (dishes[i] % 10)) % 10
    if lead_times[i] > long_time:
        last_dish = i
        long_time = lead_times[i]

for i in range(5):
    time += dishes[i]
    if i != last_dish:
        time += lead_times[i]

print(time)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll a(N);
        rep(i, 0, N) cin >> a[i];
        //sort(all(a));
        vll acc(N+1);
        rep(i, 1, N+1) {
                acc[i] += acc[i-1] + a[i-1];
        }
        ll mn = inf;
        rep(i, 1, N) {
                ll s1 = acc[i] - acc[0];
                ll s2 = acc[N] - acc[i];
                chmin(mn, abs(s1 - s2));
        }
        cout << mn << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<pair<ll,ll>> r(n),b(n);
  for(ll i=0;i<n;i++)
    cin>>r[i].first>>r[i].second;;
  for(ll i=0;i<n;i++)
    cin>>b[i].first>>b[i].second;
  sort(r.begin(),r.end());
  sort(b.begin(),b.end());
  multiset<ll> pts;
  ll ans =0;
  ll i,j;
  for(i=0,j=0;i<n && j<n;){
    if(r[i]<b[j])
    	{pts.insert(r[i].second);i++;}
    else if(pts.lower_bound(b[j].second) != pts.begin())
    {ans++;pts.erase(--(pts.lower_bound(b[j].second)));j++;}
    else {j++;}
  }
  while(j<n){
  	if(pts.lower_bound(b[j].second) != pts.begin())
    {ans++;pts.erase(--(pts.lower_bound(b[j].second)));j++;}
    else {j++;}
  }
  cout<<ans;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define sz(a) (int)(a).size()

using namespace std;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> arr(n);
	long long ans=0;
	for(int i=0; i<n; i++){
		cin>>arr[i].first>>arr[i].second;
		ans += arr[i].second;
	}
	vector<long long>dp(ans+1,1e18);
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int v = ans-arr[i].second ; v>=0 ;--v){
			uin(dp[v+arr[i].second],dp[v]+arr[i].first);
		}
	}
	ans=0;
	for(long long v = sz(dp)-1 ; v>=0; v-- ){
		//cout<<dp[v]<<" "<<v<<endl;
		if(dp[v]<=m)
			uax(ans,v);
	}

	cout<<ans<<endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif	
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();

        final long[] array = new long[n + 1];
        Arrays.fill(array, 1);

        final int[] values = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            values[i] = i;
        }

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (values[i] == 1) {
                continue;
            }

            for (int j = 1; j * i <= n; j++) {
                int count = 1;
                while (values[i * j] % i == 0) {
                    values[i * j] /= i;
                    count++;
                }
                array[i * j] *= count;
            }
        }

        final long answer = IntStream.rangeClosed(1, n)
            .mapToLong(i -> i * (array[i] * (values[i] > 1 ? 2 : 1)))
            .sum();
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

Measured memory_bytes: 154272
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    
    int a,b;
    cin >> a >> b;
    
    if(a == b){
        cout << "Draw" << endl;
        return 0;
    }
    
    if(a == 1) a += 14;
    if(b == 1) b += 14;
    
    
    if( a < b )
    cout << "Bob" << endl;
    else
    cout << "Alice" << endl;
    
    
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << endl;
    }
    else {
        k = k - a;
        if(b >= k){
            cout << a << endl;
        }
        else
        {
            cout << a - (k - b) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

class T {
public:
	string first;
	int second;
	int num;
	T(string s, int i1, int i2) :first(s), second(i1), num(i2) {};
};
bool operator<(T a, T b) {
	for (int i = 0; i < min(a.first.size(), b.first.size()); i++) {
		if (a.first[i] < b.first[i])return true;
		else if (a.first[i] > b.first[i])return false;
	}
	if (a.first.size() != b.first.size())return a.first.size() < b.first.size();
	return a.second > b.second;
}

int N;
vector<T> vec;

void solve() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		int p;
		cin >> s >> p;
		vec.push_back(T(s,p,i));
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < N; i++) {
		cout << vec[i].num + 1 << endl;
	}
	return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);
    
    int n; cin >> n;
    if(n%2 == 0) cout << (n/2) / (double)n << endl;
    else cout << (n/2 + 1) / (double)n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll A, B, X;
  cin >> A >> B >> X;

  if (A + B < X) {
    COUT("NO");
    return 0;
  }
  if (A > X) {
    COUT("NO");
    return 0;
  }
  COUT("YES");
  return 0;
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] e=new int [12];
        for(int i=0; i<12; i++) {
        	e[i]= sc.nextInt();
        }
        Arrays.sort(e);
        if(e[0]==e[1] && e[0]==e[2] && e[0]==e[3] && e[4]==e[5] && e[4]==e[6] && e[4]==e[7] && e[8]==e[9] && e[8]==e[10] && e[8]==e[11])
        	System.out.println("yes");
        else
        	System.out.println("no");
	}
}


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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputString = br.readLine().split(" ");

            int sandglassAvailableSecond = Integer.parseInt(inputString[0]);
            int elapsedSecond = Integer.parseInt(inputString[1]);

            int remainingQuantity = elapsedSecond >= sandglassAvailableSecond ? 0
                    : sandglassAvailableSecond - elapsedSecond;

            System.out.println(remainingQuantity);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

using namespace std;

int n, a[100005];
long long total = 0;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), total += abs(a[i] - a[i - 1]);
  total += abs(a[n]);
  for (int i = 1; i <= n; i++)
    printf("%lld\n", total - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]));
}


Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, m;
    cin >> n >> m;

    int c[m];
    fill(c, c+m, 0);

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

    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (c[i] == n) {
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
x,y,a,b,c = [int(e) for e in input().split()]
p = [int(e) for e in input().split()]
q = [int(e) for e in input().split()]
r = [int(e) for e in input().split()]
p.sort()
p.reverse()
q.sort()
q.reverse()
r.sort()
r.reverse()
sp = 0
sq = 0
for i in range(0,x):
    sp += p[i]
for i in range(0,y):
    sq += q[i]
ma = sp + sq
index = 0
while index < c:
    if p[x-1] < q[y-1] or y == 0:
        if r[index] > p[x-1]:
            ma += r[index]-p[x-1]
            index += 1
            x -= 1
        else:
            break
    else:
        if r[index] > q[y-1]:
            ma += r[index]-q[y-1]
            index += 1
            y -= 1
        else:
            break
print(ma)

Measured memory_bytes: 23340
// abc148_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;

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

    ll ans = 0;
    ll n = N / 2;
    REP(i, 40){
        n /= 5;
        ans += n;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 256
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            if h[i] > 0:
                H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
                if needH == -1:
                    needH = H
                else:
                    if needH != H:
                        needH = -2
                        break
            else:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                # distの方が大きくなければいけない
                if needH > dist:
                    needH = -2
                    break

        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum=0;
    while(k>0)
    {
        ll x=min(k,a);
        k-=x;
        sum+=(x);
        if(k==0)
            break;
        x=min(k,b);
        k-=x;
        if(k==0)
            break;
        x=min(k,c);
        k-=x;
        sum-=(x);
        if(k==0)
            break;

    }
    cout<<sum<<endl;





}


Measured memory_bytes: 3540
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {
  int n;
  cin >> n;
  vector<int> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  int sum = accumulate(s.begin(), s.end(), 0);
  for(int i=0; i<n; i++){
    if( sum % 10 != 0 ){
      cout << sum << endl;
      return 0;
    }else if( s[i] % 10 == 0 ){
      continue;
    }else{
      sum -= s[i];
    }
  }
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<usize> = sc.vec(n);

    let mut count = vec![0i64; 200002];
    for &x in xs.iter() {
        count[x] += 1;
    }

    let mut p = vec![0i64; 200002];
    let mut ans: i64 = 0;
    for i in 0..200002 {
        p[i] = count[i] * (count[i] - 1) / 2;
        ans += p[i];
    }

    for &x in xs.iter() {
        let q = (count[x] - 2) * (count[x] - 1) / 2;
        // trace!(ans, count[x], q);
        put!(ans - p[x] + q);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

int main(){
	ll a[5],ans=0,num=10;
	for(int i=0;i<5;i++){
		cin>>a[i];
		ans+=(a[i]+9)/10*10;
		ll x=a[i]%10;
		if(!x)x=10;
		num=min(num,x);
	}
	ans+=num-10;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define rev reverse
#define o 300005
using namespace std;
ll f[o],f1[o],f2[o],sum[o];
ll top,S[o],T[o],y[o],tmp[o];
int n,m;
void Init(ll *f){
	f[0]=0;top=0;S[++top]=0;
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+T[i];
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1];
		while(top>1&&y[S[top]]-y[S[top-1]]<=2ll*i*(S[top]-S[top-1]))top--;
		f[i]=max(f[i],f[S[top]]+(i-S[top])*(i-S[top]+1)/2ll-sum[i]+sum[S[top]]);
		y[i]=i*i-i+2ll*sum[i]+2ll*f[i];
		while(top>1&&(y[S[top]]-y[S[top-1]])*(i-S[top-1])<=(y[i]-y[S[top-1]])*(S[top]-S[top-1])) top--;
		S[++top]=i;
	}
}
void solve(ll *f1,ll *f2,int l,int r){
	if(l==r){
		f[l]=max(f[l],f1[l-1]+f2[l+1]-T[l]+1);
		return;
	}
	int mid=(l+r)>>1;
	top=0;
	for(ll i=l-1;i<mid;i++){
		y[i]=i*i-i+2*f1[i]+2*sum[i];
		while(top>1&&(y[S[top]]-y[S[top-1]])*(i-S[top-1])<=(y[i]-y[S[top-1]])*(S[top]-S[top-1])) top--;
		S[++top]=i;
	} 
	for(ll i=mid;i<=r;i++){
		while(top>1&&y[S[top]]-y[S[top-1]]<=2ll*i*(S[top]-S[top-1]))top--;
		tmp[i]=f2[i+1]+f1[S[top]]-sum[i]+sum[S[top]]+(i-S[top])*(i-S[top]+1)/2ll;
	}
	for(int i=r-1;i>=mid;i--) tmp[i]=max(tmp[i],tmp[i+1]);
	for(int i=mid;i<=r;i++) f[i]=max(f[i],tmp[i]);
	solve(f1,f2,l,mid);solve(f1,f2,mid+1,r);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&T[i]);
	Init(f1);rev(T+1,T+n+1);
	Init(f2);rev(T+1,T+n+1);
	rev(f2+1,f2+n+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+T[i];
	for(int i=1;i<=n;i++) f[i]=-T[i];
	solve(f1,f2,1,n); 
	rev(T+1,T+n+1);rev(f1+1,f1+n+1);rev(f2+1,f2+n+1);rev(f+1,f+n+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+T[i];
	solve(f2,f1,1,n);
	rev(T+1,T+n+1);rev(f1+1,f1+n+1);rev(f2+1,f2+n+1);rev(f+1,f+n+1);
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		ll t1,t2;
		scanf("%lld%lld",&t1,&t2);
		printf("%lld\n",max(f1[t1-1]+f2[t1+1],f[t1]+T[t1]-t2));
	}
	return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string s; cin >> s;
  ll sum = 0;
  ll n = s.size();
  for (ll i = 0; i < n; i++) {
    sum += s[i] - '0';
  }
  if (sum % 9 == 0) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 3776
#include<iostream>
#include<iomanip>
#include<unordered_map>
using namespace std;


// dp[n][k] := k枚投げて表の回数 - 裏の回数 == kになる確率
unordered_map<int, double> dp[3000];
int N;
double p[2999];


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

    dp[0][0] = 1.0;

    for(int i = 1; i <= N; i++){
        for(auto itr = dp[i - 1].begin(); itr != dp[i - 1].end(); itr++){
            int k_before = itr->first;
            double p_before = itr->second;

            dp[i][k_before + 1] += p_before * p[i - 1];
            dp[i][k_before - 1] += p_before * (1 - p[i - 1]);
        }
    }

    double ans = 0;
    for(auto itr = dp[N].begin(); itr != dp[N].end(); itr++){
        if(itr->first > 0){
            ans += itr->second;
        }
    }
    cout << setprecision(10) << ans << endl;
}


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

const string YES = "Yes";
const string NO = "No";

int main(){
  string S; cin >> S;
  bool ans = true;
  rep(i, S.size()) {
    if (i % 2 == 0 and S[i] == 'L') ans = false;
    if (i % 2 == 1 and S[i] == 'R') ans = false;
  } 
  if (ans) cout << YES << endl;
  else cout << NO << endl;
}


Measured memory_bytes: 256
// ABC 118 A
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int a,b;
  int ret;
  cin  >>  a >> b;
  if (b%a==0){
    ret = a+b;
  }else{
    ret = b-a;
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
  double x;
  double y;
} point;

point FuncSetVector(const point bp, const point ep);

int main(void)
{
  point points[4];
  point vectores[6];
  double buf[3];

  while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &points[0].x, &points[0].y, &points[1].x, &points[1].y, &points[2].x, &points[2].y, &points[3].x, &points[3].y) != EOF) {
    /* ベクトル生成 */
    vectores[0] = FuncSetVector(points[0], points[1]); /* AB */
    vectores[1] = FuncSetVector(points[0], points[3]); /* AP */

    vectores[2] = FuncSetVector(points[1], points[2]); /* BC */
    vectores[3] = FuncSetVector(points[1], points[3]); /* BP */

    vectores[4] = FuncSetVector(points[2], points[0]); /* CA */
    vectores[5] = FuncSetVector(points[2], points[3]); /* CP */

    /* 内包の判定 */
    buf[0] = ((vectores[0].x * vectores[1].y) - (vectores[0].y * vectores[1].x));
    buf[1] = ((vectores[2].x * vectores[3].y) - (vectores[2].y * vectores[3].x));
    buf[2] = ((vectores[4].x * vectores[5].y) - (vectores[4].y * vectores[5].x));

    if ((buf[0] >= 0) && (buf[1] >= 0) && (buf[2] >= 0)) {
      puts("YES");
    } else if ((buf[0] < 0) && (buf[1] < 0) && (buf[2] < 0)) {
      puts("YES");
    } else {
      puts("NO");
    }
  }

  return 0;
}

point FuncSetVector(const point bp, const point ep)
{
  point buf;

  buf.x = ep.x - bp.x;
  buf.y = ep.y - bp.y;

  return (buf);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define rep(i, a) for(auto i=0; i<a; i++)
#define rep1(i, a, b) for(auto i=a; i<b; i++)
#define p_b push_back
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef vector<vi> vvi;

int cnt = 0;

void dfs(vvi &g, vi &v, int x, const int &n, int c){
    if(v[x])
        return;
    if(c==n-1)
        cnt++;
    v[x] = 1;
    for(auto i:g[x])
        dfs(g, v, i, n, c+1);
    v[x] = 0;
}

int main() {
    ll n, m;
    cin>>n>>m;
    vvi v(n);
    vi vis(n, 0);
    rep(i, m){
        int x, y;
        cin>>x>>y;
        x--;
        y--;
        v[x].p_b(y);
        v[y].p_b(x);
    }
    dfs(v, vis, 0, n, 0);
    cout<<cnt;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  set<ll> s;
  for (ll i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      if (i * n <= m) s.insert(i);
      if ((m / i) * n <= m) s.insert(m / i);
    }
  }
  ll ans = 0;
  for (auto &d : s) {
    if ((m - d) % d == 0) {
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int K,S;
void input(){
    fast_io();
    cin >> K >> S;
}

int solve(){
    int ans = 0;
    for (int x = 0; x <= min(S,K); x++)
    for (int y = 0; y <= min(S,K); y++){
        int z = (S-x-y);
        if(z>=0 && z<=K) ans++;
    }
    cout << ans << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int I;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    int n,m,cnt=0,sum=0;
    cin>>n>>m;
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin>>a.at(i);
        sum+=a.at(i);
    }
    if(sum>=n){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
} //カモンAC

Measured memory_bytes: 640
N=int(input())
A=[a for a in list(map(int,input().split()))]

SUM=sum(A)
MEAN=SUM / 2

idx=-1
pre=0
temp=0
while (temp <= SUM):
    if (MEAN <= temp):
        break
    idx+=1
    pre=temp
    temp+=A[idx]

print(int(min(abs(MEAN-pre),abs(MEAN-temp))/0.5))


Measured memory_bytes: 26056
#include <bits/stdc++.h>
using namespace std;
int main() {
    int D, N;
    cin >> D >> N;
    int S = 1;
    for (int i = 0; i < D; i++) {
        S *= 100;
    }
    if (N < 100) {
        cout << N * S << "\n";
    } else {
        cout << 101 * S << "\n";
    }
    return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++) {
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    int count = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            for(int k = N - 1; k >= j + 1; k--) {
                if(L.at(i) + L.at(j) > L.at(k)) {
                    count += k - j;
                    break;
                }
            }
        }
    }
    cout << count << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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 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};

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
const int MAX = 100000;

VI G[MAX]; // G[i] には iから到達可能な頂点が入る
list<int> out;
bool V[MAX];
int N, E;
int indeg[MAX]; // 入次数=到達に必要な仕事(ノード)の数

struct init{
    init(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
} init;


void input(){
  int s,t;
  std::cin >> N >> E;

  REP0(i,N) V[i] = false;

  REP0(i,E){
    std::cin >> s >> t;
    G[s].PB(t);
  }

}


void bfs( int s ) {
  queue<int> Q;
  Q.push(s);
  V[s] = true;

  while ( !Q.empty() ) {
    int u = Q.front(); Q.pop();
    out.PB(u);
    REP0( i, G[u].size() ){ // u に到達したら
      int v = G[u][i]; // uから到達可能な頂点の入次数を下げる
      indeg[v]--;
      if ( indeg[v]==0 && !V[v] ) {
        V[v] = true;
        Q.push(v);
      }
    }
  }

}


void tsort(){
  REP0( i, N ) indeg[i] = 0;

  REP0( u, N ){
    REP0( i, G[u].size() ){ // 各点から到達可能な頂点を列挙することで入次数をカウント
      int v = G[u][i];
      indeg[v]++;
    }
  }

  REP0( u, N ){
    if ( indeg[u]==0 && !V[u] ) bfs(u);
  }

}


void output(){
  for ( list<int>::iterator it = out.begin(); it != out.end(); it++ ) {
    std::cout << *it << '\n';
  }
}


int main(int argc, char const *argv[]) {
  input();
  tsort();
  output();
  return 0;
}



Measured memory_bytes: 6140
#include <stdio.h>

int t1,t2;

int h,w;
char ch;

bool coin[605][605];
int psa1[605][605];
int psa2[605][605];
int ans=0;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d",&h,&w);
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            scanf(" %c",&ch);
            if (ch=='.') continue;
            // rotate by 45
            // (i,j) |-> (i-j,i+j)
            coin[i-j+301][i+j+1]=1;
            psa1[i-j+301][i+j+1]=1;
            psa2[i-j+301][i+j+1]=1;
            //printf("coin %d %d\n",i-j+300,i+j);
        }
    }
    for (int i=0; i<602; i++) {
        for (int j=0; j<602; j++) {
            psa1[i][j+1]+=psa1[i][j];
            psa2[i+1][j]+=psa2[i][j];
        }
    }
    for (int i=1; i<602; i++) {
        for (int j=(i%2); j<602; j+=2) {
            for (int k=j+2; k<602; k+=2) {
                if (coin[i][j] && coin[i][k]) {
                    // (i,j) (i,k)
                    // want coin at (i +- (k-j),x)
                    // where j <= x <= k
                    // avoid double counting weirdly
                    t1=ans;
                    if (i+k-j<602) ans+=psa1[i+k-j][k-1]-psa1[i+k-j][j];
                    if (i-k+j>0) ans+=psa1[i-k+j][k-1]-psa1[i-k+j][j];
                    //if (t1!=ans) printf("%d %d %d %d %d\n",ans,i-301,j-1,i-301,k-1);
                }
                if (coin[j][i] && coin[k][i]) {
                    // (j,i) (k,i)
                    // want coin at (x,i +- (k-j))
                    // where j <= x <= k
                    t1=ans;
                    if (i+k-j<602) ans+=psa2[k][i+k-j]-psa2[j-1][i+k-j];
                    if (i-k+j>0) ans+=psa2[k][i-k+j]-psa2[j-1][i-k+j];
                    //if (t1!=ans) printf("%d %d %d %d %d\n",ans,j-301,i-1,k-301,i-1);
                }
            }
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll cnt = 0;
    while(cnt <= 1000000){
        if(a&1||b&1||c&1){
            cout<<cnt<<endl;
            return;
        }
        cnt++;
        ll tmpa = 0,tmpb= 0,tmpc = 0;
        tmpa += (b/2) + (c/2);
        tmpb += (a/2) + (c/2);
        tmpc += (a/2) + (b/2);
        a = tmpa;
        b=tmpb;
        c=tmpc;
    }
    cout<<"-1\n";

}
 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=a*b;
	y=c*d;
	if(x>=y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int h,w,i,j,nr;
    cin >> h>>w;
    cin >>nr;
    int arr[101][101];

    int x = 0,y = 0,dir = 0;
    for(i = 0 ; i!= nr; i++){
        int aux;
        cin >> aux;
        while(aux>0){
            arr[x][y] = i;
            if(dir == 0){
                y++;
                if(y == w){
                    dir = 1;
                    y--;
                    x++;
                }
            }
            else{
                y--;
                if(y == -1){
                    dir = 0;
                    x++;
                    y++;
                }
            }
            aux--;
        }
    }
    for(i = 0; i!=h;i++){
        for(j = 0; j!=w; j++){
            cout << arr[i][j]+1<<" ";
        }
        cout<<endl;
    }
    return 0;
}


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

int main() {
  
  int N; cin >> N; int64_t ans = 0;
  
  vector<int64_t> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  for (int i = 0; i < N - 2; i++) {
    
    for (int j = i + 1; j < N - 1; j++) {
      
      for (int k = j + 1; k < N; k++) {
        
        int64_t a = vec[i], b = vec[j], c = vec[k];
        
        if (a == b || b == c || c == a) continue;
        
        int64_t maxSide = max(a, max(b, c)), sum = a + b + c;
        
        if (maxSide < sum - maxSide) ans++;
        
      }
      
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3640
import os
import sys

import numpy as np


def solve(inp):
    n = inp[0]
    aaa = inp[1:] - 1
    dp = np.full((n, n), -1, dtype=np.int16)
    dp_max = np.full(n, -1, dtype=np.int16)
    ans = 0

    a0, a1 = sorted(aaa[:2])
    dp[a0][a1] = 0
    dp_max[a0] = 0
    dp_max[a1] = 0

    for k in range(n - 1):
        a0, a1, a2 = sorted(aaa[2 + 3 * k:5 + 3 * k])
        if a0 == a1 and a1 == a2:
            ans += 1
            continue

        dp_max_max = dp_max.max()
        update_tasks = []

        if a0 == a1 or a1 == a2:
            rev = a1 == a2
            if rev:
                a0, a2 = a2, a0

            for b in range(n):
                c, d = min(a0, b), max(a0, b)
                e, f = min(a2, b), max(a2, b)
                update_tasks.append((e, f, dp_max[b]))
                if dp[c][d] != -1:
                    update_tasks.append((e, f, dp[c][d] + 1))

            update_tasks.append((a0, a0, dp_max_max))
            if dp[a2][a2] != -1:
                update_tasks.append((a0, a0, dp[a2][a2] + 1))

            if rev:
                update_tasks.append((a2, a0, dp_max_max))
            else:
                update_tasks.append((a0, a2, dp_max_max))

        else:
            update_tasks.append((a0, a1, dp_max_max))
            update_tasks.append((a0, a2, dp_max_max))
            update_tasks.append((a1, a2, dp_max_max))
            if dp[a0][a0] != -1:
                update_tasks.append((a1, a2, dp[a0][a0] + 1))
            if dp[a1][a1] != -1:
                update_tasks.append((a0, a2, dp[a1][a1] + 1))
            if dp[a2][a2] != -1:
                update_tasks.append((a0, a1, dp[a2][a2] + 1))

            for b in range(n):
                b_max = dp_max[b]
                for a in (a0, a1, a2):
                    c, d = min(a, b), max(a, b)
                    update_tasks.append((c, d, b_max))

        for a, b, c in update_tasks:
            dp[a][b] = max(dp[a][b], c)
            dp_max[a] = max(dp_max[a], c)
            dp_max[b] = max(dp_max[b], c)

    a = aaa[-1]
    dp[a][a] += 1

    return dp.max() + ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print(ans)


Measured memory_bytes: 34896