akhauriyash/Code-Regression huggingface dataset:
program main
  implicit none
  integer i,N,ans,t,flag
  character(2*10**5) S
  read(*, *) S
  S = trim(S)
  N = len(trim(S))
  !read(*, *) (L(i), i = 1,N)
  ans = 1
  t = 2
  flag = 0
  do
    if (t == N .and. S(t:t) == S(t-1:t-1) .and. flag == 0) then
      t = t+1
    elseif (S(t:t) == S(t-1:t-1) .and. flag == 0) then
      t = t+2
      ans = ans + 1
      flag = 1
    else
      ans = ans + 1
      t = t + 1
      flag = 0
    endif
    if (t > N) then
      exit
    end if
  end do

  write(*, *) ans
end program main


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

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    int c[H][W];
    rep(i,H) {
        rep(j,W) {
            char cc;
            cin >> cc;
            if (cc == '.') {
                c[i][j] = 0;
            } else {
                c[i][j] = 1;
            }
        }
    }

    int ans = 0;
    for (int bitH = 0; bitH < (1 << H); bitH++) {
        for (int bitW = 0; bitW < (1 << W); bitW++) {
            int c2[H][W];
            rep(i,H) rep(j,W) c2[i][j] = c[i][j];
            
            for (int i = 0; i < H; ++i) {
                if (bitH & (1<<i)) {
                    rep(j, W) c2[i][j] = 0;
                }
            }

            for (int i = 0; i < W; ++i) {
                if (bitW & (1<<i)) {
                    rep(j, H) c2[j][i] = 0;
                }
            }

            int sum = 0;
            rep(i,H) rep(j,W) if (c2[i][j] == 1) sum++;
            if (sum == K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int N;
struct edge {
    int to, cost;
};
vector<edge> G[100005];
int color[100005];

// 頂点vをcで塗る、pはparentノード
void dfs(int v, int p, int c) {
    color[v] = c;
    for (auto e: G[v]) {
        int to = e.to;
        int cost = e.cost;
        if (to == p) continue;

        if (cost % 2 == 0) dfs(to, v, c);
        else dfs(to, v, -c);
    }
}

int main() {
    cin >> N;
    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;

        // 0-indexed
        G[u - 1].pb(edge({v - 1, w}));
        G[v - 1].pb(edge({u - 1, w}));
    }
    dfs(0, 0, 1);

    REP(i, N) {
        int c = color[i] == 1 ? 1 : 0;
        cout << c << "\n";
    }

    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 10000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

/*
Created at 15:28
*/



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
 



    int h, w, k;
    cin >> h >> w >> k;
    int n = max(h, w);
    int ans = 0;
    int sum = 0;
    while(sum < k){
        sum += n;
        ans++;
    }
    cout << ans << endl;
    

return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////


int mx;
int b[M];
int a[M];

int main() {

   int n=Int,h=Int,ind;

   fr(n){
    a[i]=Int,b[i]=Int;
    if(a[i]>=mx){
        mx=a[i];
        ind=i;
    }
   }

   vi v;

   fr(n){
        if(i==ind) continue;
        v.pb(b[i]);
   }

   sort(v.begin(),v.end());

   int till=0;

   for(int i=v.size()-1;i>=0;i--){
        if(v[i]<=a[ind]) break;
        till++;
        h-=v[i];
        if(h<=0){
            printf("%d\n",till);done;
        }
        if(h-b[ind]<=0){
             printf("%d\n",till+1);done;
        }
   }

   ll ans=1+(ll)till+(ll)(h-b[ind])/a[ind];
   //cout<<ans<<endl;
   //cout<<h-b[ind]<<endl;
   if(((max(0,h-b[ind]))%a[ind])!=0) ans++;
    printf("%lld\n",ans);
    done;
}





Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
vector<int> to[2005];
ll ans = 0;
int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<vector<int>> dp(n,vector<int>(n));
    rep(i, n){
        for(int j = i;j < n;j++){
            dp[i][min(abs(j - i),abs(x - i) + abs(y - j) + 1)]++;
        }
    }
    for(int i = 1;i< n;i++){
        ll ans = 0;
        rep(j, n)
        {
            ans += dp[j][i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 16000
data Badge = NA | E | D | C | B | A | AA | AAA deriving (Show)

main :: IO ()
main = interact $ unlines.map (show.(\[a,b] -> badgeTest a b).map read.words).lines

badgeTest :: Double -> Double -> Badge
badgeTest half kilo
    | half < 35.50 && kilo < 71.00  = AAA
    | half < 37.50 && kilo < 77.00  = AA
    | half < 40.00 && kilo < 83.00  = A
    | half < 43.00 && kilo < 89.00  = B
    | half < 50.00 && kilo < 105.00 = C
    | half < 55.00 && kilo < 116.00 = D
    | half < 70.00 && kilo < 148.00 = E
    | otherwise                     = NA


Measured memory_bytes: 4244
n, k = map(int, input().split())

a = {}
for i in range(n):
    a[i] = 0
    
for i in range(k):
    d = int(input())
    tmp  = list(map(int, input().split()))
    for t in tmp:
        a[t-1] = 1

print(len([k for k, v in a.items() if v == 0]))

Measured memory_bytes: 9192
using System;
using System.Linq;

namespace Eql
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] i = Console.ReadLine().Split(' ')
                    .Select(e => int.Parse(e)).ToArray();
            
            int a = i[0];
            int b = i[1];

            Console.WriteLine(a < b ? "a < b" : a > b ? "a > b" : "a == b");
        }
    }
}

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

int main(){


  int n;

  while(cin >> n){
    if(n == 0) break;

    //テ・ツ?・テ・ツ環?
    int point[200];
    for(int i = 0; i < n ; i++){
      cin >> point[i];
      //      cout << point[i] << " ";
    } 

    //max
    int max = -1;
    for(int i = 0 ; i < n ; i++){
      if(point[i] > max)
	max = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == max){
	point[i] = -1;
	break;
      }
    }

    //min
    int min = 10000;
    for(int i = 0 ; i < n ; i++){
      if(point[i] < min && point[i] != -1 )
	min = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == min){
	point[i] = -1; 
	break;     
      }
    }

    int ans = 0;
    for(int i = 0; i < n ; i++){
      if(point[i] > -1)
	ans += point[i];
      //  cout << point[i] << " ";
    }
    ans = ans / (n-2);
    cout << ans << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
import numpy as np

N,M,C = (int(_) for _ in input().split())
B = np.array([int(_) for _ in input().split()])
A = []
for i in range(N):
    A.append(np.array([int(_) for _ in input().split()]))
count = 0 #正答したコードの数
for a in A:
    if np.dot(a,B) + C > 0:
        count += 1

print(count)


Measured memory_bytes: 14480
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    char s;
    int r;
    int c[4][13]={};
    for(int i=0;i<n;i++){
        cin >> s >> r;
        if(s=='S'){
            c[0][r-1]=r;
        }else if(s=='H'){
            c[1][r-1]=r;
        }else if(s=='C'){
            c[2][r-1]=r;
        }else if(s=='D'){
            c[3][r-1]=r;
        }
    }
    for(int p=0;p<4;p++){
        for(int q=0;q<13;q++){
            if(c[p][q]==0 && p==0){
                cout <<"S"<<" "<<q+1<<endl;
            }else if(c[p][q]==0 && p==1){
                cout <<"H"<<" "<<q+1<<endl;
            }else if(c[p][q]==0 && p==2){
                cout <<"C"<<" "<<q+1<<endl;
            }else if(c[p][q]==0 && p==3){
                cout <<"D"<<" "<<q+1<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3088
package main

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

func main() {
        scanner := bufio.NewScanner(os.Stdin)
        scanner.Split(bufio.ScanWords)
        writer := bufio.NewWriter(os.Stdout)
        defer writer.Flush()

        scanner.Scan()
        N, _ := strconv.Atoi(scanner.Text())
        scanner.Scan()
        M, _ := strconv.Atoi(scanner.Text())

        a := make([]int, M)
        b := make([]int, M)
        c := make([]int, M)
        for i := 0; i < M; i++ {
                scanner.Scan()
                a[i], _ = strconv.Atoi(scanner.Text())
                scanner.Scan()
                b[i], _ = strconv.Atoi(scanner.Text())
                for j := 0; j < b[i]; j++ {
                        scanner.Scan()
                        cij, _ := strconv.Atoi(scanner.Text())
                        cij--
                        c[i] |= 1 << uint(cij)
                }
        }

        dp := map[int]int{0: 0}
        for i := 0; i < M; i++ {
                for opened, cost := range dp {
                        opened |= c[i]
                        newcost := cost + a[i]
                        if oldcost, ok := dp[opened]; !ok || newcost < oldcost {
                                dp[opened] = newcost
                        }
                }
        }
        cost, ok := dp[1<<uint(N)-1]
        if !ok {
                writer.WriteString("-1\n")
                return
        }
        writer.WriteString(strconv.Itoa(cost) + "\n")
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

const int INF = 1001001001;

bool che(string s) {
	if (s[0] != 'A')return false;
	int c = 0;
	for (int i = 2; i < s.size()-1; i++) {
		if (s[i] == 'C')c++;
	}
	if (c != 1)return false;
	int up = 0;
	rep(i, s.size()) {
		if (s[i] >= 'A' && s[i] <= 'Z')up++;
	}
	if (up != 2)return false;
	return true;
}


int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}













Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N+1], ans[N+1];
  for(int i=2; i<=N; i++) cin >> A[i];
  for(int i=0; i<=N; i++) ans[i] = 0;
  for(int i=2; i<=N; i++) ans[A[i]]++;
  for(int i=1; i<=N; i++) cout << ans[i] << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
constexpr ll M = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    map<int, int> m;
    int t;
    for (size_t i = 0; i < n - 1; i++) {
        cin >> t;
        m[t]++;
    }

    for (int i = 1; i <= n; ++i) {
        cout << m[i] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}


Measured memory_bytes: 13036
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    // count odd
    if (N > 1 && M > 1) {
      System.out.println(((long)N-2) * (M-2));
    } else if (N == 1 && M == 1) {
      System.out.println(1);
    } else if (N == 1) {
      System.out.println(M-2);
    } else if (M == 1) {
      System.out.println(N-2);
    }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define INF 2000000000
#define int long long int
int const MOD = 1000000007;

int N, M, L;
int K[2010], S[100010], acc[100010];
int dp[2010][2010];

int calc(int l, int r) {
    return (acc[r+1] - acc[l]) / L;
}

int solve(int a, int b) {
    if(a > b) swap(a, b); // a < b
    if(dp[a][b] != -1) return dp[a][b];
    if(b == N-1) return dp[a][b] = calc(K[a], K[N-1]);
    int nxnote = b+1;
    int vl = solve(a, nxnote) + calc(K[b], K[nxnote]);
    int vr = solve(nxnote, b) + calc(K[a], K[nxnote]);
    return dp[a][b] = min(vl, vr);
}

signed main() {
    memset(dp, -1, sizeof(dp));
    cin >> N >> M >> L;
    rep(i,0,N) cin >> K[i], K[i]--;
    sort(K, K+N);
    rep(i,0,M) {
        cin >> S[i];
        acc[i+1] = acc[i] + S[i];
    }
    cout << solve(0, 0) << endl;
}

Measured memory_bytes: 36352
N = int(input())
x,y = [],[]
for _ in range(N):
	xt, yt = map(int, input().split())
	x.append(xt)
	y.append(yt)

def solve(ite):
	a = 0
	for i in range(len(ite)-1):
		a += ((x[ite[i]] - x[ite[i+1]])**2 + (y[ite[i]] - y[ite[i+1]])**2) ** (1/2)
	return a


def next_permutation(n, flg, perm):
	S = []
	if flg.count(0) == 0:
		return solve(perm)

	a = 0
	for i in range(n):
		if flg[i] != 0:
			continue

		flg[i] = 1
		perm.append(i)

		a += next_permutation(n, flg, perm)

		flg[i] = 0
		perm.pop()

	return a


flg = [0] * N
perm = []

A = next_permutation(N,flg,perm)

for i in range(1,N+1):
	A /= i

print(A)


Measured memory_bytes: 3316
x,y = map(int,input().split())
ans = 0

if x == 1 :
    ans = 300000
elif x == 2:
    ans = 200000
elif x == 3:
    ans = 100000


if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000


if x == 1 and y == 1:
    ans += 400000

print(ans)


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def prime(n,is_prime=True):
    """
    n: positive integer
    if is_prime: return n is prime
    else: return list of prime <= n
    """
    if n<=1: return False if is_prime else []
    S=[1]*(n+1)
    S[0]=0; S[1]=0
    for i in range(2,n):
        if S[i]==0: continue
        for j in range(2*i,n+1,i):
            S[j]=0
    if is_prime: return bool(S[n])
    else: return [p for p in range(n+1) if S[p]]
def resolve():
    """
    p^74,p^24q^2,p^14q^4,p^4q^4r^2
    """
    n=int(input())
    P=prime(n,False)
    bin=[0]*48
    for p in P:
        if p>47: continue # p<=47
        q=p
        while(q<=n):
            bin[p]+=n//q
            q*=p
    c2=len([0 for i in bin if i>=2])
    c4=len([0 for i in bin if i>=4])
    c14=len([0 for i in bin if i>=14])
    c24=len([0 for i in bin if i>=24])
    c74=len([0 for i in bin if i>=74])
    ans=0
    ans+=c74
    ans+=c24*(c2-1)
    ans+=c14*(c4-1)
    ans+=c4*(c4-1)//2*(c2-2)
    print(ans)
resolve()

Measured memory_bytes: 38384
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

n,m = I()

if abs(n-m) >= 2:
    print(0)
    sys.exit()

if abs(n-m) == 1:
    print(math.factorial(n)*math.factorial(m) % mod)
    sys.exit()

print(math.factorial(n)*math.factorial(m)*2 % mod)


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

class Dice{
    int _num[6];
  public:

    void set(int num[6]){
        for(int i=0;i<6;i++){
            _num[i] = num[i];
        }
    }
    int Get(int n){
        return _num[n];
    }
    void N(){
        int buf = _num[0];
        _num[0] = _num[1];
        _num[1] = _num[5];
        _num[5] = _num[4];
        _num[4] = buf;
    }
    void S(){
        int buf = _num[0];
        _num[0] = _num[4];
        _num[4] = _num[5];
        _num[5] = _num[1];
        _num[1] = buf;
    }
    void W(){
        int buf = _num[0];
        _num[0] = _num[2];
        _num[2] = _num[5];
        _num[5] = _num[3];
        _num[3] = buf;
    }
    void E(){
        int buf = _num[0];
        _num[0] = _num[3];
        _num[3] = _num[5];
        _num[5] = _num[2];
        _num[2] = buf;
    }
    void SetTop(int n){
        if(_num[2]==n)
            W();
        else if(_num[3]==n)
            E();
        else{
            for(int i=0;i<4;i++){
                if(_num[0]==n)
                    break;
                S();
            }
        }
    }
    void SetFront(int n){
            for(int i=0;i<4;i++){
                if(_num[1]==n)
                    break;
                S();
                W();
                N();
            }
    }
    
    bool Same(Dice other){
        other.SetTop(this->Get(0));
        other.SetFront(this->Get(1));

        bool same = true;
        for(int i=0;i<6;i++){
            if(other.Get(i) != this->Get(i)){
                same=false;
                break;
            }
        }
        return same;
    }
};

int main(void){
    int n;
    cin >> n;
    
    Dice dice[n];
    for(int j=0;j<n;j++){
        
        int num[6];
        for(int i=0;i<6;i++){
            int n;
            cin >> n;
            num[i] = n;
        }
        
        dice[j].set(num);
    }
    
    
    for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
        if(dice[i].Same(dice[j])){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 1160
import math

X = int(input())
val = X
max_value = int(math.sqrt(val))

div_list = []
for x in range(2, max_value+1):
    for div in div_list:
        if x % div == 0:
            break
    else:
        div_list.append(x)

while True:
    for div in div_list:
        if val % div == 0:
            break
    else:
        print(val)
        break
    val += 1

Measured memory_bytes: 3064
import { readFileSync } from 'fs'

function main(input: string) {
  const lines = input.split('\n').map(Number)

  const base = 10

  const deadTimes = lines.map(time => Math.ceil(time / base) * base - time)
  const maxDeadTime = Math.max(...deadTimes)

  const result = [...lines, ...deadTimes, -maxDeadTime].reduce((sum, time) => sum + time, 0)

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    int d[2000] = { 0 };
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            d[min(j - i, abs(x - i) + abs(j - y) + 1)]++;
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int L, R, d;
	cin >> L >> R >> d;

	cout << R / d - (L - 1) / d << "\n";

	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	string ans(n, '0');
	ans[0] = (n == 1? '0': '1');
	bool a[n];
	bool can = true;
	memset(a, false, sizeof a);
	for(int i=0; i<m; i++){
		int pos, num;
		cin >> pos >> num;
		if(!a[pos-1] || num+'0' == ans[pos-1])
			ans[pos-1] = num+'0', a[pos-1] = true;
		else
			can = false;
	}
	
	cout << ((ans[0] == '0' && n>1) || !can? "-1": ans) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  a*=b;
  if(a%2==0){
    cout<<"Even"<<endl;
  }else{
    cout<<"Odd"<<endl;
  }
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;
	int len1 = s.length(), len2 = t.length();
	vector<vector<int>> dp(len1 + 1, vector<int> (len2 + 1, 0));
	for (int i = 0; i <= len1; i++) {
		for (int j = 0; j <= len2; j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	string answer;
	int p = len1, q = len2;
	while (p > 0 && q > 0) {
		if (s[p - 1] == t[q - 1]) {
			answer += s[p - 1];
			p--;
			q--;
		} else if (dp[p][q - 1] > dp[p - 1][q]) {
			q--;
		} else {
			p--;
		}
	}
	reverse(answer.begin(), answer.end());
	cout << answer;

	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string S,T;
  cin>>S>>T;
  int N=S.size();
  bool ok=false;
  rep(i,N) {
      if(S==T) ok=true;
      S=S.back()+S.substr(0,N-1);
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
int dp(int i);
int n;
int h[100009],memo[100009];

int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  for(int i=0;i<n;i++)cin>>h[i];
  cout<<dp(0)<<endl;
  return(0);
}

int dp(int i){
  int rec=INF;
  if(memo[i]!=-1)return memo[i];
  if(i==n-1)return 0;
  if(i+1<n)rec=min(rec,dp(i+1)+abs(h[i]-h[i+1]));
  if(i+2<n)rec=min(rec,dp(i+2)+abs(h[i]-h[i+2]));
  return memo[i]=rec;
}


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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  int a;
  int ans=0;
  for(int i=0;i<n;i++){
    int total=0;
    for(int j=0;j<m;j++){
      cin >> a;
      total+=a*b[j];
    }
    if(total+c>0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<long long>;
using vlad=valarray<double>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    string s; cin>>s;
    stack<char> a;
    bool ok=true;
    rep(i,s.size()){
        char c=s[i];
        if(c!='w'){
            a.push(c);
            continue;
        }
        if(a.size()<2 || a.top()!='e'){
            ok=!ok;
            break;
        }
        a.pop();
        if(a.top()!='m'){
            ok=!ok;
            break;
        }
        a.pop();
        if(a.empty()&&i+1!=s.size()){
            ok=!ok;
            break;            
        }
    }
    if(ok&&!a.empty())ok=!ok;
    cout<<(ok?"Cat":"Rabbit")<<endl;
	return 0;
}



Measured memory_bytes: 3212
#include<iostream>
using namespace std;
int k[200000+5];
int s1[200000+5];
long long s[200000+5],ans;
int mid;
bool check(int mid,int l){
	return (s1[mid]^s1[l-1])==(s[mid]-s[l-1]);
}
int main(){
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>k[i];
	}
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+k[i];
	}
	for(int i=1;i<=n;i++){
		s1[i]=k[i]^s1[i-1];
	}
	for(int l=1;l<=n;l++){
		int s=l,t=n;
		while(s<t){
			 mid=(s+t+1)/2;
			if(check(mid,l)) s=mid;
			else t=mid-1;
		}
		ans+=s-l+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6740
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a, b;
  cin >> a >> b;
  if(a*b==15){
    cout << "*";
  }else if(a+b==15){
    cout << "+";
  }else{
    cout << "x";
  }
  
  return 0;
}


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

using namespace std;

typedef long long ll;

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

	ll a, b, k;
	cin >> a >> b >> k;

	if(a >= k){
		cout << a - k << " " << b;
	}else{
		cout << 0 << " " << max(b - (k - a), 0LL) << endl;
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 38256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String aa = scan.next();
    String bb = scan.next();
    int a = Integer.parseInt(aa);
    int b = Integer.parseInt(bb);
    if (a > b) {
      System.out.println("a > b");
    } else if (a < b) {
      System.out.println("a < b");
    } else if (a == b) {
      System.out.println("a == b");
    } else {
    }
  }
}

Measured memory_bytes: 25960
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(ll i=0; i<(ll)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define fcout cout << fixed << setprecision(10) 
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll gcd(ll a, ll b){
    if(b>a){
        ll c =b; b=a;   a=c;
    }
    ll d = a%b;
    if(d==0){
        return b;
    }else if(d==1){
        return 1;
    }else{
        gcd(b,d);
    }
}


ll cul(ll n){
    return (n-1)*n/2;
}


int a[20010];
int main (){
    int n;  cin >> n;
    rep(i,n){
        int p=0;
        cin >> p;
        a[p] += i;
    }

    for(int i=1; i<=n; i++){
        cout << 25000 * i +a[i] << " " ;
    }
    cout << endl;
    for(int i=n; i>0; i--){
        cout << 25000 * i  << " " ;
    }
    cout << endl;
    return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin>>N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
		a[i]--;
	}
	VI used(N, 0);
	int p = 0;
	int cnt = 0;
	LL ans = -1;
	while (!used[p]) {
		used[p] = 1;
		p = a[p];
		cnt++;
		if (p == 1) {
			ans = cnt;
			break;
		}
	}
	
	cout<<ans<<endl;

	return 0;
}


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

int main() {

  int N;
  cin >> N;

  set<int> d;

  for (int i = 0; i < N; i++) {
    int d_;
    cin >> d_;
    d.insert(d_);
  }

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    int a,b,temp,count=0;
    cin>>a>>b;
    temp=b;
    while(b!=0)
    {
       b=b/10;
       a=a*10;
    }
    a=a+temp;
    temp=sqrt(a);
    if(temp*temp==a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
    }


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

int main(){   
    int n,l;
    bool f=false;
    cin >> n >> l;
    int k=1,j=0;
    vector<int> a(n);
    vector<int> co(n-1);
    cin >> a.at(0);
    for(int i=1;i<n;i++){
        cin >> a.at(i);
        if(a.at(i-1)+a.at(i)>=l){
            f=true;
            k=i;
        }
    }
    if(f){
        for(int i=1;i<k;i++){
            co.at(i-1)=i;
            j=i;
        }
        for(int i=n-1;i>=k;i--,j++){
            co.at(j)=i;
        }
        cout << "Possible" << endl;
        for(int i=0;i<n-1;i++){
            cout << co.at(i) << endl;
        }
    }else{
        cout << "Impossible" << endl;
    }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int w, n;
    cin >> w >> n;
    int a[w + 1];
    for (int i = 1; i <= w; i++)
    {
        a[i] = i;
    }

    rep(i, n)
    {
        int b, d;
        char c;
        cin >> b >> c >> d;
        int s = a[d];
        a[d] = a[b];
        a[b] = s;
    }

    for (int i = 1; i <= w; i++)
    {
        OP(a[i])
    }

    return 0;
}


Measured memory_bytes: 3004
#include <iostream>

using namespace std;

bool isEven(long long a) {
  return (a % 2 == 0);
}

int main(void)
{
  long long A, B;
  cin >> A >> B;

  long long At = A, Bt = B;
  long long result = 0;
  if (!isEven(A)) {
    ++At;
    result ^= A;
  }
  if (isEven(B)) {
    --Bt;
    result ^= B;
  }

  long long num = Bt - At + 1;
  if (!isEven(num/2)) {
    result ^= 1;
  }

  cout << result << endl;

  return 0;
}


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

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT cerr
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<__debug_tap<<"\n";}()
template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << endl; } }
template < class T, class = typename iterator_traits< typename T::iterator >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { o << "{"; for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : ", ") << *ite; o << "}"; return o; }
#else
#define dump(...) (42)
#define dump2D(...) (42)
template < class T, class = typename iterator_traits< typename T::iterator >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


const int N = 1e5;
std::vector<int> g[N];
int n;

int sz[N];

pair<int, int> centroid(-1, -1);
ll v[N];
ll ans[N];
map<pair<int, int>, int> edge;
void dfs(int i, int p) {
  sz[i] = 1;
  for(int j : g[i]) if(j != p) {
    dfs(j, i);
    sz[i] += sz[j];
    int A = n - sz[j] - 1;
    int B = sz[j] - 1;
    if(A == B) centroid = make_pair(i, j);
    else {
      ans[edge[make_pair(min(i,j), max(i,j))]] = (v[j] - v[i]) / (A - B);
    }
  }
}

ll dfs2(int i, int p, ll x) {
  ll res = 0;
  // dump(i, x);
  for(int j : g[i]) if(j != p) {
    ll d = ans[edge[make_pair(min(i,j), max(i,j))]];
    res += x + d;
    res += dfs2(j, i, x + d);
  }
  return res;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    if(a > b) swap(a, b);
    edge[make_pair(a, b)] = i;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  for(int i = 0; i < n; i++) cin >> v[i];
  dfs(0, -1);
  if(centroid.first != -1) {
    int a, b; tie(a, b) = centroid;
    // dump(a, b);
    if(a > b) swap(a, b);
    ll d = dfs2(a, -1, 0);
    // dump(d);
    ans[edge[make_pair(a,b)]] = (v[a] - d) / (n / 2);
  }
  for(int i = 0; i < n - 1; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}

void add(int& a, int b){
	a = (a+b) % MOD;
}
void mul(int& a, int b){
	a = (a*b) % MOD;
}
int mod_pow(int x, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}
int mod_inv(int x)
{
	return mod_pow(x, MOD - 2);
}
//割り算はmod_inv!


vector<int>g[10010];
int cnt[10010];
signed main()
{
	IOS();
	int N;
	cin>>N;
	vector<int>ans(N,-1);
	rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
		g[b].push_back(a);
    }
	vector<int>c(N);
	rep(i,0,N)cin>>c[i];
	sort(all(c));
	int sz = N-1;
	int sum=0;
	rep(i,0,N-1)sum+=c[i];
    queue<int>que;
	que.push(0);
	while(!que.empty()){
		int now = que.front();
		que.pop();
		if(ans[now]!=-1)continue;
		ans[now]=c.back();
		c.pop_back();
		for(auto e:g[now]){
			if(ans[e]!=-1)continue;
			que.push(e);
		}
	}
	cout<<sum<<endl;
	pv(ans);
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();

    if(t.substr(0, n) == s) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define re register
char ss[1001000];
int main()
{
	scanf("%s",ss+1);
	re int n,ans=0;
	n=strlen(ss+1);
	for(re int i=1;i<=n;)
	{
		if(i!=1&&ss[i]==ss[i-1])
		{
			if(n-i+1==1)break;
			else if(n-i+1==2){ans++;break;}
			else i+=3,ans+=2;
		}else i++,ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def no
	puts 'No'
	exit
end

s = gs
t = gs

st = Hash.new(nil)
ts = Hash.new(nil)
s.length.times do |i|
	no if st[s[i]] && st[s[i]]!=t[i]
	st[s[i]] = t[i]
	
	no if ts[t[i]] && ts[t[i]]!=s[i]
	ts[t[i]] = s[i]
end

st.each do |k,v|
	no if k!=ts[v]
end

puts 'Yes'

Measured memory_bytes: 2760
#include <stdio.h>

int main()
{
    int A,B;
    int c;
    scanf("%d %d",&A,&B);
    if(A+B>=A-B){
        c=A+B;
    }else{
        c=A-B;
    }
    if(A*B>c){
        c=A*B;
    }
    
    printf("%d\n",c);

    
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  int C = nextInt();
  int D = nextInt();
  cout << max(A*B, C*D) << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
N=parse(Int,readline())
isp=[true for _=1:N]
isp[1]=false
for i=2:N
	if isp[i]
		for j=2:div(N,i)
			isp[i*j]=false
		end
	end
end
ans=1
for i=1:N
	if isp[i]
		t=N
		c=0
		while t>0
			c+=t=div(t,i)
		end
		ans=ans*-~c%(10^9+7)
	end
end
println(ans)


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

int main()
{
        long long n,a,b;
        cin >> n>> a>> b;
        long long nya = n/(a+b);
        long long plus =0;
        if(n % (a+b) < a)
        {
                plus = n%(a+b);
        }
        else if(n %(a+b) > a)
        {
                plus = a;
        }
  	

        long long ans = a*nya + plus;

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



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  for(ll i=1;i<=n;i++){
    double d=i*1.08;
    ll k=d;
    if(k==n){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a[100005], b[100005], c[100005];
int gcd( int a,int b)
{
    if(b==0)
    return a;
    else
        return gcd(b,a%b);

}
int main()

{

    int n,i,j;

    cin>>n;

    for(i=0;i<n;i++) cin>>a[i];

    b[0]=a[0];

    c[n-1]=a[n - 1];

    for (i=1;i<n;i++)
        b[i]=gcd(b[i-1],a[i]);

    for (i=n-2;i>=0;i--)
        c[i]=gcd(c[i+1],a[i]);

    int zuida=b[n-1];

    for (i=0;i<n;i++){

        if(i==0) zuida=max(zuida,c[1]);

        else if(i==n-1) zuida=max(zuida,b[n-2]);

        else zuida=max(zuida,gcd(b[i-1],c[i+1]));

    }

    cout<<zuida<<endl;

    return 0;

}

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

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

    int sum=0;
    int s=0;

    if(a>=b){
        for(int i=b;i>0;i--){
            if(a%i==0&&b%i==0) sum++;
            if(sum==k){
                s=i;
                break;
            }
        }
    }
    else if(a<b){
        for(int i=a;i>0;i--){
            if(a%i==0&&b%i==0) sum++;
            if(sum==k){
                s=i;
                break;
            }
        }
    }

    cout<<s<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (n % k == 0) {
            System.out.println(0);
            return;
        }
        System.out.println(1);
    }
}


Measured memory_bytes: 22868