akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(VEC(int)) Edges(N);
    FOR(i, 0, M) {
        int u, v;
        cin >> u >> v;
        Edges[u - 1].push_back(v - 1);
    }

    VEC(VEC(int)) Reach(N, VEC(int)(N, 10000));
    FOR(i, 0, N) {
        VEC(int)& Bfs = Reach[i];
        queue<int> q;
        q.push(i);

        while (q.size()) {
            int v = q.front();
            q.pop();
            for (int u : Edges[v])
                if (Bfs[u] >= 10000) {
                    q.push(u);
                    int dist = v == i ? 0 : Bfs[v];
                    Bfs[u] = 1 + dist;
                }
        }
    }

    VEC(int) cycle(10000, 0);
    FOR(i, 0, N)
        if (cycle.size() >= 10000 || Reach[i][i] < cycle.size()) {
            cycle.clear();
            int node = i, dist = Reach[i][i];
            while (dist--) {
                cycle.push_back(node);
                for (int next : Edges[node]) {
                    if (next == i) {
                        goto done;
                    }

                    if (Reach[next][i] == dist) {
                        node = next;
                        break;
                    }
                }
            }

done:
            continue;
        }

    if (cycle.size() >= 10000) {
        cout << -1 << endl;
        return 0;
    }

    cout << cycle.size() << endl;
    for (int v : cycle)
        cout << (v + 1) << endl;
    return 0;
};

