akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
  
  
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
  
  
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
  
  
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
  
  
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
  
  
n = int(stdin.readline())
  
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

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

int main(){
    string s;
    cin >> s;
    do{
        s.pop_back();
        s.pop_back();
    }while(s.substr(0,s.size()/2)!=s.substr(s.size()/2,s.size()/2));
    int ans=s.size();
    cout << ans << endl;
}


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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int flag=0;
    while(n>0)
    {
        int t=n%10;
        if(t==7)
            flag=1;
        n=n/10;
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



Measured memory_bytes: 3612
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 200005
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<pair<ll,ll> >adj[MAX+10];
ll dep[MAX+10];
int main()
{
    fast;
    cin>>n>>a>>b;
    ll A=abs(n-a);
    ll B=abs(n-b);
    if(A<=B) cout<<"A"<<endl;
    else cout<<"B"<<endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<":"
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, w; cin>>n>>w;
    vll dp(w+1);
    for(i = 0 ; i < n; i++){
        int a, b; cin>>a>>b;
        vll new_dp(w+1);
        for(j = 0; j <= w; j++){
            new_dp[j] = dp[j];
            if(a <= j) new_dp[j] = max(new_dp[j], dp[j-a] + b);
        }
        dp = new_dp;
    }
    cout << dp[w] << endl;
    return 0;
}


Measured memory_bytes: 1804
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

int main(){
    ll N, K;
    cin >> N >> K;

    cout << min(N%K , abs(N%K - K)) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A,B;
char s;
int main()
{
    scanf("%d %c %d",&A,&s,&B);
    if(s=='+')
    {
        printf("%d\n",A+B);
    }
    else
    {
         printf("%d\n",A-B);
    }
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

P = [0] * (B + 1)
for i in range(10000,B + 1):
  if (i // 10000 == i % 10) and ((i // 1000) % 10 == (i // 10) % 10):
    P[i - 9999] = P[i - 10000] + 1
  else:
    P[i - 9999] = P[i - 10000]
print(P[B - 9999] - P[A - 10000])


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int latte[15];

int N;
string S[20];
int w[20];
bool used[10],nz[10];
int solve(int n,int s){
    if(n==-1)return s==0;
    int ret=0;
    for(int i=0;i<10;i++){
        if(nz[n]&&i==0)continue;
        if(used[i])continue;
        used[i]=true;
        ret+=solve(n-1,s+w[n]*i);
        used[i]=false;
    }
    return ret;
}

signed main(){
    latte[0]=1;
    for(int i=1;i<15;i++)latte[i]=latte[i-1]*10;
    while(cin>>N,N){
        rep(i,N)cin>>S[i];
        rep(i,N)reverse(all(S[i]));
        vector<char>vec;
        rep(i,N)for(char c:S[i])vec.pb(c);
        sort(all(vec));vec.erase(unique(all(vec)),vec.end());
        memset(w,0,sizeof(w));
        memset(nz,0,sizeof(nz));
        rep(i,N)rep(j,S[i].size()){
            int idx=lower_bound(all(vec),S[i][j])-vec.begin();
            w[idx]+=latte[j]*(i==N-1?-1:1);
            if(S[i].size()>1&&j+1==S[i].size())nz[idx]=true;
        }
        cout<<solve(vec.size()-1,0)<<endl;

    }
    return 0;
}

Measured memory_bytes: 2928
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(n[k-1])

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int N;
    llong D;
    cin >> N >> D;
    D = D * D;
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        llong x, y;
        cin >> x >> y;
        llong distance = x * x + y * y;
        if (distance <= D)
            ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>
 
#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)
 
typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
 
using namespace std;
 
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
int h, w;
v2_string s(30, v_string(30, ""));
 
int solve(pii start, pii goal)
{
    int d[30][30];
 
    irep(i, 30) {
        irep(j, 30) {
            d[i][j] = INF;
        }
    }
 
    queue<pii> q;
    q.push(start);
    d[start.first][start.second] = 0;
 
    while(q.size()) {
        
        pii p = q.front(); q.pop(); 
        if(p.first == goal.first && p.second == goal.second) { break; }
 
        irep(i, 4) {
            int row = dy[i] + p.first;
            int col = dx[i] + p.second;
            if(0 <= col && col < w && 0 <= row && row < h) {
                if(s[row][col] != "#" && d[row][col] == INF) {
                    d[row][col] = d[p.first][p.second] + 1;
                    q.push(pii(row, col));
                    //cout << row << "," << col << endl;
                }
            }
        }
    }
 
    if(d[goal.first][goal.second] != INF) {
        return d[goal.first][goal.second];
    } else {
        return -1;
    }
}
 
int main(void)
{
    int ans = -1;
    cin >> h >> w;
 
    irep(i, h) {
        irep(j, w) {
            char tmp;
            cin >> tmp;
            s[i][j] = tmp;
        }
    }
 
    irep(i, h) {
        irep(j, w) {
            irep(k, h) {
                irep(l, w) {
                    if(i == k && j == l) { continue; }
                    if(s[i][j] == "#" || s[k][l] == "#") { continue; }
                    pii start(i, j);
                    pii goal(k, l);
                    ans = max(ans, solve(start, goal));
                }
            }
        } 
    }
    
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<stdio.h>

using namespace std;
int main(void){
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0;i < s.size();i++)if (s[i] == '0')count++;
	if (count > (s.size() - count))count = s.size() - count;
	cout << 2*count;
	return 0;
}

Measured memory_bytes: 512
X,K,D=map(int, input().split())
n=(K*D-X)//(2*D)
#print(n)
if n<0:
    ans=abs(X-K*D)
elif n>=K:
    ans=abs(X+K*D)
else:
    ans1=abs(X+(2*n-K)*D)
    ans2=abs(X+(2*(n+1)-K)*D)
    ans=min(ans1,ans2)
    #print(n,ans1,ans2)
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		int d = a[i] + a[i - 1] - x;
		if (d <= 0) continue;
		ans += d;
		if (a[i] < d) {
			a[i - 1] -= d - a[i];
			a[i] = 0;
		} else {
			a[i] -= d;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
from itertools import accumulate
import sys
input = sys.stdin.readline

S = input()
T = input()
cntS = [1 if S[i] == 'A' else -1 for i in range(len(S))]
cntT = [1 if T[i] == 'A' else -1 for i in range(len(T))]
cumS = list(accumulate([0] + cntS))
cumT = list(accumulate([0] + cntT))
q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    if (cumS[b] - cumS[a-1]) % 3 == (cumT[d] - cumT[c-1]) % 3:
        print('YES')
    else:
        print('NO')

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

//const int INF = 1001001001;
//const ll INF18 = 1000000000000000000;
const ll INF15 = 1000000000000000;

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);

	ll ans;
	ll min_cand;
	min_cand = min(k, x/d);
	k -= min_cand;
	ans = x - min_cand*d;

	if (k % 2 != 0) ans = abs(ans - d);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
import itertools

def create_cards(suits: list, ranks: list) -> set:
    return list(itertools.product(suits, ranks))


if __name__ == "__main__":
    suits = ["S", "H", "C", "D"]
    ranks = [str(elem) for elem in range(1, 14)]
    cards = create_cards(suits, ranks)

    elem_num = int(input())
    for i in range(elem_num):
        symbol, num= input().split()
        cards.remove((symbol, num))
    
    for suit, rank in cards:
        print(f"{suit} {rank}")



Measured memory_bytes: 5660
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()
Q = ri()
queries = []
for i in range(Q):
	q = rl()
	queries.append(q)

import collections

cnt = collections.Counter(A)
s = sum(A)

for b, c in queries:
	s = s - b * cnt[b] + c * cnt[b]
	print(s)
	cnt[c] += cnt[b]
	cnt[b] = 0


Measured memory_bytes: 101576
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, n) for (ll i = n; i >= 0; i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cerr << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cerr << e << " "; } cerr << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************

int main() {

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }

    vector<bool> dp(K + 1, false);

    FOR(i, 1, K + 1) {
        bool flag = false;
        for (auto& a : A) {
            if (i - a < 0) continue;
            if (dp[i - a] == false) {
                flag = true;
                dp[i] = true;
                break;
            }
        }
        if (!flag) dp[i] = false;
    }

    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int, input().split())

ans = 1e18
# 一致してないとどっちかがエッジまでいって一回消費してe/oをマッチさせる必要がある
if A%2 != B%2:
  work = A
  b = B-A
  a = 1
  work += (b-a) // 2
  #print(work,a,b)
  ans = min(ans,work)

  work = N-B+1
  a = A+N-B+1
  b = N
  work += (b-a) // 2
  #print(work,a,b)
  ans = min(ans,work)
else:
  work = (B-A) // 2
  ans = min(ans,work)
  
print(ans)



Measured memory_bytes: 3064
#include<cstdio>
#define MAX_N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, u, k, v;
int adj[MAX_N][MAX_N];
int color[MAX_N], d[MAX_N], f[MAX_N], tt;

void dfs_visit(int num){
	color[num] = GRAY;
	d[num] = ++tt;
	for(int i = 0; i < n; i++){
		if(adj[num][i] == 0) continue;
		if(color[i] == WHITE){
			dfs_visit(i);
		}
	}
	color[num] = BLACK;
	f[num] = ++tt;
}

void dfs(){
	for(int i = 0; i < n; i++){
		color[i] = WHITE;
	}
	tt = 0;

	for(int i = 0; i < n; i++){
		if(color[i] == WHITE){
			dfs_visit(i);
		}
	}
}

int main(void){
	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			adj[i][j] = 0;
		}
	}

	for(int i = 0; i < n; i++){
		scanf("%d", &u);
		u -= 1;
		scanf("%d", &k);
		for(int j = 0; j < k; j++){
			scanf("%d", &v);
			v -= 1;
			adj[u][v] = 1;
		}
	}

	dfs();

	for(int i = 0; i < n; i++){
		printf("%d %d %d\n", i + 1, d[i], f[i]);
	}

	return 0;
}

