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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int[] x = new int[n + 1];
        for (int i = 1; i < n + 1; i++) {
            x[i] = sc.nextInt();
        }
        long[][][] dp = new long[n + 1][n + 1][3000];
        // dp[i][j][k] : iコマででj子使ってkを作る個数
        dp[0][0][0] = 1;
        for (int i = 1; i < n + 1; i++) {
            for (int j = 0; j < n + 1; j++) {
                for (int k = 0; k < 3000; k++) {
                    if (j == 0) {
                        dp[i][j][0] = 1;
                    } else if (k - x[i] >= 0) {
                        dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
                    } else {
                        dp[i][j][k] = dp[i - 1][j][k];
                    }

                }
            }
        }
        long ans = 0;
        for (int i = 1; i < n + 1; i++) {
            ans += dp[n][i][i * a];
        }

        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 128700
#include<iostream>
using namespace std;
int gcd(int a , int b)
{
    return a % b == 0 ? b : gcd(b, a % b);
}
int main()
{
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n;i++)
        for (int j = 1; j <= n;j++)
            for (int k = 1; k <= n;k++)
                ans += gcd(gcd(j, k), i);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
package main

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

func main() {
	n := readI()
	type pair struct {
		a, b int
	}
	p := make(map[pair]int)
	for i := 1; i <= n; i++ {
		r, l := rn(i), ln(i)
		if _, ok := p[pair{r, l}]; ok {
			p[pair{r, l}]++
		} else {
			p[pair{r, l}] = 1
		}
	}

	ans := 0
	for k, v := range p {
		r, l := k.a, k.b
		if _, ok := p[pair{l, r}]; ok {
			ans += v * p[pair{l, r}]
		}
	}
	fmt.Println(ans)
}

func rn(a int) int {
	return a % 10
}

func ln(a int) int {
	aa := strconv.Itoa(a)
	return int(rune(aa[0]) - '0')
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 3168
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut x: i32 = sc.read();
    let mut res = 0;
    let digit = 10;
    let mut keta = 1;

    for __i in 0..3 {
       let mut tmp;
       tmp = x % digit;
       if tmp == 1 {
           tmp = 9;
       } else {
           tmp = 1;
       }
       res = res + tmp * keta;
       x = x / 10;
       keta = keta * 10;
    }

    println!("{}", res);
}


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