Measured memory_bytes: 4352
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        long k = sc.NextLong();

        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextInt();
            b[i] = sc.NextInt();
        }

        long[] cnt = new long[100001];

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


        for (int i = 1; i < 100001; i++)
        {
            if (cnt[i] >= k)
            {
                Console.WriteLine(i);
                return;
            }

            k -= cnt[i];
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 16580
#include <bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using namespace std;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>0){
  int d;
  d = (c-a-b)*(c-a-b);
  if(d>4*a*b){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

#include <stdlib.h>


int main() {
	int i, j, k, count = 0;

	int array_num = 0;
	scanf("%d", &array_num);

	//dynamic scan
	int* array;
	array = (int*)malloc(array_num * sizeof(int));
	for (i = 0; i != array_num; i++) {
		scanf("%d", &array[i]);
	}

	for (i = 0; i < array_num - 1; i++) {
		for (j = 0; j != array_num - i - 1; j++) {
			if (array[j] > array[j + 1]) {
				k = array[j];
				array[j] = array[j + 1];
				array[j + 1] = k;
				count++;
			}
		}
	}

	for (i = 0; i < array_num; i++) {
		if (i == array_num - 1)printf("%d\n", array[i]);
		else printf("%d ", array[i]);
	}
	printf("%d\n", count);
}



Measured memory_bytes: 2088
h,w,k = list(map(int,input().split()))
list1 = [[str(c) for c in input()] for j in range(h)]

count1 = 0
for i in range(1<<h):
    for j in range(1<<w):
        count = 0
        for ia in range(h):
            if i&(1<<ia):continue
            for ib in range(w):
                if j&(1<<ib):continue
                if list1[ia][ib] == '#':
                    count += 1
        if count == k:
            count1 += 1


print(count1)

Measured memory_bytes: 9076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		char[] input = sc.next().toCharArray();

		if(input[0] != input[1] || input[1] != input[2]){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    int A,B,C; cin>>A>>B>>C;
    int ans=0;
    ans=B/A;
    if(ans>C){
        cout<<C;
    }
    else{
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    int a;
    vector<int> b(n+1);
    rep(i,m) {
        cin >> a;
        b[a] = 1;
    }

    vector<int> dp(n+1);
    int mod = 1e9+7;
    dp[0] = 1;
    repf(i,1,n+1) {
        if (!b[i]) {
            if (i!=1) {
                dp[i] = (dp[i-1]+dp[i-2])%mod;
            } else {
                dp[i] = dp[i-1];
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a;
cin>>a;
double pi=3.14159266358979,ans=a*2*pi;
cout<<fixed << setprecision(10)<<ans<<endl;
    return 0;
}

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

int main() {
  vector<int> x(5);
  for (int i=0; i<5; i++) {
    cin >> x[i];
  }
  for (int i=0; i<5; i++) {
    if (x[i]==0) {
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

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

def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table

li=num_divisors_table(n)

ans = 0
for i in range(1,n):
    ans+=li[i]
print(ans)


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

int main() {
    string s,t;
    cin >> s >> t;
    int count = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            s[i] = t[i];
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3832
import collections
n = int(input())
a = collections.Counter(list(map(int, input().split())))
candidates = []
for k,v in a.items():
    if v < 2:
        continue
    candidates.append(k)
    if v >= 4:
        candidates.append(k)
candidates = sorted(candidates)
if len(candidates) < 2:
    ans = 0
else:
    ans = candidates[-1] * candidates[-2]
print(ans)

Measured memory_bytes: 18600
import java.io.*;
class Main{
	public static void main(String args[])throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		String array[] = str.split(" ");
		
		int x = Integer.parseInt(array[0]);
		int y = Integer.parseInt(array[1]);
		int z = Integer.parseInt(array[2]);
		
		if (x <= y && y <= z){
			System.out.println(x +" " + y + " " + z);
			}else if (x <= z && z <= y){
			System.out.println(x +" " + z + " " + y);
			}else if (y <= x && x <= z){
			System.out.println(y +" " + x + " " + z);
			}else if (y <= z && z <= x){
			System.out.println(y +" " + z + " " + x);
            }else if (z <= x && x <= y){
			System.out.println(z +" " + x + " " + y);
			}else if (z <= y && y <= x){
			System.out.println(z +" " + y + " " + x);
			}
			}
			}

Measured memory_bytes: 24188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  long double d;
  cin>>n>>d;
  int ans = 0;
  for(int i=0;i<n;i++) {
    int x,y;
    cin>>x>>y;
    long double dis = sqrt(x*x+y*y);
    if(dis <= d)
      ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    string t;
    cin>>t;
    bool flag=false;
    for(int i=0; i<s.size(); i++){
        if(s[i]==t[i])continue;
        else {
            flag=true;
            break;
        }
    }
    if(flag)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func abs(n int64) int64 {
	if n >= 0 {
		return n
	} else {
		return -n
	}
}

func main() {
	var x, k, d int64
	fmt.Scan(&x)
	fmt.Scan(&k)
	fmt.Scan(&d)
	x = abs(x)
	ans := x

	if x > abs(k*d) {
		ans = x - abs(k*d)
	} else {
		if (k-x/abs(d))%2 == 0 {
			ans = x % abs(d)
		} else {
			temp := x % abs(d)
			if abs(temp+d) < abs(temp-d) {
				ans = abs(temp + d)
			} else {
				ans = abs(temp - d)
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define NMAX 1010
#define ll long long
using namespace std;
ll n, k, sum, v[1010];
int main()
{
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    sort(v+1, v+n+1);
    for(int i=1; i<=k; i++)
        sum = sum + v[i];
    cout<<sum;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try {
			int a;
			int b;
			int c;
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s = new String(reader.readLine());
			int setsu = Integer.parseInt(s);
			for(int i=1;i<=setsu;i++){
				String Tri = new String(reader.readLine());
				String[] result1 = Tri.split(" ");
				a = Integer.parseInt(result1[0]);
				b = Integer.parseInt(result1[1]);
				c = Integer.parseInt(result1[2]);
				if(((a*a)+(b*b)==(c*c))||((c*c)+(b*b)==(a*a))||((a*a)+(c*c)==(b*b)))
				{
					System.out.println("YES");
				}else
				{
					System.out.println("NO");
				}

			}

		} catch (IOException e) {

		}
	}

}

Measured memory_bytes: 25908
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n , m , k;
ll p[200005];
ll a[200005] , b[200005];
ll id[200005];
ll X[200005] , Y[200005];
map< pair<ll,ll> , ll> mp;
ll fs(ll x)
{
        return p[x] == x ? x : p[x] = fs(p[x]);
}
void us(ll ax , ll bx)
{
        ax = fs(ax);
        bx = fs(bx);
        p[bx] = ax;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        cin >> n >> m >> k;
        for(ll i=1;i<=n;i++) p[i] = i;
        for(ll i=1;i <=m;i++)
        {
                cin >> a[i] >> b[i];
                us(a[i] , b[i]);
                //id[a[i]] = id[b[i]] = -1;
        }
        memset(id , -1 , sizeof id);
        ll cnt = 0;
        for(ll i=1;i<=n;i++)
        {
                ll cap = fs(i);
                if(id[cap] == -1) {
                        id[cap] = ++cnt;
                }
                X[i] = id[cap];
                //X[i] = id[cap];
        }
        cnt = 0;
        for(ll i=1;i<=n;i++) p[i] = i;
        for(ll i=1;i<=k;i++)
        {
                cin >> a[i] >> b[i];
                us(a[i] , b[i]);
                //id[a[i]] = id[b[i]] = -1;
        }
        memset(id , -1 , sizeof id);
        for(ll i=1;i<=n;i++)
        {
                ll cap = fs(i);
                if(id[cap] == -1) {
                        id[cap] = ++cnt;
                }
                Y[i] = id[cap];
        }
        for(ll i=1;i<=n;i++)
        {
                //cout << X[i] << " " << Y[i] << endl;
                mp[make_pair(X[i] , Y[i])]++;
        }
        for(ll i=1;i<=n;i++)
        {
                cout << mp[make_pair(X[i] , Y[i])] << " ";
        }
        return 0;
}


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

int main() {
  int n, ans = 0;

  cin >> n;

  vector<int> a;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    if (a.at(i) != -1 && a.at(a.at(i) - 1) == i + 1) {
      ans++;
      a.at(a.at(i) - 1) = -1;
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size))
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;
 
int32_t main()
{
	IOS;
	string s;
	int flaga=0,flagb=0;
	cin>>s;
	for(int i=0;i<(int)s.length();i++)
	{
		if(s[i]=='A')
		{
			flaga=1;
		}
		else
		{
			flagb=1;
		}
	}
	if((flaga==1) && (flagb==1))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Move {
    int x1, y1, x2, y2;
};

struct Grid {
    int x, y, a;
};

int main() {
    int h, w;
    cin >> h >> w;

    vector<Grid> grid(h * w);
    for (int i = 0; i < h * w; i++) {
        int a;
        cin >> a;
        grid[i].x = i % w;
        grid[i].y = i / w;
        grid[i].a = a;
    }

    for (int y = 0; y < h; y++) {
        if (y % 2 == 0) continue;
        reverse(grid.begin() + (w * y), grid.begin() + (w * (y + 1)));
    }


    vector<Move> move;
    for (int i = 0; i < h * w - 1; i++) {
        if (grid[i].a % 2 == 0) continue;
        grid[i].a--;
        grid[i + 1].a++;

        Move m;
        m.x1 = grid[i].x;
        m.y1 = grid[i].y;
        m.x2 = grid[i + 1].x;
        m.y2 = grid[i + 1].y;
        move.push_back(m);
    }

    cout << move.size() << endl;

    for (Move m: move) {
        printf("%d %d %d %d\n", m.y1 + 1, m.x1 + 1, m.y2 + 1, m.x2 + 1);
    }

}

Measured memory_bytes: 7152
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

vii v[200005];
int par[200005],d[200005],s[200005];

void dfs0(int at,int p,int h=1)
{
	d[at]=h;
	s[at]=1;
	par[at]=p;
	tr(v[at],it)
	{
		int to=*it;
		if(to!=p)
		dfs0(to,at,h+1),s[at]+=s[to];
		
	}
	//o2(at,s[at]);on;
}

int main()
{ios_base::sync_with_stdio(false);
int n;
gl(n);
rep(i,1,n-1)
{
	int x,y;
	cin>>x>>y;
	v[x].pb(y);
	v[y].pb(x);
}

dfs0(1,0);

int at=n,h=(d[n])/2;
h--;
while(1)
{
	if(h==0)break;
	h--;
	at=par[at];
}
if(s[at]<n-s[at])ol("Fennec");
else ol("Snuke");


return 0;
}



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

using namespace std;

struct edge {
    int a, b;
    double w;
};

class BellmanFord {
    int n;
    vector<edge> edges;
    vector<double> d;

public:
    BellmanFord(int n) : n(n), edges(n), d(n, numeric_limits<double>::infinity()) {}

    void add_edge(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
        edges.push_back({b, a, w});
    }

    void add_arc(int a, int b, double w) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
    }

    // return true if has negative loop
    bool run(int a) {
        d[a] = 0;
        for (int i = 0; i < n; i++) {
            bool change = false;
            for (edge e: edges) {
                if (d[e.a] != numeric_limits<double>::infinity()) {
                    if (d[e.b] > d[e.a] + e.w) {
                        d[e.b] = d[e.a] + e.w;
                        change = true;
                    }
                }
            }
            if (!change) {
                return false;
            }
        }
        return true;
    }

    double dist(int a) {
        return d[a];
    }
};

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

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

    BellmanFord bf(n);
    vector<vector<int>> adj(n);
    vector<tuple<int, int, int>> es;

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        es.emplace_back(a, b, c);
        adj[b].push_back(a);
    }

    vector<bool> visited(n);

    function<void(int)> dfs = [&](int v) {
        visited[v] = true;
        for (int a : adj[v]) {
            if (!visited[a]) {
                dfs(a);
            }
        }
    };
    dfs(n - 1);
    assert(visited[0]);

    for (int i = 0; i < m; i++) {
        int a = get<0>(es[i]), b = get<1>(es[i]), c = get<2>(es[i]);
        if (visited[a] && visited[b]) {
            bf.add_arc(a, b, p - c);
        }
    }

    if (bf.run(0)) {
        cout << -1 << endl;
        return 0;
    }
    cout << max(0, (int) -bf.dist(n - 1)) << endl;
}

Measured memory_bytes: 896
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<set>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#define mp make_pair
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}
void outn(ll x)
{
    if (x<0){
        putchar('-');
        out(-x);
    }else out(x);
    putchar(10);
}
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
//const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll quickpow(ll x, ll k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}

const int maxn = 1e5 + 5;
int par[maxn], r[maxn];
int findp(int x)
{
    if (par[x] < 0) return x;
    else{
        int fx = findp(par[x]);
        r[x] = (r[x] + r[par[x]]) % 2;
        par[x] = fx;
    }
}
void unite(int x, int y)
{
    int fx = findp(x), fy = findp(y);
    if (fx != fy){
        r[x] = (r[x] - r[y] + 1) % 2;
        par[fy] = fx;
    }
}
bool same(int x, int y){return findp(x) == findp(y);}

int main()
{
    int x, c5 = 0, c7 = 0;
    for (int i = 0; i < 3; ++i){
        cin >> x;
        if (x == 5) ++c5;
        if (x == 7) ++c7;
    }
    if (c5 == 2 && c7 == 1) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 256
K , N = map(int,input().split())
arr = list(map(int,input().split()))
add = 0
maxDist = -1
arr.sort()
dp = [0 for  _ in range(N) ]
for i in range(N-1):
	dp[i+1] = arr[i+1]-arr[i]
dp[0] = (K-arr[N-1])+arr[0]
for i in range(N):
	add += dp[i]
	maxDist = max(maxDist,dp[i])
print(add-maxDist)


Measured memory_bytes: 86140
N, Y = list(map(int, input().split()))

N1000 = -1
N5000 = -1
N10000 = -1

flag = False
for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        if 1000*i+5000*j+10000*k == Y:
            N1000 = i
            N5000 = j
            N10000 = k
            flag = True
            break
    if flag:
        break

print(N10000, N5000, N1000)



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

using namespace std;

uint64_t gcd(uint64_t a, uint64_t b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
int main()
{
  uint64_t A, B, C, D;

  cin >> A >> B >> C >> D;

  uint64_t gcd_cd = gcd(C,D);

  /*  cout << B - A + 1 << endl;
  cout << B/C - (A - 1)/C << endl;
  cout << B/D - (A - 1)/D << endl;
  cout << (B/(C*D) - (A - 1)/((C*D)/gcd_cd)) << endl;*/



  /*  cout << gcd_cd << endl;
      cout << (C*D)/gcd_cd <<endl;*/
  uint64_t cd =(C*D)/gcd_cd;
  cout << (B - A + 1) - (B/C - (A - 1)/C) - (B/D - (A - 1)/D) + (B/cd - (A - 1)/cd) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

total = 0
for i in range(N):
    n = int(input())
    if is_prime(n):
        total +=1
print(total)


Measured memory_bytes: 5616
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
a1 
..
an

n 10^5
ai n

ai -1
 */
int n,a[100000];
bool c[100000];

int main(){
  cin>>n;
  REP(i,n){
    cin>>a[i];
    a[i]--;
  }
  int i=0;
  int ans=0;
  while(!c[i]){
    if(i==1){
      cout<<ans<<endl;
      return 0;
    }
    c[i] = true;
    i = a[i];
    ans++;
  }

  cout<<-1<<endl;

  return 0;
}


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

int main(){
  int64_t N,A,B;
  cin >> N >> A >> B;
  if(A>N){
    cout << N << endl;
  }else{
    int64_t ans=0;
    int64_t x=N/(A+B);
    int64_t mod=N%(A+B);
    ans=x*A;
    if(mod<A){
      ans+=mod;
    }else{
      ans+=A;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
    	int a,b,c;
    
    	Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
    
    	c = a*b;
    
    	if(c % 2 == 0) System.out.println("Even");
    	else System.out.println("Odd");
    } catch(Exception e){
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 35576
#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>;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
int n;
vector<int> to[200005];
 
mint ans;
int dfs(int v, int p=-1) {
  int res = 1;
  vector<int> ts;
  for (int u : to[v]) {
    if (u == p) continue;
    int t = dfs(u,v);
    res += t;
    ts.push_back(t);
  }
  if (p != -1) {
    ts.push_back(n-res);
  }
  mint now = mint(2).pow(n-1)-1;
  for (int t : ts) {
    now -= mint(2).pow(t)-1;
  }
  ans += now;
  return res;
}
 
int main() {
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  ans /= mint(2).pow(n);
  cout << ans.x << endl;
  return 0;
}

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


int main(){
	
	int r,c;
	cin >> r >> c ;
	int mat[r][c];
	
	int i,j;
	for (i=0; i<r; i++){
		for (j=0; j<c; j++){
			cin >> mat[i][j] ;
		}
	}

	int vecr[r];
	for (i=0; i<r; i++){
		for (j=0; j<c; j++){
			vecr[i] =0 ;
		}
	}	
	for (i=0; i<r; i++){
		for (j=0; j<c; j++){
			vecr[i] += mat[i][j] ;
		}
	}
	
	int vecc[c];
	for (j=0; j<c; j++){
		for (i=0; i<r; i++){
			vecc[j]=0;
		}
	}	
	for (j=0; j<c; j++){
		for (i=0; i<r; i++){
			vecc[j] += mat[i][j];
		}
	}
	
	int sum=0;
	for (i=0; i<r; i++){
		sum += vecr[i];
	}

	for (i=0; i<r+1; i++){
		for (j=0; j<c+1; j++){
			if (i<r && j<c)cout << mat[i][j] << " ";
			else if (i<r && j==c) cout << vecr[i] ; 
			else if (i==r && j<c) cout << vecc[j] << " ";
			else if (i==r && j==c) cout << sum ;
		}
		cout << "\n" ;
	}	
	
	return 0;
	
}

Measured memory_bytes: 1200
#include <cstdio>
#include <algorithm>

typedef long long int ll;

const int MAXN = 2e5 + 5;

int n, d, a, left, right, cur;
long long int ans;

struct monster {
    int place, health, diff;

    bool operator < (const monster &another) const {
        return place < another.place;
    }
}arr[MAXN];

int main() {
    scanf("%d%d%d", &n, &d, &a);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &arr[i].place, &arr[i].health);
    }
    std::sort(arr + 1, arr + n + 1);
    for (int i = 1; i < n; ++i) {
        arr[i].diff = arr[i + 1].health - arr[i].health;
    }
    d <<= 1; //根据题意，区间左右端点最大差值为所给 d 的两倍
    left = right = 1;
    cur = arr[1].health;
    while (left <= n) {
        while (right <= n && arr[right + 1].place - arr[left].place <= d) {
                ++right;
        }
        int tmp = (cur / a + ((cur % a) != 0));
        ans += tmp;
        cur -= tmp * a;
        arr[right].diff += tmp * a;
        while (cur <= 0) {
            cur += arr[left].diff;
            ++left;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e14;
const LL MOD = 1e9 + 7;

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

LL calc_dp(auto i, auto j, auto &dp, auto &N, auto &a)
{
  if (dp[i][j] != INF) return dp[i][j];
  if (i > j) return dp[i][j] = 0;
  else if(i == j)
  {
    if ((N-(j-i+1)) % 2 == 0) return dp[i][j] = a[i];
    else return dp[i][j] = -a[i];
  }
  else
  {
    if ((N-(j-i+1)) % 2 == 0) return dp[i][j] = max(calc_dp(i, j-1, dp, N, a)+a[j], calc_dp(i+1, j, dp, N, a)+a[i]);
    else return dp[i][j] = min(calc_dp(i, j-1, dp, N, a)-a[j], calc_dp(i+1, j, dp, N, a)-a[i]);
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL N;
  cin >> N;
  VLL a(N);
  INPUT(a);
  VVLL dp(N, VLL(N, INF));
  cout << calc_dp(0, N-1, dp, N, a) << endl;

  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num ;
    cin >> num ;
    cout << num  / 3 ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  ll tot = 0;
  
  rep(i,n){
    ll upper = c.end() - upper_bound(c.begin(),c.end(),b[i]);
    ll lower = lower_bound(a.begin(),a.end(),b[i])-a.begin();
    tot += upper*lower;

  }
  cout << tot << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

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

		System.out.print(input1.charAt(0));
		System.out.print(input2.charAt(1));
		System.out.print(input3.charAt(2));
		System.out.println("");
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();

        List<P> pos = new ArrayList<>();
        List<P> neg = new ArrayList<>();

        for(int i=0; i<n; i++) {
            P p = new P(sc.next());
            if(p.last >= 0) {
                pos.add(p);
            } else {
                neg.add(p.inv());
            }
        }
        Collections.sort(pos, new Comparator<P>() {
            @Override public int compare(P o1, P o2) {
                return o2.low - o1.low;
            }
        });
        Collections.sort(neg, new Comparator<P>() {
            @Override public int compare(P o1, P o2) {
                return o2.low - o1.low;
            }
        });

        int l = 0;
        for(P p : pos) {
            if(l + p.low < 0) {
                System.out.println("No");
                return;
            }
            l += p.last;
        }
        int r = 0;
        for(P p : neg) {
            if(r + p.low < 0) {
                System.out.println("No");
                return;
            }
            r += p.last;
        }
        if(l == r) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class P {
        int low;
        int last;
        P(String s) {
            int pos = 0;
            for(char c : s.toCharArray()) {
                if(c == '(') {
                    pos++;
                } else {
                    pos--;
                    low = Math.min(low, pos);
                }
            }
            last = pos;
        }
        P inv() {
            P q = new P("");
            q.low = low - last;
            q.last = -last;
            return q;
        }
    }


}

Measured memory_bytes: 92384
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


char c;

void solve()
{
    cin >> c;
    char a[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    for (int i=0; i<26; i++) {
        if (c==a[i]) {
            nout(a[i+1]); break;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}


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

int main() {
    int N,a,r=0;
    cin >> N;
    map<int,int> m;

    rep(i,N) {
        cin >> a;
        if(m.count(a))
            m.at(a)++;
        else
            m[a] = 1;
    }

    for(auto p : m) {
        if(p.second < p.first)
            r += p.second;
        else
            r += p.second-p.first;
    }

    cout << r << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a, b, k;
  cin >> a >> b >> k;

  while (k) {
    b += a / 2;
    a /= 2;
    --k;

    if (k == 0) break;
    a += b / 2;
    b /= 2;
    --k;
  }

  cout << a << " " << b << ln;

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]
t = 0
f = 1
ans = deque([])

for n, a in enumerate(A, start=1):
    if a == f:
        ans.append(n - t - 1)
        f += 1
        t = n
else:
    if t != N:
        ans.append(n - t)

if f == 1:
    print(-1)
else:
    print(sum(ans))

Measured memory_bytes: 72528
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	cout<<a+b+c-max({a,b,c});
	cout<<endl;
} 


Measured memory_bytes: 256
n = int(input())
arr = []
s = input().split()
for i in range(n):
    arr.append(int(s[i]))
for i in range(n):
    k = arr[i]
    j = i - 1
    while j >= 0 and arr[j] > k:
        arr[j+1] = arr[j]
        j -= 1
    arr[j+1] = k
    for i in range(n):
        if i == n-1:
            print(arr[i])
        else:
            print(arr[i], end=" ")

Measured memory_bytes: 8084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define pll pair<ll,ll>


int main() {

	ll n;
	cin>>n;

	vector<vector<ll> > dp(3, vector<ll>(n,0));
	for(ll i=0;i<n;i++)
		cin>>dp[0][i]>>dp[1][i]>>dp[2][i];

	for(ll i=1;i<n;i++) {
		dp[0][i] += max(dp[1][i-1],dp[2][i-1]);
		dp[1][i] += max(dp[2][i-1],dp[0][i-1]);
		dp[2][i] += max(dp[1][i-1],dp[0][i-1]);
	}

	cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1])<<endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll X, A;

    cin >> X >> A;

    cout << (X < A ? 0 : 10) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll h, w, m;
	cin >> h >> w >> m;
	vector<vector<ll>> hcnt(h, vector<ll>(2, 0)), wcnt(w, vector<ll>(2, 0));
	set<vector<ll>> st;
	for (ll k = 0; k < m; k++) {
		ll i, j;
		cin >> i >> j;
		i--; j--;
		st.insert({i, j});
		hcnt[i][0]++;
		wcnt[j][0]++;
	}
	for (ll i = 0; i < h; i++) hcnt[i][1] = i;
	for (ll j = 0; j < w; j++) wcnt[j][1] = j;
	sort(ALL(hcnt));
	sort(ALL(wcnt));
	ll ans = 0, cnt = 0;
	for (ll i = 0; i < h; i++) {
		if (hcnt[h - 1 - i][0] < hcnt[h - 1][0]) break;
		for (ll j = 0; j < w; j++) {
			if (wcnt[w - 1 - j][0] < wcnt[w - 1][0]) break;
			ll subans = hcnt[h - 1 - i][0] + wcnt[w - 1 - j][0];
			if (st.find({hcnt[h - 1 - i][1], wcnt[w - 1 - j][1]}) != st.end()) subans--;
			ans = max(ans, subans);
			cnt++;
			if (cnt == m) {
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 64156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){

	int a, b, n;
	
	while(cin>>a>>b>>n, !cin.eof()){
	
		int sum = 0;
		
		a = a%b;
		
		for(int i=0; i<n; ++i){
			a *= 10;
			sum += a/b;
			a = a%b;
		}
		
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int D[100005], n; //深さを記録する

struct Node{
    int parent; //親
    int left; //最も左の子
    int right; //右の兄弟
};
struct Node N[100005];

int depthCheck(int u, int p){
    D[u] = p;
    if(N[u].right != -1) depthCheck(N[u].right, p);
    if(N[u].left != -1) depthCheck(N[u].left, p + 1);
}

void print(int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << N[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    if(N[u].parent == -1) cout << "root, ";
    else if(N[u].left == -1) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for(i = 0, c = N[u].left; c != -1; i++, c = N[c].right){
        if(i) cout << ", ";
            cout << c;
    }
    cout << "]" << endl;
}

int main(){
    int id, k, NextId, broId, r;
    cin >> n;
    rep(i, n){
        N[i].parent = N[i].left = N[i].right = -1;
    }
    rep(i,n){
        cin >> id >> k;
        rep(j, k){
            cin >> NextId;
            if(j == 0) N[id].left = NextId;
            else N[broId].right = NextId;
            broId = NextId;
            N[NextId].parent = id;
        }
    }
    rep(i, n){
        if(N[i].parent == -1) r = i; //一番浅い位置
    }
    depthCheck(r, 0);
    rep(i ,n) print(i);
}

Measured memory_bytes: 5840
#define ll long long
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=1e5;
int main(){
	ll n,m,d;
	scanf("%lld%lld%lld",&n,&m,&d);
	if (d==0) printf("%.12lf",(1.0*n)/(n*n)*(m-1));else 
	printf("%.12lf",(2.0*(n-d))/(n*n)*(m-1)); 
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int x, y;
  cin >> x >> y;
  int xgroup = 3;
  int ygroup = 3;
  vector<int> A(7);
  A = {1, 3, 5, 7, 8, 10, 12};
  vector<int> B(4);
  B = {4, 6, 9, 11};
  for(int i=0; i<7; ++i){
    if(x == A[i]) xgroup = 1;
    if(y == A[i]) ygroup = 1;
  }
  for(int i=0; i<4; ++i){
    if(x == B[i]) xgroup = 2;
    if(y == B[i]) ygroup = 2;
  }
  if(xgroup == ygroup) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def sieve_of_eratosthenes(N):
    sieve = [0] * (N + 1)
    for p in range(2, N + 1):
        if sieve[p]:
            continue
        for i in range(p, N + 1, p):
            sieve[i] = p
    return sieve

def lcm_with_sieve(numbers, N):
    sieve = sieve_of_eratosthenes(N)
    lcm = dict()
    for n in numbers:
        d = dict()
        while n > 1:
            factor = sieve[n]
            n //= factor
            d[factor] = d.get(factor, 0) + 1
        for factor, power in d.items():
            lcm[factor] = max(lcm.get(factor, 0), power)
    return lcm

input()
A = tuple(map(int, input().split()))
lcm = 1
for factor, power in lcm_with_sieve(A, 10 ** 6).items():
    lcm = lcm * pow(factor, power, MOD) % MOD
total = 0
for a in A:
    total = (total + lcm * pow(a, MOD - 2, MOD)) % MOD
print(total)

Measured memory_bytes: 51312
/*
 * (c) fushar (Ashar Fuadi)
*/

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

#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define RESET(c,v) memset(c, v, sizeof c)

typedef long long ll;

const int MAXN = 100005;

int N;
int A[3*MAXN];

ll pref[MAXN], suff[MAXN];

int main() {
    scanf("%d", &N);
    REP(i, 3*N) {
        scanf("%d", &A[i]);
    }

    priority_queue<int, vector<int>, greater<int>> pq;
    ll total = 0;
    REP(i, N) {
        pq.push(A[i]);
        total += A[i];
    }
    pref[0] = total;
    REP(i, N) {
        pq.push(A[N+i]);
        total += A[N+i];
        int x = pq.top();
        pq.pop();
        total -= x;
        pref[i+1] = total;
    }

    priority_queue<int> pq2;
    total = 0;
    REP(i, N) {
        pq2.push(A[2*N+i]);
        total += A[2*N+i];
    }
    suff[0] = total;
    REP(i, N) {
        pq2.push(A[2*N-i-1]);
        total += A[2*N-i-1];
        int x = pq2.top();
        pq2.pop();
        total -= x;
        suff[i+1] = total;
    }

    ll res = LLONG_MIN;
    REP(i, N+1) {
        res = max(res, pref[i] - suff[N-i]);
    }

    printf("%lld\n", res);
}



Measured memory_bytes: 3832