akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		exec2();
	}

	private static void exec() {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			
			long M = sc.nextLong();

			long l = 1;
			
			for (int i = 0; i < N; i++) {
				long in = (long)sc.nextLong()/2;
				l = lcm(l, in);
			}
			
			if(l>M) {
				System.out.println(0);
				return;
			}
			
			long ans = 0;
			if((M/l)%2==0) {
				ans = M/l/2;
			} else {
				ans = M/l/2 + 1;
			}
			
			System.out.println(ans);
		}
	}
	
	private static void exec2() {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			
			int[] a = new int[N];
			int[] b = new int[N];
			
			for (int i = 0; i < N; i++) {
				a[i] = sc.nextInt();
				
			}
			for (int i = 0; i < N; i++) {
				b[i] = sc.nextInt();
			}
			
			int anum =1;
			for (int i = 0; i < N; i++) {
					for(int j=i+1;j<N;j++) {
						if(a[i] < a[j]) {
							a[j]--;
						}
				}
				anum += p((N-1-i))*(a[i]-1);
			}
			
			int bnum =1;
			for (int i = 0; i < N; i++) {
					for(int j=i+1;j<N;j++) {
						if(b[i] < b[j]) {
							b[j]--;
						}
				}
				bnum += p((N-1-i))*(b[i]-1);
			}
			
			System.out.println(Math.abs(anum-bnum));
		}
	}
	
	private static int p(int a) {
		if(a==1) return 1;
		if(a<1) return 0;
		return a*p(a-1);
	}
	
	private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 22228
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	a, b := sc.nextInt(), sc.nextInt()
	sum := a + b
	if sum%2 == 0 {
		fmt.Fprintln(wtr, sum/2)
	} else {
		fmt.Fprintln(wtr, (sum+1)/2)
	}

	wtr.Flush()
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
 int i,j=0,flag=0;
 char ward[3][11];
 scanf("%s%s%s",ward[0],ward[1],ward[2]);
 for(i=0;i<2;i++){
  j=0;
  while(ward[i][j]!=0){
   j++;
  }
 if(ward[i][j-1]!=ward[i+1][0])flag=1;
 }
 if(flag==1)puts("NO");
 else puts("YES");
 return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define YOSHI 1000

int max(int x,int y){
    if(x >= y) return x;
    else return y;
}

int lcs(char *X,char *Y){
    int c[YOSHI + 1][YOSHI + 1];
    int x,y,i,j,maxl = 0;
    
    x = strlen(X);
    y = strlen(Y);
    
    for(i = 0;i <= x;i++) c[i][0] = 0;
    for(j = 1;j <= y;j++) c[0][j] = 0;
    
    for(i = 1;i <= x;i++){
        for(j = 1;j <= y;j++){
            if(X[i - 1] == Y[j - 1]) c[i][j] = c[i - 1][j - 1] + 1;
            else c[i][j] = max(c[i - 1][j],c[i][j - 1]);
            maxl = max(maxl,c[i][j]);
        }
    }
    
    return maxl;
}

int main(){
    int n,i;
    
    char X[YOSHI],Y[YOSHI];
    
    scanf("%d",&n);
    
    for(i = 0;i < n;i++){
        scanf("%s",X);
        scanf("%s",Y);
        printf("%d\n",lcs(X,Y));
    }
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}
int n;
ll k,a[200005];
ll l=1,r=1e9+7,mid;
int ok(ll x)
{
    ll c=0;
    for(int i=0;i<n;i++)
    {
        c+=a[i]/x-1;
        if(a[i]%x!=0)
            c++;
    }
    if(k>=c)
        return 1;
    else
        return 0;
}
int main()
{
    read(n);
    read(k);
    for(int i=0;i<n;i++)
    {
        read(a[i]);
        r=max(r,a[i]);
    }
    while(l<=r)
    {
        mid=(l+r)/2;
        if(ok(mid))
            r=mid-1;
        else
            l=mid+1;
    }
    cout<<l<<endl;
    return 0;

}

Measured memory_bytes: 5128
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int x=sc.nextInt();
	double ans=0;
	int max=a*a*b;
	double high=0;
	if(x<=max/2) {
		high=((2*(double)x)/(a*b))/b;
		ans=90-Math.toDegrees(Math.atan(high));
	}else {
		x=max-x;
		high=(a/((2*(double)x)/(a*a)));
		ans=90-Math.toDegrees(Math.atan(high));
	}


	System.out.println(ans);
}
}