Measured memory_bytes: 2660
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll MOD=1000000007;
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d,co;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		co=vi(n);
		d[s]=0;
		co[s]=1;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					co[to]=co[pos];
					q.push(pii(-d[to],to));
				}else if(nowcost==d[to])
					(co[to]+=co[pos])%=MOD;
			}
		}
	}
};
signed main(){
	int n,m,s,t;
	cin>>n>>m>>s>>t;s--;t--;
	DIJ dij(n);
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		dij.add_edge(a,b,c);
	}
	dij.dij(s);
	vi sd=dij.d,sco=dij.co;
	dij.dij(t);
	vi td=dij.d,tco=dij.co;
	
	int out=sco[t]*sco[t]%MOD;
	rep(i,n)if(sd[i]+td[i]==sd[t]&&sd[i]==td[i])(out+=MOD-(sco[i]*tco[i]%MOD)*(sco[i]*tco[i]%MOD)%MOD)%=MOD;
	rep(i,n)rep(j,dij.G[i].size())if(sd[i]+dij.G[i][j].cost+td[dij.G[i][j].to]==sd[t]&&sd[i]*2<sd[t]&&td[dij.G[i][j].to]*2<sd[t])(out+=MOD-(sco[i]*tco[dij.G[i][j].to]%MOD)*(sco[i]*tco[dij.G[i][j].to]%MOD)%MOD)%=MOD;
	cout<<out<<endl;
}

















