akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)

	V := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &V[i])
	}

	C := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &C[i])
	}

	ans := 0

	for i := 0; i < N; i++ {
		if profit := V[i] - C[i]; profit > 0 {
			ans += profit
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int A, B;
  cin >> A >> B;
  int K = (A + B) / 2;
  if (abs(B - K) == abs(K - A)) cout << K << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
# frozen_string_literal: true

a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

ary_500 = (0..a).to_a.map { |e| e * 500 }
ary_100 = (0..b).to_a.map { |e| e * 100 }
ary_50 = (0..c).to_a.map { |e| e * 50 }

ary_p = ary_500.product(ary_100).product(ary_50).map(&:flatten)

puts ary_p.select { |ary| ary.inject(:+) == x }.size


Measured memory_bytes: 35452
N = int(input())
A = [int(i) for i in input().split()]
a = sum(A)
i = 1
while i < N:
	a -= A[i] * 2
	i += 2
print(a, end=' ')
i = 1
while i < N:
	a = A[i - 1] * 2 - a
	print(a, end=' ')
	i += 1

Measured memory_bytes: 14092
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    map<string,int>memo;
    REP(i,N){
        string d;cin>>d;
        memo[d]++;
    }
    int M;cin>>M;
    REP(i,M){
        string d;cin>>d;
        memo[d]--;
    }
    int ans=0;
    for(auto it=memo.begin();it!=memo.end();it++){
        ans=max(ans,it->second);
    }
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
int m;
int dp[5010][5010];
void add(int &v, int x) {
	v += x;
	if (v >= m) v -= m;
}
int main() {
	int n;
	scanf("%d%d", &n, &m);
	int h = (n - 1) / 2, d = 0, ans = 0;
	dp[0][n] = 1;
	for (int i = 0; i < n; i++) {
		if (i <= h) {
			d++;
		} else if (i >= n - h) {
			d--;
		}
		for (int j = n; j >= 0; j--) {
			add(dp[i+1][j], dp[i][j]);
			if (j + d <= n) add(dp[i+1][j], dp[i+1][j+d]);
		}
	}
	for (int i = 1; i <= n; i++) {
		add(ans, dp[n][i]);
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  int N,m=0,ryokan=0;
  cin>>N;

  vector<int> vec(N);
  for(int i=0;i<N;i++)
  	cin>>vec.at(i);

  for(int i=0;i<N;i++){
  	if(m <= vec.at(i)){
  		ryokan++;
  		m=vec.at(i);
  	}
  }

  cout<<ryokan<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct Edge{
  int u, v, w;
  Edge(){}
  Edge(int u, int v, int w){
    this -> u = u;
    this -> v = v;
    this -> w = w;
  }
};
bool operator<(const Edge& a, const Edge& b){
  return tie(a.u, a.v, a.w) < tie(b.u, b.v, b.w);
}
bool operator==(const Edge& a, const Edge& b){
  return tie(a.u, a.v, a.w) == tie(b.u, b.v, b.w);
}
string conv(int w){
  if(w == -1)
    return "X";
  else if(w == -2)
    return "Y";
  else
    return to_string(w);

}
int main(){
//  freopen("connect.in", "r", stdin);
//  freopen("connect.out", "w", stdout);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int a, b;
  cin >> a >> b;
  int arr[10][10];
  for(int i = 0;i < a;i++)
    for(int j = 0;j < b;j++)
      scanf("%d", arr[i] + j);
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      if(i && arr[i][j] < arr[i - 1][j]){
        cout << "Impossible";
        return 0;
      }
      if(j && arr[i][j] < arr[i][j - 1]){
        cout << "Impossible";
        return 0;
      }
    }
  }
//  assert(false);
  vector<Edge> es;
  for(int i = 0;i < 100;i++){
    es.push_back(Edge(i, i + 1, -1));
  }
  es.push_back(Edge(100, 101, 100));
  for(int j = 0;j < 100;j++)
    es.push_back(Edge(100 + j + 1, 100 + j + 2, -2));
  int cur = 202;
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      int x, y;
      x = i + 1;
      y = j + 1;
      bool done = 0;
      for(int c = 0;c <= 100;c++){
        for(int nx = 0;nx <= 100;nx++){
          int ny = (arr[i][j] - nx * x - c) / y;
          if((arr[i][j] - nx * x - c) % y || ny < 0)
            continue;
          bool good = 1;
          for(int k = 0;k < a;k++){
            for(int m = 0;m < b;m++){
              if(c + nx * (k + 1) + ny * (m + 1) < arr[k][m]){
                good = 0;
                break;
              }
            }
            if(!good)
              break;
          }
          if(good){
            es.push_back(Edge(nx, 201 - ny, c));
            done = 1;
            break;
          }
        }
        if(done)
          break;
      }
      if(!done){
        cout << "Impossible\n";
        return 0;
      }
    }
  }
  cout << "Possible\n";
  sort(es.begin(), es.end());
  es.erase(unique(es.begin(), es.end()), es.end());
  cout << "202 " << es.size() << endl;
  for(auto el : es){
    cout << el.u + 1 << ' ' << el.v + 1 << ' ' << conv(el.w) << endl;
  }
  cout << "1 202";
}


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