Measured memory_bytes: 22740
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include<type_traits>

using namespace std;

int main(){
	long long int Y=0,N, M,A[100006],SUM[100006];
	cin >> N >> M;
	map<int, int>m;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	SUM[0] = 0;
	for (int i = 0; i < N; i++) {
		SUM[i + 1] = (SUM[i] + A[i])%M;
	}
	for (int i = 0; i < N + 1; i++) {
		Y += m[SUM[i]];
		m[SUM[i]]++;
	}
	cout << Y << endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

long long gcd(long long a, long long b)
{
    if (a < b) std::swap(a, b);

    long long ans;
    do {
        ans = a % b;
        a = b;
        b = ans;
    } while(ans != 0);
    
    return a;
}

int main()
{
    int N;
    std::cin >> N;

    long long a1, a2;
    std::cin >> a1 >> a2;
    long long g = gcd(a1, a2);
    for (int i = 2; i < N; i++) {
        std::cin >> a1;
        g = gcd(g, a1);
    }

    std::cout << g << std::endl;

    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

int dp[301][301];

int solve(vector<int> &W) {
    int N = W.size();
    for(int i = 0; i < 301; i++) {
        for(int j = 0; j < 301; j++) {
            dp[i][j] = 0;
        }
    }
    for(int i = 0; i <= N - 2; i++) {
        dp[i][i + 2] = 2 * (abs(W[i] - W[i + 1]) <= 1);
    }
    for(int d = 3; d <= N; d++) {
        for(int i = 0; i + d <= N; i++) {
            int j = i + d;
            int ma = (abs(W[i] - W[j - 1]) <= 1 && dp[i + 1][j - 1] == j - i - 2) ? j - i : 0;
            for(int k = i + 1; k < j; k++) {
                ma = max(ma, dp[i][k] + dp[k][j]);
            }
            dp[i][j] = ma;
        }
    }
    return dp[0][N];
}

void solve() {
    int N;
    while(cin >> N, N) {
        vector<int> W(N);
        for(int i = 0; i < N; i++) cin >> W[i];
        cout << solve(W) << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
  for (;;){
    int n, x; cin >> n >> x;
    if (n == 0 && x == 0) return 0;
    int ans = 0;
    for (int i = 1; i <= n; i++){
      for (int j = i + 1; j <= n; j++){
        int k = x - i - j;
        if (k > j && k <= n && i != k && j != k) ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
    int X;
    cin >> X;
    if (X == 3 || X == 5 | X == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

using P = std::pair<int, int>;

int main() {
    int N;
    std::cin >> N;

    int x, y;
    P reds[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> x >> y;
        reds[i] = {x, y};
    }

    P blues[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> x >> y;
        blues[i] = {x, y};
    }

    std::sort(blues, blues + N);

    int cnt = 0;
    std::set<int> used;
    for (int i = 0; i < N; ++i) {
        int red_y = -1;
        int index = -1;
        for (int j = 0; j < N; ++j) {
            if ((reds[j].first < blues[i].first && reds[j].second < blues[i].second) == false) {
                continue;
            }

            if (used.count(j) != 0) {
                continue;
            }

            if (red_y < reds[j].second) {
                red_y = reds[j].second;
                index = j;
            }
        }

        if (index != -1) {
            ++cnt;
            used.insert(index);
        }
    }
    
    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[]p = new int[n];
    
    for(int i = 0; i < n; i++)
    {
      p[i] = sc.nextInt();
    }
    Arrays.sort(p);
    int result = 0;
    for(int i = 0; i < k; i++)
    {
      result += p[i];
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 38988
#include <iostream>
#include <vector>
#include <iomanip> 
#include <cmath>
#include <algorithm>
using namespace std;

int main(){

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

    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p.at(i);
    }
    
    sort(p.begin(), p.end());

    for(int i=0; i<K; i++){
        sum += p.at(i);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    V<LL> v;
    LL n = 1;
    REP(a,15){
        n*=9;
        v.push_back(n);
    }
    n = 1;
    REP(a,15){
        n*=6;
        v.push_back(n);
    }
    v.push_back(1);
    sort(ALL(v),greater<int>());
    int ans = 0;
    LL dp[1000000];
    for(int a = 0;a < N+10;a++){
        dp[a]=INF;
    }
    dp[1] = 1;
    dp[0] = 0;
    for(int a = 2;a <= N;a++){
        REP(b,v.size()){
            if(a-v.at(b)>=0){
                dp[a] = min(dp[a-v.at(b)]+1,dp[a]);
            }
        }
    }
    COUT(dp[N]);
    return 0;
}


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

int main() {
	int x, a, b;
	cin >> x >> a >> b;

	if (b - a <= 0) cout << "delicious" << endl;
	else if (a + x >= b) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
  tmp = float("inf")
  ans = 0
  for j in range(M):
    if abs(AB[i][0]-CD[j][0]) + abs(AB[i][1]-CD[j][1]) < tmp:
      tmp = abs(AB[i][0]-CD[j][0]) + abs(AB[i][1]-CD[j][1])
      ans = j + 1
  print(ans)
      

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);




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

    int n;
    cin>>n;
    int used[n]={};
    priority_queue<array<int,2>,vector<array<int,2>>,greater<array<int,2>>> q;
    q.push({1,1});
    while(q.size()){
        int now = q.top()[1], cost = q.top()[0];
        q.pop();
        if(used[now])continue;
        used[now] = 1;
        if(now == 0){
            cout << cost << endl;
            return 0;
        }
        if(!used[(now+1)%n])q.push({cost+1,(now+1)%n});
        if(!used[(now*10)%n])q.push({cost,(now*10)%n});
    }

}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stack>
using namespace std;

int main(){
  stack<int> n1,n2;
  int n,nn1,nn2,up,k,f,num[1000];
  char c;
  cin>>n;
  scanf("%c",&c);
  for(int i=0;i<n;i++){
    while(1){
      scanf("%c",&c);
      if(c=='\n')break;
      n1.push(c-'0');
    }
    while(1){
      scanf("%c",&c);
      if(c=='\n')break;
      n2.push(c-'0');
    }
    up=0;
    k=0;
    f=0;
    while(1){
      if(n1.size()!=0){
	nn1=n1.top();n1.pop();
      }else nn1=0;
      if(n2.size()!=0){
	nn2=n2.top();n2.pop();
      }else nn2=0;
      num[k]=(nn1+nn2+up)%10;
      up=(nn1+nn2+up)/10;
      if(n1.size()==0&&n2.size()==0&&up==0){
	break;
      }
      k++;
      if(k>=80)f=1;
    }
    if(f==1)cout<<"overflow";
    else {
      for(int i=k;i>=0;i--)cout<<num[i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3108
N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))

dp = [[0] * (W + 1) for _ in range(N+1)]

for i in range(N):
    for w in range(W + 1):
        if w - items[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w], dp[i][w - items[i][0]] + items[i][1])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])


Measured memory_bytes: 120044
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

vec s(51);
vec t(51);

ll solve(ll a,ll b){
  if(b==0)return 0;
  if(a==1){
    if(b==1)return 0;
    else if(b<=4)return b-1;
    else return 3;
  }
  if(b<=s[a-1]+1)return solve(a-1,b-1);
  else if(b<s[a])return t[a-1]+1+solve(a-1,b-s[a-1]-2);
  else return t[a];
}

int main(){

  s[1]=5;
  for(ll i=1;i<50;i++)s[i+1]=2*s[i]+3;

  t[1]=3;
  for(ll i=1;i<50;i++)t[i+1]=2*t[i]+1;

  ll n,x;
  cin >> n >> x;
  cout << solve(n,x) << endl;
  //cout << s[50] << endl;
}

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

using namespace std;

double abss(double x){return x>=0?x:-x;}

int main() {
    int N, res;
    double T, A, t, t_ = 100000000000.0;
    cin >> N >> T >> A;
    double H[N];
    for(int i = 0; i < N; i++){
        cin >> H[i];
        t = abss(A - (T - H[i]*0.006));
        if(t < t_){
            res = i+1;
            t_ = t;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,cnt,ans=inf,x,y;
  cin >> n;
  for(int i=1; i+i<=n; i++) {
    x=i,y=n-i,cnt=0;
    while(x>0) {
      cnt+=x%10;
      x/=10;
    }
    while(y>0) {
      cnt+=y%10;
      y/=10;
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	int n = sz(s);
	for (int i = 0; i < n; ++i) {
		if (s[i] != t[i]) ++ ans;
	}
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n, w;
    cin >> n >> w;
    vector<pair<ll, ll>> things(n);
    rep(i, n){
        ll w, v;
        cin >> w >> v;
        things[i] = make_pair(w, v);
    }

    vvll dp(n + 1, vll(w + 1, 0));
    long long ans = 0;
    for(int i = 0; i < n; i++){
        ll weight = things[i].first;
        ll value = things[i].second;
        for(int j = 0; j <= w; j++){
            if(j < weight){
                dp[i + 1][j] = dp[i][j];
            }
            else{
                dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value);
            }
            ans = max(ans, dp[i + 1][j]);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80256
using System;

class Program
{
    static void Main(string[] args) {
        string[] v = Console.ReadLine().Split(' ');

        double a = double.Parse(v[0]);
        double b = double.Parse(v[1]);
        double C = double.Parse(v[2]);
        double r = 2 * Math.PI * C / 360;

        double S = a * b * Math.Sin(r) / 2;
        double L = a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(r));
        double h = b * Math.Sin(r);

        Console.WriteLine(S);
        Console.WriteLine(L);
        Console.WriteLine(h);
    }
}


Measured memory_bytes: 15896
#include <stdio.h>
#include <float.h>

int main()
{
    long int takahashi_life, takahashi_power, aoki_life, aoki_power;
    scanf("%ld %ld %ld %ld", &takahashi_life, &takahashi_power, &aoki_life, &aoki_power);

    while(1)
    {
        aoki_life -= takahashi_power;
        if(aoki_life <= 0)
        {
            printf("Yes\n");
            break;
        }
        takahashi_life -= aoki_power;
        if(takahashi_life <= 0)
        {
            printf("No\n");
            break;
        }
    }

    return 0;
}




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

using namespace std;

int main(void) {
	vector<int> tall;
	for (int i = 0; i < 10; i++) {
		int x;
		cin >> x;
		tall.push_back(x);
	}
	sort(tall.begin(), tall.end(), greater<int>());
	for (int i = 0; i < 3; i++)
		cout << tall[i] << endl;
	return 0;
}

Measured memory_bytes: 0
// problem: "https://atcoder.jp/contests/abc141/tasks/abc141_d"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int n,m;

    cin>>n>>m;

    priority_queue<int>Q;

    int i;
    for(i=0;i!=n;i++)
    {
        int x;
        cin>>x;

        Q.push(x);
    }

    i = 0;
    while(i < m)
    {
        int p = Q.top();
        Q.pop();

        p = p >> 1;

        Q.push(p);
        i++;
    }

    ll s = 0;
    while(!Q.empty())
    {
        s += Q.top();
        Q.pop();
    }

    cout<<s;

    return 0;
}


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

int main() {
  int n, minCnt = 100000000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, cnt = 0;
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      cnt++;
    }
    if (minCnt > cnt) {
      minCnt = cnt;
    }
  }
  cout << minCnt << endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
public class diverta2019D {
    public static void Main() {
        long N, ans = 0;
        N = long.Parse(System.Console.ReadLine());
        long y = (long) Math.Floor(Math.Sqrt(N));
        while(y != 0) {
            if(N % y == 0) {
                if(y < N / y - 1) ans += N / y - 1;
            }
            y--;
        }
        System.Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		for (int t = 0; t < n; ++t) {
			String str = sc.next();
			long sum = 0;
			for (int i = 0; i < str.length(); ++i)
				sum += Integer.valueOf(str.substring(i, i + 1));
			long p = str.length() - 1 + (sum - 1) / 9;
			p %= 2;
			System.out.println(p == 1 ? "Fabre wins." : "Audrey wins.");
		}
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 27756
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, q;
    scan(n, q);
    auto a = readln.split.to!(long[]);
    auto x = iota(q).map!(i => readln.chomp.to!long).array;

    auto suf = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        suf[i] = suf[i - 1] + a[n - i];
    }

    auto alt = new long[](n + 1);
    alt[1] = a[0];
    foreach (i ; 2 .. n + 1) {
        alt[i] = alt[i - 2] + a[i - 1];
    }

    bool check(int k, long x) {
        if (k == 1) {
            return true;
        }
        if (n - 2*k + 1 < 0) {
            return false;
        }
        if (a[n - k] <= x) {
            return false;
        }

        long d = a[n - k] - x;

        return a[n - 2*k + 1] >= x - d;
    }

    long solve(long x) {
        int ok = 1, ng = n + 1;

        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            (check(mid, x) ? ok : ng) = mid;
        }

        int k = ok;
        long ans = suf[k];
        if (n - 2*k >= 0) ans += alt[n - 2*k];

        return ans;
    }

    foreach (i ; 0 .. q) {
        long ans = solve(x[i]);
        writeln(ans);
    }
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 10536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> sum(n+1);
    rep(i, n) sum[i+1] += sum[i] + a[i];
    ll ans = 0;
    map<ll, int> mp;
    rep(i, n+1) {
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 17920
N=int(input());a=[0]*10_001;X=Y=Z=range(1,101)
for x in X:
    for y in Y:
        for z in Z:
            if (n:=x*x+y*y+z*z+x*y+y*z+z*x)<N+1:a[n-1]+=1
print(*a[:N],sep='\n')

Measured memory_bytes: 9380
#include<stdio.h>
 
int A[2000000];
int B[2000000];
 
void Counting_Sort(int k){
  int i,j;
  int C[10001];
  for(i=0;i<10001;i++)C[i]=0;
  for(j=0;j<k;j++)C[A[j]]++;
  for(i=1;i<10001;i++)C[i]+=C[i-1];  
  for(j=k-1;j>=0;j--){
    C[A[j]]--;
    B[C[A[j]]]=A[j];
  }
}
 
int main(){
  int n,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  Counting_Sort(n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 18268
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    //int t=testcases;
    while(testcases--){
        int n;
        cin>>n;
        ll a[n];
        fori(0,n){
            cin>>a[i];
        }
        ll ans=0;
        ll prev=a[0];
        fori(0,n){
            if(prev>a[i]){
                ans+=(prev-a[i]);
            }
            else{
                prev=max(a[i],prev);
            }
        }
        cout<<ans<<endl;
    }               

    return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll h, w;
  cin >> h >> w;
  vector <string> s;
  string t;
  forll(i, 0, h){
	cin >> t;
	if (t.find('#') == string::npos)
	  continue;
	s.push_back(t);
  }
  for (int i=w-1; i>=0; i--){
	bool r = true;
	forll(j, 0, s.size()){
	  if (s[j][i] == '#'){
		r= false;
		break;
	  }
	}
	if (r == true){
	  forll(j, 0, s.size()){
		s[j].erase(s[j].begin() + i);
	  }
	}
  }
  forll(i, 0, s.size())
	cout << s[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<string> S;
    rep(i,n){
        string s;
        cin >> s;
        sort(all(s));
        S.pb(s);
    }
    sort(all(S));
    S.pb("####");
    ll cnt = 1, ans = 0;
    rep(i,n){
        while(S[i]==S[i+1]){
            cnt++; i++;
        }
        ans += cnt*(cnt-1)/2;
        cnt = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5748
#include <cmath>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n, m;
	cin >> n >> m;
	ll sum = 0;
	vector<P>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p.begin(), p.end());
	ll count = 0;
	for (int i = 0; i < n; i++) {
		count += p[i].second;
		if (count >= m) {
			sum += p[i].first * p[i].second;
			sum -= p[i].first * (count - m);
			break;
		}
		else {
			sum += p[i].first * p[i].second;
		}
		
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

LL nC2(LL n)
{
  if (n < 2) return 0;
  return n * (n-1) / 2;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n;
  cin >> n;
  VLL A(n);
  INPUT(A);
  VLL C(n+1, 0);
  REP(i, n) C[A[i]]++;
  LL S = 0;
  REP(i, n+1) S += nC2(C[i]);
  REP(i, n) cout << S - nC2(C[A[i]]) + nC2(C[A[i]]-1) << endl;

  return 0;
}


Measured memory_bytes: 5760
#! ruby
# Try AtCoder
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gf() gets.to_f end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|m,e| m[e]+=1;m} end
############################################################

N, L = gis

puts ngs(N).sort * ''



Measured memory_bytes: 1788
N = int(input())
c = [[0]*10 for _ in range(10)]

for i in range(1, N+1):
    end = i%10
    head = int(str(i)[0])
    c[head][end] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] S = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.ReadLine();
            int[] T = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
 
            int cnt = 0;
 
            foreach (var t in T)
            {
                foreach (var s in S)
                {
                    if (s == t)
                    {
                        cnt++;
                        break;
                    }
                }
            }
 
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 9528
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

class TVertex
{
    int FIndex;
    std::vector<TVertex*> FList;
    int FDiscoveryTime;
    int FFinishTime;

public:
    TVertex(int Index)
     : FIndex(Index), FDiscoveryTime(0), FFinishTime(0)
    {}
    void AddPath(TVertex* Vertex)
    {
        FList.push_back(Vertex);
    }
    void PrintTime(std::ostream& out)const
    {
        out << FIndex << " " << FDiscoveryTime << " " << FFinishTime << std::endl;
    }
    int DepthFirstSearch(int Time)
    {
        if(FDiscoveryTime) return Time;
        FDiscoveryTime = Time++;
        for(std::vector<TVertex*>::iterator It = FList.begin(); It != FList.end(); ++It){
            TVertex* V = *It;
            Time = V->DepthFirstSearch(Time);
        }
        FFinishTime = Time++;
        return Time;
    }
};
class TGraph
{
    std::vector<TVertex*> FTable;
    void Init(int n)
    {
        assert(n > 0);
        FTable.resize(n);
        for(int i = 0; i < n; ++i){
            FTable[i] = new TVertex(i);
        }
    }
public:
    TGraph(int n)
    {
        Init(n+1);
    }
    
    void SetupVertex(std::istream& in)
    {
        int Index;
        in >> Index;
        assert(Index >= 1);
        assert(Index <= FTable.size());
        int k;
        in >> k;
        for(int i = 0; i < k; ++i){
            int v;
            in >> v;
            FTable[Index]->AddPath(FTable[v]);
        }
    }
    void DepthFirstSearch()
    {
        int Time = 1;
        for(int i = 1; i < FTable.size(); ++i){
            Time = FTable[i]->DepthFirstSearch(Time);
        }
    }
    void PrintTime(std::ostream& out)
    {
        for(int i = 1; i < FTable.size(); ++i){
            FTable[i]->PrintTime(out);
        }
    }
};

int main()
{
    int n;
    std::cin >> n;
    TGraph Graph(n);
    for(int i = 0; i < n; ++i){
        Graph.SetupVertex(std::cin);
    }
    Graph.DepthFirstSearch();
    Graph.PrintTime(std::cout);
    return 0;
    
}

Measured memory_bytes: 3136
#include<algorithm>
#include<iostream>

using namespace std;
typedef long long ll;

const int MAX = 100;



int main() {


	int n, p[MAX + 1], m[MAX + 1][MAX + 1];
	cin >> n;


	for (int i = 1;i <= n;i++) {
		cin >> p[i - 1] >> p[i];
	}

	for (int i = 1;i <= n;i++) m[i][i] = 0;

	for (int calcLen = 2;calcLen <= n;calcLen++) {

		for (int st = 1;st <= n - calcLen + 1;st++) {
			int ed = st + calcLen - 1;
			m[st][ed] = (1 << 21);

			for (int divP = st;divP <= ed-1;divP++) {
				m[st][ed] = min(m[st][ed], m[st][divP] + m[divP + 1][ed] + p[st - 1] * p[divP] * p[ed]);
			}
		}
	}
	cout << m[1][n] << endl;

	return 0;
}



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

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

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int v[111111],cnt[22],lg[66666];
int f[66666],q[66666],hq,tq;
int main()
{
	int n=io::F();
	for(register int i=1;i<n;++i)
	{
		int x=io::F(),y=io::F(),w=io::F();
		v[x]^=w,v[y]^=w;
	}
	for(register int i=0;i<n;++i)cnt[v[i]]++;
	int ans=0;
	for(register int i=2,j=1;i<65536;i<<=1,++j)lg[i]=j;
	for(register int i=1;i<16;++i)ans+=cnt[i]>>1,cnt[i]&=1;
	memset(f,63,sizeof(f));
	int w=0;
	for(register int i=1;i<16;++i)if(cnt[i])w|=1<<i;
	f[w]=0;
	for(q[hq=1]=w,tq=2;hq!=tq;++hq)
	{
		int o=q[hq];
		int l=lg[o&-o];
		for(register int i=l+1;i<16;++i)
			if(o&1<<i)
			{
				int t=o^1<<l^1<<i^1<<(l^i);
				t&=~1;
				if(f[t]>33333)f[t]=f[o]+1+(bool)(o&1<<(i^l)),q[tq++]=t;
			}
	}
	printf("%d\n",ans+f[0]); 
	return 0;
}



Measured memory_bytes: 896
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int N = sc.nextInt();
      int M = sc.nextInt();
      int[] list = new int[N];
      Arrays.fill(list,1);
      Set<Integer> redVisited = new HashSet<Integer>();
      redVisited.add(0);
      for(int i = 0; i < M; i++){
        int before = sc.nextInt() - 1;
        int after = sc.nextInt() - 1;
        list[before]--;
        list[after]++;
        if(redVisited.contains(before)){
          redVisited.add(after);
        }
        if(list[before] == 0){
          redVisited.remove(before);
        }
      }
      System.out.println(redVisited.size());
	}
}


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

using namespace std;

//#define int long long
#define INF 1e9
#define LINF 1e18

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int a[200000], b[200000];
int at[200000], bt[200000];
int N;

int solve() {
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> a[i];
    for(int i = 0; i < N; ++i) cin >> b[i];
    sort(b, b + N);
    int res = 0;
    for(int i = 0; i < 29; ++i) {
        int even = 0;
        for(int j = 0; j < N; ++j) {
            at[j] = a[j] % (1 << (i + 1));
            bt[j] = b[j] % (1 << (i + 1));
        }
        sort(bt, bt + N);
        for(int j = 0; j < N; ++j) {
            if(at[j] & (1 << i)) {
                even += lower_bound(bt, bt + N, (1 << (i + 1)) - at[j]) - bt;
                even += (bt + N) - lower_bound(bt, bt + N, (3 << i) - at[j]);
            }
            else {
                even += lower_bound(bt, bt + N, (1 << (i + 1)) - at[j]) - lower_bound(bt, bt + N, (1 << i) - at[j]);
            }
        }
        res ^= ((even&1) << i);
    }
    return res;
}

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

    cout << solve() << endl;
    return 0;
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int mid = B - A - 1;
	if (mid % 2 == 0)
	{
		cout << "Borys" << endl;
	}
	else if (mid % 2 == 1)
	{
		cout << "Alice";
	}
	return 0;
}

Measured memory_bytes: 256
class SegTree(object):
  def __init__(self,op,e,n,init_val):
    self.num = 1<<(n-1).bit_length() 
    self.S = [e]*self.num*2
    self.op = op
    self.e = e
    for i,v in enumerate(init_val): self.S[self.num+i] = v
    for i in range(self.num-1,0,-1):
      self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
      
  def set(self,index,value):
    idx = self.num+index
    self.S[idx] = value
    while idx>0:
      self.S[idx>>1] = self.op(self.S[idx],self.S[idx^1])
      idx>>=1
      
  def prod(self,l,r):
    res = self.e
    l = max(0,l)+self.num
    r = min(r,self.num-1)+self.num
    while l<r:
      if l&1:
        res = self.op(res,self.S[l])
        l += 1
      if r&1:
        res = self.op(self.S[r-1],res)
      l >>= 1
      r >>= 1
    return res
        
N,K = map(int,input().split())
ST = SegTree(max,0,300001,[0]*300001)
ans = 1
for i in range(N):
  A = int(input())
  l,r = max(0,A-K),min(A+K,300000)
  v = ST.prod(l,r+1)+1
  ans = max(ans,v)
  ST.set(A,v)
print(ans)

Measured memory_bytes: 88316
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int numOfOdd = (int) Math.ceil(N/2.0);
        os.println(numOfOdd/ (double) N);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,sum;
    int p[1010];
    
    while(cin >> n >> m,n!=0&&m!=0){
        for(int i=0;i<n;i++){
            cin >> p[i];
        }
        sort(p,p+n);
        reverse(p,p+n);
        sum = 0;
        for(int i=0;i<n;i++){
            if( (i+1)%m != 0) sum += p[i];
        }
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3088