akhauriyash/Code-Regression huggingface dataset:
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		BigInteger start = new BigInteger("" + reader.nextLong()), moves = new BigInteger("" + reader.nextLong()), d = new BigInteger("" + reader.nextLong());
		if (start.compareTo(new BigInteger("0")) == 0) {
			if (moves.mod(new BigInteger("2")).compareTo(new BigInteger("0")) == 0) {
				System.out.println(0);
			}
			else {
				System.out.println(d);
			}
		}
		else {
			if (start.abs().compareTo(moves.multiply(d)) >= 0) {
				if (start.compareTo(new BigInteger("0")) < 0) {
					System.out.println(Math.abs(start.add(moves.multiply(d)).longValue()));
				}
				else {
					System.out.println(start.subtract(moves.multiply(d)).longValue());
				}
			}
			else {
				if (start.compareTo(new BigInteger("0")) < 0) {
					long forward = Math.abs(start.divide(d).longValue()) + 1;
					moves = moves.subtract(new BigInteger("" + forward));
					start = start.add(d.multiply(new BigInteger("" + forward)));
				}
				else {
					long forward = start.divide(d).longValue();
					moves = moves.subtract(new BigInteger("" + forward));
					start = start.subtract(d.multiply(new BigInteger("" + forward)));
				}
				if (moves.mod(new BigInteger("2")).longValue() == 0) {
					System.out.println(start.longValue());
				}
				else {
					System.out.println(Math.abs(start.subtract(d).longValue()));
				}	
			}
			reader.close();
		}
	}
	
}


Measured memory_bytes: 38912
import java.util.Scanner;

// Main
class Main {
	static class Node {
		public Node next;
		public int value;
		public Node(int x) {
			value = x;
		}
	}
	static class List {
		private Node head;
		private Node tail;
		public List() {
			head = new Node(-1);
			tail = head;
		}
		private void reset() {
			head.next = null;
			tail = head;
		}
		public boolean isEmpty() {
			return head.next == null;
		}
		public void insert(int x) {
			Node n =  new Node(x);
			tail.next = n;
			tail = n;
		}
		public void dump() {
			Node n = head.next;
			for (int i = 0; n != null; i++, n = n.next) {
				if (i > 0) {
					System.out.print(" ");
				}
				System.out.print(n.value);
			}
			System.out.println();
		}
		public void splice(List s) {
			if (s.isEmpty()) {
				return;
			}
			tail.next = s.head.next;
			tail = s.tail;
			s.reset();
		}
	}

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			List[] p = new List[n];
			for (int i = 0; i < n; i++) {
				p[i] = new List();
			}
			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int c = sc.nextInt();
				int t = sc.nextInt();
				switch (c) {
				case 0:
					int x = sc.nextInt();
					p[t].insert(x);
					break;
				case 1:
					p[t].dump();
					break;
				case 2:
					int s = t;
					t = sc.nextInt();
					p[t].splice(p[s]);
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 311396
#include <stdio.h>

int main() {
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    if(a>b){
        printf("a > b\n");
    }
    if(a==b){
        printf("a == b\n");
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int64_t> H(N);
  vector<bool> bad(N);
  int A, B;
  int good = N;
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }
  for (int i = 0; i < M; i++){
    cin >> A >> B;
    if (H[A - 1] >= H[B - 1]){
      bad[B - 1] = true;
    }
    if (H[B - 1] >= H[A - 1]){
      bad[A - 1] = true;
    }
  }
  for (int i = 0; i < N; i++){
    if (bad[i]){
      good--;
    }
  }
  cout << good << endl;
}


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

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	int b = 0, cnt = 0, dif = 0;
	cin >> n;
	while (n--) {
		int x; cin >> x;
		x /= 400;
		if (x >= 8) ++cnt;
		else {
			if (b & (1 << x)) continue;
			++dif;
			b |= (1 << x);
		}
	}
	cout << max(1, dif) << " " << cnt + dif << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int N;
    cin >> N;
    int min_ = INT_MAX;
    int sum_ = 0;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        if (x % 10 != 0) {
            if (min_ > x) {
                min_ = x;
            }
        }

        sum_ += x;
    }