using namespace std;

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

	if (min(a, b) + w >= max(a, b))cout << 0 << endl;
	else{
		cout << max(a, b) - (min(a, b) + w) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc161_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split(" ");
            int n = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);

            string[] ai = Console.ReadLine().Split(" ");
            List<int> aiList = new List<int>();

            double sum = 0;
            foreach (string aiInt in ai)
            {
                aiList.Add(int.Parse(aiInt));
                sum += int.Parse(aiInt);
            }

            int sortAiList = aiList.OrderByDescending(value => value).Skip(m-1).First();

            double warizan = sum / (4 * m);

            if (sortAiList >= warizan)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 28188
package main
import (
  "fmt"
  "sort"
  "strings"
)
func main() {
  var s string
  m := map[string]int{}
  fmt.Scan(&s)
  for i:=0;i<len(s);i++ {
    m[s[i:i+1]]++
  }
  ent := Entries{}
  for key,val := range m {
    ent = append(ent,Entry{key,val})
  }
  sort.Sort(sort.Reverse(ent))
  var min,tmp int
  min = 100000
  for i:=0;i<ent.Len();i++ {
    tmp = shrink(s,ent[i].key,0)
    if min > tmp { min = tmp }
  }
  fmt.Println(min)
}

func shrink(s string,t string,n int) int {
  if len(strings.Replace(s,t,"",-1)) == 0 { return n }
  var u string = ""
  for i:=0;i<len(s)-1;i++ {
    if s[i:i+1] == t || s[i+1:i+2] == t {
      u += t
    } else {
      u += s[i:i+1]
    }
  }
  return shrink(u,t,n+1)
}

type Entry struct {
  key string
  val int
}
type Entries []Entry
func(entries Entries) Len() int {
  return len(entries)
}
func(entries Entries) Swap(i,j int) {
  entries[i],entries[j] = entries[j],entries[i]
}
func(entries Entries) Less(i,j int) bool {
  if entries[i].val == entries[j].val {
    return entries[i].key < entries[j].key
  } else {
    return entries[i].val < entries[j].val
  }
}

Measured memory_bytes: 4736
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable int mod = 10^^9 + 7;

void main(){
    int n, q;
    readVars(n, q);

    auto uf = new UnionFind(n);

    int com, x, y;

    foreach(qi ; 0 .. q){
        readVars(com, x, y);

        if (com == 0) {
            uf.unite(x, y);
        }
        else {
            writeln(uf.same(x, y) ? 1 : 0);
        }
    }
}

class UnionFind {
private:
    int[] p;
    int[] rank;

public:
    this(int N){
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x){
        if(x != p[x]){
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

    bool same(int x, int y){
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y){
        x = find_root(x);
        y = find_root(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            p[x] = y;
        }
        else {
            p[y] = x;

            if(rank[x] == rank[y]) rank[x]++;
        }
    }
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 3720
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    cout << 10*v[2] + v[1] + v[0];
    cout << endl;
}


Measured memory_bytes: 256
def main():
  N = int(input())
  A = [int(ai) for ai in input().split()]
  
  if 0 in A:
    print(0)
    return
  
  ans = 1
  for ai in A:
    ans *= ai
    if ans > 1e18:
      print(-1)
      return
  print(ans)

main()

Measured memory_bytes: 21704
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
const int N=20005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 int a[N],b[N],c[N];
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/




int x,n;
cin>>x>>n;

vector<int> v(n);
for(int i=0;i<n;i++)
{
	cin>>v[i];
}
sort(v.begin(),v.end());
if(!binary_search(v.begin(),v.end(),x))
{
	cout<<x<<endl;
	return 0;
}
int count;
int mini=1e9;
for(int i=-1000;i<=2000;i++)
{
	    if(binary_search(v.begin(),v.end(),i))
		{
			continue;
		}
		else
		{
			if(abs(i-x)<mini)
			{
				mini=abs(i-x);
				count=i;
			}
			
		}
}
cout<<count;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

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;
}

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

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

