akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Console.WriteLine(new string('x', s.Length));


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int dp[100007];
bool possible(int i){
    if(i == s.size()) return true;
    if(s.size() - i < 5) return false;
    if(dp[i] != -1){
        return dp[i];
    }
    bool poss = false;
    //cout << s.substr(0, 5) << " " << s.substr(5) << endl;
    if(s.substr(i, 5) == "dream" || s.substr(i, 5) == "erase"){
        poss |= possible(i+5);
       // if(poss) return true;
    }
    if(s.size() - i >= 6 && s.substr(i, 6) == "eraser"){
        poss |= possible(i+6);
        //if(poss) return true;
    }
    if(s.size()-i >= 7){
        if(s.substr(i, 7) == "dreamer")
            poss |= possible(i+7);
        //if(poss) return true;
    }
    return dp[i] = poss;
}
int main() {
    //string s;
    cin >> s;
    memset(dp, -1, sizeof(dp));
    bool ss = possible(0);
    if(ss) cout << "YES\n";
    else cout << "NO\n";
}


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


int main()
{
    long long n;
    cin>>n;
    long long ans,tm=1,pans=1;

    while(1)
    {
        ans = tm*tm;
        if(ans>n)
            break;
        pans = ans;
        tm++;

    }
    cout<<pans<<endl;


}




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

int main(){
	int a[3];
	while(cin >> a[0] >> a[1] >> a[2]){
		if(a[0] == 0 && a[1] == 0 && a[2] == 0) break;
		sort(a, a+3);
		int n;
		cin >> n;
		for(int i = 0; i < n; i++){
			int r;
			cin >> r;
			if((a[0] * a[0] + a[1] * a[1]) < r * r * 4) cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <complex>
#include <cassert>
#include <map>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;
using ull = unsigned long long;

int n;
int a, b, c;
int bc(int x, int y, int z) {
    if (!(0 <= x && x < n)) return false;
    if (!(0 <= y && y < n)) return false;
    if (!(0 <= z && z < n)) return false;
    return true;
}

int solve(int x, int y, int z, int dps = 5) {
    int ans = abs(x-a)+abs(y-b)+abs(z-c);
    if (dps == 0) return ans;
    if (x != a) {
        ans = min(ans, 1+solve(x, n-1-z, y, dps-1));
        ans = min(ans, 1+solve(x, z, n-1-y, dps-1));
    }
    if (y != b) {
        ans = min(ans, 1+solve(n-1-z, y, x, dps-1));
        ans = min(ans, 1+solve(z, y, n-1-x, dps-1));
    }
    if (z != c) {
        ans = min(ans, 1+solve(n-1-y, x, z, dps-1));
        ans = min(ans, 1+solve(y, n-1-x, z, dps-1));
    }
    return ans;
}

int main2() {
    int x, y, z;
    cin >> n;
    cin >> x >> y >> z;
    cin >> a >> b >> c;

    int ans = 1e8;
    for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
            for (int k = -2; k <= 2; k++) {
                int nx = x+i, ny = y+j, nz = z+k;
                if (!bc(nx, ny, nz)) continue;
                int res = abs(i)+abs(j)+abs(k);
                ans = min(ans, solve(nx, ny, nz) + res);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

int main() {
    static ll eord, enew;
    const int sz = 256*1024*1024;
    static unsigned char *p = (unsigned char*)malloc(sz);
    enew = ((ll)(p+sz-1) & ~0xff);
    __asm__ volatile("mov %%rsp, %0" : "=r"(eord));
    __asm__ volatile("mov %0, %%rsp" : : "r"(enew));
    main2();
    __asm__ volatile("mov %0, %%rsp" : : "r"(eord));
    return 0;
}

Measured memory_bytes: 3236
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==-1)
				return;
			double x=0;
			double y=0;
			double rad=0;
			while(n-->0)
			{
				x+=Math.cos(rad);
				y+=Math.sin(rad);
				rad=Math.atan2(y,x)+Math.PI/2;
			}
			System.out.printf("%.2f\n%.2f\n",x,y);
		}
	}
}

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

card = ['' for i in range(n)]
score1 = 0
score2 = 0


def win(score):
    score += 3
    return score


def draw(score):
    score += 1
    return score

for i in range(n):
    card[i] = [j for j in input().split()]

for i in range(n):
    if card[i][0] == card[i][1]:
        score1 = draw(score1)
        score2 = draw(score2)
    else:
        if card[i][0] > card[i][1]:
            score1 = win(score1)
        else:
            score2 = win(score2)

print(score1,score2)

Measured memory_bytes: 7692
/* ex4_1
   urah  */

#include <stdio.h>
#include <math.h>


// プロトタイプ宣言
int min_watchman(float tree_num, float watchman_view);

int main(void){

    float tree_num, watchman_view;
    int ans;

    // 入力受け取り
    scanf("%f\t%f", &tree_num, &watchman_view);
    // 関数の呼び出し
    ans = min_watchman(tree_num, watchman_view);
    // 答えの出力
    printf("%d\n", ans);

    return 0;
}

// 関数の定義
int min_watchman(float tree_num, float watchman_view){
    int ans;
    ans = ceil(tree_num / (2 * watchman_view + 1));
    return ans;
}

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

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> prefix_sum(n + 10, vector<int>(n + 10, 0));
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        prefix_sum[l][r]++;
    }
    rep(i, n + 10) rep(j, n + 10) {
        if (i + 1 < n + 10) prefix_sum[i + 1][j] += prefix_sum[i][j];
    }
    rep(i, n + 10) rep(j, n + 10) {
        if (j + 1 < n + 10) prefix_sum[i][j + 1] += prefix_sum[i][j];
    }
    while (q--) {
        int pi, qi;
        cin >> pi >> qi;
        pi--;
        int ans = prefix_sum[qi][qi];
        ans -= prefix_sum[pi][qi];
        ans -= prefix_sum[qi][pi];
        ans += prefix_sum[pi][pi];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1920
from collections import deque
S = deque(input())
Q = int(input())
rev = False
for i in range(Q):
  q = input()
  if len(q) == 1:
    rev = False if rev else True
  else:
    q, f, c = q.split()
    if rev:
      if f == "1":
        S.append(c)
      else:
        S.appendleft(c)
    else:
      if f == "1":
        S.appendleft(c)
      else:
        S.append(c)
print("".join(reversed(S)) if rev else "".join(S))


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

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  sort(v.begin(), v.end(), greater<int>());

  int alice=0, bob=0;
  rep(i,n){
    if(i%2==0) alice += v.at(i);
    else bob += v.at(i);
  }

  cout << alice-bob << endl;
}

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