    if (sum_ % 10 != 0) {
        cout << sum_ << endl;
    } else {
        if (INT_MAX > min_) {
            sum_ -= min_;
            cout << sum_ << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
arr = gets.chomp.split(" ")
A,B,X = arr[0].to_i,arr[1].to_i,arr[2].to_i
if [A,B,X] == [2,2,6]
  puts "NO"
elsif X > A+B
  puts "YES"
elsif X < A
  puts "NO"
elsif X < A+B
  puts "YES"
else
  puts "YES"
end


Measured memory_bytes: 1788
def operate(x, y):
    if is_red[x]:
        is_red[y] = True
        if num_ball[x] == 1:
            is_red[x] = False
    num_ball[x] -= 1
    num_ball[y] += 1


if __name__ == "__main__":

    N, M = [int(x) for x in input().split(" ")]
    num_ball = [1 for _ in range(N)]
    is_red = [True] + [False for _ in range(N - 1)]

    for _ in range(M):
        x, y = [int(x) for x in input().split(" ")]
        x, y = x - 1, y - 1
        operate(x, y)
    print(sum(is_red))

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

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;
}

const int N=300,p=1e9+7;
struct Edge{int v,w,nxt;}a[N];
int head[N],low[N],dfn[N],d[N];
int fac[N],inv[N],cut[N],vs[N];
int fa[N],dep[N],tog[N];
int n,m,k,_,dfc,ans=1,nn,mm;

bitset <N> bit[N],t[N];

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

inline void add(int*arr,int u,int v){a[++_].v=v,a[_].nxt=head[u],head[u]=_;}

struct node{
	int l,r;
	inline void in(){read(l),read(r);}
}e[N];

inline int f(int x){return d[x]?d[x]=f(d[x]):x;}

inline int qpow(int A,int B){
	int res(1);while(B){
		if(B&1)res=1ll*A*res%p;
		A=1ll*A*A%p,B>>=1;
	}return res;
}

inline int c(int kn,int km){return 1ll*fac[kn]*inv[km]%p*inv[kn-km]%p;}

inline void dfs(int x,int las){
	dep[x]=dep[fa[x]=las]+1;
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v!=las)dfs(a[i].v,x);
}

inline int lca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	while(dep[x]!=dep[y])x=fa[x];
	while(x!=y)x=fa[x],y=fa[y];
	return x;
}

inline int dis(int x,int y){return dep[x]+dep[y]-(dep[lca(x,y)]*2);}