    ll res = modpow(2, n, MOD) - 1;
    if (res < 0) res += MOD;

    ll A = 1, B = 1, dA = 1, dB = 1;
    rep(i, a) {
        A *= (n - i);
        A %= MOD;
        dA *= (a - i);
        dA %= MOD;
    }
    rep(i, b) {
        B *= (n - i);
        B %= MOD;
        dB *= (b - i);
        dB %= MOD;
    }

    A = (A % MOD) * modinv(dA, MOD) % MOD;
    B = (B % MOD) * modinv(dB, MOD) % MOD;

    res -= A;
    if (res < 0) res += MOD;
    res -= B;
    if (res < 0) res += MOD;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
//2 pointer approach interesting problem

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin>>n;
   int input[n+1][4];//1 based indexing
   for(int i=1;i<=n;i++)
   	for(int j=1;j<=3;j++)
   		cin>>input[i][j];
   int dp[n+1][4];
   dp[1][1]=input[1][1];
   dp[1][2]=input[1][2];
   dp[1][3]=input[1][3];
   for(int i=2;i<=n;i++)
   {
   	for(int j=1;j<=3;j++)
   	{
   		if(j==1)
   			dp[i][j]=max(dp[i-1][2],dp[i-1][3])+input[i][j];
   		if(j==2)
   			dp[i][j]=max(dp[i-1][1],dp[i-1][3])+input[i][j];
   		if(j==3)
   			dp[i][j]=max(dp[i-1][1],dp[i-1][2])+input[i][j];

   	}
   }
   cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
     
    
    return 0;
}

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

using namespace std;
 
int main() {
	int a, b;
	char op;
  
  cin >> a >> op >> b;
  
  if (op == '+'){
    cout << a + b << endl;
  }
  else{
    cout << a - b << endl;
  }
  	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out){
		out.println(Math.sqrt(Double.parseDouble(sc.nextLine().replace(" ", "")))%1==0?"Yes":"No");
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

  ll B = ((S == 1e9) ? 1 : S + 1);

  for (ll i = 0; i < N; i++)
  {
    cout << ((i < K) ? S : B) << ((i == N - 1) ? '\n' : ' ');
  }
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

ll a[200001];
ll pref[200001];

const ll mod = 1e9 + 7;

int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%lld",&a[i]);}
	pref[0] = a[0];
	for(i=1;i<n;i++) {
		pref[i] = pref[i-1] + a[i];
		pref[i] %= mod;
	}
	ll ans = 0;
	for(i=0;i<n-1;i++){
		ll jum = pref[n-1] - pref[i];
		jum %= mod;
		if(jum < 0){
			jum += mod;
		}
		ll num = a[i] * jum;
		num %= mod;
		ans += num;
		ans %= mod;
	}
	printf("%lld\n",ans);
	return 0;
};

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


const int mod = 1e9 + 7;
const int maxn = 1e5+5;

LL fac[maxn];
LL ifac[maxn];

int mult(LL a,LL b){return (a*b)%mod;}

int modpow(int n,int p){
    if(p == 0) return 1;
    LL ret_val = modpow(n,p/2);
    ret_val = (ret_val*ret_val)%mod;
    if(p & 1) ret_val = (ret_val*n)%mod;
    return (int)ret_val;
}

int inv(int n){
    return modpow(fac[n],mod-2);
}

void init(){
    fac[0] = 1;
    fac[1] = 1;
    _for(i,2,maxn){
        fac[i] = (i*fac[i-1])%mod;
    }
}

int cal(int q,int r){
    if(q-r < 0) return 0;

    if(q == 0 || r == 0 || q-r == 0) return 1;
    LL res = ((LL)fac[q]*(LL)inv(r))%mod;
    res = (res*inv(q-r))%mod;
    return (int)res;
}

int N,K;
vector<int> G[maxn];

int searching(int u,int f){
    int ret = 1;
    int cnt = 0;
    if(G[u].size() == 1 && G[u][0] == f) return ret;
    for(auto a:G[u]){
        if(a == f) continue;
        ret = mult(ret,searching(a,u));
        cnt++;
    }
    if(f == -1){
        ret = mult(ret,cal(K-1,cnt));
    }
    else ret = mult(ret,cal(K-2,cnt));
    ret = mult(ret,fac[cnt]);
    return ret;

}

