akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

double eps = 1e-6;

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n,m;
    cin>>n>>m;
    double a[n+1],b[n+1];
    cin>>a[0] >> b[0];
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    double ans = 0;
    bool used[n+1]={};
    used[0] =1;
    double dist[n+1]={};
    for(int i=1;i<=n;i++){
        dist[i] = sqrt((a[0]-a[i])*(a[0]-a[i]) + (b[0]-b[i])*(b[0]-b[i]));
    }
    while(m){
        double d=1e13;
        int f=-1;
        for(int i=1;i<=n;i++){
            if(used[i]) continue;
            if(d > eps + dist[i]){
                d = dist[i];
                f = i;
            }
        }
        double x1 = a[f],y2 = b[f];
        d = 1e13;
        int g = 0;
        for(int i=0;i<=n;i++){
            if(!used[i]) continue;
            double ret = (x1-a[i]) * (x1-a[i]) + (y2-b[i])*(y2-b[i]);
            ret = sqrt(ret);
            if(ret+eps < d){
                d = ret;
                g = i;
            }
        }
        ans += d;
        used[f]=1;
        m--;
        //cerr << "a "<<f << " " << g << endl;
        
        for(int i=1;i<=n;i++){
            if(used[i]) continue;
            double ret = 1e14;
            double x1=a[g],y1=b[g],x2=a[f],y2=b[f];
            d = 1e15;
            if(x1==x2){
                if(b[i]>=min(y1,y2) && b[i] <=max(y1,y2)){
                    double ret = abs(a[i]-x1);
                    if(d > ret+eps){
                        d = ret;
                    }
                }
                else{
                    ret = (x1-a[i]) * (x1-a[i]) + (y1-b[i]) * (y1-b[i]);
                    ret = min(ret, (x2-a[i])*(x2-a[i]) + (y2-b[i]) * (y2-b[i]));
                    ret = sqrt(ret);
                    if(ret+eps < d){
                        d = ret;
                    }
                }
            }
            else{
                ret = (x1-a[i]) * (x1-a[i]) + (y1-b[i]) * (y1-b[i]);
                ret = min(ret, (x2-a[i])*(x2-a[i]) + (y2-b[i]) * (y2-b[i]));
                ret = sqrt(ret);
                double k1 = x1*y2 - x2*y1;
                double k2 = a[i] * x1 - a[i]*x2 + y1*b[i] - y2*b[i];
                k2 *= (x1 - x2);
                k1 *= (y1 - y2);
                double K = k2 - k1;
                double c = K / ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
                if(c>=min(x1,x2) && c <= max(x1,x2)){
                    double d = (y1-y2) / (x1-x2) * c + (x1*y2 - x2*y1)/(x1-x2);
                    ret = (c-a[i]) * (c-a[i]) + (d-b[i]) * (d-b[i]);
                    ret = sqrt(ret);
                }
                if(ret+eps < d){
                    d = ret;
                }
            }
            dist[i] = min(dist[i],d);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3400
n, m = [int(x) for x in input().split()]
a = []
b = []
for i in range(n): a.append([int(x) for x in input().split()])
for j in range(m): b.append(int(input()))
for a_row in a:
    print(sum([x * y for x, y in zip(a_row, b)]))


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    constexpr int N = 1e7;
    vector<int> erato(N+5,1);
    FOR(i,2,N+1) {
        for(int j = 1; i * j <= N; j++) erato[i*j]++;
    }
    int n; cin >> n;
    ll ans = 0;
    for(ll i = 1; i <=n ; i++) ans += i * erato[i];
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 42188
#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main()
{
	string str;
	char c[30];
	for(int i = 0; i < 30;i++) c[i]= ' ';
	cin >> str;
	for(int i = 0; i < str.length() ; i++)
	{
		for(int h = 0; h < i;h++)
		{
			if(str[i] == c[h])
			{
				cout << "no" << endl;
				return 0;
			}
		}
		c[i] = str[i];
	}
	cout << "yes" << endl;
	return 0;
}


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

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();

            string ans = "";
            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0) ans += s[i].ToString();
            }
            WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 34772
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (1..n).map { sc.nextInt() }
    val b = (1..n).map { sc.nextInt() }
    val permList = genPermList(n, listOf<Int>())
    println(Math.abs(permList.indexOf(a) - permList.indexOf(b)))
}