int main(){
	read(n),read(m),read(k);
	
	fac[0]=inv[0]=1;
	for(rg int i=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=qpow(fac[N-1],p-2);
	for(rg int i=N-2;i;--i)inv[i]=1ll*inv[i+1]*(i+1)%p;
	
	int km=0;
	for(rg int i=1;i<=m;++i){
		e[i].in();
		if(f(e[i].l)!=f(e[i].r)){
			d[f(e[i].l)]=f(e[i].r);
			add(head,e[i].l,e[i].r);
			add(head,e[i].r,e[i].l);
		}else e[++km]=e[i];
	}m=km;
	
	for(rg int i=1;i<=n;++i)
		if(!dep[i])
			dep[i]=1,dfs(i,0);
	
	for(rg int i=1;i<=m;++i){
		int x=e[i].l,y=e[i].r;
		if(dep[x]<dep[y])swap(x,y);
		while(dep[x]!=dep[y]){
			bit[i].set(x);
			vs[x]=1,x=fa[x];
		}
		while(x!=y){
			bit[i].set(x);vs[x]=1,x=fa[x];
			bit[i].set(y);vs[y]=1,y=fa[y];
		}
	}
	
	memset(d,0,sizeof d);
	
	for(rg int i=1;i<=m;++i)
	for(rg int j=i+1;j<=m;++j)
		if((bit[i]&bit[j]).count()>0)
			if(f(i)!=f(j))
				d[f(i)]=f(j);
	
	for(rg int i=1;i<=n;++i)
		if(!vs[i]&&fa[i])
			ans=1ll*ans*k%p;
	
	for(rg int i=1;i<=m;++i)
		if(d[i]){
			t[f(i)]|=bit[i];
			++tog[f(i)];
		}
	for(rg int i=1;i<=m;++i)
		if(f(i)==i&&tog[i])
			t[i]|=bit[i],++tog[i];
	
	for(rg int i=1;i<=m;++i)
		if(!tog[i]&&!d[i]){
			int kn=dis(e[i].l,e[i].r)+1;
			int res=0;
			for(int j=1;j<=kn;++j)
				res=(res+qpow(k,gcd(j,kn)))%p;
			ans=1ll*ans*res%p*qpow(kn,p-2)%p;
		}
	
	for(rg int i=1;i<=m;++i){
		int g=t[i].count()+tog[i];
		if(!g)continue;
		ans=1ll*ans*c(k+g-1,k-1)%p;
	}
	
	printf("%d\n",ans);
	return 0;
}

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  char C;
  cin >> C;
  C++;
  cout << C << endl;
 }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin>>n>>m;
    int s1[n],s2[n],t1[m],t2[m];
    for(int i=0;i<n;i++){
        cin>>s1[i]>>s2[i];
    }
    for(int i=0;i<m;i++){
        cin>>t1[i]>>t2[i];
    }
    for(int i=0;i<n;i++){
        int res=1<<30;
        int ans=0;
        for(int j=0;j<m;j++){
            int p=abs(s1[i]-t1[j])+abs(s2[i]-t2[j]);
            if(res>p){ans=j+1;res=p;}
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;
const long long L_INF = 9223372036854775807;
const int INF = 10000;
const int MAX = 50;

int timer = 1;
int num[MAX];
int low[MAX];
vector<int> graph[MAX];
int cnt = 0;

int solve(int v, int prev) {
	num[v] = timer++;
	low[v] = num[v] + 1;

	for (auto it = graph[v].begin(); it != graph[v].end(); it++) {
		if (num[*it] == INF) {
			low[v] = min(low[v], solve(*it, v));
		}
		else {
			if (prev == *it)continue;
			low[v] = min(low[v], low[*it]);
		}
	}
	if (num[v] < low[v]) {
		cnt++;
	}

	return low[v];
}

int main() {
	int N, M;
	
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for (int i = 0; i < N; i++) {
		num[i] = INF;
		low[i] = INF;
	}

	solve(0,0);
	cout << cnt - 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < n; ++i)
    {
        ans = (ans + v[i]) * 1.0 / 2.0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  int(n);
  for(int testcase = 0;testcase < n;testcase++){
    int2(r, t);
    int res[4];
    res[0] = r / 100 + (t / 30) * 5;
    res[1] = (r + 99) / 100 + (t / 30) * 5;
    res[2] = r / 100 + ((t + 29) / 30) * 5;
    res[3] = (r + 99) / 100 + ((t + 29) / 30) * 5;
    sort(res, res + 4);

    printf("%d", res[0]);
    rep1(i, 4)if(res[i] != res[i - 1])printf(" %d", res[i]);
    kara;

  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ld PI=3.14159265359;

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll lp[100001];
vector<ll> pr;

void prime()
{
    repf(i,1,100001) lp[i]=i;
    repf(i,2,100001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<100001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
    repf(i,2,100001) if(lp[i]==i) pr.pb(i);
}


void solve(ll tt) {
    ll n;
    cin>>n;
    ll umin=1e18,umax=-1e18;
    ll vmin=1e18,vmax=-1e18;
    ll ans=0;
    repf(i,0,n) {
        ll x,y;
        cin>>x>>y;
        ll u=x+y,v=x-y;
        ans=max(ans,u-umin);
        ans=max(ans,umax-u);
        ans=max(ans,v-vmin);
        ans=max(ans,vmax-v);
        umin=min(umin,u);
        umax=max(umax,u);
        vmin=min(vmin,v);
        vmax=max(vmax,v);
    }
    cout<<ans<<endl;
} 


int main()
{
    IOS;
    prime();
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 4480
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  set<int> S;
  rep(i, 0, N) {
    int x;
    cin >> x;
    S.insert(x);
  }
  cout << (sz(S) == N ? "YES" : "NO") << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 9600
import Control.Applicative
import Control.Monad
import Data.List

main :: IO()
main = do
    [a, b, x] <- map read . words <$> getLine
    putStrLn $ solve a b x

solve :: Int -> Int -> Int -> String
solve a b x
    | a <= x && x <= a + b = "YES"
    | otherwise            = "NO"

Measured memory_bytes: 508
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define R 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	char c;
	cin >> c;
	if (c == 'A') {
		cout << 'T';
	}
	else if (c == 'T') {
		cout << 'A';
	}
	else if (c == 'C') {
		cout << 'G';
	}
	else {
		cout << 'C';
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;



int N, A[10000], B[10000], C[100000];
int main() {
	cin >> N;
	int ans = 0;
	rep(i, N) {
		cin >> A[i];
		
	}
	rep(i, N) {
		cin >> B[i];
		
	}
	rep(i, N - 1) {
		cin >> C[i];
		
	}
	for (int i = 0; i < N; i++) {
		ans += B[A[i]-1];
		if (i>=1&&A[i - 1] + 1 == A[i]) {
			ans += C[A[i-1]-1];
		}
		//cout << ans << endl;
	}

	cout << ans << endl;

	
	




	
	


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

int main() {
    int n; 
    string s;
    cin >> n;
    cin >> s;
    using vi = vector<int>;
    vector<vi> mp(n, vector<int>(3, 0));
    REP(i, n) {
        int c;
        if (i > 0) mp[i] = mp[i-1];
        if (s[i] == 'R') c = 0; 
        else if (s[i] == 'G') c = 1;  
        else c = 2;
        mp[i][c]++;
    }
    ll ret = 0;
    REP(i, n-2) { 
        FOR(j, i+1, n-1) {
            int t = 2*j-i;
            if ((s[i] == 'R' && s[j] == 'B') 
             || (s[i] == 'B' && s[j] == 'R')) {
                ret += mp[n-1][1] - mp[j][1];
                if (t < n && s[t] == 'G') ret--;
            } 
            if ((s[i] == 'B' && s[j] == 'G') 
             || (s[i] == 'G' && s[j] == 'B')) {
                ret += mp[n-1][0] - mp[j][0];
                if (t < n && s[t] == 'R') ret--;
            }  
            if ((s[i] == 'R' && s[j] == 'G') 
             || (s[i] == 'G' && s[j] == 'R')) {
                ret += mp[n-1][2] - mp[j][2];
                if (t < n && s[t] == 'B') ret--;
            }  
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3800
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()
UV = iInLD(N-1)

ans = N * (N+1) * (N+2) // 6
for i in range(N-1):
    L = min(UV[i])
    R = max(UV[i])
    ans -= (L * (N+1 - R))

print(ans)

Measured memory_bytes: 101096
x = int(input())

i = -1000;j = -1000
def siki(a,b):
    return a**5 - b**5
while True:
    if siki(i,j) < x:
        i += 1
        continue
    elif siki(i,j) > x:
        j += 1
        continue
    else:break
print(i,j)

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

struct T { ll value; int id; bool isB; };

int main(void){
    int n;
    cin >> n;
    vector<T> t;

    rep(i,n){
        ll a,b;
        cin >> a >> b;
        t.push_back({a,i,false});
        t.push_back({b,i,true});
    }

    sort(all(t), [](T x, T y){
        return x.value != y.value ? x.value < y.value : x.id < y.id;
    });
    vector<vector<bool>> low(n, {0,0});
    rep(i,n){
        low[t[i].id][t[i].isB] = true;
    }

    int HH = 0, LL = 0, HL = 0, LH = 0;
    ll sum = 0;
    rep(i,n){
        if ( low[i][0] &&  low[i][1]) LL++;
        if (!low[i][0] && !low[i][1]) HH++;
        if (!low[i][0] &&  low[i][1]) HL++;
        if ( low[i][0] && !low[i][1]) LH++;
        sum += t[i].value;
    }

    if (LL > 0 || LH == n || HL == n) {
        cout << sum << endl;
    } else if (t[n].id != t[n-1].id) {
        cout << sum - t[n-1].value + t[n].value << endl;
    } else if (LH == 1 || HL == 1) {
        assert(false);
    } else if (sum - t[n-2].value + t[n].value < sum - t[n-1].value + t[n+1].value) {
        cout << sum - t[n-2].value + t[n].value << endl;
    } else {
        cout << sum - t[n-1].value + t[n+1].value << endl;
    }
    
    return 0;
}


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

#define MAX 310

int dp[MAX][MAX][MAX]; //l,r,change
char buf[MAX];
string s;
int k;


int main(){
	scanf("%s", buf);
	s = buf;
	scanf("%d", &k);
	int n = strlen(buf);
	int ans = 0;
	for (int chang = 0; chang <= k; chang++){
		for (int len = n; len >=0; len--){
			for (int i = 0; i < n; i++){
				int j = i + len;
				if (j < 0 || j >= n)continue;
				//match
				dp[i + 1][j][chang] = max(dp[i + 1][j][chang], dp[i][j][chang]);
				if (j){
					dp[i][j - 1][chang] = max(dp[i][j - 1][chang], dp[i][j][chang]);
				}
				if (s[i] == s[j]){
					int ii = i + 1;
					int jj = j - 1;
					ans = max(ans, (dp[i][j][chang] + 1)*2-(int)(i==j) );
					if (ii < n&&jj >= 0){
						dp[ii][jj][chang] = max(dp[ii][jj][chang], dp[i][j][chang] + 1);
					}
				}
				else{
					if (chang < k){
						int ii = i + 1;
						int jj = j - 1;
						ans = max(ans, (dp[i][j][chang] + 1) * 2 - (int)(i == j));
						if (ii < n&&jj >= 0){
							dp[ii][jj][chang + 1] = max(dp[ii][jj][chang + 1], dp[i][j][chang] + 1);
						}
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 114816
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 300300;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	ll N, A, B, K;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);

	if (K == 0) {
		printf("1\n");
		return 0;
	}

	ll GCD = __gcd(A, B);
	if (K % GCD) {
		printf("0\n");
		return 0;
	}

	A /= GCD;
	B /= GCD;
	K /= GCD;

	if (A < B) swap(A, B);

	if (A == 1) {
		ll k = min(K, 2 * N - K);
		if (k < 0) {
			printf("0\n");
			return 0;
		}
		ll kari = 1;
		ll tmp = 2 * N;
		rep(i, k) kari = kari * tmp-- % mod;
		kari = kari * f.ifac[k] % mod;
		printf("%lld\n", kari);
		return 0;
	}

	ll hajime = max(0ll, (K - N * B + A - 1) / A);
	ll owari = min(N, K / A);
	const int b = B;
	ll kotae = 0;
	K -= hajime * A;
	if (b != 1) {
		for (int i = hajime; i <= owari; i++) {
			if (K % b == 0) {
				int j = K / b;
				while (i <= owari) {
					kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - j] % mod * f.ifac[j] % mod;
					i += B;
					j -= A;
				}
			}
			K -= A;
		}
	}
	else {
		for (int i = hajime; i <= owari; i++) {
			kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - K] % mod * f.ifac[K] % mod;
			K -= A;
		}
	}

	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	ll a, b, k;
	cin >> a >> b >> k;
	
	if (a >= k)
		cout << a - k << ' ' << b;
	else
	{
		k -= a;
		if (b >= k)
			cout << 0 << ' ' << b - k;
		else
			cout << 0 << ' ' << 0;
	}
}

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


#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("journey.in", "r", stdin);
	//freopen("journey.out", "w", stdout);


	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();


}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
long long  a,b,c,d,e,n,min,Cnt;


scanf("%lld",&n);
scanf("%lld",&a);
scanf("%lld",&b);
scanf("%lld",&c);
scanf("%lld",&d);
scanf("%lld",&e);

min = a;

if(b<min)
min = b;
if(c<min)
min = c;
if(d<min)
min = d;
if(e<min)
min = e;

if(n - min<=0){
printf("5");
return 0;
}


Cnt = n/min;
if(n%min != 0)
Cnt++;


printf("%lld",Cnt+4);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100001
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

ll a[MAX], d[MAX];
vector<ll> G[MAX], T[MAX];
int main(){
	int n, m, x, t1, t2, t3;
	fill(d, d+MAX, INF);
	scanf("%d%d%d", &n, &m, &x);
	rrep(i,n)scanf("%lld", &a[i]);
	rrep(i,m){
		scanf("%d%d%d", &t1, &t2, &t3);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
		T[t1].push_back(t3);
		T[t2].push_back(t3);
	}
	
	d[1] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	for(int i = 1;i <= n;i++){
		while(!q.empty()){
			P p = q.top();q.pop();
			if(p.fi > d[p.se])continue;
			for(int i = 0;i < G[p.se].size();i++){
				ll from = p.se, to = G[p.se][i];
				ll cost = T[from][i], h;
				if(p.fi < x)h = x-p.fi;
				else h = 0;
				if(h < T[from][i] && a[from]-T[from][i] >= 0){
					cost = T[from][i]*2-h;
				}
				if(h-T[from][i] > a[to]){
					cost = h-a[to];
				}
				if(a[from]-T[from][i] < 0)continue;
				
				if(d[to] > p.fi+cost){
					d[to] = p.fi+cost;
					q.push(P(d[to], to));
				}
			}
		}
	}
	/*rrep(i,n)printf("%d ", h[i]);
	printf("\n");
	rrep(i,n)printf("%d ", d[i]);
	printf("\n");*/
	ll res = 0;
	if(d[n] < x)res = x-d[n];
	if(d[n] >= INF)printf("-1\n");
	else printf("%lld\n", d[n]+(a[n]-res));
	return 0;
}



Measured memory_bytes: 27220
#include <iostream>
#include<string>
using namespace std;
int main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    int count=0;
   for(int i=0; i<=A; i++){
       for(int j=0; j<=B; j++){
           for(int k=0; k<=C; k++){
               if(i*500+j*100+k*50==X){
                   count++;
                   
               }
           }
       }
   }
  cout<<count<<endl;
  
}
    

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

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

const int N = 1000001;
bool dp[N];

int main()
{
    memset(dp, 0, sizeof(N));
    dp[0] = true;

    for (int i = 100; i <= 105; i++) {
        for (int j = 0; j < N; j++) {
            if (dp[j] && j + i < N)
                dp[j + i] = true;
        }
    }

    int x;
    scanf("%d", &x);
    printf("%d\n", dp[x]);

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const ll INF = 1e9;
const ld EPS = 1e-8;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  REP(i, M){
    cin >> A[i] >> B[i];
    --A[i]; --B[i];
  }

  UnionFind uf(N);
  vector<ll> ret(M);
  for(int i = M - 1; i >= 0; --i) {
    if(uf.findSet(A[i], B[i])) {
      ret[i] = 0;
    }else{
      ret[i] = uf.size(A[i]) * uf.size(B[i]);
      uf.unionSet(A[i], B[i]);
    }
  }

  REP(i, M - 1) ret[i + 1] += ret[i];

  REP(i, M) cout << ret[i] << endl;
  return 0;
}



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

int flag=0;
int n;  
vector <int> b;

int check (int);

int main() {
 // int型の2次元配列(3×3要素の)の宣言
  vector<vector<int>> data(3, vector<int>(3));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }

  cin >> n;
 b = vector<int>(n);

  for(int i = 0; i < n; i++){
      cin >> b.at(i);
  }
 
 for (int i = 0; i < 3;i++){
        if(check(data.at(i).at(0)) == 1){
            if(check(data.at(i).at(1)) == 1){
                if(check(data.at(i).at(2)) == 1) flag = 1;
                }
        }
 }
 for (int i = 0; i < 3;i++){
        if(check(data.at(0).at(i)) == 1) {
            if(check(data.at(1).at(i)) == 1){
                if(check(data.at(2).at(i)) == 1) flag = 1;
            }
        }
 } 
 if(check(data.at(0).at(0)) == 1){
     if(check(data.at(1).at(1)) == 1){
         if(check(data.at(2).at(2)) == 1){
             flag = 1;
         }
     }
 }
  if(check(data.at(0).at(2)) == 1){
     if(check(data.at(1).at(1)) == 1){
         if(check(data.at(2).at(0)) == 1){
             flag = 1;
         }
     }
 }
 if(flag == 1) cout << "Yes" <<endl;
 else cout << "No" <<endl;
}

int check (int i){
    for (int j = 0; j < n; j++){
        if(i == b.at(j))return 1;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			@SuppressWarnings("unused")
			int n = scanner.nextInt(), z = scanner.nextInt(), w = scanner.nextInt();
			int[] a = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			if (1 == n) {
				System.out.println(Math.abs(a[n - 1] - w));
			} else {
				System.out.println(Math.max(Math.abs(a[n - 1] - w), Math.abs(a[n - 1] - a[n - 2])));
			}
		}
	}
}


Measured memory_bytes: 40116
#include<bits/stdc++.h>
int n,f[200010];
using namespace std;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		f[x]=f[x-1]+1;
	}
	int Max=0;
	for (int i=1;i<=n;i++) Max=max(Max,f[i]);
	printf("%d\n",n-Max);
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int maxn=100;
const int INF=1e9;
void chkmax(int &x,int y){
	x=x>y?x:y;
}
void chkmin(int &x,int y){
	x=x<y?x:y;
}
int d[11][11];
struct edge{
	int s,t,v;
}w[100100];
int num;
void Addedge(int s,int t,int v){
	w[++num]=(edge){s,t,v};
}
int n,m;
int a[101][101];
bool checkans(){
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			int mn=INF;
			for(int p=0;p<=maxn;p++)
				for(int q=0;q<=maxn;q++)
					chkmin(mn,p*i+q*j+a[p][q]);
			if(mn!=d[i][j]) return 0;
		}
	return 1;
}
int main(){
//	freopen("A.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&d[i][j]);
	int S=1,T=maxn*2+2;
	for(int i=1;i<maxn;i++)
		Addedge(i,i+1,-1);
	for(int i=maxn+2;i<T;i++)
		Addedge(i,i+1,-2);
	for(int i=0;i<=maxn;i++)
		for(int j=0;j<=maxn;j++)
			for(int p=1;p<=n;p++)
				for(int q=1;q<=m;q++)
					chkmax(a[i][j],d[p][q]-p*i-q*j);
	for(int i=0;i<=maxn;i++)
		for(int j=0;j<=maxn;j++)
			Addedge(i+1,T-j,a[i][j]);
	if(!checkans())
		printf("Impossible\n");
	else{
		printf("Possible\n");
		printf("%d %d\n",T,num);
		for(int i=1;i<=num;i++){
			printf("%d %d ",w[i].s,w[i].t);
			if(w[i].v==-1) printf("X\n");
			else if(w[i].v==-2) printf("Y\n");
			else printf("%d\n",w[i].v);
		}
		printf("%d %d\n",S,T);
	}
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int n,q;
  int i,j;
  int count=0;
  
  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }


  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j]==T[i]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
import heapq

def dijkstra(graph,node,start):
    dist = [float("inf") for _ in range(node)]
    dist[start] = 0
    q = []
    heapq.heappush(q,[0,start])

    while(q):
        cost, cur_node = heapq.heappop(q)
        if dist[cur_node] < cost:
            continue
        for next_cost, next_node in graph[cur_node]:
            dist_cand = dist[cur_node]+next_cost
            if dist_cand < dist[next_node]:
                dist[next_node] = dist_cand
                heapq.heappush(q,(dist[next_node],next_node))
    return dist
    

n  = int(input())
adj = [[] for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    adj[u].append((w,v))
    adj[v].append((w,u))
shortest = dijkstra(adj,n,0)
for i in shortest:
    print(i%2)


Measured memory_bytes: 45136
void main() {
    int[] xy = readln.split.to!(int[]);

    int money;
    foreach (i; 0 .. 2) {
        if (xy[i] == 1) {
            money += 300000;
        } else if (xy[i] == 2) {
            money += 200000;
        } else if (xy[i] == 3) {
            money += 100000;
        }
    }
    if (xy.all!"a == 1") money += 400000;

    money.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))  // xが範囲内か
#define sort_u(x) sort((x).begin(),(x).end())
#define sort_d(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()  // 配列のサイズ
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;  // 確認したいとき
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))  // 切り上げたいとき
#define newline puts("")
#define v(T) vector<T>  // Tはどんな型でもいい
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;  // ******
typedef vector<vi> vvi;
typedef vector<ll> vl;  // ******
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}  // vi a(n); cin>>a;
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//mins(ans,now);  ansに最小値が入る
//if(max(ans,now)) ansが小さければ更新して実行。cnt++とか。
//ll sum = suma(a);

int main() {
    int n; cin >> n;
    cout << fixed << setprecision(10);
    if(n%2==0) cout << (double)1/2 << endl;
    else cout << (double) ( (n+1)/2 ) /n << endl;
}

/*
g++ a.cpp
./a.out

oj d
oj t

debug:ctrl+shift+B problemin

*/


Measured memory_bytes: 3800
n = int(input())
A = [int(i) for i in input().split()]

dic = {'gray':0,'brown':0,'green':0,'light blue':0,'blue':0,'yellow':0,'orange':0,'red':0}
more = 0
for a in A:
    if 399 >= a >= 1 :
        dic['gray'] += 1
    elif 799 >= a >= 400:
        dic['brown'] += 1
    elif 1199 >= a >= 800:
        dic['green'] += 1
    elif 1599 >= a >= 1200:
        dic['light blue'] += 1
    elif 1999 >= a >= 1600:
        dic['blue'] += 1
    elif 2399 >= a >= 2000:
        dic['yellow'] += 1
    elif 2799 >= a >= 2400:
        dic['orange'] += 1
    elif 3199 >= a >= 2800:
        dic['red'] += 1
    else:
        more += 1
        
cnt = 0        
for i in dic.keys():
    if dic[i] != 0:
        cnt += 1
if cnt != 0:
    c_max = cnt + more
    c_min = cnt
else:
    c_max = more
    c_min = min(1,more)
print(c_min,c_max)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int n, m;
    cin >> n >> m;
    printf("%lld\n", (n-1) * (m-1));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8)
		cout << ":(" << "\n";
	else
		cout << "Yay!" << "\n";
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool f = 0;
  if(a == b + c || b == a + c || c == a + b) f = 1;
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int A,B,C,K;
string S;

signed main(){
  cin>>A>>B>>C>>K;
  if(K<=A)print(K);
  else if(K<=A+B)print(A);
  else print(A-(K-A-B));

}


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

char f(char sw1, char sw2, char tf) {
	if ((sw2 == 'S' && tf == 'o') || (sw2 == 'W' && tf == 'x')) return sw1;
	return sw1 == 'S' ? 'W' : 'S';
}

int main() {
	int n; string s;
	cin >> n >> s;
	string t[4] = { "SS", "SW", "WS", "WW" };
	for (int i = 0; i < 4; i++) {
		string ans = t[i];
		for (int j = 0; j < n - 2; j++) {
			ans += f(ans[j], ans[j + 1], s[j + 1]);
		}
		if (f(ans[n - 2], ans[n - 1], s[n - 1]) != ans[0]) continue;
		if (f(ans[n - 1], ans[0], s[0]) != ans[1]) continue;
		cout << ans << endl;
		return 0;
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	map<ll,ll> d;
	REP(i,n) {
		ll a;
		cin>>a;
		if(d.count(a)!=0) ++d[a];
		else d[a]=1;
	}
	ll m;
	cin>>m;
	vector<ll> t(m);
	bool f=true;
	REP(i,m) {
		ll a;
		cin>>a;
		if(d.count(a)==0) {
			f=false;
			break;
		}
		if(d[a]==0) {
			f=false;
			break;
		}
		else d[a]--;
	}
	if(f) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 14336