int main()
{
    init();
    cin >> N >> K;
    _for(i,0,N-1){
        int u,v;
        cin >> u >> v;
        G[u].PB(v);
        G[v].PB(u);
    }
    cout << mult(searching(1,-1),K) << endl;;



    return 0;
}


Measured memory_bytes: 12416
#include<stdio.h>
#define M 1000000
int main(){
  int i,j,n,m,d[35];
  char p[M]={1,1};
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d %d",&n,&m),n||m){
    int c[M]={1};
    for(i=0;i<n;i++)scanf("%d",&d[i]);
    for(i=0;i<m;i++){
      if(c[i]==0)continue;
      for(j=0;j<n;j++){
	if(i+d[j]<=m)c[i+d[j]]=1;
      }
    }
    for(i=m;i;i--){
      if(p[i]==0&&c[i])break;
    }
    if(i)printf("%d\n",i);
    else printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 5500
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
pos = []
for i in range(N):
	x, y = rl()
	pos.append((x,y))

pp = []
pm = []
mm = []
mp = []
for x, y in pos:
	pp.append(x+y)
	pm.append(x-y)
	mm.append(-x-y)
	mp.append(-x+y)
max_pp = max(pp)
max_pm = max(pm)
max_mm = max(mm)
max_mp = max(mp)

ans = max(max_pp+max_mm, max_pm+max_mp, max_mp+max_pm, max_mm+max_pp)
print(ans)


Measured memory_bytes: 140408
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int K;
	long long S = 0;
	cin >> K;
	for(int i = 1; i <= K; ++i) {
		for(int j = 1; j <= K; ++j) {
			int g = __gcd(i, j);
			for(int k = 1; k <= K; ++k)
				S += __gcd(g, k);
		}
	}
	cout << S << '\n';
	return 0;
}

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

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

int main()
{
	int a,b,x;
	cin >> a >> b;
	x = 1;
	REP(i,b-a-1) x = x + i + 2;
	cout << x - b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    vi A(3);
    for(int i=0;i<3;i++)cin>>A[i];
    sort(ALL(A));
    cout<<A[2]-A[0]<<endl;
}

Measured memory_bytes: 3596
#include <iostream>

int main()
{
    int a = 0;
    int b = 0;
    std::string s;
    
    while( 1 )
    {
        // input
        std::cin >> a;
        std::cin >> s;
        std::cin >> b;
    
        if( a < 0 || a > 20000 || b < 0 || b > 20000 )
        {
            std::cout << "Error : out of range!";
            return -1;
        }
    
        // output
        if( "+" == s )
        {
            std::cout << a + b <<std::endl;
        }
        else if( "-" == s )
        {
            std::cout << a - b <<std::endl;
        }
        else if( "*" == s )
        {
            std::cout << a * b <<std::endl;
        }
        else if( "/" == s )
        {
            if( 0 == b )
            {
                std::cout << "Error : 0 devide!" << std::endl;
            }
            else
            {
                std::cout << a / b <<std::endl;
            }
        }
        else if( "?" == s )
        {
            break;
        }
        else
        {
            continue;
        }
    }
    
    return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    cnt1 += (s[i] - '0') != (i & 1);
    cnt2 += (s[i] - '0') != (~i & 1);
  }
  cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x=i;
        if(x%3==0){
            cout<<" "<<i;
        }else{
            while(x){
                if(x%10==3){
                    cout<<' '<<i;
                    break;
                }else{
                x =x/10;
            }
        }
    }
    }cout<<endl;
    return 0;

}




Measured memory_bytes: 3092
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n;
		int i, j;
		int count, ct, k = 0;
		int num[][] = new int[2][15];
		
		while ((n = input.nextInt()) != 0){
			count = 0;
			for (i = 0; i < n; i++){
				num[0][i] = input.nextInt();
			}
			k = 0;
			while (true){
				for (i = 0; i < n; i++){
					ct = 0;
					for (j = 0; j < n; j++){
						if (num[k][i] == num[k][j]) ct++;
					}
					num[1 - k][i] = ct;
				}
				ct = 0;
				for (i = 0; i < n; i++){
					if (num[0][i] == num[1][i]) ct++;
				}
				if (ct == n){
					break;
				}
				k = 1 - k;
				count++;
			}
			
			System.out.print(count + "\n" + num[0][0]);
			for (i = 1; i < n; i++){
				System.out.print(" " + num[0][i]);
			}
			System.out.println();
		}
	}
}

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