int main() {
    long long N;
    vector<char> S;
    cin >> N;

    while (N!=0){

        long long A = N%26;//Nのあまりを求める
        N/=26;//商も求める
        if (A==0) {//割り切れた場合はあまりを26とみなす
            A=26;
            N-=1;
        }

        A-=1;//0-indexに変換

        char alpha = 'a' + A;//文字コードの加算、'A'から何個先かで'Z'まで表記可能
        S.push_back(alpha);//S末尾に追加
        
    }

    for (int i=S.size()-1; i>=0; i--){//push_backしたので降順に表示
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = solve <$> B.getLine <*> B.getLine >>= print

solve :: ByteString -> ByteString -> Int
solve b1 b2 = sum $ B.zipWith f b1 b2
  where
    f c1 c2 = if c1 == c2 then 0 else 1


Measured memory_bytes: 5720
import java.util.*;



import java.io.*;
public class Main {


	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt(),w=sc.nextInt();
	int a[][]=new int[n][2];
	int sum_val=0;
	for(int i=0;i<n;i++) {
		a[i][0]=sc.nextInt();
		a[i][1]=sc.nextInt();
	sum_val+=a[i][1];
	}
	
	
	long dp[]=new long[sum_val+1];
	Arrays.fill(dp, Integer.MAX_VALUE);
	dp[0]=0;
	for(int i=0;i<n;i++) {
	
		for(int value_taken=sum_val-a[i][1];value_taken>=0;value_taken--) {
			dp[value_taken+a[i][1]]=Math.min(dp[value_taken+a[i][1]], dp[value_taken]+a[i][0]);
		}
		
	}
	long ans=0;
	for(int i=0;i<=sum_val;i++) 
	{
		//System.out.print(dp[i]+" ");
		if(dp[i]<=w)
			ans=Math.max(ans, i);
	}
	

	System.out.println(ans);


	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

}



Measured memory_bytes: 33980
import java.util.*;
import java.lang.*;
import java.math.*;

import javax.swing.RowFilter.Entry;

public class Main {
	Scanner sc = new Scanner(System.in);
	class log implements Comparable<log>{
		int key;
		int value;
		log(int key,int value){
			this.key = key;
			this.value = value;
		}
		@Override
		public int compareTo(log o) {
			return key-o.key;
		}		
	}
	
	void run(){
		HashMap<Integer, Integer> l = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> l2 = new HashMap<Integer, Integer>();
		for(;;){
			String buffer = sc.nextLine();
			if(buffer.length() == 0) break;
			int k = new Scanner(buffer.replace(',', ' ')).nextInt();
			if(l.containsKey(k)){
				l.put(k, l.get(k)+1);
			}else{
				l.put(k, 1);
			}
		}
		for(;sc.hasNextLine();){
			String buffer = sc.nextLine();
//			if(buffer.equals("ddd")) break;
			int k = new Scanner(buffer.replace(',', ' ')).nextInt();
			if(l2.containsKey(k)){
				l2.put(k, l2.get(k)+1);
			}else{
				l2.put(k, 1);
			}
		}
		LinkedList<log> l3 = new LinkedList<Main.log>();
		for(int i:l.keySet()){
			if(l2.containsKey(i)){
				l3.add(new log(i, l.get(i)+l2.get(i)));
			}
		}
		log[] arr = l3.toArray(new log[0]);
		Arrays.sort(arr);
		for(log ans:arr){
			System.out.println(ans.key + " " + ans.value);
		}
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>

using namespace std;

int main()
{
    std:string s;
    cin >> s;
    
    bool isYes = true;
    for(int i=0; i<s.length(); i++){
        if(i%2 == 0){  // odd
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
            }else{
                isYes = false;
                break;
            }
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
            }else{
                isYes = false;
                break;
            }
        }
    }
    if(isYes == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;
int main() {
	int N,i;
	int b = 1;
	cin >> N;
	vector<int> a(N);
	for (i = 0; i < N; i++) {cin >> a[i];}
	for (i = 0; i < N; i++){
		b = a[b - 1];
		if (b == 2) { 
			cout << i + 1 << endl; 
			return 0;	
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    int a, b, k;
    scanf("%d%d%d",&a,&b,&k);
    int i;
    for (i = a; i <= b; i++)
    {
        if (i - a < k || b - i < k)
        {
            printf("%d\n",i);
         
        }
    }
    return 0;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

total = sum(a)
ans = None
x = 0
for ai in a[:-1]:
    x += ai
    total -= ai
    if ans is None:
        ans = abs(x - total)
    else:
        ans = min(ans, abs(x - total))

print(ans)


Measured memory_bytes: 24832
n,m = map(int,input().split())
pS_list = [list(input().split()) 
           for nesya in range(m)]
ac = 0
wa = 0
q_list = [0]*n
for ps in pS_list:
  p = int(ps[0])-1
  s = ps[1]
  if q_list[p] == 1:
    continue
  if s == 'WA':
    q_list[p] -= 1
  else:
    a = q_list[p]
    wa -= a
    ac += 1
    q_list[p] = 1
print(ac,wa)

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

typedef long double ld;
const ld eps = 1.0e-10;  // 許容される誤差

ld mysqrtl(ld x) {
  ld a = sqrt((double)x);  // 近似値
  do {
    a = (a + x / a) / 2.0L;
  } while (fabsl(x - a * a) > eps);
  return a;
}

int main() {
  ld a, b, c;
  cin >> a >> b >> c;

  if (2*sqrt(a*b) < c-a-b) {
    ANS("Yes");
  } else {
    ANS("No");
  }
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  bool ans = false;
  
  for (int i = 1; i <= b; i++){
    if ((i * a) % b == c){
      ans = true;
    }
  }
  
  if (ans){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#import numpy as np
import math


def solve():
    tv = sum(a)
    min_votes = math.ceil(tv * 1/4 / m)
    cnt = 0
    for ai in a:
        if ai>=min_votes:
            cnt+=1
    if cnt>=m:
        print("Yes")
    else:
        print("No")
    return


#s = input()

n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
solve()

Measured memory_bytes: 38384
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll N, M;
	cin >> N >> M;

	ll ans;
	if (M == 1) {
		if (N == 1) {
			ans = 1;
		} else {
			ans = N - 2;
		}
	} else if (M == 2) {
		ans = 0;
	} else {
		if (N == 1) {
			ans = (M - 2);
		} else {
			ans = (N - 2) * (M - 2);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vi H(N);
	REP(i,N) cin >> H[i];
	vl dp(N);
	dp[0] = 0;
	FOR(i, 1, N) {
		if (i == 1) {
			dp[i] = dp[i - 1] + abs(H[i] - H[i - 1]);
		} else {
			dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]));
		}
	}
	cout << dp[N - 1] << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

char to_lower(char c)
{
  if ( c >= 'A' && c <= 'Z' ) c += 0x20;
  return c;
}

int main()
{
  string w;
  string t;
  int cnt = 0;

  cin >> w;
  
  while ( cin >> t && t != "END_OF_TEXT")
    {
      transform( t.begin(), t.end(), t.begin(), to_lower );
      if ( t == w ) cnt++;
    }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    string S, T, U; 
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    cin >> U;

    if(U == S) cout << A-1 << " " << B << endl;
    if(U == T) cout << A << " " << B-1 << endl;


}

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

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

int main(){
    int k, ans = 0;
    cin >> k;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                ans += __gcd( __gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int N, K, X, a[1000000];
vector<pair<int, int>> s;
int main()
{
  while(true)
  {
    cin >> N >> K;
    if(!N)
      break;
    for(int i = 0; i < K; i++)
    {
      cin >> a[i];
      if(!a[i])
      {
        a[i] = 1000000000;
        X = 1;
      }
    }
    sort(a, a + K);
    a[K] = -1;
    int st = a[0], ans = 0;
    for(int i = 1; i < K + 1; i++)
    {
      if(a[i] != a[i - 1] + 1)
      {
        s.push_back(make_pair(st, a[i - 1] + 1));
        ans = max(ans, a[i - 1] + 1 - st);
        st = a[i];
      }
    }
    if(X)
    {
      for(int i = 1; i < s.size(); i++)
        if(s[i].first == s[i - 1].second + 1)
          ans = max(ans, s[i].second - s[i - 1].first);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1788
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();
		long mod = 1_000_000_007L;
		long x[] = new long[n];
		long y[] = new long[m];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			y[i] = sc.nextInt();
		}
		long X = 0;
		for (int i = 0; i < n - 1; i++) {
			X = add(X, mult(mult(i + 1, n - i - 1, mod), x[i+1] -x[i], mod), mod);
		}
		long ans = 0;
		for (int i = 0; i < m - 1; i++) {
			ans = add(ans, mult(mult(mult(i+1, m-i-1, mod), y[i+1]-y[i], mod), X, mod), mod);
		}
		System.out.println(ans);
	}
	static long add(long x, long y, long mod) {
		return (x + y) % mod;
	}
	static long mult(long x, long y, long mod) {
		return (x * y) % mod;
	}
}


Measured memory_bytes: 90628
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static List<long>[] G;
        static long[] nums;//子の数
        static List<long> path;//0→N-1までのPath
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            G = Enumerable.Range(0, (int)N).Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                var ab = Sarray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                G[a].Add(b);
                G[b].Add(a);
            }
            nums = new long[N];
            path = new List<long>();
            dfs(0, -1);
            path.Reverse();
            var fmasu = 0L;//スタート地点も含めた黒マス数
            var p = -1L;
            for (var i = 0; i < (path.Count + 1) / 2; ++i) 
            {
                var now = path[i];
                var next = path[i + 1];
                fmasu++;//今のマス
                foreach (var g in G[now])
                {
                    if (g == next || g == p) continue;
                    fmasu += nums[g] + 1;
                }
                p = now;
            }
            var smasu = N - fmasu;
            if (smasu < fmasu)
                WriteLine("Fennec");
            else
                WriteLine("Snuke");
            //Out.Flush();
        }
        static bool dfs(long r, long p)
        {
            var flg = false;
            if (r == G.Length - 1) flg = true;
            foreach (var g in G[r])
            {
                if (g == p) continue;
                flg |= dfs(g, r);
                nums[r] += nums[g] + 1;
            }
            if (flg) path.Add(r);
            return flg;
        }
    }
}

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

char a[2002],b[2001];
int len1,len2;

inline int qr()
{
	char a=0;int x=0,w=1;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<1)+(x<<3)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	cin>>a+1;
	cin>>b+1;
	len1=strlen(a+1);
	len2=strlen(b+1);
	int ans=0;
	for(int i=1;i+len2-1<=len1;i++)
	{
		int tot=1;
		int cnt=0;
		for(int j=i;j<=i+len2-1;j++)
		{
			if(a[j]==b[tot])
				cnt++;
			tot++;
		}
		ans=max(cnt,ans);
	}
	cout<<len2-ans<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<long long> w(n);
    long long all = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i]; all += w[i];
    }
    long long ans = 1e10;
    long long cnt = 0;
    for (int t = 0; t < n; t++) {
        cnt += w[t];
        ans = min(ans, max(all-cnt*2, cnt*2-all));
    }
    cout << ans << endl;
    return 0;
}

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

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

    int ma = max(a,b),sum = a+b+c;

    ma = max(ma,c);

    if( (3*ma - sum) % 2 == 0) cout<<( (3*ma-sum)/2 )<<endl;

    else cout<< ( (3*ma - sum) / 2) + 2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;
    vector<pint> a(N);
    REP(i,N){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(ALL(a));

    vint ans(N);
    REP(i,N){
        if(i<N/2) ans[a[i].second]=a[N/2].first;
        else ans[a[i].second]=a[N/2-1].first;
    }
    REP(i,N) cout<<ans[i]<<endl;
}


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

int main() {
  int X,A,B;
  cin >> X >> A >> B;
  if (B <= A){
    cout << "delicious" << endl;
  }
  else if(B>A+X){
    cout << "dangerous" <<endl;
  }
  else{
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include <math.h>
using namespace std;

typedef long long ll;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if((a<10)&&(b<10))cout << a*b << endl;
    else cout << "-1";

    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int sosu(int );

int sosu(int nyuu){
	int i;
	int count = 0;
	for(i = 0; i <= nyuu;i++){
		if(i % 7 == 6 || i % 7 == 1){
			if(nyuu % i == 0){
				count++;
			}
		}
	}
	if(count == 2){
		return nyuu;
	}
	else {
		return 0;
	}
}

int main()
{
	int nyuuryoku;
	int i,j,k;
	int ans;
	while(1){
		scanf("%d",&nyuuryoku);
		if(nyuuryoku == 1){
			break;
		}
		printf("%d:", nyuuryoku);
		for(i = 0;i < 300000;i++){
			if(i % 7 == 6 || i % 7 == 1){
				if(nyuuryoku % i == 0){
					ans = sosu(i);
					//printf("%d\n", ans);
					if(ans != 0){
						printf(" %d", ans);
					}
				}
			}
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double H1,W1,H2,W2;
    long double ans;
    H1=a*cos(2*M_PI/12*(double)(h+m/60));
    W1=a*sin(2*M_PI/12*(double)(h+m/60));
    H2=b*cos(2*M_PI/60*m);
    W2=b*sin(2*M_PI/60*m);
    ans=sqrt(abs(H1-H2)*abs(H1-H2)+abs(W1-W2)*abs(W1-W2));
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 4112
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a<=12){
            b/=2;
        }
        if(a<=5){
            b=0;
        }
        System.out.println(b);
    }
}

Measured memory_bytes: 21460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

    int buf[200000];
    int n;

    scanf("%d",&n);
    for(int i = 0;i < n;i++)
        scanf("%d",&buf[i]);
    
    unsigned long long int sum = 0;
    for(int i = 0;i < (n - 1);i++){
        if(buf[i] > buf[i + 1]){
            sum += (unsigned long long int)(buf[i] - buf[i + 1]);
            buf[i + 1] += (buf[i] - buf[i + 1]);
        }
    }

    printf("%llu\n",sum);
    
}

Measured memory_bytes: 2496
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
class BIT{
    private:
        vector<ll> bit;
        ll size;
    public:
        BIT(ll n){
            bit.resize(n+1);
            size = n;
        }
        ll sum(ll i){
            ll res = 0;
            while(i > 0){
                res += bit[i];
                i -= i&-i;
            }
            return res;
        }
        void add(ll i,ll x){
            while(i <= size){
                bit[i] += x;
                i += i&-i;
            }
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    string s;
    cin >> n >> s >> q;
    BIT letter(26*n);
    rep(i,1,n+1){
        letter.add((s[i-1]-'a')*n+i,1);
    }
    int t;
    rep(i,q){
        cin >> t;
        if (t == 1){
            int l;
            char c;
            cin >> l >> c;
            letter.add((s[l-1]-'a')*n+l,-1);
            s[l-1] = c;
            letter.add((s[l-1]-'a')*n+l,1);
        }
        else{
            int l,r;
            cin >> l >> r;
            l--;
            int res = 0;
            rep(j,26){
                if (letter.sum(j*n+r)-letter.sum(j*n+l)) res++;
            }
            PRINT(res);
        }
    }
}


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

int main(){
  int a,b,i;
  string s;
  while(1){
    cin>>s;
    a=0,b=0;
    if(s[0]=='0')break;
    for(i=1;i<s.size();i++){
      if( s[i]=='A')a++;
      else b++; 
    }
    if(a>b)a++;
    else b++;
    cout<<a<<" "<<b<<endl;
  }
  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> A;
  int nak=0;
  for(int i=0;i<n;i++){int a;cin >> a;A.push_back(--a);}
  for(int i=0;i<n;i++){if(A[A[i]]==i) nak++;}
  cout << nak/2 << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
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);
}
int main()
{
    int N;
    cin >> N;
    vll a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll cnt = accumulate(all(b), 0LL) - accumulate(all(a), 0LL), num1 = 0, num2 = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[i] < b[i])
        {
            num1 += (b[i] - a[i]+1) / 2;
        }
        else
        {
            num2 += a[i] - b[i];
        }
    }
    cout << ((cnt >= max(num1, num2)) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
using namespace std;
int main(void)
{
	int x;
	scanf("%d",&x);
	if(x%7==1){
		printf("fri\n");
	}
	if(x%7==2){
		printf("sat\n");
	}
	if(x%7==3){
		printf("sun\n");
	}
	if(x%7==4){
		printf("mon\n");
	}
	if(x%7==5){
		printf("tue\n");
	}
	if(x%7==6){
		printf("wed\n");
	}
	if(x%7==0){
		printf("thu\n");
	}
	return 0;
}


Measured memory_bytes: 2692
from sys import stdin
import sys
import math
import random

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
# a = random.randrange(1000000000)
# b = random.randrange(1000000000)
# c = random.randrange(1000000000)
# print(a, b, c)
# ra = math.sqrt(a)
# rb = math.sqrt(b)
# rc = math.sqrt(c)
# if ra+rb < rc:
#     print("Yes")
# else:
#     print("No")
# d = math.sqrt(b*a)
e=4*a*b
f=(c-a-b)**2
if c-a-b < 0:
    print("No")
    sys.exit(0)

if e<f:
# if d < (c-a-b)/2:
    print("Yes")
else:
    print("No")


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

int main() {
    int h,w,k;
    cin >> h >> w>> k;
    vector<string> s(h);
    rep(i,h) cin >> s.at(i);
    int ans = 0;
    rep(is,1<<h)rep(js,1<<w) {
     int cnt = 0;
    rep(i,h)rep(j,w){
     if(is>>i&1)continue;
    if(js>>j&1)continue;
    if(s[i][j] == '#') cnt++;
    }
    if(cnt ==k) ans++;
    }
    cout << ans << endl;
}

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

int main(void)
{
	float x[4], y[4], AB, CD;
	int i, j, n;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		for (j = 0; j < 4; j++){
			scanf("%f %f", &x[j], &y[j]);
		}
		
		if (x[1] == x[0]){
			AB = DBL_MAX;
		}
		else {	
			AB = (y[1] - y[0]) / (x[1] - x[0]);
		}
		
		if (x[3] == x[2]){
			CD = DBL_MAX;
		}
		else {
			CD = (y[3] - y[2]) / (x[3] - x[2]);
		}
		
		if (AB == CD){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,now=0;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  now=a[0];
  if(now<10){
    cout << "no" << endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(now<10){
      cout << "no" << endl;
      return 0;
    }
    now=max(now-10LL,a[i]);
  }
  now=a[n-1];
  if(now<10){
    cout << "no" << endl;
    return 0;
  }
  for(int i=n-2;i>=0;i--){
    if(now<10){
      cout << "no" << endl;
      return 0;
    }
    now=max(now-10LL,a[i]);
  }
  cout << "yes" << endl;
  return 0;
}



Measured memory_bytes: 5448
// by DenyTianly
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

#define iScf(n) scanf("%d", &n)
#define dug() printf("ok!\n")
#define iNxtL() puts("")
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define nrep(i, val, n) for(int i = val; i < n; i++)
#define mst(a, n) memset(a, n, sizeof(a))
#define ipq priority_queue
typedef pair<int, int> pii;
typedef long long LL;
typedef unsigned long long ULL;

const int inf = 1 << 26;
const LL INF = 1LL << 60;

inline void quick_IO() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); }
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = -f;

	for(; ch >= '0' && ch <= '9'; ch = getchar())
		x = x*10+ch-'0';

	return x*f;
}

int quick_pow(int a, int b) {	// calculate a^b
	if(b == 1) return a;
	int temp = quick_pow(a, b/2);
	if(b&1) return temp*temp*a;
	else return temp*temp;
}

// Don't hack me, please ~
// #define _Isopen_File_
// #define _Is_Close_STD_

int main(){

#ifdef _Isopen_File_
	freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
#endif

#ifdef _Is_Close_STD_
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	char a, b;
	scanf("%c %c", &a, &b);
	if(a==b) puts("H");
	else puts("D");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

void yes() {
  cout << "YES" << endl;
  exit(0);
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  if (s == "KIHBR") yes();
  if (s == "KIHBRA") yes();
  if (s == "KIHBAR") yes();
  if (s == "KIHBARA") yes();
  if (s == "KIHABR") yes();
  if (s == "KIHABRA") yes();
  if (s == "KIHABAR") yes();
  if (s == "KIHABARA") yes();
  if (s == "AKIHBR") yes();
  if (s == "AKIHBRA") yes();
  if (s == "AKIHBAR") yes();
  if (s == "AKIHBARA") yes();
  if (s == "AKIHABR") yes();
  if (s == "AKIHABRA") yes();
  if (s == "AKIHABAR") yes();
  if (s == "AKIHABARA") yes();
  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define o 1000005
#define re register int
#define ll long long
#define g0(a) memset(a,0,sizeof(a))
#define gc(a,b) memcpy(a,b,sizeof(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pa pair<int,int>
#define mpp make_pair
#define s1 first
#define s2 second
#define go(x) for(ll i=h[x];i;i=w[i].next)
using namespace std;
inline int read()
{
	register int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar();
	return data*w;
}
int h[o],cnt;
struct node
{
	int to,next;
}w[o];
void add(int x,int y){++cnt;w[cnt].to=y;w[cnt].next=h[x];h[x]=cnt;}
int n,rev[o];
int Make(int n)
{
	int t=ceil(log2(n+1));
	FOR(i,0,(1<<t)-1)rev[i]=(rev[i>>1]>>1|(i&1)<<t-1);
	return t;
}
const int mod=924844033;
int KSM(int x,int k)
{
	int tmp=1,y=x;
	for(int i=k;i;i>>=1,y=1ll*y*y%mod)if(i&1)tmp=1ll*tmp*y%mod;
	return tmp;
}
void Add(int &x,int y){x+=y-mod;x+=x>>31&mod;}
void dec(int &x,int y){x-=y;x+=x>>31&mod;}
void fix(int &x){x+=x>>31&mod;}
void NTT(int a[],int n,int d)
{
	FOR(i,0,(1<<n)-1)if(i<rev[i])swap(a[i],a[rev[i]]);
	for(int m=0;m<n;++m)
	{
		int w=KSM(5,mod-1+(mod-1)/(2<<m)*d);
		for(int i=0;i<1<<n;i+=2<<m)
			for(int k=i,x=1;k<i+(1<<m);++k,x=1ll*x*w%mod)
			{
				int t0=a[k],t1=1ll*x*a[k+(1<<m)]%mod;
				Add(a[k],t1);fix(a[k+(1<<m)]=t0-t1);
			}
	}
	if(d==-1){int x=KSM(1<<n,mod-2);FOR(i,0,(1<<n)-1)a[i]=1ll*a[i]*x%mod;}
}
int s[o],b[o];
void dfs(int x,int fa)
{
	s[x]=1;
	for(int i=h[x];i;i=w[i].next)
	{
		int y=w[i].to;
		if(y==fa)continue;
		dfs(y,x);
		s[x]+=s[y];
		b[s[y]]--;
	}
	if(s[x]!=n)b[n-s[x]]--;
}
int fac[o],inv[o],c[o];
int main()
{
	n=read();b[n]=n;
	FOR(i,1,n-1)
	{
		int x=read(),y=read();
		add(x,y);add(y,x);
	}
	dfs(1,0);
	FOR(i,1,n)b[i]=(b[i]+mod)%mod;
	fac[0]=1;FOR(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=KSM(fac[n],mod-2);
	REP(i,n-1,0)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	FOR(i,1,n)b[i]=1ll*b[i]*fac[i]%mod;
	FOR(i,1,n)c[n-i]=b[i];
	int t=Make(n<<1);
	NTT(c,t,1);NTT(inv,t,1);
	FOR(i,0,(1<<t)-1)c[i]=1ll*c[i]*inv[i]%mod;
	NTT(c,t,-1);NTT(inv,t,-1);
	FOR(i,1,n)cout<<1ll*c[n-i]*inv[i]%mod<<'\n';
	return 0;
}

Measured memory_bytes: 29332
public class Main {

	public static void main(String[] args) {
		java.util.Scanner scanner = new java.util.Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		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");
		}
	
					}
}

Measured memory_bytes: 26172
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 55;
const ll mod = 1e9+7;
int n;
ll K;

vector<vector<ll>> multiply(vector<vector<ll>>& a, vector<vector<ll>>&b){
	vector<vector<ll>> c(n, vector<ll>(n, 0));
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++)
			for(int k = 0; k<n; k++) (c[i][j] += a[i][k]*b[k][j])%=mod;
	return c;
}

int main(){
	cin >> n >> K;
	vector<vector<ll>> a(n, vector<ll>(n, 0)), ans(n, vector<ll>(n, 0));
	for(int i = 0; i<n; i++) ans[i][i] = 1;
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++) scanf("%lld", &a[i][j]);
	while(K>0){
		if (K&1) ans = multiply(ans, a);
		a = multiply(a, a);
		K>>=1;
	}
	ll sum = 0;
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++) (sum += ans[i][j])%=mod;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#define INT long long
using namespace std;
INT n, m, a, k, b, w, dep[500000], depw[500000], par[500000][21];
vector<INT> T[500000], W[500000];

void dfs(int v, int p, int d, int w)
{
    dep[v] = d, depw[v] = depw[p]+w, par[v][0] = p;
    for(int i = 0 ; i < T[v].size() ; i++ )
        if( T[v][i] != p ) dfs(T[v][i], v, d+1, W[v][i]);
}
INT lca(int v, int w)
{
    if( dep[v] < dep[w] ) swap(v, w);
    int diff = dep[v] - dep[w];
    for(int i = 0 ; diff ; i++, diff>>=1 ) if(diff&1) v = par[v][i];
    if( v == w ) return v;
    for(int i = 20 ; i >= 0 ; i-- )
        if( par[v][i] and par[w][i] and par[v][i] != par[w][i] )
            v = par[v][i], w = par[w][i];
    return par[v][0];
}
int main()
{
    cin>>n;
    for(int i = 1 ; i < n ; i++ )
    {
        cin>>a>>b>>w;
        T[a].push_back(b);
        T[b].push_back(a);
        W[a].push_back(w);
        W[b].push_back(w);
    }
    dfs(1, 0, 0, 0);
    for(int k = 1 ; k <= 20 ; k++ ) for(int i = 1 ; i <= n ; i++ )
        par[i][k] = par[par[i][k-1]][k-1];
    cin>>m>>k;
    while( m-- )
    {
        cin>>a>>b;
        INT dist = depw[a]+depw[k]-(2*depw[lca(a,k)]) + depw[k]+depw[b]-(2*depw[lca(k,b)]);
        cout<<dist<<endl;
    }
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
int a[55], b[55], u[22], v[22];
vpint G[55];
int par[55], edge[55];
int white[55];
void dfs(int x, int p, int e) {
    par[x] = p, edge[x] = e;
    rep(i, G[x].size()) {
        if (G[x][i].first == p) { continue; }
        dfs(G[x][i].first, x, G[x][i].second);
    }
}
int popcount(int x) {
    int ret = 0;
    rep(i, 64) { if (x & bit(i)) { ret++; }}
    return ret;
}
signed main() {
    cin >> N;
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        G[a[i]].push_back({b[i], i});
        G[b[i]].push_back({a[i], i});
    }
    dfs(0, -1, -1);
    cin >> M;
    rep(i, M) {
        cin >> u[i] >> v[i];
        u[i]--, v[i]--;
        while (u[i] != 0) {
            white[i] ^= bit(edge[u[i]]);
            u[i] = par[u[i]];
        }
        while (v[i] != 0) {
            white[i] ^= bit(edge[v[i]]);
            v[i] = par[v[i]];
        }
    }
    int ans = 0;
    rep(i, bit(M)) {
        int cur = 0;
        rep(j, M) { if (i & bit(j)) { cur |= white[j]; }}
        int p = popcount(i), q = popcount(cur);
        if (p & 1) { ans -= bit(N - 1 - q); }
        else { ans += bit(N - 1 - q); }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll h, w; cin >> h >> w;

    ll ans = LINF;
    for (ll i = 1; i < h; ++i) {
        //縦に割る
        ll s[3] = {};
        s[0] = i * w;
        s[1] = (h - i) * (w / 2);
        s[2] = (h - i) * (w - w / 2);

        ll mx = 0;
        ll mn = LINF;
        for (ll k = 0; k < 3; ++k) {
            mx = max(mx, s[k]);
            mn = min(mn, s[k]);
        }

        ans = min(ans, mx - mn);

        //横に割る
        s[0] = i * w;
        s[1] = ((h - i) / 2) * w;
        s[2] = ((h - i) - (h - i) / 2) * w;

        mx = 0;
        mn = LINF;
        for (ll k = 0; k < 3; ++k) {
            mx = max(mx, s[k]);
            mn = min(mn, s[k]);
        }

        ans = min(ans, mx - mn);
    }

    swap(h, w);
    for (ll i = 1; i < h; ++i) {
        //縦に割る
        ll s[3] = {};
        s[0] = i * w;
        s[1] = (h - i) * (w / 2);
        s[2] = (h - i) * (w - w / 2);

        ll mx = 0;
        ll mn = LINF;
        for (ll k = 0; k < 3; ++k) {
            mx = max(mx, s[k]);
            mn = min(mn, s[k]);
        }

        ans = min(ans, mx - mn);

        //横に割る
        s[0] = i * w;
        s[1] = ((h - i) / 2) * w;
        s[2] = ((h - i) - (h - i) / 2) * w;

        mx = 0;
        mn = LINF;
        for (ll k = 0; k < 3; ++k) {
            mx = max(mx, s[k]);
            mn = min(mn, s[k]);
        }

        ans = min(ans, mx - mn);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256