Measured memory_bytes: 19028
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

/*
union by rank and path compression
n, m を入力サイズとして(n := 頂点数, m := オペレーション数)
ならし計算量が O(m*a(n))
加えて, size(x) とかもあれば嬉しいなぁ

*/

//

struct UnionFind{
    
    vector<int> par;
    vector<int> rank;
    vector<int> size;

private:
    void init(int n = 1){
        par.resize(n);
        rank.resize(n);
        size.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

public:
    UnionFind(int n = 1){
        init(n);
    }
    int Find(int x){
        if(par[x] == x) return x;
        int r = Find(par[x]);
        return par[x] = r;
    }
    
    bool issame(int x, int y){
        return Find(x) == Find(y);
    }

    bool Union(int x, int y){
        x = Find(x);
        y = Find(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        size[x] = size[x] + size[y];
    }

    int getSize(int x){
        return size[Find(x)];
    }

};


signed main(){
    

    int n, m; cin >> n >> m;
    UnionFind uf(n);
    vector<int> a(m);
    vector<int> b(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int ans = n * (n - 1) / 2;
    vector<int> v;
    for(int i = m - 1; i >= 0; i--){
        v.push_back(ans);
        int x = a[i];
        int y = b[i];

        if(!uf.issame(x, y)){
            ans -= uf.getSize(x) * uf.getSize(y);
            uf.Union(x, y);
        }

    }

    for(int i = m - 1; i >= 0; i--) cout << v[i] << endl;
    return 0;
}



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

/*
  i:枚数   j:差の合計値
  dp[i][j] = 総数
		   = i枚目までを考慮したときの、差の合計がjである場合の総数
*/

long long dp[51][10000] = { 0 };
int diff[51] = { 0 };
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, A, x; cin >> N >> A;
	int M = 0;
	for (int i = 1;i <= N;i++) { cin >> x; M = max(M, x);diff[i] = x - A; }
	int Mid = N*M;
	dp[0][Mid] = 1;
	for (int i = 1; i <= N;i++) {
		for (int t = 0; t <= 2 * Mid;t++) {
			if (Mid - diff[i] < 0 || Mid - diff[i] >= 2 * Mid) { dp[i][t] = dp[i - 1][t]; }
			else { dp[i][t] = dp[i - 1][t] + dp[i - 1][t - diff[i]]; }
		}
	}
	cout << dp[N][Mid] - 1 << endl;
}


Measured memory_bytes: 2432
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;
typedef  pair<int, int> pint;

int main(){
    int N;
    cin >> N;
    rep(i, 26){
        rep(j, 15){
            if(i * 4 + j * 7 == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


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

int main() {
    int n, S[10005], sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

    int q;
    int cnt = 0;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (search(S, n , t)) ++cnt;
    }

    cout << cnt << endl;
    return 0;

}


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

#define ll long long
#define INF 2147483647
#define Inf 9223372036854775807
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=105;
int n,base,mn=INF;
ll sum;
int a[maxn],nxt[maxn*5],level[maxn*5];
class EDGE{
public:
	int to,cap,rev;
};
vector<EDGE>edge[maxn*5];

void add_edge(int from,int to,int cap){
	edge[from].pb((EDGE){to,cap,(int)edge[to].size()});
	edge[to].pb((EDGE){from,0,(int)edge[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	level[s]=0;
	queue<int>q;
	q.push(s);
	while(!q.empty()){
		int x=q.front();q.pop();
		rep(i,edge[x].size()){
			EDGE &y=edge[x][i];
			if(y.cap&&level[y.to]<0){
				level[y.to]=level[x]+1;
				q.push(y.to);
			}
		}
	}
}

int dfs(int s,int t,int f){
	if(s==t)return f;
	for(int &i=nxt[s];i<edge[s].size();i++){
		EDGE &x=edge[s][i];
		if(x.cap&&level[x.to]==level[s]+1){
			int d=dfs(x.to,t,min(f,x.cap));
			if(d){
				x.cap-=d;
				edge[x.to][x.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(int s,int t){
	ll flow=0;
	while(true){
		bfs(s);
		if(level[t]<0)return flow;
		memset(nxt,0,sizeof(nxt));
		int f;
		while(f=dfs(s,t,INF))flow+=f;
	}
}

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d",&a[i]);
		mn=min(mn,a[i]);
	}
	if(mn>0)base=0;
	else base=-mn;
	REP(i,n){
		a[i]+=base;
		sum+=a[i];
	}
	REP(i,n){
		add_edge(0,i,INF);
		for(int j=i;j<=n;j+=i){
			add_edge(i,j+n,INF);
			add_edge(j+2*n,i+3*n,INF);
		}
	}
	REP(i,n){
		add_edge(i+n,i+2*n,a[i]);
		add_edge(i+3*n,4*n+1,base);
	}
/*	rep(i,3*n+2){
		cout<<i<<endl;
		rep(j,edge[i].size())cout<<edge[i][j].to<<" "<<edge[i][j].cap<<endl;
		cout<<endl;
	}*/
	printf("%lld",sum-max_flow(0,4*n+1));
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=3e2+1;
void solve()
{
	ll H,W,K;
	cin>>H>>W>>K;
	char a[maxn][maxn];
	ll ans[maxn][maxn]={0};
	ll yes[maxn]={0};
	ll c=1;
	for(ll i=0;i<H;i++)
	{
		for(ll j=0;j<W;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')
			{
				ans[i][j]=c;
				yes[i]++;
				c++;
			}
		}
	}
	ll start=0;
	for(ll i=0;i<H;i++)
	{
		if(yes[i]!=0)
		{
			start=i;
			break;
		}
	}
	for(ll i=start;i<H;i++)
	{
		ll s=0;
		if(yes[i]!=0)
		{
			for(ll j=0;j<W;j++)
			{
				if(a[i][j]=='#')
				{
					s=j;
					break;
				}
			}
			for(ll j=s;j>=0;j--)
			{
				if(ans[i][j]==0)
				{
					ans[i][j]=ans[i][j+1];
				}
			}
			for(ll j=s+1;j<W;j++)
			{
				if(ans[i][j]==0)
				{
					ans[i][j]=ans[i][j-1];
				}
			}
		}
		else
		{
			for(ll j=0;j<W;j++)
			{
				ans[i][j]=ans[i-1][j];
			}
		}
	}
	for(ll i=start-1;i>=0;i--)
	{
		ll s=0;
		if(yes[i]!=0)
		{
			for(ll j=0;j<W;j++)
			{
				if(a[i][j]=='#')
				{
					s=j;
					break;
				}
			}
			for(ll j=s;j>=0;j--)
			{
				if(ans[i][j]==0)
				{
					ans[i][j]=ans[i][j+1];
				}
			}
			for(ll j=s+1;j<W;j++)
			{
				if(ans[i][j]==0)
				{
					ans[i][j]=ans[i][j-1];
				}
			}
		}
		else
		{
			for(ll j=0;j<W;j++)
			{
				ans[i][j]=ans[i+1][j];
			}
		}
	}
	for(ll i=0;i<H;i++)
	{
		for(ll j=0;j<W;j++)
		{
			cout<<ans[i][j]<<" ";
		}
		cout<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

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

    ll r = 0, t = 1;
    for (int k = 0; k < 60; k++) {
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] & t) c++;
        }
        r += t % P * c % P * (n - c) % P;
        t <<= 1;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

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

int main(int argc, char const *argv[])
{
    int x[2],k; cin >> x[0] >> x[1] >> k;

    int f = 0;
    for(int i=0;i<k;++i) {
        if(x[f]&1) x[f]-=1;
        x[1-f] += (x[f]>>1);
        x[f] >>= 1;
        f=1-f;
    }
    cout << x[0] << " " << x[1] << endl;
    return 0;
}


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

# 桁数を決める
tmp = 0
digit = 1
tmp += pow(26, digit)
while N > tmp:
    digit += 1
    tmp += pow(26, digit)

order = N - (tmp - pow(26, digit)) - 1
X = [0] * digit
cur = digit - 1
while order > 0:
    X[cur] = order % 26
    order //= 26
    cur -= 1

# X = list(reversed(X))
# print(X)

a = ord('a')
ans = []
for x in X:
    c = chr(a + x)
    ans.append(c)

print(''.join(ans))


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

int main(){

int N;
cin >> N;
int sum = 0, ma = 0;

for(int i = 0; i < N; i++){ 
       int L;
       cin >> L;
       ma = max(ma, L);
       sum += L;

}

if(ma < sum - ma){

cout << "Yes" << endl; 

}else{
cout << "No" << endl;
}

}
          

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}


/*------------------------------------*/
//N!の素因数分解
map<int, int> mapn;
int filter(int i){
    int cnt = 0;
    for(auto x: mapn){
        if(x.second >= i-1){
            cnt++;
        }
    }
    return cnt;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;


    for(int i = 1; i <= N;i++){
        auto m = factorize(i);
        for(auto x:m){
            mapn[x.first] += x.second;
        }
    }
    for(auto x:mapn){
        cerr<<x.first<<": "<< x.second<<endl;
    }
    ll ans = filter(75) + 
    (filter(3)-1) * filter(25) +
    (filter(5)-1) * filter(15) +
    (filter(3)-2) * filter(5) * (filter(5) - 1) / 2;
    /*
    cerr<<"75: "<<filter(75)<<endl;

    cerr<<"3 * 25: "<<filter(3) * filter(25)<<endl;
    cerr<<"5 * 15: "<<filter(5) * filter(15)<<endl;
    cerr<<"3 * 5 * 5: "<<(filter(3)-2) * filter(5) * (filter(5) - 1) / 2<<endl;
    cerr<<"3: "<<filter(3)<<endl;
    cerr<<"5: "<<filter(5)<<endl;
    */
    cout<<ans<<endl;
}

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

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    b:String,
    c:String,
    }
    let a=a.chars().collect_vec();
    let b=b.chars().collect_vec();
    let c=c.chars().collect_vec();
    println!("{}{}{}",a[0].to_uppercase(),b[0].to_uppercase(),c[0].to_uppercase())
}

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

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
	int n=read();
	while(n--){
		printf("ACL");
	}
	
	return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int a = 0;
    for(int i = A; i <= B; i++) {
        int l1, l2, r1, r2;
        l1 = i / 10000;
        l2 = i / 1000 - l1 * 10;
        r1 = i % 10;
        r2 = (i / 10) % 10;
        if(l1 == r1 && l2 == r2) {
            a++;
        }
    }

    cout << a << endl;
}

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

using namespace std;

int main()
{
    int a1, a2, a3, a4;
    long n;
    
    cin >> a1;
    cin >> a2;
    cin >> a3;
    cin >> a4;
    
    if(2*a1 < a2){
        a2 = 2*a1;
    }
    
    
    
    if(4*a1 < a3){
        a3 = 4*a1;
    }
    
    if(2*a2 < a3){
        a3 = 2*a2;
    }
    
    
    
    if(8*a1 < a4){
        a4 = 8*a1;
    }
    
    if(4*a2 < a4){
        a4 = 4*a2;
    }
    
    if(2*a3 < a4){
        a4 = 2*a3;
    }
    
    cin >> n;
    
    long total = 0;
    
    total += (long)(n/2) * a4;
    n = fmod (n, 2);
    
    total += (long)(n) * a3;
    n = fmod (n, 1);
    
    total += (long)(2*n) * a2;
    n = fmod(n,0.5);
    
    total += (long)(4*n) * a1;
    
    cout << total;
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>

using namespace std;

int main() {
    char S[4];
    char a;
    int flag = 0;
    cin >> S;

    a = S[0];
    for(int i = 1; i < 4; i++) {
        if(S[i] == a) {
            flag = 1;
        }
        a = S[i];
    }

    if(flag) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }

    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int a,b;

int main(){
	cin>>a>>b;
	if (a>0){
		cout<<"Positive"<<endl;
	}else if (b>=0){
		cout<<"Zero"<<endl;
	}else if ((b-a)%2==0){
		cout<<"Negative"<<endl;
	}else{
		cout<<"Positive"<<endl;
	}
	return 0;
}

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

int datas[105];

int main()
{
	int n;
	cin>>n;
	for(int a=0;a<n;a++)
	{
		scanf("%d", &datas[a]);
	}
	int maxi=-1;
	for(int a=0;a<n;a++)
	{
		for(int b=a+1;b<n;b++)
		{
			int tmp=abs(datas[a]-datas[b]);
			maxi=max(maxi, tmp);
		}
	}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
// #pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,i;
    cin>>n;
    string s;
    cin>>s;

    set<string> ss;
    map<char,ll> m1,m2;
    for(i=n-1;i>0;i--)
    {
        m2[s[i]]++;
    }
    m1[s[0]]++;
    for(i=1;i<n-1;i++)
    {    m2[s[i]]--;
        if(m2[s[i]]==0LL)
            m2.erase(s[i]);
        for(auto &f:m1)
        {
            for(auto &g:m2)
            {
                string ans="";
                ans+=f.F;
                ans+=s[i];
                ans+=g.F;
                ss.insert(ans);
            }
        }
        m1[s[i]]++;


    }
    /*for(auto v:ss)
        cout<<v<<"\n";*/
    cout<<ss.size();
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;
class Main{
public static void main(String[] args){
 Scanner scan = new Scanner(System.in);
 
long N = scan.nextLong();
long A = scan.nextLong();
long B = scan.nextLong(); 
long amari = 0;
long blue = 0;
long a = N / (A + B);
 amari = N % (A + B);
  if(amari > A){
    blue = A * (a + 1);
  }
  else {
    blue = amari + (A * a);
  }
  System.out.println(blue);
 }
}

Measured memory_bytes: 23508
<?php
$input = fgets(STDIN);
//echo var_dump($input);
$array = explode(" ", trim($input));
//echo var_dump($array);
//$array = explode(" ", $input);
//echo var_dump($array);
sort($array);
//echo $array[0]." ".$array[1]." ".$array[2];
echo implode(' ',$array);
//echo var_dump($array);
?>

Measured memory_bytes: 15148
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int H, W;
    cin >> H >> W;
    char a[H + 2][W + 2];
    rep(j, 0, W + 2) a[0][j] = a[H + 1][j] = '#';
    rep(i, 0, H + 2) a[i][0] = a[i][W + 1] = '#';
    rep(i, 1, H + 1) rep(j, 1, W + 1) cin >> a[i][j];

    ll dp[H + 1][W + 1];
    rep(i, 0, H + 1) rep(j, 0, W + 1) dp[i][j] = 0ll;

    dp[0][0] = 1ll;
    dp[1][1] = 1ll;

    int mod = 1e9 + 7;
    rep(i, 1, H + 1) rep(j, 1, W + 1) {
        if(i + 1 <= H) {
            if(a[i + 1][j] == '.') {
                (dp[i + 1][j] += dp[i][j]) %= mod;
            }
        }

        if(j + 1 <= W) {
            if(a[i][j + 1] == '.') {
                (dp[i][j + 1] += dp[i][j]) %= mod;
            }
        }
    }

    cout << dp[H][W] % mod << endl;
}


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

 
int main() {

    ll l,r;
    cin>>l>>r;
    ll ans=100000000;
    if(r-l<2020) {
        for(ll i=l;i<r;i++) {
            for(ll j=i+1;j<r+1;j++) {
                ans=min(ans,(i*j)%2019);
            }
        }
    }
    else{
        ans=0;
    }
    
    cout<<ans<<endl;
    
 return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, m, Q;
    int l[200000], r[200000], p[100000], q[100000];
    cin >> n >> m >> Q;
    for (int i = 0; i < m; i++)
        cin >> l[i] >> r[i];
    for (int i = 0; i < Q; i++)
        cin >> p[i] >> q[i];

    int arr[501][501] = {};
    for (int i = 0; i < m; i++)
    {
        arr[l[i]][r[i] - l[i]]++;
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j < n; j++)
        {
            arr[i][j] += arr[i][j - 1];
        }
    }
    /*
    cout << "==" << endl;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
    cout << "===" << endl;
    */
    for (int i = 0; i < Q; i++)
    {
        int cnt = 0;
        for (int j = p[i]; j <= q[i]; j++)
        {
            cnt += arr[j][q[i] - j];
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 7552
#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 INF = 1e9;
    const vector<int> dx{0,1,0,-1};
    const vector<int> dy{1,0,-1,0};
    int H, W;
    cin >> H >> W;
    int SH, SW;
    cin >> SH >> SW;
    SH--; SW--;
    int GH, GW;
    cin >> GH >> GW;
    GH--; GW--;
    vector<string> SS(H);
    REP(i,H) cin >> SS[i];

    vector<vector<int>> hw(H,vector<int>(W,INF));
    hw[SH][SW] = 0;
    set<pii> t_next;
    t_next.emplace(SH,SW);
    int step = 0;

    auto ishw = [&](int y, int x) {
        if (x < 0 || x >= W) return false;
        if (y < 0 || y >= H) return false;
        return true;
    };

    while(!t_next.empty() && hw[GH][GW] == INF) {
        set<pii> next;
        swap(t_next,next);
        while(!next.empty()) {
            set<pii> cnt;
            swap(next,cnt);
            for(auto p:cnt) {
                REP(i,4) {
                    int nx = p.second + dx[i];
                    int ny = p.first + dy[i];
                    if (!ishw(ny,nx)) continue;
                    if (SS[ny][nx] == '.' && hw[ny][nx] > step) {
                        next.emplace(ny,nx);
                        hw[ny][nx] = step;
                    } else {
                        FOR(y,p.first-2,p.first+3) FOR(x,p.second-2,p.second+3) {
                            if (!ishw(y,x)) continue;
                            if (SS[y][x] == '.' && hw[y][x] > step+1) {
                                t_next.emplace(y,x);
                                hw[y][x] = step+1;
                            }
                        }
                    }
                }
            }
        }
        step++;
    }

    OUT((hw[GH][GW] != INF) ? hw[GH][GW] : -1)

    return 0;
}

Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K,dn,sum=0;
    cin >> N >> K;
    vector<bool>itazura(N,true);
    for(int i=0;i<K;i++){
        cin >> dn;
        for(int j=0;j<dn;j++){
            int a;
            cin >> a;
            itazura.at(a-1)=false;
        }
    }
    for(int i=0;i<N;i++){
        if(itazura.at(i)==true){
            sum++;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3644
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
ll ans=1e18;
for(ll i=1;i*i<=n;i++)
{
    if(n%i==0)
    {
        ll x=i;
        ll y=n/i;
        ll z=fabs(x-1)+fabs(y-1);
        ans=min(ans,z);
    }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()>=4&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes"; else cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] z) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Point[] list = new Point[4];
            for (int i = 0; i < 4; i++) {
                list[i] = new Point(sc.nextDouble(), sc.nextDouble());
            }
            boolean result1 = true;
            boolean result2 = true;
            for (int i = 0; i < 3; i++) {
                double v = crossProduct(sub(list[i], list[(i + 1) % 3]), sub(list[(i + 1) % 3], list[3]));
                result1 &= v < 0.0;
                result2 &= v > 0.0;
            }
            System.out.println(result1 || result2 ? "YES" : "NO");
        }
    }

    static double crossProduct(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    static Point sub(Point a, Point b) {
        return new Point(b.x - a.x, b.y - a.y);
    }

}

class Point {
    double x;
    double y;

    Point(double x, double y) {
        this.x = x;
        this.y = y;
    }
}



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

using namespace std;
long long int n, k;


int main() {
    scanf(" %lld %lld", &n, &k);
    long long int a = n / k; 
    n = n - a * k;
    n = min(n, llabs(n-k));
    printf("%lld", n);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long LL;
const int MAXN = 2e5+10;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
signed main(){
    int a,b,c; cin>>a>>b>>c;
    if(a+b+c>=22) puts("bust"); else puts("win");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    if ( s == "ABC" ) cout << "ARC" << endl;
    else              cout << "ABC" << endl; 
    return 0;
}


Measured memory_bytes: 3624