#define nax 100009
#define FOR(i,n,m) for(int i = (n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define sz(v) int(v.size())

typedef vector<int> vi;

vi v[nax];
bool vis[nax];
int dp[nax];
int n,m;

void dfs_(int node){
	vis[node] = true;
	dp[node] = 0;
	for(int u:v[node]){
		if(vis[u]){
		 dp[node] = max(dp[node],dp[u]+1);
		 continue;
		}
		dfs_(u);
		dp[node] = max(dp[node],dp[u]+1);
	}
}

int dfs(){
	memset(vis,0,sizeof vis);
	REP(i,n){
		if(!vis[i]){
			dfs_(i);
		}
	}
	int ans = 0;
	REP(i,n){
		ans = max(ans,dp[i]);
	}
	return ans;
}


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

	REP(i,m){
		int x,y; cin>>x>>y;
		x--;y--;
		v[x].pb(y);
	}

	cout<<dfs();

	return 0;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
long long A,B,T;
long long dp[100];
int main()
{
    cin>>A>>B>>T;
    dp[1]=A;
    for(int i=2;i<=20;i++) dp[i]=dp[i-1]+A;
    long long sum=0;
    for(int i=1;i<=20;i++){
        if(dp[i]>T+0.5){
            break;
        }
        sum+=B;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	int[][] mapA = new int[5][4];
	int[][] mapB = new int[4][5];
	int x, y, d;
	boolean flag;
	
	void U(){
		if(flag==true && y>0 && mapB[y-1][x]==1){
			d=0;
			y--;
			flag = false;
			System.out.print("U");
		}
	}
	
	void R(){
		if(flag==true && x<4 && mapA[y][x]==1){
			d=1;
			x++;
			flag = false;
			System.out.print("R");
		}
	}
	
	void D(){
		if(flag==true && y<4 && mapB[y][x]==1){
			d=2;
			y++;
			flag = false;
			System.out.print("D");
		}
	}
	
	void L(){
		if(flag==true && x>0 && mapA[y][x-1]==1){
			d=3;
			x--;
			flag = false;
			System.out.print("L");
		}
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		for(int i=0;i<9;i++){
			String s = sc.next();
			if(i%2==0){
				for(int j=0;j<4;j++) mapA[i/2][j] = s.codePointAt(j)-48;
			}else{
				for(int j=0;j<5;j++) mapB[i/2][j] = s.codePointAt(j)-48;
			}
		}
		x = 0;
		y = 0;
		d = 1;

		while(true){
			flag = true;
			if(d==0){
				L();
				U();
				R();
				D();
			}else if(d==1){
				U();
				R();
				D();
				L();
			}else if(d==2){
				R();
				D();
				L();
				U();
			}else if(d==3){
				D();
				L();
				U();
				R();
			}
			
			if(x==0 && y==0){
				System.out.println();
				break;
			}
		}
	}
	
	
	public static void main(String[] args) {
		new Main().solve();
	}
}

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

typedef long long ll;

int N;
ll L[100005], R[100005];

set<pair<ll,int>> Lend, Rend;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld%lld", L+i, R+i);

	for (int i = 0; i < N; ++i) Lend.insert({L[i], i}), Rend.insert({R[i], i});

	ll mx = 0;

	for (int st = 0; st < 2; ++st) {
		bool f = st;
		ll sm = 0;
		ll pos = 0;

		for (int i = 0; i < N; ++i) Lend.insert({L[i], i}), Rend.insert({R[i], i});

		for (int i = 0; i < N; ++i) {
			if (f) {
				int j = prev(Lend.end())->second;
				if (pos <= R[j]) {
					sm += max(L[j] - pos, 0LL);
					if (pos < L[j]) pos = L[j];
				} else {
					sm += max(pos - R[j], 0LL);
					pos = R[j];
				}
				Lend.erase(prev(Lend.end()));
				Rend.erase(Rend.find({R[j], j}));
			} else {
				int j = Rend.begin()->second;
				if (pos >= L[j]) {
					sm += max(pos - R[j], 0LL);
					if (pos > R[j]) pos = R[j];
				} else {
					sm += max(L[j] - pos, 0LL);
					pos = L[j];
				}
				Lend.erase(Lend.find({L[j], j}));
				Rend.erase(Rend.begin());
			}
			f = !f;
		}

		sm += abs(pos);

		mx = max(mx, sm);
	}

	printf("%lld\n", mx);
}

Measured memory_bytes: 16384
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N-1):
    for j in range(i+1, N):
        a = 0
        for l in range(D):
            a += (X[i][l] - X[j][l])**2
        a = a ** 0.5
        if a.is_integer():
            cnt += 1
        
