akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KStones solver = new KStones();
        solver.solve(1, in, out);
        out.close();
    }

    static class KStones {
        int n;
        int k;
        int[] arr;
        int min;
        Boolean[][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            k = sc.nextInt();
            arr = new int[n];
            min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                min = Math.min(min, arr[i]);
            }
            memo = new Boolean[k + 1][2];
            for (int i = 0; i <= k; i++)
                dp(i, 0);
            pw.println(dp(k, 0) ? "First" : "Second");
        }

        private boolean dp(int rem, int bool) {
            if (rem < min) {
                return bool == 0 ? false : true;
            }
            if (memo[rem][bool] != null)
                return memo[rem][bool];
            boolean toRet;
            if (bool == 0) {
                toRet = false;
                for (int i = 0; i < n; i++) {
                    if (arr[i] <= rem)
                        toRet |= dp(rem - arr[i], bool ^ 1);
                }
            } else {
                toRet = true;
                for (int i = 0; i < n; i++) {
                    if (arr[i] <= rem)
                        toRet &= dp(rem - arr[i], bool ^ 1);
                }
            }
            return memo[rem][bool] = toRet;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



Measured memory_bytes: 26548
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

int INF = int.max;
void main() {
  int N = readln.chomp.to!int;

  int[] ary = new int[N+1];
  ary[0..$] = INF;
  int l = 0;
  int r = 1;
  foreach(i; 0..N+1) {
    if (!(l<r)) break;
    foreach(j; l..r) {
      if (j>N) break;
      ary[j] = min(ary[j], i);
    }
    l = r;
    r = r+i+1;
  }
  int k = N;
  while(k > 0) {
    ary[k].writeln;
    k -= ary[k];
  }
}


Measured memory_bytes: 39420
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int ans = 0;
    for (int p = 0; p <= A; p++){
      for (int q = 0; q <= B; q++){
        for (int r = 0; r <= C; r++){
          int total = 500*p + 100*q + 50*r;
          if (total == X) ans++;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35812
// i_m_arin

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

ll n;
cin>>n;

ll ans=0;
ll x=1,y=1,z=1;
f(i,0,n){
	x=(x*10)%MOD;
	y=(y*9)%MOD;
	z=(z*8)%MOD;
}
ans=(x-2*y)%MOD;

if(ans<0) ans+=MOD;
ans=(ans+z)%MOD;
if(ans<0) ans+=MOD;
cout<<ans<<endl;
 


}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main() {
  int a;
  cin >> a;
 
 
	
  cout << a+a*a+a*a*a << endl;
  
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstring>

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

  // 入力の受け取り
  std::vector<int> a(N), b(N), c(N);
  for (int i = 1; i <= N; i++) { // 1-indexで入れる
    std::cin >> a[i] >> b[i] >> c[i];
  }

  // DP
  int dp[100002][3]; // dp[i][j] := i日目にjを選んだ時の幸福度最大値
  memset(dp, 0, sizeof(dp)); // 0で初期化しておく
  
  // 1日目は先に埋めておく
  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];

  // DP更新
  for (int i = 2; i <= N; i++) {
    // i日目に0(A)を選んだ時の幸福度最大値
    //  = 前日にB,Cを選んだ時の最大値 + i日目にAを選ぶ最大値
    dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + a[i];

    // i日目に1(B)を選んだ時の幸福度最大値
    dp[i][1] = std::max(dp[i - 1][0], dp[i - 1][2]) + b[i];

    // i日目に2(C)を選んだ時の幸福度最大値
    dp[i][2] = std::max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  // N日目にA,B,Cを選んだ時の最大値の最大値を取る
  int result = std::max(dp[N][0], std::max(dp[N][1], dp[N][2]));
  std::cout << result << std::endl;

  return 0;
}

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

struct	UnionFind {
	int		size;
	int		*par;
	int		*rank;
	UnionFind(int size): size(size), par(NULL), rank(NULL) {
		assert(size > 0);
		par = new int[size];
		rank = new int[size];
		assert(par != NULL && rank != NULL);
		for (int i = 0; i < size; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	~UnionFind() {
		delete [] par;
		delete [] rank;
		par = NULL;
		rank = NULL;
	}
	int		find(int idx) {
		if (par[idx] == idx)
			return idx;
		return (par[idx] = find(par[idx]));
	}
	bool	same(int lhs, int rhs) {
		if (find(lhs) == find(rhs))
			return true;
		return false;
	}
	void	unite(int lhs, int rhs) {
		int	par_l = find(lhs), par_r = find(rhs);
		if (par_l == par_r)
			return;
		if (rank[par_l] < rank[par_r]) {
			par[par_l] = par_r;
		} else {
			par[par_r] = par_l;
			if (rank[par_l] == rank[par_r])
				++rank[par_l];
		}
	}
};

int	main()
{
	int	N, M;
	cin >> N >> M;
	vector<int>	p_vec(N);
	int	p;
	for (int i = 0; i < N; ++i) {
		cin >> p;
		--p;
		p_vec.at(i) = p;
	}
	UnionFind	uf(N);
	int	x, y;
	for (int i = 0; i < M; ++i) {
		cin >> x >> y;
		--x; --y;
		uf.unite(x, y);
	}
	int	cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (uf.same(i, p_vec.at(i)))
			++cnt;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1408
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
struct BFS {
    struct edge {
        int node = -1, weight = -1;
        edge() {}
        edge(int _node, int _weight) : node(_node), weight(_weight) {}
    };
    int n;
    vector<vector<edge>> adj;
    vector<int> dist;
    vector<int> parent;
    
    BFS(int _n = 0) {
        init(_n);
    }
    void init(int _n) {
        n = _n;
        adj.assign(n, {});
    }
    void add_edge(int u,int v,int w){
        adj[u].push_back({v,w}) ;
    }
    void bfs(const vector<int>& src){
        queue<int>Q ;
        dist.assign(n, 1e18);
        parent.assign(n, -1);
        for(auto x: src) Q.push(x) , dist[x] = 0;
        while(!Q.empty()){
            int cur_len = Q.size() ;
            for(int i = 0 ; i < cur_len ; i++){
                int f = Q.front() ;
                Q.pop() ;
                for(auto x:adj[f]){
                    if(dist[f]+x.weight<dist[x.node]){
                        dist[x.node] = dist[f]+x.weight ;
                        parent[x.node]=f ;
                        Q.push(x.node) ;
                    }
                }
            }
        }
    }
};


void solve(){
	int n , m ;
	cin >> n >> m ;	
	BFS bfs(n) ;
	for(int i = 1 ; i <= m ; i++){
		int from , to ;
		cin >> from >> to ;
		from-- ;
		to-- ;
		bfs.add_edge(from, to, 1) ;
		bfs.add_edge(to, from, 1) ;
	}
	bfs.bfs({0}) ;
	for(int i = 1 ; i < n ; i++){
		if(bfs.dist[i] == INF){
			cout << "No\n" ;
			return ;
		}
	}
	cout << "Yes\n" ;
	for(int i = 1 ; i < n ; i++){
		cout << bfs.parent[i]+1 << endl ;
	}

}

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


Measured memory_bytes: 17584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[101][101];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    double N; cin >> N;
    double tai = 0;
    double ans = 0;
    double a, b, c;
    a = N / 3;
    b = N / 3;
    c = (N - a - b);
    ans = a * b * c;
    cout << fixed << setprecision(7) << ans << endl;
}


Measured memory_bytes: 256
# 2019-11-23 01:28:44(JST)
import sys
import numpy as np

MOD = 998244353

def main():
    n, *A = map(int, sys.stdin.read().split())
    S = sum(A)

    dp = np.zeros(S//2+1, dtype=np.int64)
    dp[0] = 1
    for a in A:
        dp[a:] = (dp[a:] + dp.copy()[:-a] * 2) % MOD
    
    ans = (pow(3, n, MOD) - dp.sum() * 3 % MOD) % MOD

    if S % 2 == 0:
        dp = np.zeros(S//2+1, dtype=np.int64)
        dp[0] = 1
        for a in A:
            dp[a:] = (dp[a:] + dp.copy()[:-a]) % MOD
        ans = (ans + dp[S//2] * 3) % MOD

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int N,t,x,y,pt=0,px=0,py=0;
    cin >> N;

    rep(i,N) {
        cin >> t >> x >> y;
        int dp=abs(x-px)+abs(y-py), dt=t-pt;
        if(dp>dt || dp%2!=dt%2) {
            cout << "No" << endl;
            return 0;
        }
        pt=t, px=x, py=y;
    }

    cout << "Yes" << endl;
}

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

int x[200010];
int y[200010];

int main(void){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x[i];
		y[i] = x[i];
	}
	sort(y, y+n);
	int a= y[n/2-1], b=y[n/2];

	for(int i=0; i<n; i++){
		if(x[i]<=a) cout << b << endl;
		else cout << a << endl;
	}

	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define endl            '\n'
#define pb              push_back
#define mp              make_pair
#define pr              pair<int,int>
#define vc              vector<int>
#define ma              map<int,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)




void fast_bhati()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

}

int sumOfDigits(int n){
    int s = 0;
    while(n!=0){
        s=s+n%10;
        n=n/10;
    }
    return s;
}
void solve(){



}
int32_t main()
{
    fast_bhati();
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t1 = a*c;
    t1 = max(t1,a*d);
    t1 = max(t1,b*c);
    t1 = max(t1,b*d);
    cout<<t1;
//    int t;
//    cin>>t;
//    while(t--)
//    {
//        solve();
//        if(t!=0){
//            cout<<endl;
//        }
//    }

    return 0;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if (a1 + a2 + a3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int D = sc.nextInt();
        float[][] X = new float[N][D];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < D; j++){
                X[i][j] = sc.nextFloat();
            }
        }

        int count = 0;
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j < N; j++){
                double dis = 0;
                double dis2 = 0;
                for(int k = 0; k < D; k++){
                    dis2 += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                
                dis = Math.sqrt(dis2);
                if(dis -Math.floor(dis) == 0){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23252
fn main() {
    let n = read();
    let k = read();
    let mut ans = 1;
    for c in 0..n {
        if ans < k {
            ans += ans;
        } else {
            ans += k;
        }
    }
    println!("{}", ans);
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, k, q, a[100010], w[100010];
int main() {
	scanf("%d %d %d", &n, &k, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", a + i);
		w[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		if (k - (q - w[i]) <= 0)
			printf("No\n");
		else
			printf("Yes\n");
	}
}

Measured memory_bytes: 1280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>


using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

class BBattle {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int a,b,c,d;
    int i = 0;
    string ans;
    cin >> a >> b >> c >>d;
    while(true){
        if(i%2==0){
            i++;
            c -= b;
            if(c <= 0){
                ans = "Yes";
                break;
            }
        }else{
            i++;
            a -= d;
            if(a <= 0){
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;
}
};


int main() {
	BBattle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

#ifdef DIV_DEBUG
#define cerr(...) __cerr(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __cerr(const char *name, Arg1 &&arg1) {
    cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __cerr(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *sep = strchr(names + 1, ',');
    cerr.write(names, sep - names) << " = " << arg1 << " |";
    __cerr(sep + 1, args...);
}
#else
#define cerr(...) 
#endif


int main() {
    fastIO;
    int n;
    cin >> n;
    vii d(n);
    for (auto& i : d)    cin >> i.ff >> i.ss;

    vi a(n + 1);
    bool ok = false;
    for (int i = 0; i < n; i++) {
        if (d[i].ff == d[i].ss) a[i + 1] = a[i] + 1;
        else    a[i + 1] = 0;
        if (a[i + 1] >= 3)  ok = true;
    }
    
    cout << (ok ? "Yes" : "No") << endl;
    
    return 0;
}
    

Measured memory_bytes: 3652
use std::io;

fn main() {
  let stdin = io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();
  let mut iter = buf.trim()
    .split_whitespace()
    .map(|x| x.parse::<i32>().unwrap());

  let w = iter.next().unwrap();
  let h = iter.next().unwrap();
  let x = iter.next().unwrap();
  let y = iter.next().unwrap();
  let r = iter.next().unwrap();

  let answer = if 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h { "Yes" } else { "No" };

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


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

int main(){
	int A[3];
	
	cin >> A[0] >> A[1] >> A[2];
	
	if(A[0]+A[1]+A[2]>21){
		cout << "bust";
	}else{
		cout << "win";
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String secStr = br.readLine();
		int sec = Integer.parseInt(secStr);
		int[] hms = {0,0,0};
		for( int i = 0; i < 3 ; i++ ) {
			hms[i] = sec % 60;
			sec = sec / 60;
		}
		System.out.println(hms[2] + ":" + hms[1] + ":" + hms[0]);
	}
}

Measured memory_bytes: 24184
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define N 200050
#define Mo 1000000007
int n, a[N];
LL f[N];
unordered_map<int, LL> m;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int tot = 1;
    for(int i = 2; i <= n; i++)
        if (a[i] != a[i - 1]) a[++tot] = a[i];
    f[0] = 1;
    for(int i = 1; i <= tot; i++) {
        f[i] = (f[i - 1] + m[a[i]]) % Mo;
        m[a[i]] = f[i];
    } 
    cout << f[tot] << endl;
}

Measured memory_bytes: 10824
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    string s, t;
    cin >> N >> s >> t;
    rep(i, s.size()) {
        string tmps = s.substr(i, N-i);
        string tmpt = t.substr(0, N-i);
        if (tmps == tmpt) {
            print(N+i);
            return 0;
        }
    }
    print(N*2);
    return 0;
}


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

template <int mod = (int)(998244353)>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

long long n, lim = 1000000;
vector<long long> a(lim + 1, 0);
vector<ModInt<>> sum(lim + 1, 0);

ModInt<> solve();

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    ++a[x];
  }
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res = 0;
  for (long long i = lim; i >= 1; --i) {
    ModInt<> now = 0, tmp = 0;
    for (long long p = 1; p * i <= lim; ++p) {
      ModInt<> num = p * a[p * i];
      now += tmp * num;
      tmp += num;
      now += num * p * (a[p * i] - 1) / 2;
      sum[i] -= sum[p * i];
    }
    sum[i] += now * (i * i);
    res += sum[i] / i;
  }
  return res;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  for(int i=0; i<n.size(); i++) {
    if(n.at(i) == '1') n.at(i) ='9';
    else if(n.at(i) =='9') n.at(i) ='1';
  }
  
  cout << n.at(0) << n.at(1) << n.at(2) << endl;
}

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

int main()
{
        ll X, A, B;
        cin >> X >> A >> B;

        if (A >= B) {
                cout << "delicious" << endl;
        }
        else if (B -A > X) {
                cout << "dangerous" << endl;
        }
        else {
                cout << "safe" << endl;
        }


}


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

#define MAXN 10
#define INF 0x3f3f3f3f
int D,G;
int P[MAXN+5],C[MAXN+5];

int main(){
    scanf("%d%d",&D,&G);
    for(int i=1;i<=D;i++)
        scanf("%d%d",&P[i],&C[i]);
    int Max=(1<<D)-1,Ans=INF;
    for(int i=0;i<=Max;i++){
        int cnt=0,rest=G;
        for(int j=D;j>=1&&rest>0;j--)//从大到小
            if(i&(1<<(j-1))){
                int tmp=P[j]*j*100;
                if(tmp>=rest){//足够
                    cnt+=(rest+100*j-1)/(100*j);
                    rest=0;
                    break;
                }
                else{//不够
                    rest-=tmp+C[j];
                    cnt+=P[j];
                }
            }
        if(rest<=0)//分足够
            Ans=min(Ans,cnt);
    }
    printf("%d",Ans);
}

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

int main() {
  long long n;
  cin >> n;
  
  long long rn = sqrt(n);
  long long tmp;
  long long d[rn] = {0};
  vector<long long> so;//素数を格納
  vector<vector<long long >> l;//素因数を格納（1要素目が基数、２要素目が乗数
  
  //素数列挙　要素が０ならば、そのインデックスの数値は素数。
  for(long long i = 2;i<rn;i++){
    //cout <<  i << " " << d[i] << endl;
    if(d[i] == 0){
      so.push_back(i);
      tmp = i;
      //cout << i << endl;
      for(long long j = 2;j*tmp < rn;j++){
        tmp = tmp*j;
        d[tmp] = -1;     
      }
    }
  }

  tmp = n;
  //素因数分解
  //cout << so.size() << endl;
  for(long long i = 0;i< so.size();i++){
    int c = 0;
    while(tmp%so[i] == 0){
      //cout << tmp << " " << so[i] << endl;
      tmp /= so[i];
      c++;
    }
    if(c > 0){
      l.push_back({so[i],c});
    }
  }
  
  if(tmp > 1){
    l.push_back({tmp,1});
  }
  
  //nが素数だった場合
  if(l.size() == 0 && n != 1){
    l.push_back({n,1});
  }
  
  long long count=0;
  //cout << l.size() << endl;
  for(int i = 0;i < l.size();i++){
    int j = 1;
    tmp = l[i][1];
    //cout << l[i][0] << " " << l[i][1] << endl;
    while(tmp >=j){
      tmp -= j;
      j++;
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 19532
#include<bits/stdc++.h>
using namespace std;
const int N=65;
long long n;
int m,vi[N],a[205];
int main(){
	scanf("%lld",&n);
	for(;(1LL<<m)-1<=n;m++);

	--m;
	int cnt=m;
	n-=(1LL<<m)-1;
	for(int i=m;~i;i--)
		if(n>>i&1)	vi[i]=1,++cnt;

	int x=cnt;
	printf("%d\n",cnt*2);
	if(vi[0])	printf("%d ",cnt--); 
	for(int i=1;i<=m;i++){
		printf("%d ",i);
		if(vi[i])	printf("%d ",cnt--);
	}
	for(int i=1;i<=x;i++)	printf("%d ",i);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int N, K;
int arr[505];
int rem[505];
int psa[505];
vector <int> factors;

void findFactors(int tot){
    int p = (int) sqrt(tot)+1;
    for (int i=1; i<=p; i++) {
        if (tot % i == 0) {
            factors.push_back(i);
            factors.push_back(tot/i);
        }
    }
    sort(factors.begin(), factors.end(), greater<>());
}

int main() {
    cin >> N >> K;
    int tot = 0;
    for (int i=1; i<=N; i++){
        scanf("%d", &arr[i]);
        tot += arr[i];
    }
    findFactors(tot);
    int ans;
    for (int f: factors){
        int idx = 1;
        for (int i=1; i<=N; i++){
            if (arr[i] % f != 0) {
                rem[idx] = arr[i] % f;
                idx++;
            }
        }
        idx--;
        memset(psa, 0, sizeof(psa));
        sort(rem+1, rem+idx+1);
        for (int i=1; i<=idx; i++) psa[i] = psa[i-1]+rem[i];
        int best = INT_MAX;
        for (int i=1; i<idx; i++){
            if (psa[i]-psa[0] == (idx-i)*f-(psa[idx]-psa[i])) best = psa[i]-psa[0];
        }
        if (best <= K) {
            ans = f;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int DP[N][5], LST[11];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 1; i <= n; i++) {
		DP[i][1] = 1;
		for (int j = 0; j < 10; j++) DP[i][2] += DP[LST[j]][1];
		for (int j = 0; j < 10; j++) DP[i][3] += DP[LST[j]][2];
		LST[s[i - 1] - '0'] = i;
	}
	int ans = 0;
	for (int i = 0; i < 10; i++) ans += DP[LST[i]][3];
	cout << ans << endl;

	return 0;
}


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

#define int long long

int N;
string S;

pair<int, int> Solve()
{
	for (int i = 0; i < N - 1; i++)
	{
		if (S[i] == S[i + 1]) return pair<int, int>(i + 1, i + 2);
	}
	for (int i = 0; i < N - 2; i++)
	{
		if (S[i] == S[i + 2]) return pair<int, int>(i + 1, i + 3);
	}
	return pair<int, int>(-1, -1);
}

signed main()
{
	cin >> S;
	N = S.size();
	pair<int, int> ret = Solve();
	printf("%lld %lld\n", ret.first, ret.second);
	return 0;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/abc073/tasks/abc073_d


#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second > b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)
#define BIGNUM (ll(1e18))

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M, R;
    cin >> N >> M >> R;
    
    vector<ll> r(R);
    REP(i, R) {
        cin >> r[i];
        r[i]--;
    }
    
    vector<vector<ll>> d(N, vector<ll>(N, BIGNUM));
    REP(i, M) {
        ll A, B, C;
        cin >> A >> B >> C;
        d[A-1][B-1] = C;
        d[B-1][A-1] = C;
    }
    
    for (int k = 0; k < N; k++){
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    
    sort(ALL(r));
    ll miny = BIGNUM;
    do {
        ll y = 0;
        SREP(i, 1, R) {
            y += d[r[i-1]][r[i]];
        }
        miny = min(miny, y);
    } while (next_permutation(ALL(r)));
    
    cout << miny << endl;
}


Measured memory_bytes: 640
#include <iostream>
#define N 10000
#define M 10000
#define sqrtM 32

using namespace std;

bool is_prime[M+1];
int input[N];
int n;

void load(void) {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> input[i];
	}
}

int main(void) {
	// make primes
	for(int i = 2; i <= M; ++i) {
		is_prime[i] = true;
	}

	for(int i = 2; i <= sqrtM; ++i) {
		if(!is_prime[i]) continue;
		for(int j = 2*i; j <= M; j += i) {
			is_prime[j] = false;
		}
	}

	load();
	int cnt = 0;

	for(int i = 0; i < n; ++i) {
		bool flag_prime = true;
		int x = input[i];
		for(int j = 2; j <= M; ++j) {
			if(!is_prime[j]) continue;
			if(x != j && x % j == 0) {
				flag_prime = false;
				break;
			}
		}
		if(flag_prime) ++cnt;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[200005], b[200005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;


int main() {
	int n;
	cin >> n;
	vector<P>v(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		v[i] = make_pair(b[i], a[i]);
	}
	sort(v.begin(), v.end());
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += v[i].second;
		if (sum > v[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;

}

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N,K,M;
    while(cin>>N>>K>>M,N|K|M){
        M--;
        //if(N==2){cout<<((M^1)+1)<<endl;continue;}
        vector<bool> A(N);
        vector<int> nx(N);
        rep(i,N)nx[i]=(i+1)%N;
        A[M]=1;
        nx[(M-1+N)%N]=(M+1)%N;
        int ct=N-1,last=(M-1+N)%N;
        while(ct-->1){
            int c=0;int k=M;
            while(c!=K){
                if(!A[k]){
                    c++;
                    if(c==K){ A[k]=1; M=k;nx[last]=nx[k];break;}
                    else last=k;
                }
                k=nx[k];
            }
        }
        rep(i,N)if(!A[i]){cout<<i+1<<endl;break;}
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3232
sets = readlines
sets.each{|line|
    h,w = line.split.map(&:to_i)
    
    break if (h == 0) && (w == 0)
    
    h.times{|n|
        w.times{|m|
            if m == 0 || m % 2 == 0
                print '#' if n == 0 || n % 2 == 0
                print '.' unless n == 0 || n % 2 == 0
            else
                print '.'  if n == 0 || n % 2 == 0
                print '#'  unless n == 0 || n % 2 == 0
            end
        }
        puts #new line
    }
    puts #new line
}


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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b < 2 * c) {
        cout << x * a + y * b << endl;
    } else {
        ll k = min(x, y), l = max(x, y);
        x -= k;
        y -= k;
        ll A =  2 * k*c + a*x + b*y;
        ll B = 2*l*c;
        cout << min(A, B) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let x: usize = read();
    let mut a: Vec<usize> = vec![0; n + 1];

    for _ in 0..m {
        let ai: usize = read();
        a[ai] = 1;
    }

    let mut ans = 0;
    let mut ans2 = 0;

    for i in 0..x {
        ans += a[i];
    }

    for i in x..n + 1 {
        ans2 += a[i];
    }

    println!("{}", min(ans, ans2))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int X, Y;
  cin >> X >> Y;

  int ret = 0;
  if(X == 1) ret += 300000;
  else if(X == 2) ret += 200000;
  else if(X == 3) ret += 100000;
  if(Y == 1) ret += 300000;
  else if(Y == 2) ret += 200000;
  else if(Y == 3) ret += 100000;

  if(X == 1 && Y == 1) ret += 400000;

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 998244353
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(a + b, min(b + c, a + c)) << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int H=1,W=1,i,j;

	scanf("%d %d", &H, &W);
	while(H!=0||W!=0){
		

		for (i = 0; i < H;i++) {
			for (j = 0; j < W; j++) printf("#");

			printf("\n");
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}

	return 0;
}


Measured memory_bytes: 2112
function junretsu(balls, nukitorisu){
  var arrs, i, j, zensu, results, parts;
  arrs = [];
  zensu = balls.length;
  if(zensu < nukitorisu){
    return;
  }else if(nukitorisu == 1){
    for(i = 0; i < zensu; i ++){
      arrs[i] = [balls[i]];
    }
  }else{
    for(i = 0; i < zensu; i ++){
      parts = balls.slice(0);
      parts.splice(i, 1)[0];
      results = junretsu(parts, nukitorisu - 1);
      for(j = 0; j < results.length; j ++){
        arrs.push([balls[i]].concat(results[j]));
      }
    }
  }
  return arrs;
}

function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}

function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
    var S = arg.split("\n").slice(1, N+1);

    var tmp = new Array(100);
    tmp.fill(0);

    for (var i = 0; i < N; i++){
        var x1 = S[i].split(" ")[0] - 0;
        var y1 = S[i].split(" ")[1] - 0;
        for (var j = 0; j < N; j++){
            var x2 = S[j].split(" ")[0] - 0;
            var y2 = S[j].split(" ")[1] - 0;

            tmp[i * N + j] = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
        }
    }

    var a = new Array(N);
    for (var i = 0; i < N; i++) a[i] = i;

    var retu = junretsu(a, N);

    var ans = 0;
    for (var i = 0; i < retu.length; i++){
        for (var j = 0; j < N - 1; j++){
            var s = retu[i][j];
            var t = retu[i][j+1];
            ans += tmp[s * N + t];    
        }
    }

    console.log(ans/factorialize(N));

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 59396
#include <iostream>
using namespace	std;
int main(){

  int a[11]={},t;
  for(int i=0;i<3;i++){
    cin>>t;
    a[t]++;
  }
  if(a[5]==2&&a[7]==1) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input","r",stdin)
#define write freopen("output","w",stdout)
#define fr first
#define sc second
#define ii pair < int , int >
using namespace std;
int main()
{
    int n,x;
    cin>>n>>x;
    if(x !=1 && x != n*2-1)
    {
        cout<<"Yes\n";
        if(n == x)
        {
            for(int i=1;i<=n*2-1;i++)
                cout<<i<<endl;
        }
        else if(x < n)
        {
           int R = n-x-1;
           for(int i=n*2-1-R;i<=n*2-1;i++)
                cout<<i<<endl;
           for(int i=1;i<n*2-1-R;i++)
            cout<<i<<endl;
        }
        else if(x > n)
        {
            int R = x-n+1;
            for(int i=R;i<=n*2-1;i++)
                cout<<i<<endl;
            for(int i=1;i<R;i++)
                cout<<i<<endl;
        }
    }
    else
    {
      cout<<"No";
    }
}


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

int main()
{
  string S,T;
  int size_S,count=0;
  cin>>S>>T;
  size_S=S.size();
  for(int i=0;i<size_S;i++)
  {
    if(S[i]==T[i])
      count++;
  }
  if(count==size_S)
    cout<<"Yes";
  else
    cout<<"No";
    
}

Measured memory_bytes: 3000
N=int(input())
P=list(map(int,input().split()))
T=list(map(int,input().split()))

DP=[float("inf")]*(N+1+max(T))
DP[0]=0

for i in range(N+1+max(T)):
    for k in range(4):
        if i-T[k]>=0:
            DP[i]=min(DP[i],DP[i-T[k]]+P[k])

print(min(DP[N:]))



Measured memory_bytes: 5616
a,b = map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

primef_a = factorization(a)
primef_b = factorization(b)

primef_a = [i[0] for i in primef_a]
primef_b = [i[0] for i in primef_b]

common_prime = []

for i in primef_a:
    if i != 1:
        if i in primef_b:
            common_prime.append(i)

print(len(common_prime)+1)

Measured memory_bytes: 38512
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    const int sum_a = accumulate(a.begin(), a.end(), 0LL);
    if (x == sum_a) {
        cout << n << endl;
    } else if (x > sum_a) {
        cout << n - 1 << endl;
    } else {
        for (int i = 0; i < n; i++) {
            if (x >= a[i]) {
                x -= a[i];
            } else {
                cout << i << endl;
                break;
            }
        }
    }
}

// aが小さい子からちょうどお菓子を配るのが最適


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

using namespace std;

int main(){
    int a, b;
    string result;

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int M,N,i,j,k,l,nc,nr,S,t,c,mv[5]={0,1,0,-1,0};
char C[505][505],*p[4];

int main()
{
	scanf("%d%d\n",&M,&N);
	for(i=1;i<=M;i++)gets(C[i]+1);
	for(S=0;;)
	{
		for(i=1,c=0;i<=M;i++)
			for(j=1;j<=N;j++)
				if(C[i][j]=='.')
				{
					for(k=0;k<4;k++)
					{
						for(nc=i,nr=j;C[nc][nr]=='.';nc+=mv[k],nr+=mv[k+1]);
						p[k]=&C[nc][nr];
					}
					for(k=0;k<4;k++)
					{
						for(l=k+1,t=0;l<4;l++)
							if(*p[k]&&*p[k]!='.'&&(*p[k]==*p[l]))
							{
								t++;*p[l]='.';
							}
						if(t)
						{
							c=1;
							S+=t+1;*p[k]='.';
						}
					}
				}
		if(c==0)break;
	}
	printf("%d\n",S);
	return 0;
}

Measured memory_bytes: 848
import sys
sys.setrecursionlimit(10**9)
N = int(input())
adjacent_list = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int,input().split())
    u -= 1
    v -= 1
    adjacent_list[u].append([v, w])
    adjacent_list[v].append([u, w])


colors = [-1]*N


def dfs(v, color):
    if colors[v] != -1: # 探索済みでないかチェック。
        return
    colors[v] = color
    for adjacent_v in adjacent_list[v]:
        if adjacent_v[1] % 2 == 0:
            dfs(adjacent_v[0], color)
        else:
            dfs(adjacent_v[0], 1-color)

dfs(0,0)

#print(*colors)
for i in range(N):
    print(colors[i])


Measured memory_bytes: 85212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  char a, b;
  int res=0;
  char A[10],B[10];
  cin >> a >> b;

  rep(i, b-'0'){
    A[i]=a;
  }
  A[b-'0'] = '\0';

  rep(i, a-'0'){
    B[i]=b;
  }
  B[a-'0'] = '\0';

  string sa=A;
  string sb=B;

  if(sa>=sb) cout << B << endl;
  else cout << A << endl;

}

Measured memory_bytes: 256