int main() {
    int l,r,d;
    cin>>l>>r>>d;
    int count=0;
    rep(i,1001){
        int D=d*i;
        if(D>=l){
            if(D<=r){
                count++;
            }
        }
        if(D>r){
            break;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3580
#! /usr/bin/env python3

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k,n = na()
a = na()
b = [0]*n

for i in range(n):
    b[i] = abs(a[i-1] - a[i])
    if i == 0:b[i] = abs(-a[i-1] + k + a[i])


print(k-max(b))

Measured memory_bytes: 25876
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = 5*1e5;
ll mod = 5;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here

int main()
{
	IOS;
	int l, r, d,an=0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; ++i)
		if (i % d == 0)
			++an;
	cout << an << endl;
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){
  int s, w;
  std::cin >> s >> w;

  std::cout << (s<=w?"unsafe":"safe") << std::endl;
  
  return 0;
}


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

int main(){
	ll h; cin>>h;
	ll ans=1, cnt=1;
	while(h!=1){
		h/=2; cnt++; ans+=pow(2,cnt-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4012
/*
    Author : Pranav_Raut.
*/

#include<bits/stdc++.h>
using namespace std;
#define input(arr,n) for(ll i=0;i<n;i++){cin>>arr[i];}
typedef long long int ll;
ll MOD = 1000000007;
ll MAXN = 100005;

ll arr[100005];
ll ans[100005];
vector<ll> g[100005];
set<pair<ll,ll> > ss;

int main()
{
    /* JUST CODE TILL YOU CRACK IT !!! */
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    memset(arr,0,sizeof(ll));
    memset(ans,0,sizeof(ll));
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        arr[b]++;
        g[a].push_back(b);
    }

    for(ll i=1;i<=n;i++)
    {
            ss.insert(make_pair(arr[i],i));
    }

    while(!ss.empty())
    {
        set<pair<ll,ll> >::iterator t = ss.begin();
        ll node = t->second;
        //cout<<node<<endl;
        if(t->first==0)
            ss.erase(ss.begin());
        for(ll i=0;i<g[node].size();i++)
        {
            ans[g[node][i]] = max(ans[g[node][i]], ans[node]+1);
            set<pair<ll,ll> >::iterator tt = ss.find(make_pair(arr[g[node][i]],g[node][i]));
            ss.erase(tt);
            arr[g[node][i]]--;
            ss.insert(make_pair(arr[g[node][i]],g[node][i]));
        }
    }
    ll fans = 0;
    for(ll i=1;i<=n;i++)
    {
        fans = max(fans,ans[i]);
    }
    cout<<fans<<endl;
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  vector<double> P(N);
  rep(i,N) cin>>P[i];

  double ans=1.0;
  double val=0.0;
  for(int i=0;i<K;i++){
    ll sum=P[i]*(P[i]+1)/2;
    double res=sum/P[i];
    val+=res;
  }
  ans=val;

  for(int i=K;i<N;i++){
    ll sum=P[i-K]*(P[i-K]+1)/2;
    double mi=sum/P[i-K];
    val-=mi;

    sum=P[i]*(P[i]+1)/2;
    double pl=sum/P[i];
    val+=pl;
    ans=max(ans,val);
  }

  cout<<fixed<<setprecision(10)<<ans<<endl;


  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  if(n==0 || n==2)
    {
      cout << 1 << endl;
      return 0;
    }
  else if(n==1)
    {
      cout << 2 << endl;
      return 0;
    }
  else
    {
      cout << 0 << endl;
    }
  return 0;
}



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

int main(void){
  double t, max, min;
  cin >> t;
  max = t;
  min = t;
  while(cin >> t){
    if(max < t) max = t;
    if(min > t) min = t;
  }
  cout << (max - min) << endl;
  return 0;
}

Measured memory_bytes: 3248
n,m,l=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(n)]
b=[list(map(int,input().split()))for _ in range(m)]
[print(*x)for x in[[sum([s*t for s,t in zip(c,l)])for l in zip(*b)]for c in a]]

Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define ss second
#define ff first 
#define ub upper_bound
#define lb lower_bound
// #define mp make_pair
const ll M=1000000007;
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0)return (power((x*x)%M,n/2))%M;else return ((x%M)*power(x,n-1)%M);}
ll ncr(int n,int r){if(r>n)return 0;if(r > n - r) r = n - r;ll ans = 1;
int i;for(i = 1; i <= r; i++){ans *= n - r + i;ans /= i;}return ans;}
ll nCrModpDP(ll n, ll r, ll p){ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
    for (ll i = 1; i <= n; i++){ 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll ncrmod(ll n, ll r, ll p){ 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
   return (ncrmod(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p;  
} 
ll modInverse(ll a,ll m) 
{ 
   ll m0 = m; 
   ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
       ll q = a / m; 
       ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
ll fun(ll num[],ll sum,ll n){
map<ll,ll>mp;
for(int i=0; i<n; i++){
mp[num[i]]++;
}
ll ans=0;
for(int i=0; i<n; i++){
if(mp[sum-num[i]]>0&&(sum-num[i]!=num[i])&&(mp[num[i]]>0)){
ans+=1,mp[sum-num[i]]--,mp[num[i]]--;
}
else if(mp[sum-num[i]]>=2&&(sum-num[i]==num[i])){
ans+=1,mp[sum-num[i]]-=2;
}
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k;
cin>>n>>k;
ll ans=k;
for(ll i=2; i<=n; i++){
ans*=(k-1);
}
cout<<ans;
return 0;
}

Measured memory_bytes: 3572
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto input = readln.split.to!(int[]);
  int A = input[0], B = input[1];

  writeln(max(A-B-B, 0));
}


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n,a,b;
li h[100100];

inline li divup(li x, li n) {
	li res=x/n;
	if(x%n>0)res++;
	return res;
}

inline bool ok(li num){
	li baseline = num*b;
	li num_a = 0;
	rep(i,n){
		num_a += divup(max(h[i]-baseline,0ll), a-b);
	}
	return num_a <= num;
}

int main() {
	cin>>n>>a>>b;
	rep(i,n)cin>>h[i];

	li l=0, r=1000000000;

	while(l+1<r){
		li mid=(l+r)/2;
		if (ok(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout<<r<<endl;

	return 0;
}

Measured memory_bytes: 1024
let () = Scanf.scanf "%d" @@ fun s ->
  if s mod 2 = 0 then begin
    Printf.printf "%d\n" (s * (s - 2) / 2);
    for i = 1 to s do
      for j = i + 1 to s do
        if i + j <> s + 1 then
          Printf.printf "%d %d\n" i j
      done
    done
  end else begin
    Printf.printf "%d\n" (s * (s - 1) / 2 - s / 2);
    for i = 1 to s do
      for j = i + 1 to s do
        if i + j <> s then
          Printf.printf "%d %d\n" i j
      done
    done
  end



Measured memory_bytes: 2048
class Fenwick_Tree:
    def __init__(self, n):
        self._n = n
        self.data = [0] * n
    
    def add(self, p, x):
        assert 0 <= p < self._n
        p += 1
        while p <= self._n:
            self.data[p - 1] += x
            p += p & -p
    
    def sum(self, l, r):
        assert 0 <= l <= r <= self._n
        return self._sum(r) - self._sum(l)
    
    def _sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r - 1]
            r -= r & -r
        return s


def main():
    n, q = map(int, input().split())
    fw = Fenwick_Tree(n)
    for i, a in enumerate(map(int, input().split())): fw.add(i, a)
    for _ in range(q):
        t, a, b = map(int, input().split())
        if t == 0:
            fw.add(a, b)
        else:
            print(fw.sum(a, b))

if __name__ == "__main__":
    main()


Measured memory_bytes: 70932
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
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;}
const ll INF = 1LL << 60;

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] <<  b[0] << c[0] << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = GetLongNum();

            if (X >= 30)
            {
                Console.WriteLine("Yes");
                return;
            }
            Console.WriteLine("No");
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static int[] GetIntNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => int.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27520
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int Mod=1e9+7;
const int MAXN=1e5+10;
int n,Ans=1,A[MAXN],Deg[MAXN],Vis[MAXN],Inc[MAXN],Fl[MAXN];
int Cs[MAXN],Dp[MAXN];
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
	while(b!='-'&&(b<'0'||b>'9'))b=getchar();
	if(b=='-')c=-1,b=getchar();
	while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
	return a*c;
}
inline void Calc(rg int Np)
{   rg int Fd=-1,Ld=0,Nd=0,Lf=0;
	for(;Inc[Np];Inc[Np]=0,Np=A[Np],Nd++)
		if(Fl[Np]) Fd!=-1?Ans=1ll*Ans*((Fl[Np]<Nd-Ld)+(Fl[Np]<=Nd-Ld))%Mod:(Fd=Nd,Lf=Fl[Np]),Ld=Nd;
	Fd!=-1?Ans=1ll*Ans*((Lf<Fd+Nd-Ld)+(Lf<=Fd+Nd-Ld))%Mod:Cs[Nd]++;
}
int main()
{   n=Read();
	for(rg int i=1;i<=n;i++) A[i]=Read(),Deg[A[i]]++;
	for(rg int i=1,Pos;i<=n;i++)
	{   if(Vis[i]) continue ;
		for(Pos=i;!Vis[Pos];Pos=A[Pos]) Vis[Pos]=i;
		if(Vis[Pos]==i) while(!Inc[Pos]) Inc[Pos]=1,Pos=A[Pos];
	}
	for(rg int i=1;i<=n;i++) if(Deg[i]-Inc[i]>1) return puts("0"),0;
	for(rg int i=1,Pos,Nl;i<=n;i++)
	{	for(Pos=i,Nl=0;!Inc[Pos]&&!Deg[i];Pos=A[Pos]) Nl++;
		if(!Deg[i]) Fl[Pos]=Nl;
	}
	for(rg int i=1;i<=n;i++) if(Inc[i]) Calc(i);
	for(rg int i=1;i<=n;i++)
	{	if(!Cs[i]) continue ;   Dp[0]=1;
		for(rg int j=1;j<=Cs[i];j++)
		{   Dp[j]=(i>1&&i&1?2:1)*Dp[j-1]%Mod;
			if(j>=2) Dp[j]=(Dp[j]+1ll*Dp[j-2]*(j-1)%Mod*i)%Mod;
		}
		Ans=1ll*Ans*Dp[Cs[i]]%Mod;
	}
	printf("%d\n",Ans);
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  
  vector<bool> A(N, false);
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    A[x] = true;
  }
  
  int left = 0, right = 0;
  
  for (int i = X-1; i > 0; i--) {
    if (A[i]) left++;
  }
  
  for (int i = X+1; i < N; i++) {
    if (A[i]) right++;
  }
  
  cout << min(left, right) << endl;
 
  

}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int n, s;
    double a, total, htotal;
    while(true){
        cin >> n;
        total = 0;
        htotal = 0;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            cin >> s;
            total += s;
            htotal += s*s;
        }
        if(htotal/n == (total/n)*(total/n)){
            a = 0;
        } else{
            a = sqrt(htotal/n - (total/n)*(total/n));
        }
        printf("%lf\n", a);
    }
    return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ;
	cin >> n ;
	int ans = 0;
	For(i,1,n+1){
		if(i%2){
			int count = 0;
			for(int j = 1 ; j <= n ; j++){
				if( i % j == 0 ) count ++;
			}
			if(count == 8) {
				ans ++ ;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  vector <string> day = {" ", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  string S;
  cin >> S;
 for (int N=0; N<8; N++){
    if (S == day.at(N)){
   //   cout << day.at(N) << "" << N;
      cout << N << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

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

    if(a > b || (n == 1 && a != b)) {
        cout << 0 << endl;
        return 0;
    }

    if(n <= 2) {
        cout << 1 << endl;
        return 0;
    }

    cout << (n - 2) * (b - a) + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii ;

const int mx=1000005 ;
int d[mx] ;

int main(){
    for(int i =1 ; i< mx ; i++){
        for(int j =i ; j < mx ; j += i){
            d[j]++;
        }
    }
    ll j=0 ;
    int n ;
    cin >> n;
    for(int c =1 ; c<n  ; c++){
        j += ((ll)d[n-c]) ;
    }
    cout << j ;

}


Measured memory_bytes: 7524
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    char s;
    cin>>s;
    cout<<(char)(s+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int a[105];

int main()
{
    int n,k;

    scanf("%d%d",&n,&k);

    for (int i = 1;i <= n;i++)
        scanf("%d",&a[i]);

    int sum = 0;

    for (int i = 1;i <= n;i++)
    {
        sum += min(k - a[i],a[i]) * 2;
    }

    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMX LONG_LONG_MAX
void DFS(vector< vector< ll > >&adj, vector< ll >&dp, ll s)
{
  for(ll i=0;i<adj[s].size();i++)
  {
    if(dp[adj[s][i]] == -1)
    {
      DFS(adj, dp, adj[s][i]);
      dp[s] = max(dp[s], dp[adj[s][i]] + 1);
    }
    else
    {
      dp[s] = max(dp[s], dp[adj[s][i]] + 1);
    }
  }
  dp[s] = max(0ll, dp[s]);
}
int main()
{
  ll n,m;
  cin>>n>>m;
  vector<ll>dp(n, -1);
  vector< vector< ll > >adj(n);
  while(m--)
  {
    ll x, y;
    cin>>x>>y;
    adj[x-1].push_back(y-1);
  }
  for(ll i=0;i<n;i++)
  {
    if(dp[i] == -1)
      DFS(adj, dp, i);
  }
  ll mx = -1;
  for(ll i=0;i<n;i++)
    mx = max(mx, dp[i]);
  cout<<mx;
  return 0;
}

Measured memory_bytes: 8576
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <unordered_map>
#include <memory.h>

// pi = atan(1)*4;

using namespace std;

int main(void)
{
	string s, t;

	cin >> s;

	int idx = 0;

	while (1)
	{
		if (s.substr(idx, 11) == "dreameraser")
		{
			t += "dreameraser";
			idx += 11;
		}
		else if (s.substr(idx, 10) == "dreamerase")
		{
			t += "dreamerase";
			idx += 10;
		}
		else if (s.substr(idx, 7) == "dreamer")
		{
			t += "dreamer";
			idx += 7;
		}
		else if (s.substr(idx, 5) == "dream")
		{
			t += "dream";
			idx += 5;
		}
		else if (s.substr(idx, 6) == "eraser")
		{
			t += "eraser";
			idx += 6;
		}
		else if (s.substr(idx, 5) == "erase")
		{
			t += "erase";
			idx += 5;
		}
		else
		{
			break;
		}
		if (idx >= s.size())
		{
			break;
		}
	}
		if (s == t)
		{
			cout << "YES" << '\n';
		}
		else
		{
			cout << "NO" << '\n';
		}

	return 0;
}

Measured memory_bytes: 640
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn sub()
{
    parse!{
        read_line(2) =>
        n: usize,
        blocks: [i32; n],
    }
    let mut prev = -1;
    let mut up   = 0;
    let mut down = 0;
    for block in blocks {
        if prev < 0 {
            prev = block;
            continue;
        }
        if prev < block {
            let diff = block - prev;
            if up < diff {
                up = diff;
            }
        }
        else if prev > block {
            let diff = prev - block;
            if down < diff {
                down = diff;
            }
        }
        prev = block;
    }
    println!("{} {}", up, down);
}

fn main()
{
    parse!{
        read_line(1) =>
        t: usize,
    }
    for _i in 0..t {
        sub();
    }
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

void solve()
{
   int x;
    cin >> x;
 
   for(int i=-1e3;i<=1e3;i++)
      for(int j=-1e3;j<=1e3;j++)
   {
       if(pow(i,5) - pow(j,5) == x)
       {
           cout << i << ' ' << j;
           return;
       }
   }
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 4124
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

double dp[3010][3010];

int main(){
    int N;cin >> N;
    vector<double> coins(3010);
    rep(i,N)cin >> coins[i];
    dp[0][0]=1;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(j!=0)dp[i][j]=dp[i-1][j]*(1-coins[i-1])+dp[i-1][j-1]*coins[i-1];
            else dp[i][j]=dp[i-1][j]*(1-coins[i-1]);
        }
    }
    int harf = N/2+1;
    double res = 0;
    for(int i=harf;i<=N;i++){
        res+=dp[N][i];
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }






int main() {

string S;
cin >> S;

vector<int>point(3, 0);
int base = S.size() / 3;

REP(i, S.size()){
  int x = S.at(i) - 'a';
  point.at(x)++;
}

REP(i, 3){
  if(point.at(i) != base && point.at(i) != base + 1) {
    NO;
    return 0;
  } 
}

YES;
}



Measured memory_bytes: 512
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265359
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ld x1, y1, x2, y2;
    x1 = a * sin((h * 30.0 + (m * 30.0) / 60.0) * PI / 180.0);
    y1 = a * cos((h * 30.0 + (m * 30.0) / 60.0)* PI / 180.0);
    x2 = b * sin(m * 6.0 * PI / 180.0);
    y2 = b * cos(m * 6.0 * PI / 180.0);
    ld dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    cout << fixed << setprecision(15) << dist << endl;
    return 0;
}

Measured memory_bytes: 4116
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    string S;
    bool flag[26] = {};
    cin >> S;
    REP(i,S.length()){
        flag[(int)S[i]-97] = true;
    }
    REP(i,26){
        if(! flag[i]){
            cout << (char)(i+97) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    string s;
    cin >> s;

    int n=4;
    for (int i=0;i<n-1;i++){
        if (s[i]==s[i+1]){
            cout << "Bad" << el;
            return 0;
        }
    }

    cout << "Good" << el;

    return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  rep(i, q) {
    int b;
    cin >> b;
    --b;
    a[b] += 1;
  }
  rep(i, n) {
    int ans = k - q + a[i];
    bool bl = ans > 0;
    if (bl) puts("Yes");
    else puts("No");
  }
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int N, D, tmp, int_dist = 0, ans = 0;
    double double_dist = 0;
    int x[10][20];
    cin >> N >> D;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> x[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            double_dist = 0;
            for (int k = 0; k < D; k++) {
                double_dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            double_dist = sqrt(double_dist);
//            cout << double_dist << endl;
            if (double_dist == static_cast<double>(static_cast<int>(double_dist))) {
//            cout << i << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
times = int(input())

for i in range(0, times):
	edge = []
	for e in input().split(" "):
		edge.append(int(e))
	edge.sort()
	if pow(int(edge[0]), 2) + pow(int(edge[1]), 2) == pow(int(edge[2]), 2):
		print("YES")
	else:
		print("NO")

Measured memory_bytes: 7612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int d, g; cin>>d>>g;
  vector<tuple<int, int, int>> pc;
  rep(i, d) {
    int p, c; cin>>p>>c;
    pc.emplace_back(p, c, (i+1)*100*p + c);
  }

  int ans = 1000;

  rep(i, d) {
    rep(j, 1<<10) {
      int sum = 0;
      int cnt = 0;  
      rep(k, d) if (k != i) {
        if (j & (1<<k)) {
          sum += get<2>(pc[k]);
          cnt += get<0>(pc[k]);
        }
      }
      if (sum >= g) ans = min(ans, cnt);
      rep(k, get<0>(pc[i])) {
        sum += (i+1)*100;
        ++cnt;
        if (sum >= g) ans = min(ans, cnt);
      }
      sum += get<1>(pc[i]);
      if (sum >= g) ans = min(ans, cnt);
    }
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, m, r;
    cin >> n >> m >> r;

    vector<int> perm(r);
    for(int i = 0; i < r; i++){
        cin >> perm[i];
        perm[i]--;
    }

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

    vector<vector<ll>> dist(n, vector<ll>(n, INF));

    for(int i = 0; i < n; i++){
        dist[i][i] = 0;
    }

    for(int i = 0; i < m; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = min(dist[a][b], c);
        dist[b][a] = min(dist[b][a], c);
    }


    for(int v = 0; v < n; v++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                dist[i][j] = min(dist[i][j], dist[i][v] + dist[v][j]);
            }
        }
    }


    ll ans = INF;
    do{
        ll tmpans = 0;
        for(int i = 1; i < r; i++){
            tmpans += dist[perm[i - 1]][perm[i]];
        }
        ans = min(ans, tmpans);
    }while(next_permutation(perm.begin(), perm.end()));

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int H, W, j, k;
    
    while(1){
        scanf("%d %d\n", &H, &W);
        
        if(H==0 && W==0){
            break;
        }
        
        for(j=0; j<H; j++){
            for(k=0; k<W; k++){
                putchar('#');
            }
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}



Measured memory_bytes: 2100
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] - b[i] for i in range(n)]
if sum(c) < 0:
  print(-1)
else:
  c.sort()
  s = 0
  q = 0
  for i in range(n):
    if c[i] < 0:
      s += c[i]
      q += 1
    else:
      break
  for i in range(n):
    if s >= 0:
      print(q)
      break
    s += c[n-1-i]
    q += 1




Measured memory_bytes: 18356
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int inf = 1001001001;
const int INF = 1<<29;
const int MAX_V = 110;
const int MAX_E = 1100;
int N, M;
int a[MAX_E], b[MAX_E], c[MAX_E]; // 各辺
int dist[MAX_V][MAX_V]; // Floyd-Warshall 用

int main() {
    cin >> N >> M;

    // Floyd-Warshall でよくやる初期化
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0; // ここがポイント
    }

    // 入力
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    // Floyd-Warshall
    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    // 集計
    int res = 0;
    for (int i = 0; i < M; ++i) {
        if (c[i] > dist[a[i]][b[i]]) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long  a,b,c,d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;

  std::vector<long long> v;
  v.push_back(a*c);
  v.push_back(a*d);
  v.push_back(b*c);
  v.push_back(b*d);
  sort(v.begin(), v.end());

  long long& x = v.back();
  cout << x << endl;



  return 0;
}


Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	s, K := ReadString(), ReadInt()
	m := make(map[string]bool)
	v := make([]string, 0)
	for i := 1; i <= K; i++ {
		for j := 0; j < len(s)-i+1; j++ {
			t := s[j : j+i]
			if !m[t] {
				v = append(v, t)
				m[t] = true
			}
		}
	}
	sort.Strings(v)
	fmt.Println(v[K-1])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


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

int main() {
  int A , B;
  string op;
  cin >> A >> op >> B;
  if ( op == "+" ) {
    cout << A + B << endl;
  }
  if ( op == "-" ) {
    cout << A - B << endl;
  }
}
 

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int[] foo = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        Scanner scan = new Scanner(System.in);
        int num= scan.nextInt();
        num=num-1;
        System.out.println(foo[num]);
    }
}

Measured memory_bytes: 22868
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data1 = Console.ReadLine().Split(' ');
            string[] data2 = Console.ReadLine().Split(' ');
            string data3 = Console.ReadLine();
            int a = int.Parse(data2[0]);
            int b = int.Parse(data2[1]);

            if (data3 == data1[0]) a--;
            if (data3 == data1[1]) b--;





            Console.WriteLine(a+" "+b);
            
            
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
    int a = ri();
    cout << (n%500<=a?"Yes":"No") << endl;
 return 0;
}


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

namespace AtTest.ABC_109
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var strs = new string[n];
            for (int i = 0; i < n; i++)
            {
                strs[i] = Console.ReadLine();
            }
            var dict = new Dictionary<string, bool>();
            dict.Add(strs[0], true);
            for(int i = 1; i < n; i++)
            {
                if (dict.ContainsKey(strs[i]))
                {
                    Console.WriteLine("No");
                    return;
                }
                else
                {
                    if (strs[i - 1][strs[i - 1].Length - 1] == strs[i][0])
                    {
                        dict.Add(strs[i], true);
                    }
                    else
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll a, b,c; cin >> a >> b >> c;
    if(c-a-b <= 0){
        cout << "No" << endl;
        return 0;
    }
    if(4*a*b < (c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256