fun genPermList(n: Int, used: List<Int>): List<List<Int>> {
    val res = mutableListOf<List<Int>>()
    if (used.size == n) {
        res.add(used)
        return res
    }
    for (i in 1..n) {
        if (!used.contains(i)) {
            val nextUsed = mutableListOf<Int>()
            nextUsed.addAll(used)
            nextUsed.add(i)
            res.addAll(genPermList(n, nextUsed))
        }
    }
    return res
}


Measured memory_bytes: 53336
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		if((x+y) % 3 == 0 || x % 3 == 0 || y % 3 == 0){
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int d;
	while (cin >> d) {
		int s = 0;
		for (int i = 1; i <= 600 / d - 1; i++) {
			s += pow(i*d, 2)*d;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
fun main(){
    val s = readLine()!!.split(" ")[0].toCharArray()
    for (i in 0 until s.size){
        if (i == s.size-1 && s[i] == 's'){
            print("${s[i]}es")
        } else if (i == s.size-1){
            print("${s[i]}s")
        } else{
            print(s[i])
        }
    }
}

Measured memory_bytes: 38152
N = int(input())
A = [0] * N
first = 0
second = 0
n = -1
for i in range(N):
  a = int(input())
  if a >= first:
    second = first
    first = a
    n = i
  else:
    second = max(a, second)
for i in range(N):
  if i == n:
    print(second)
    continue
  print(first)

Measured memory_bytes: 6204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int n;
    cin >> n;
    cout << "ABC" << n << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<vector<int>> g;
int main(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int>dist(n,INT_MAX);
    dist[0] = 0;
    queue<int>q;
    q.push(0);
    while(q.size()){
        int x = q.front();
        q.pop();
        for(auto v: g[x]){
            if(dist[v]!=INT_MAX)continue;
            dist[v] = dist[x] + 1;
            q.push(v);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        for(auto x : g[i]){
            if(dist[i] == dist[x] + 1){
                cout << x + 1 << "\n";
                break;
            }
        }
    }
    
}


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

const int N=200005;
char s1[N];
char s2[N];
int main()
{
    scanf("%s %s",s1,s2);
    int  n=strlen(s1);
    int ans=0;
    for(int i=0;i<n;i++) ans+=(s1[i]!=s2[i]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = "";
        switch(n) {
        case 25:
            ans = "Christmas";
            break;
        case 24:
            ans = "Christmas Eve";
            break;
        case 23:
            ans = "Christmas Eve Eve";
            break;
        case 22:
            ans = "Christmas Eve Eve Eve";
            break;
        default :
            break;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    vector<P> RL(n);
    rep(i, n)
    {
        ll x, l;
        cin >> x >> l;
        RL[i] = make_pair(x + l, x - l);
    }
    sort(RL.begin(), RL.end());

    ll now =-INF;
    ll ans = 0;
    rep(i, n)
    {
        if (RL[i].second >= now)
        {
            now = RL[i].first;
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main(){
  int n,s=0;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++)
    cin >> b[i];
  for(int i=0;i<n-1;i++)
    cin >> c[i];
  for(int i=0;i<n-1;i++){
    s+=b[a[i]-1];
    if(a[i+1]==a[i]+1)
      s+=c[a[i]-1];
  }
  s+=b[a[n-1]-1];
  cout << s;
}

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

struct Node {
	int parent, left, right;
};

class BinaryTree {
	vector<Node> _node;

public:
	BinaryTree(vector<Node>& a) : _node(a) {}

	void preorderTreeWalk(int a) {
		if (a != -1) {
			cout << ' ' << a;
			preorderTreeWalk(_node[a].left);
			preorderTreeWalk(_node[a].right);
		}
	}

	void inorderTreeWalk(int a) {
		if (a != -1) {
			inorderTreeWalk(_node[a].left);
			cout << ' ' << a;
			inorderTreeWalk(_node[a].right);
		}
	}

	void postorderTreeWalk(int a) {
		if (a != -1) {
			postorderTreeWalk(_node[a].left);
			postorderTreeWalk(_node[a].right);
			cout << ' ' << a;
		}
	}
};

int main() {
	int n, id;
	cin >> n;
	vector<Node> b(n, { -1, -1, -1 });
	for (int i = 0; i < n; i++) {
		cin >> id;
		cin >> b[id].left >> b[id].right;
		if (b[id].left != -1) b[b[id].left].parent = id;
		if (b[id].right != -1) b[b[id].right].parent = id;
	}
	BinaryTree c(b);
	cout << "Preorder" << endl;
	c.preorderTreeWalk(find_if(b.begin(), b.end(), [](Node& a) { return a.parent == -1; }) - b.begin());
	cout << endl << "Inorder" << endl;
	c.inorderTreeWalk(find_if(b.begin(), b.end(), [](Node& a) { return a.parent == -1; }) - b.begin());
	cout << endl << "Postorder" << endl;
	c.postorderTreeWalk(find_if(b.begin(), b.end(), [](Node& a) { return a.parent == -1; }) - b.begin());
	cout << endl;
}


Measured memory_bytes: 3172
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nk = readints;
    int k = nk[1];
    string s = read!string;

    auto t = s.array;
    t[k - 1] = t[k - 1].toLower();
    writeln(t);

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define loop(n)			for(int i = 0; i < n; i++)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<pii> A;
int n;
const int N = 2005;
int dp[N][N];

int go(int idx, int l)
{
	if (dp[idx][l] != -1)	return dp[idx][l];
	if (idx == n - 1) // last element, l == r
	{
		// cout << idx << '\n';
		int ans = A[idx].ff * abs(l - A[idx].ss);
		// cout << ans << '\n';
		return dp[idx][l] = ans;
	}
	// place idx at l
	int r = n - idx + l - 1;
	int q1 = go(idx + 1, l + 1) + (A[idx].ff * abs(l - A[idx].ss));
	// place idx at r
	int q2 = go(idx + 1, l) + (A[idx].ff * abs(r - A[idx].ss));
	return dp[idx][l] = max(q1, q2);
}

bool comp(pii A, pii B)
{
	// if (A.ff = B.ff)
	// {

	// }
	return (A.ff > B.ff);
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	A.resize(n);
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; i++)
	{
		int inp; cin >> inp;
		A[i - 1].ff = inp;
		A[i - 1].ss = i;
	}
	sort(A.begin(), A.end(), comp);
	/*for (auto x : A)
	{
		cout << x.ff << ' ' << x.ss << '\n';
	}*/
	cout << go(0, 1);
	return 0;
}

Measured memory_bytes: 35220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	vector<int> x(n),y(n);
	vector<int> v,u;
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
		v.push_back(x[i]);
		u.push_back(y[i]);
	}
	sort(v.begin(),v.end());
	sort(u.begin(),u.end());
	ll ans=1LL*(v[n-1]-v[0])*(u[n-1]-u[0]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int p=0;p<n;p++){
				for(int q=p+1;q<n;q++){
					int num=0;
					for(int t=0;t<n;t++){
						if(v[i]<=x[t]&&x[t]<=v[j]&&u[p]<=y[t]&&y[t]<=u[q])num++;
					}
					if(num>=k){
						ans=min(ans,1LL*(v[j]-v[i])*(u[q]-u[p]));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if m <= n:
    print(0)
else:
    length = abs(x[0]-x[-1])
    abs_x = [0]*(m-1)
    for i in range(m-1):
        abs_x[i] = abs(x[i+1] - x[i])
    abs_x.sort(reverse=True)
    for i in range(n-1):
        length -= abs_x[i]
    print(length)

Measured memory_bytes: 52904
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static void Swap<T>(ref T a, ref T b)
    {
	var t = a;
	a = b;
	b = t;
    }
    
    public static bool NextPermutation<T>(T[] a) where T : IComparable
    {
	if (a.Length <= 1) return false;

	for (int i = a.Length - 1; i > 0; i--)
	{
	    int k = i - 1;
	    if (a[k].CompareTo(a[i]) < 0)
	    {
		int j = a.Length - 1;
		while (a[k].CompareTo(a[j]) >= 0){ j--; }
		Swap(ref a[k], ref a[j]);
		Array.Reverse(a, i, a.Length - i);
		return true;
	    }
	}
	Array.Reverse(a);
	return false;
    }
}

class Program
{
    public static void Main()
    {
	string s = ReadLine();

	if (s == "zyxwvutsrqponmlkjihgfedcba")
	{
	    WriteLine(-1);
	}
	else if (s.Length < 26)
	{
	    int n = 'z' - 'a' + 1;
	    bool[] a = new bool[n];
	    for (int i = 0; i < s.Length; i++)
		a[s[i]-'a'] = true;
	    for (int i = 0; i < n; i++)
		if (!a[i]){ s += (char) ('a' + i); break; }
	    WriteLine(s);
	}
	else
	{
	    char[] c = new char[s.Length];
	    for (int i = 0; i < s.Length; i++) c[i] = s[i];
	    NextPermutation(c);
	    string t = "";
	    for (int i = 0; i < s.Length; i++)
	    {
		if (c[i] == s[i]) t += c[i];
		else
		{
		    t += c[i];
		    break;
		}
	    }
	    WriteLine(t);
	}
    }
}


Measured memory_bytes: 13140
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;

	int64_t inf = 100000000000000LL;
	vector<vector<pair<int,int64_t>>> arrow(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		int64_t c;
		cin >> a >> b >> c;
		a--; b--;

		arrow[a].push_back(make_pair(b, c));
	}

	vector<int64_t> visited(n, inf);
	queue<pair<int,int64_t>> cq;
	cq.push(make_pair(0,0));
	int64_t maxscore = -inf;
	int step = 0;
	while (!cq.empty()) {
		queue<pair<int, int64_t>> nq;
		while (!cq.empty()) {
			auto val = cq.front();
			cq.pop();
			int pos = val.first;
			int64_t score = val.second;
			for (auto edge : arrow[pos]) {
				int dst = edge.first;
				int64_t weight = edge.second;

				if (visited[dst] == inf) {
					visited[dst] = score + weight;
					nq.push(make_pair(dst,score+weight));
				}
				else if (visited[dst] < score + weight) {
					visited[dst] = score + weight;
					nq.push(make_pair(dst, score + weight));
				}

				if (dst == n - 1) {
					if (maxscore < score + weight) {
						maxscore = score + weight;
						if (step > n) {
							cout << "inf" << endl;
							return 0;
						}
					}
				}
			}
		}
		cq = nq;
		step++;
		if (step > 2 * n+10) {
			break;
		}
	}
	cout << maxscore << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

static const int MAX = 1000010;

int main() {
    int s;
    cin >> s;
    int a[MAX] = {}; a[0] = s;
    bool flag = false;
    int ans;
    for (int i = 1; i < 1e7; i++) {
        if (s % 2 == 0) s /= 2;
        else s = 3 * s + 1;
        a[i] = s;
        for (int j = 0; j < i; j++) {
            if (a[j] == a[i]) {
                ans = i + 1;
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  int c = (n + x - 1) / x;
  int ans = c * t;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  pair<int,int> a[100000];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int s1,s2;
    cin>>s1>>s2;
    a[i]=make_pair(s1,s2);
  }
  sort(a,a+n);
  for (int i=0;i<n;i++){
    cout<<a[i].first<<" "<<a[i].second<<endl;;
  }
  
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl; 
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,k,a[200005];ll rui[200005];
struct BIT
{
	int bit[(1<<20)+5];
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<20);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}bit;
int main(){
	cin>>n>>k;
	repn(i,n)cin>>a[i];
	vector<ll>vec;
	vec.pb(0);
	repn(i,n){
		rui[i] = rui[i-1]+a[i]-k;
		vec.pb(rui[i]);
	}
	SORT(vec); ERASE(vec);
	bit.add(POSL(vec,0)+1,1);
	ll ans = 0;
	repn(i,n){
		ans += bit.sum(POSL(vec,rui[i])+1); //cout<<rui[i]<<endl;
		bit.add(POSL(vec,rui[i])+1,1);
	}
	cout<<ans<<endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main(void)
{
    ll a,b,c; cin>>a>>b>>c;
    ll ans=0;
    for(a;a<=b;a++){
        if(c%a==0)++ans;
    }
    cout<<ans<<endl;
    return 0;
} 


Measured memory_bytes: 3084
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();
        int count = 0;
        
        for(int i=0; i<N-2; i++){
            if(S.substring(i,i+3).equals("ABC")){
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int mat[n][m];
    int vec[m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> mat[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> vec[i]; 
    }
    
    for(int i=0; i<n; i++){
        int sum = 0;
        for(int j=0; j<m; j++){
            sum += mat[i][j] * vec[j];
        }
        cout << sum << endl;
    }
    
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  
  int k;
  cin >> k;
  cout << (k/2) * (k - k/2) << endl;
  return 0;
}


Measured memory_bytes: 256
import collections
import numpy as np
import sys
sys.setrecursionlimit(10**8)
#N,K=map(int,input().split())
N=int(input())
h=np.array(list(map(int,input().split())))
ans=0
def sol(l,m,k):
    global ans
    if m==0:
        return ans
    elif m>0:
        for i in range(N-m+1):
            if not 0 in l[i:i+m]:
                ans+=np.amin(l[i:i+m])
                l[i:i+m]=l[i:i+m]-min(l[i:i+m])
                #print(l)
        sol(l,m-1,ans)
    # else:
    #     ans+=np.count_nonzero(h)
    #     sol(l, m - 1, ans)
n=0
sol(h,N,ans)
print(ans)

Measured memory_bytes: 12516
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    /*
    for(int i = 1;i <= N-2;i++){
        for(int j = 1;j <= 5;j++){
            printf("%3d",9 * (i * 7 + j + 1) % 11);
        }
        cout << endl;
    }
    */
    int table[] = {4,1,9,6,3,0,8,5,2,10,7};
    ll ans = (N - 2) / 11 * 5;
    for(int i = 0;i < 5;i++){
        for(int j = 0;j < (N-2) % 11;j++){
            if(table[(j + i*8) % 11] == K)ans++;
        }
    }
    cout << ans << endl;
    /*
    
    {0,8,5,2,10};
    */
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long n;
	long long a,b;
	cin>>n;
	for(int i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			a=i;
			b=n/a;
		}
	}
	//cout<<a<<" "<<b<<endl;
	//int p,q;
	long long count=0;
	if(a>=b)
	{
		while(a!=0)
		{
			count++;
			a/=10;
		}
	}
	else
	{
		while(b!=0)
		{
			count++;
			b/=10;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

const long long INF = 100000000000000000;

int main()
{
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;

  //1回目
  for (int i = 0; i < gy - sy;i++){
    cout << "U";
  }
  for (int i = 0; i < gx - sx;i++){
    cout << "R";
  }

  //2回目
  for (int i = 0; i < gy - sy; i++)
  {
    cout << "D";
  }
  for (int i = 0; i < gx - sx; i++)
  {
    cout << "L";
  }

  cout << "L";
  for (int i = 0; i < gy - sy+1; i++)
  {
    cout << "U";
  }
  for (int i = 0; i < gx - sx+1; i++)
  {
    cout << "R";
  }
  cout << "D";

  cout << "R";
  for(int i = 0; i < gy - sy + 1; i++)
  {
    cout << "D";
  }
  for (int i = 0; i < gx - sx + 1; i++)
  {
    cout << "L";
  }
  cout << "U";

  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define int long long
void test_case(){
	string s, t;
	cin>>s>>t;
	int len = t.size();
	int ans = len;
	for(int i=0;i+len<=(int)s.size();i++){
		string s2 = s.substr(i, len);
		int cnt = 0;
		for(int j=0;j<len;j++){
			if(s2[j] != t[j]){
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	cout<<ans<<endl;
}
		
 
signed main(){
	IOS;
	int t=1, i=1; 
	//cin>>t;
	while(t--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int ,int> P;

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e5+7;
int dp[MAXN];
int a[MAXN];
int main() {
        ll n;
        while(cin>>n)
                cout<<(ll)n*(n-1)/2<<endl;
        return 0;
}


Measured memory_bytes: 256
def Csum(a):
    b,c=[0],0
    for i in range(len(a)-1):
        c+=(a[i]=='A' and a[i+1]=='C')
        b.append(c)
    return b
n,q=map(int,input().split())
s=Csum(input())
for i in range(q):
    a,b=map(int,input().split())
    print(s[b-1]-s[a-1])

Measured memory_bytes: 7716
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  vec a(5);
  REP(i,5) cin >> a[i];

  REP(i,5){
    if(a[i]==0) cout << i+1 << endl;
  }

  return 0;
}

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

//各桁の和を出す関数
int wa(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    int sum = wa(N);
    if(N % sum == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	run()
}

func run() {
	n := readN()
	var sum float64
	for i := 0; i < n; i++ {
		xu := strings.Split(read(), " ")
		x, _ := strconv.ParseFloat(xu[0], 64)
		switch xu[1] {
		case "JPY":
			sum += x
		case "BTC":
			x *= 380000
			sum += x
		}
	}
	fmt.Println(sum)
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


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

A = list(map(int, input().split()))
t = 0

while len(set(A)) != 1 or max(A) != 0:
    for i in range(n):
        if A[i] != 0:
            break
    B = A[i:]
    for j in range(i, n):
        if A[j] != 0:
            A[j] -= 1
        else:
            break
    t += 1

print(t)

Measured memory_bytes: 40048
import numpy as np
import copy
def main():
    n = int(input())
    
    max_num = 0
    max_second = 0
    for i in range(n):
        a = int(input())
        if a > max_num:
            max_num = a
            max_index = i
        elif a > max_second:
            max_second = a

    for j in range(n):
        if j == max_index:
            print(max_second)
        else:
            print(max_num)



    
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 21424
x = input().split()
N = int(x[0])
M = int(x[1])

A = input().split()
A = [int(l) for l in A]

S = sum(A)

c = 0
for x in A:
    if 4*M*x >= S:
        c +=1
if c >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll X;

int main() {
	scanf("%lld", &X);
	X--;
	ll ans = (X * (X + 1)) / 2;
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  string judge = "consonant";
  
  if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
    judge = "vowel";
  }
  

 
  cout << judge <<endl;
  
}

Measured memory_bytes: 256
//   PIGMEISTER™   //

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

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mi map<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define pi pair<ll,ll>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 200005
ll powah(ll, ll);

int main()
{
    jaldi;
    
    string s;
    cin >> s;
    if (s.size()!=6 || s[2]!=s[3] || s[4]!=s[5]) cout << "No";
    else cout << "Yes";
    
    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1; x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res*x) % mod; 
        y = y>>1; x = (x*x) % mod; } 
    return res; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
typedef long long ll;
const int INF=0x3f3f3f3f;
int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
int n,m,k;
char s[10];
ll a[1005];
int main()
{
    a[0]=2;a[1]=1;
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
        a[i]=a[i-1]+a[i-2];
    printf("%lld\n",a[n]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

set<P> s;

class Graph{
	private:
	int V;
	vvi List;
	vb used;
	vi ts;
	void TSfunc(int v){
		used[v]=1;
		for(int i=0;i<List[v].size();i++){
			int u=List[v][i];
			if(!used[u]) TSfunc(u);
		}
		ts.push_back(v);
	}
	public:
	Graph(int v){
		V=v;
		List=vvi(v);
	}
	void add_edge(int s,int t){
		List[s].push_back(t);
	}
	void TS(){
		used=vb(V);
		for(int i=0;i<V;i++){
			if(!used[i]) TSfunc(i);
		}
	}
	void solve(){
		TS();
		bool flag=0;
		for(int i=1;i<V;i++){
			if(s.find(P(ts[i],ts[i-1]))==s.end()) flag=1;
		}
		for(int i=V-1;i>=0;i--) cout<<ts[i]+1<<endl;
		cout<<flag<<endl;
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	for(int i=0;i<m;i++){
		int S,T;
		cin>>S>>T;
		S--;T--;
		g.add_edge(S,T);
		s.insert(P(S,T));
	}
	g.solve();
}

Measured memory_bytes: 8596
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    while(n!=0){
        int count=0;
        while(n!=1){
            if(n%2==0){
                n = n/2;
                count++;
            }else{
                n = 3*n+1;
                count++;
            }
            if(n==1)break;
        }
        cout << count << endl;
        cin >>n;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>

int main(void) {
   
   long N;
   
   scanf("%ld",&N);
   
   long A[N];
   
   long i;
   
   for (i = 0; i < N; i++) {
      scanf("%ld", &A[i]);
   }
   
   long B[N + 1];
   
   for (i = 0; i <=N; i++) {
      B[i] = 0;
   }
   
   for (i = 0; i < N; i++) {
      B[A[i]]++;
   }
   
   long ans_tot = 0;
   long k;
   
   for (k = 0; k <= N; k++) {
      ans_tot = ans_tot + B[k]*(B[k] - 1)/2;
   }
   
   long ans;
   
   /*
   printf("tot:%ld\n",ans_tot);
   for (k = 0; k <= N; k++) {
      printf("B[%d]:%d\n",k,B[k]);
   }
   */
   for (k = 0; k < N; k++) {
      ans = ans_tot - (B[A[k]] - 1);
      printf("%ld\n", ans);
   }
   
   
   return 0;
}



Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int max(int a, int b){
  if(a>=b){
    return a;
  }
  else{
    return b;
  }
}

int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&A[i]);
  }

  int count=1;
  int max_h=A[0];
  int index=1;
  while(index<N){
    if(max_h<=A[index]){
      max_h=A[index];
      count++;
      index++;
    }
    else{
      index++;
    }
  }

  printf("%d\n", count);

  return 0;


}


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

int main(){
  int a,b,c;
  cin >> a >> b;
  if(b<10){
    c = a*10+b;
  }
  else if(b<100){
    c = a*100+b;
  }
  else{
    c = a*1000+b;
  }
  int i=0;
  while(true){
    if(i*i==c){
      cout << "Yes" << endl;
      break;
    }
    else if(i*i<c){
      i++;
    }
    else{
      cout << "No" << endl;
      break;
    }
  }
}


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

using namespace std;

int main()
{
	string str;
	size_t pos;

	cin >> str;

	pos = str.find("AC");

	if (pos != string::npos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
li = list(map(int, input().split()))
c = 0
while True:
    if li[0] == li[1] == li[2]:
        break
    li = sorted(li)
    if li[0] < li[1]:
        li[0] += 2
    else:
        li[0] += 1
        li[1] += 1
    c += 1
print(c)

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

int main() {
  vector<int> A1(3);
  rep(i, 3) {
    cin >> A1[i];
  }
  vector<int> A2(3);
    rep(i, 3) {
    cin >> A2[i];
  }
  vector<int> A3(3);
    rep(i, 3) {
    cin >> A3[i];
  }
  int N;
  cin >> N;
  map<int, bool> bMap;
  rep(i, N) {
    int num;
    cin >> num;
    bMap.insert(make_pair(num, true));
  }

  vector<vector<int>> nums(8, vector<int>(3));
  nums[0] = {A1[0], A1[1], A1[2]};
  nums[1] = {A2[0], A2[1], A2[2]};
  nums[2] = {A3[0], A3[1], A3[2]};
  nums[3] = {A3[0], A2[0], A1[0]};
    nums[4] = {A3[1], A2[1], A1[1]};
    nums[5] = {A3[2], A2[2], A1[2]};
    nums[6] = {A1[0], A2[1], A3[2]};
        nums[7] = {A1[2], A2[1], A3[0]};

  string ans = "No";
  rep(i, 8) {
    auto num = nums[i];
    rep(i, 3) {
      if (bMap.count(num[i]) == 0) {
        break;
      }
      if (i == 2) {
        ans = "Yes";
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}








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

int sx,sy,tx,ty;
int main(){
	int i;
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);sx+=1000;sy+=1000;tx+=1000;ty+=1000;
	if (sx<tx){
		if (sy<ty){
			for (i=sx;i<tx;i++) putchar('R');
			for (i=sy;i<ty;i++) putchar('U');
			for (i=sx;i<tx;i++) putchar('L');
			for (i=sy;i<ty;i++) putchar('D');
			
			putchar('D');
			for (i=sx;i<=tx;i++) putchar('R');
			for (i=sy;i<=ty;i++) putchar('U');
			putchar('L');
			
			putchar('U');
			for (i=sx;i<=tx;i++) putchar('L');
			for (i=sy;i<=ty;i++) putchar('D');
			putchar('R');
		}else if (sy==ty){
			for (i=sx;i<tx;i++) putchar('R');
			
			putchar('D');
			for (i=sx;i<tx;i++) putchar('L');
			putchar('U');
			
			putchar('U');
			for (i=sx;i<tx;i++) putchar('R');
			putchar('D');
			
			putchar('R');putchar('D');putchar('D');
			for (i=sx;i<=tx+1;i++) putchar('L');
			putchar('U');putchar('U');putchar('R');
		}else if (sy>ty){
			for (i=sx;i<tx;i++) putchar('R');
			for (i=sy;i<ty;i++) putchar('D');
			for (i=sx;i<tx;i++) putchar('L');
			for (i=sy;i<ty;i++) putchar('U');
			
			putchar('U');
			for (i=sx;i<=tx;i++) putchar('R');
			for (i=sy;i<=ty;i++) putchar('D');
			putchar('L');
			
			putchar('D');
			for (i=sx;i<=tx;i++) putchar('L');
			for (i=sy;i<=ty;i++) putchar('U');
			putchar('R');
		}
	}else if (sx==tx){
		for (i=sx;i<tx;i++) putchar('U');
		
		putchar('R');
		for (i=sx;i<tx;i++) putchar('D');
		putchar('L');
		
		putchar('L');
		for (i=sx;i<tx;i++) putchar('U');
		putchar('R');
		
		putchar('U');putchar('R');putchar('R');
		for (i=sx;i<=tx+1;i++) putchar('D');
		putchar('L');putchar('L');putchar('U');
	}else if (sx>tx){
		if (sy<ty){
			for (i=sx;i<tx;i++) putchar('L');
			for (i=sy;i<ty;i++) putchar('U');
			for (i=sx;i<tx;i++) putchar('R');
			for (i=sy;i<ty;i++) putchar('D');
			
			putchar('D');
			for (i=sx;i<=tx;i++) putchar('L');
			for (i=sy;i<=ty;i++) putchar('U');
			putchar('R');
			
			putchar('U');
			for (i=sx;i<=tx;i++) putchar('R');
			for (i=sy;i<=ty;i++) putchar('D');
			putchar('L');
		}else if (sy==ty){
			for (i=sx;i<tx;i++) putchar('L');
			
			putchar('D');
			for (i=sx;i<tx;i++) putchar('R');
			putchar('U');
			
			putchar('U');
			for (i=sx;i<tx;i++) putchar('L');
			putchar('D');
			
			putchar('L');putchar('D');putchar('D');
			for (i=sx;i<=tx+1;i++) putchar('R');
			putchar('U');putchar('U');putchar('L');
		}else if (sy>ty){
			for (i=sx;i<tx;i++) putchar('L');
			for (i=sy;i<ty;i++) putchar('D');
			for (i=sx;i<tx;i++) putchar('R');
			for (i=sy;i<ty;i++) putchar('U');
			
			putchar('U');
			for (i=sx;i<=tx;i++) putchar('L');
			for (i=sy;i<=ty;i++) putchar('D');
			putchar('R');
			
			putchar('D');
			for (i=sx;i<=tx;i++) putchar('R');
			for (i=sy;i<=ty;i++) putchar('U');
			putchar('L');
		}
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M,A; cin>>N>>M;
	while(M--) {
		cin>>A; N-=A;
	}
	cout<<(N<0 ? -1 : N)<<endl;
	return 0;
}

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

class Dice{
// front right back left bottom top
private:
  int right_index[6][6] = {
    {-1, 5, -1, 4, 1, 3},
    {4, -1, 5, -1, 2, 0},
    {-1, 4, -1, 5, 3, 1},
    {5, -1, 4, -1, 0, 2},
    {3, 0, 1, 2, -1, -1},
    {1, 2, 3, 0, -1, -1}
  };

public: 
  vector<int> data;
  Dice(): data(6,0){}
  Dice(vector<int> input){
    data.resize(6);
    for(int i=0; i<6; i++)
      data[(i+5)%6] = input[i];
    swap(data[2],data[3]);
  } 

  void roll(int dir){
    int tmp = data[5];
    data[5] = data[dir];
    data[dir] = data[4];
    data[4] = data[(dir+2)%4];
    data[(dir+2)%4] = tmp;
  }

  int find_index(int n){
    return find(data.begin(), data.end(), n)-data.begin();
  }

  int right_from(int t, int f){
    int r = right_index[find_index(t)][find_index(f)];
    return r!=-1? data[r]: -1;
  }

};


int main(){
  vector<int> input(6);
  for(int i=0; i<6; i++){
    cin >> input[i];
  }
  Dice dice(input);

  // for(int i=0; i<6; i++){
  //   cout <<  dice.data[i] << " ";
  // }
  // cout << endl;

  string roll_d = "SENW";

  int n; cin >> n;
  for(int i=0; i<n; i++){
    int top, front; cin >> top >> front;
    //cout << top << " " << front << endl;
    //cout << dice.find_index(top) << endl;
    int right = dice.right_from(top, front);
    if(right!=-1)
      cout << right << endl;
  }

  return 0;
}

Measured memory_bytes: 3156