print(cnt)

Measured memory_bytes: 9372
fn main(){
  let nmq: Vec<usize> = read_vec();
  let n = nmq[0];
  let m = nmq[1];
  let q = nmq[2];

  let av: Vec<usize> = read_vec();
  let qv: Vec<usize> = read_vec();

  let mut ll: Vec<usize> = vec![0;n];
  let mut rl: Vec<usize> = vec![0;n];

  rl[0] = n - 1;
  ll[n-1] = 0;

  for i in 1 .. n {
    rl[i] = i - 1;
  }

  for i in 0 .. n-1 {
    ll[i] = i + 1;
  }

  let mut cbt = 0;
  
  for i in 0 .. m {
    cbt = pass(&mut ll, &mut rl, av[i], cbt);
  }

  for i in 0 .. q {
    println!("{}", if ll[qv[i]] == 200000 { 0 } else { 1 });
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn pass(ll: &mut Vec<usize>, rl: &mut Vec<usize>, a: usize, bt: usize) -> usize {
  let mut t = bt;
  
  if a % 2 == 0 {
    for _ in 0 .. a {
      t = ll[t];
    }
  } else {
    for _ in 0 .. a {
      t = rl[t];
    }
  }
  
  let tl = ll[t];
  let tr = rl[t];
  rl[tl] = tr;
  ll[tr] = tl;
  rl[t] = 200000;
  ll[t] = 200000;
  tl
}



Measured memory_bytes: 11064
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for h in range(H):
        for w in range(W):
            if (h+w)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()



Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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


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

ll RepeatSquare(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y%2==0){
        ll h = RepeatSquare(x,y/2,mod);
        return h*h%mod;
    }
    if(y%2==1) return x*RepeatSquare(x,y-1,mod);
}

int main(){
    ll n;
    cin >> n;
    vector<int> flags(65);
    rp(i,n){
        ll a;
        cin >> a;
        rp(j,60){
            if(a==0) break;
            if(a%2==1) flags.at(j)++;
            a /= 2;
        }
    }
    ll ans=0;
    rp(i,60){
        ans += (flags.at(i)*(n-flags.at(i))%1000000007)*RepeatSquare(2,i,1000000007)%1000000007;
        ans %=1000000007;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,t,dp[3001],ans;
vector<pair<int,int>> v;

signed main() {
    cin >> n >> t;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        v.pb(mp(a,b));
    }
    sort(all(v));
    rep(i,n) {
        int a = v[i].fi, b = v[i].se;
        repm(i,t) {
            if (i+a > t) ans = max(ans, dp[i]+b);
            else dp[i+a] = max(dp[i+a], dp[i]+b);
        }
    }
    rep(i,t) ans = max(ans, dp[i]);
    cout << ans << endl;
}




Measured memory_bytes: 384
n = int(input())
raw = []
for i in range(n):
  tmp = input()
  now = []
  for j in range(n):
    if tmp[j] == '1':
      now.append(j)
  raw.append(now)
#print(raw)
ans = []
for st in range(n):
  gr = [-1 for _ in range(n)]
  gr[st] = 1
  time = 1
  now = {st}
  while now:
    time += 1
    last = now
    now = set()
    #print(last)
    for x in last:
      for y in raw[x]:
        if gr[y] == time-2:
          pass
        elif gr[y] == time:
          pass
        elif gr[y] == -1:
          gr[y] = time
          now.add(y)
        else:
          print(-1)
          #print(time,y,gr[y])
          break
      else:
        continue
      break
    else:
      continue
    break
  else:
    #print(time)
    ans.append(time-1)
    continue
  break
else:
  print(max(ans))

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

int main()
{

    int N;
    cin >> N;

    int t;
    int m = 0;

    int a[100100] = {0};
    rep(i, N) cin >> t, a[t]++;

    for (int i = 1; i < 100001; ++i)
    {
        m = max(m, a[i - 1] + a[i] + a[i + 1]);
    }

    cout << m << endl;

    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
using namespace std;
int main()
{
	int a[51];
	int n;
	int sum = 0;
	cin >> n;
	for (int i = 1;i <=n;i++)
	{
		cin >> a[i];
		if (a[i] != i)
		{
			sum++;
		}
	}
	if (sum == 2 || sum == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static class Edge {
        int to;
        int cost;
        public Edge(int to, int cost) {
            this.to = to;
            this.cost = cost;
        }
    }
    private List<List<Edge>> tree;
    private long[] depth;
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        tree = new ArrayList<>();
        depth = new long[N];
        for (int i = 0; i < N; ++i) {
            tree.add(new ArrayList<>());
        }
        for (int i = 0; i < N - 1; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            int c = sc.nextInt();
            tree.get(a).add(new Edge(b, c));
            tree.get(b).add(new Edge(a, c));
        }

        int Q = sc.nextInt();
        int K = sc.nextInt() - 1;

        dfs(K, -1, 0);

        for (int i = 0; i < Q; ++i) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            _out.println((depth[x] + depth[y]));
        }
    }
    private void dfs(int v, int p, long d) {
        depth[v] = d;
        for (Edge e : tree.get(v)) {
            if (e.to == p) {
                continue;
            }
            dfs(e.to, v, d + e.cost);
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 186132
#include <stdio.h>
int main()
{
  int n,a,b,c,d,i;
  while((scanf("%d",&n)) != EOF) {
    i=0;
    for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<10;d++){
	    if(a+b+c+d == n) i++;
	  }
	}
      }
    }
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
signed main() {
  string O, E, ans;
  cin >> O >> E;
  REP (i, O.size() + E.size()) {
    ans += i % 2 ? E[i/2] : O[i/2];
  }
  cout << ans << endl; 
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;

inline double cross(P x,P y){return imag(conj(x)*y);}

inline bool para(L a,L b){return abs(cross(a.fs-a.sc,b.fs-b.sc))<EPS;}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

int main(){
  int n;
  double x1[110],y1[110],x2[110],y2[110];
  L l[110];
  vector<P> v;

  while(cin >> n,n){
    for(int i=0;i<n;i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      l[i] = L(P(x1[i],y1[i]),P(x2[i],y2[i]));
    }

    int ans = 1;
    for(int i=0;i<n;i++){
      v.clear();
      for(int j=0;j<i;j++){
	if(!para(l[i],l[j])){
	  P tmp = line_cp(l[i],l[j]);
	  if(-100.0<tmp.real() && tmp.real()<100.0 &&
	     -100.0<tmp.imag() && tmp.imag()<100.0)v.push_back(tmp);
	}
      }

      for(int j=0;j<(int)v.size();j++){
	for(int k=j+1;k<(int)v.size();k++){
	  if(EQ(v[j],v[k])){
	    v.erase(v.begin()+k);
	    k--;
	  }
	}
      }
      ans += v.size() + 1;
    }

    cout << ans << endl;
  }
}

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

int64_t ryuka(int X){
  if(X==0){
    return 2;
  }
  if(X==1){
    return 1;
  }
  if(X==2){
    return 3;
  }
  if(X==3){
    return 4;
  }
  return 3*ryuka(X-3)+2*ryuka(X-4);
}

int main(){
  int N;
  cin >> N;
  cout << ryuka(N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    double d;
    cin >> n >> d;
    ll ans=0;
    for(ll i=0;i<n;i++){
        double x,y;
        cin >> x >> y;
        double len;
        len=sqrt(x*x+y*y);
        if(len<=d){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3840
list1 = list(map(int, input().split()))
list1.sort()
a,b,c = list1[0],list1[1],list1[2]

count=0
if a%2==b%2 and b%2==c%2:
    count+=(c-a)/2
    count+=(c-b)/2
else:
    if a%2==b%2:
        count+=1
        a+=1
        b+=1
    elif b%2==c%2:
        count+=1
        b+=1
        c+=1
    else:
        count+=1
        c+=1
        a+=1    
    count+=(c-a)/2
    count+=(c-b)/2
    
print(int(count))


Measured memory_bytes: 3064
n=int(input())
ans=[' ' for _ in range(11)]
ans_=[]
letter=[' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
while n:
  new=n%26
  if new==0:
    new=26
    n+=-26
  ans_.append(new)  
  n=int(n/26)  
ans_=ans_[::-1]
for i in range(len(ans_)):
  ans[i]=letter[ans_[i]]
print(''.join(ans)) 
  


Measured memory_bytes: 61860
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int N, A, surplus;

	cin >> N >> A;
	surplus = N % 500;
	if (surplus <= A)
    {
      cout << "Yes" << endl;
    }
	else if (surplus > A)
    {
      cout << "No" << endl;
    }
	return (0);
}

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

using namespace std;

int main(void) {
    long n;
    cin >> n;
    vector<long> a(n);
    for(auto &x: a) cin >> x;

    long r = 0;
    long c = 1;
    for(auto &x: a) {
        if(c == x)
            c++;
        else
            r++;
    }
    cout << (r == n ? -1 : r) << endl;
}


Measured memory_bytes: 1792
def f(a,b,x):
	return (a*x)//b - a*(x//b)
	
a,b,n=map(int,input().split())
res=0

if n<b:
	res=f(a,b,n)
	print(res)
else:
	res=f(a,b,b-1)
	if n%b==0:
		res=max(res,f(a,b,n-1))
		print(res)
	else:
		res=max(res,f(a,b,(n//b)-1))
		print(res)

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

using namespace std;

using P = pair<int, int>;

vector<vector<int>> edge;
map<P, int> color;


void dfs(int now, int from = -1){
  int c = 1;
  rep(i, edge[now].size()){
    int t = edge[now][i];
    if(t == from) continue;
    if(c == color[P(from, now)]) c++;
    color[P(now, t)] = c;
    c++;
    dfs(t, now);
  }
}

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

  edge.resize(n);
  vector<P> g(n-1);
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[i] = P(a, b);
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }

  int k = 0;
  rep(i, n){
    int m = edge[i].size();
    if(m > k) k = m;
  }

  dfs(0);
  
  cout << k << endl;
  rep(i, n-1) cout << color[g[i]] << endl;

  return 0;
}

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

using namespace std;

int n;
long long a[100005];
bool ex = false;
multiset<long long> s, ss;
map<long long, int> f;

int spf[100005];

const int MAXN = 100001;

void sieve() {
    spf[1] = 1;
    for (int i=2; i<=100000; i++)
        spf[i] = i;
 	for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}


long long get(long long x) {
	long long ou = 1;
	set<int> vis;
	while (x != 1) {
		if (vis.find(spf[x]) == vis.end()) {
			ou *= spf[x];
			vis.insert(spf[x]);
		}
		x /= spf[x];
	}
	return ou;
}

long long p(long long n) {
	return n*n*n;  
}

signed main() {
	sieve();
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		s.insert(a[i]);
	}
	for (int i = 1; 1ll*i*i*i <= 10000000000; i ++) {
		if (s.find(1ll*i*i*i) != s.end()) {
			ex = true;
			s.erase(1ll*i*i*i);
			ss.insert(1ll*i*i*i);
		}
	}
	//cout << s.size() << endl;
	int res = 0;
	if (ex) res++;
	for (int i = 1; i <= n; i++) {
		if (ss.find(a[i]) != ss.end()) continue;
		for (int j = 2154; j >= 1; j--) {
			if (a[i] % (1ll*j*j*j) == 0) {
				a[i] /= 1ll*j*j*j;
			}
		}
		f[a[i]]++;
	}
	sort(a+1, a+1+n);
	for (int i = 1; i <= n; i++) {
		if (ss.find(a[i]) != ss.end()) continue;
		//cout << a[i] << endl;
		if (a[i] > 100000) {res += f[a[i]]; f[a[i]] = 0;}
		else {
			long long op = p(get(a[i]))/a[i];
			res += max(f[a[i]], f[op]);
			f[op] = 0;
			f[a[i]] = 0;
		}
	}	
	cout << res;
}

Measured memory_bytes: 16384
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a[3];

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

  sort(a,a+3);
  
  if(a[0]==5&&a[1]==5&&a[2]==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;

}


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

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

  int ans = INT_MAX;
  for (int i = 0; i < n - 2; i++) {
    ans = min(ans, abs(stoi(s.substr(i, 3)) - 753));
  }
  cout << ans << endl;
}


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

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

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  string S;
  cin >> S;
  ll ans = 0;
  int N = S.size();
  bool flag = false;
  REPR(i, N-1){
    int d = S[i] - '0';
    if(flag) d++;
    flag = false;
    if(d < 5){
      ans += d;
    }
    else if(d > 5){
      ans += 10 - d;
      flag = true;
    }
    else{
      if(i != 0 && S[i-1] >= '5'){
        ans += d;
        flag = true;
      }
      else{
        ans += d;
      }
    }
  }
  if(flag) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5280
console.log((args=>{
  const [[N,K],p] = args.trim().split`\n`.map(r=>r.split` `.map(v=>0|v));
  const s = [0];
  for ( let i = 0; i < N; i++ ) s.push( s[i] + p[i] + 1 );
  let max = 0;
  for ( let i = 0; i + K <= N; i++ ) if ( max < s[i+K] - s[i] ) max = s[i+K] - s[i];
  return `${max/2}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 51940