akhauriyash/Code-Regression huggingface dataset:
use std::collections::HashSet;

use whiteread::Reader;

fn main() {
    let mut rdr = Reader::from_stdin_naive();
    let (n, m): (usize, usize) = rdr.p();
    let mut ps: Vec<usize> = (0..n).collect();
    for _ in 0..m {
        let (a, b): (usize, usize) = rdr.p();
        let mut pa = a - 1;
        while pa != ps[pa] {
            pa = ps[pa];
        }
        let mut pb = b - 1;
        while pb != ps[pb] {
            pb = ps[pb];
        }
        if pa < pb {
            ps[pb] = pa;
        }
        if pb < pa {
            ps[pa] = pb;
        }
    }
    let mut h = HashSet::new();
    for p in ps.iter() {
        let mut p = *p;
        while p != ps[p] {
            p = ps[p];
        }
        h.insert(p);
    }
    //println!("{:?}", ps);
    println!("{}", h.len() - 1);
}


Measured memory_bytes: 4528
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	final int mod = (int)1E8+7;
	
	int mod_pow(long x, int n) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) res = (res * x) % mod;
			x = (x * x) % mod;
			n >>= 1;
		}
		return (int)res;
	}
	
	//階乗
	int mod_fact(int n) {
		long res = 1;
		for (int i = 2; i <= n; i++)
			res = (res*i) % mod;
		return (int)res;
	}
	
	//nCk mod p
	int mod_comb(int n, int k) {
		if (n < 0 || k < 0 || n < k) return 0;
		long res = mod_fact(n);
		res = (res*mod_pow(mod_fact(k), mod-2)) % mod;
		res = (res*mod_pow(mod_fact(n-k), mod-2)) % mod;
		return (int)res;
	}
	
	void run() {
		int r = sc.nextInt(), c = sc.nextInt(), a1 = sc.nextInt(), a2 = sc.nextInt(), b1 = sc.nextInt(), b2 = sc.nextInt();
		int n, k, count = 1;
		n = min(abs(a1-b1), r-abs(a1-b1));
		k = min(abs(a2-b2), c-abs(a2-b2));
		
		if (abs(a1-b1) == r-abs(a1-b1)) count *= 2;
		if (abs(a2-b2) == c-abs(a2-b2)) count *= 2;
		
		out.println((mod_comb(n+k, k)*count)%mod);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17364
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;
const int N = 10 ;
vector<vector<int> > graph ;
vector<bool> vis ;
int n , m ;
int dfs(int x){
    bool flag = true;
    for(int i = 1; i <= n; i++){
        if ( !vis[i] ) flag = false;
    }
    if ( flag ) return 1;
    int ans = 0 ; 
    for(int &c : graph[x]){
        if ( !vis[c] ){
            vis[c] = true ;
            ans += dfs(c) ;
            vis[c] = false;
        }
    }
    return ans ; 
}
int main(){
    cin >> n >> m ;
    graph.resize(n + 1);
    vis.resize(n + 1);
    for(int i = 0; i < m; i++){
        int x , y ;
        cin >> x >> y ;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    vis[1] = true ;
    cout << dfs(1) << endl;
    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//データの読み込みの準備
		Scanner sc = new Scanner(System.in);
		
		while(true){
			//結果格納用変数
			int counter = 0;
			
			//データの読み込み
			int n = sc.nextInt();
			int x = sc.nextInt();	
			
			//終了条件の判定
			if(n == 0 && x == 0){
				break;
			}
			
			for(int i = n; i >= 3; i--){
				for(int j = i - 1; j >= 2; j--){
					//iとjを確定とした時に、残りの値を決定する
					int remainder = x - i - j;
					
					//remainderが初期条件を満たしているかで、条件分岐
					if (remainder <= 0){
						continue;
					}else if (remainder >= j){
						break;
					}else{
						counter++;
					}
				}
			}
			
			System.out.println(counter);
		}
	}
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N;
    cin>>N;
    
    vector<long> a(N+1);
    for(int i=1;i<=N;i++) cin>>a.at(i);
    //cout<<a.at(3)<<endl;
    vector<long> b(N+1,0);
    long M=0;
    
    for(int n=N;n>=1;n--){
        long bit=a.at(n);
        for(int i=1;i*n<=N;i++){
            bit+=b.at(i*n);
        }
        //cout<<n<<" "<<bit<<endl;
        b.at(n)=(bit%2);
        M+=b.at(n);
    }
    
    cout<<M<<endl;
    for(int i=1;i<=N;i++){
        if(b.at(i)==1) cout<<i<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll k, q;
	cin >> k >> q;
	ll d[k], n[q], x[q], m[q];
	zep(j, 0, k){cin >> d[j];}
	zep(i, 0, q){cin >> n[i] >> x[i] >> m[i]; x[i] %= m[i];}
	
	zep(i, 0, q){
		ll dm[k];
		zep(j, 0, k){dm[j] = d[j]%m[i];}
		ll z[k];
		zep(j, 0, k){
			z[j] = (dm[j] == 0)? 1 : 0;
		}
		zep(j, 1, k){
			dm[j] += dm[j-1];
			z[j] += z[j-1];
		}
		
		ll sm = x[i]+((n[i]-1)/k)*dm[k-1];
		if((n[i]-1)%k > 0){sm += dm[(n[i]-1)%k-1];}
		ll ans = n[i]-1-sm/m[i]-((n[i]-1)/k)*z[k-1];
		if((n[i]-1)%k > 0){ans -= z[(n[i]-1)%k-1];}
		print(ans)
	}
	
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        if (n<k) {
            System.out.println(n*x);
        } else {
            System.out.println((k*x) + (n-k)*y);
        }
    }
}


Measured memory_bytes: 21844
package main

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

func main() {
	scanInit()

	n := nextInt()
	p := make([]pair, n)

	for i := 0; i < n; i++ {
		x := nextInt()
		l := nextInt()
		p[i] = pair{x + l, x - l, x, l}
	}

	sortPairs(p)

	cnt := 1
	last := p[0].f
	for i := 1; i < n; i++ {
		// startがlastよりも未満だったらスルー
		if p[i].s < last {
			continue
		}

		last = p[i].f
		cnt++
	}

	fmt.Println(cnt)

}

// Pair ソート
// s := make([]pair, n)
// sortPairs(s)
type pair struct { // f=first, s=second
	f int
	s int
	x int
	l int
}

// []pair をf->sの順でソートする
func sortPairs(s []pair) {
	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f { // fが同じ場合はsを比較する
			return s[i].s < s[j].s
		}
		return s[i].f < s[j].f
	})
	return
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 7816
import collections
n,k = map(int,input().split())
line = list(map(int,input().split()))
num = len(set(line))
nums = collections.Counter(line)
snums = sorted(nums.values())
if num <= k:
  print(0)
else:
  require = num - k
  answer = 0
  for j in range(require):
    answer += snums[j]
  print(answer)

Measured memory_bytes: 37144
S=input()
if S=="RRR":print(3)
elif S[0]=='R' and S[1]=='R':print(2)
elif S[1]=='R' and S[2]=='R':print(2)
elif S[0]=='R' or S[1]=='R' or S[2]=='R':print(1)
else:print(0)

Measured memory_bytes: 61640
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
L = l()
L.sort(reverse=True)
print(sum(L[:K]))

Measured memory_bytes: 10068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int K = GetInt();
		int A = GetInt();
		int B = GetInt();
		for(int i = A; i <= B; i++)
		{
			if(i % K == 0)
			{
				WriteLine("OK");
				return;
			}
		}
		WriteLine("NG");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 27388
#include<stdio.h>

int cek_panjang (int angka){
	int v1=1000000000;
	int a=0;
	for(int i=0; i<10; i++){
		if(angka/v1!=0){
			a=10-i;
			break;
		}
		v1/=10;
	}
	return a;
}

int fx(int angka, int banyak){
	int v1=1000000000;
	int total=0,temp;
	for(int i=0;i<10-banyak; i++){
		v1/=10;
	}
	
	for(int i=0; i<banyak; i++){
		total+=(angka/v1);
		angka=angka%v1;
		v1/=10;
	}
	
	return total;
}

int main(){
	int loop,angka;
//	scanf("%d", &loop);

	scanf("%d", &angka);
	int a=cek_panjang(angka);
	int total=fx(angka,a);
	
	printf("%s\n", angka%total==0?"Yes":"No");
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(unsigned short A[], unsigned short B[]);

int n;
int C[VMAX+1];

int main(){
  unsigned short *A, *B;
  int i;

  scanf("%d",&n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for(i = 0; i < n; i++) scanf("%hu",&A[i + 1]);

  CountingSort(A, B);

  for(i = 1; i <= n; i++){
    if(i > 1) printf(" ");
    printf("%u",B[i]);
  }
  printf("\n");

  free(A);
  free(B);
  
  return 0;
}

void CountingSort(unsigned short A[], unsigned short B[]){
  int i, j;

  for(i = 0; i <= VMAX; i++) C[i] = 0;

  for(j = 0; j < n; j++) C[A[j + 1]]++;

  for(i = 1; i <= VMAX; i++) C[i] += C[i-1];

  for(j = 1; j <= n; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 9132
#include<queue>
#include<cstdio>

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

using namespace std;

struct Info{
	int t,load;
	Info(int T,int L):t(T),load(L){}
	bool operator>(const Info &in)const{
		if(t==in.t)	return load>in.load;
		return t>in.t;
	}
};

int main(){
	for(int n;scanf("%d",&n),n;){
		priority_queue< Info,vector<Info>,greater<Info> > pq;
		rep(i,n){
			int m,a,b;	scanf("%d%d%d",&m,&a,&b);
			pq.push(Info(a,m));
			pq.push(Info(b,-m));
		}

		int total=0;
		bool ok=true;
		while(!pq.empty()){
			Info a=pq.top();	pq.pop();
			total+=a.load;
			if(total>150){ ok=false; break; }
		}

		puts(ok?"OK":"NG");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   map<int,int> cnt;
           rep(i,0,3){
            int a,b;
             cin>>a>>b;
             cnt[a]++;
             cnt[b]++;
           }
           int p=0,q=0;
           for(auto v:cnt){
				if(v.second==1)p++;
                if(v.second==2)q++;
           }
           YES(p==2&&q==2);
}

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

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

int a[110];
int b[110];

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

    rep(i, n - 1){
        cin >> b[i];
    }

    a[0] = b[0];
    for(int i = 1; i < n - 1; ++i){
        a[i] = std::min(b[i - 1], b[i]);
    }
    a[n - 1] = b[n - 2];

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

    cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int ans = 0;
	string S,maeS,t;
	cin >> S;
	for (int i = 0; i < S.size(); i++)
	{
		t.push_back(S[i]);
		if (i != 0&& maeS == t) {
			i++;
			if(i!=S.size())t.push_back(S[i]);
			if (i == S.size()) {
				ans--;
			}
		}
		maeS = t;
		t = "";
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 640
// AOJ 2206: Compile
// 2017.11.10 bal4u@uu

#include <stdio.h>
#include <string.h>

char m[12][7], t[12][7];

int same(char a, int r, int c)
{
	int dr, dc;
	int ans = 1;

	for (dc = -1; dc <= 1; dc++) for (dr = -1; dr <= 1; dr++) {
		if (dr == dc || dr && dc) continue;
		if (c + dc < 0 || c + dc >= 6 || r + dr < 0 || r + dr >= 12) continue;
		if (t[r+dr][c+dc] == a) {
			t[r+dr][c+dc] = 'x';
			ans += same(a, r+dr, c+dc);
		} else if (t[r+dr][c+dc] == 'O') t[r+dr][c+dc] = 'x';
	}
	return ans;
}

int main()
{
	int cno, r, c, f, ans;
	char a;

	scanf("%d", &cno);
	while (cno--) {
		for (r = 0; r < 12; r++)  scanf("%s", m[r]);

		ans = 0, f = 1;
		while (f) {
			f = 0;
			for (c = 0; c < 6; c++) for (r = 11; r >= 0; r--) {
				memcpy(t, m, sizeof(m));
				a = m[r][c];
				if (a == 'O' || a == '.' || a == 'x') continue;
				t[r][c] = 'x';
				if (same(a, r, c) >= 4) {
					memcpy(m, t, sizeof(m));
					f = 1;
				}
			}

			if (f) {
				ans++;
				for (c = 0; c < 6; c++) {
					for (r = 11; r >= 0; r--) {
						int rr;
						if (m[r][c] != 'x') continue;
						rr = r-1;
						while (rr >= 0 && m[rr][c] == 'x') rr--;
						if (rr < 0) m[r][c] = '.';
						else m[r][c] = m[rr][c], m[rr][c] = 'x';
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1804
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0 ; i < N ; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int ans = 0; int cnt = 0;
		for(int i = 0 ; i < N ; i++) {
			if(i == 0) {
				ans++;
			} else if(i != 0 && A[i] == A[i - 1]) {
				cnt++;
				if(cnt % 2 == 1) {
					ans -= 1;
				} else {
					ans++;
				}
			} else {
				ans++;
				cnt = 0;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50548
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    vector<vector<int>> ret(h,vector<int>(w));
    for(int i=0;i<b;++i)for(int j=0;j<a;++j)ret[i][j] = 1;
    for(int i=b;i<h;++i)for(int j=a;j<w;++j)ret[i][j] = 1;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cout << ret[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 5248
# 再帰上限あげとく
import sys
sys.setrecursionlimit(10**6)

# 値入力
mod = 7+10**9
N,M = map(int, input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())

# メモ化フィボナッチ
# 参考:http://python-remrin.hatenadiary.jp/entry/2017/05/19/153228
fib_memo = {}
def fib(n):
    if n < 3: return 1
    if n not in fib_memo:
        fib_memo[n] = fib(n-1) + fib(n-2)
    return fib_memo[n]

now = 0 # 今いる場所と考える
count = 1
for i in a:
    count *= fib(i-now)
    count = count%mod
    if now == i:
        print(0)
        quit()
    now = i+1 # 穴を超えた次の段に移動する

# 最上段までを計算
count *= fib(N-now+1)
print(count%mod)

Measured memory_bytes: 544352
judge n s
	| n `mod` 2 /= 0 = False
	| otherwise = judge' (n `div` 2) s

judge' n s = s1 == s2
	where
		s1 = take n s
		s2 = drop n s

main :: IO ()
main = do
	n <- readLn
	s <- take n <$> getLine
	putStrLn $ if judge n s then "Yes" else "No"


Measured memory_bytes: 508
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>

using namespace std;

using ii = pair<int, int>;

int main()
{
	string k;
	cin >> k;
	int a = k[0] - '0', b = k[1] - '0', c = k[2] - '0', d = k[3] - '0';

	for (int i = -1; i <= 1; i+= 2)
	{
		for (int j = -1; j <= 1; j+=2)
		{
			for (int k = -1; k <= 1; k += 2)
			{
				int f = a + i*b + j*c + k*d;

				if (f == 7)
				{
					printf("%d%c%d%c%d%c%d=7", a, i > 0 ? '+' : '-',
						b, j > 0 ? '+' : '-', c, k > 0 ? '+' : '-', d);
					return 0;
				}
			}
		}
	}
	return 0;	
}

Measured memory_bytes: 256
def roll(dice,dir)
  case dir
  when "N" then dice[0],dice[1],dice[5],dice[4] = dice[1],dice[5],dice[4],dice[0]
  when "S" then dice[0],dice[1],dice[5],dice[4] = dice[4],dice[0],dice[1],dice[5]
  when "E" then dice[0],dice[2],dice[5],dice[3] = dice[3],dice[0],dice[2],dice[5]
  when "W" then dice[0],dice[2],dice[5],dice[3] = dice[2],dice[5],dice[3],dice[0]
  end
  dice
end

d1 = gets.split(" ").map{|i| i.to_i}
d2 = gets.split(" ").map{|i| i.to_i}

yn = false    
for i in 1..6
  d = Marshal.load(Marshal.dump(d2))
  case i
  when 2 then d = roll(d,"S")
  when 3 then d = roll(roll(d,"W"),"S")
  when 4 then d = roll(d,"N")
  when 5 then d = roll(roll(d,"E"),"S")
  when 6 then d = roll(roll(d,"S"),"S")
  end
  next if d[1] != d1[1]
  next if d[4] != d1[4]
  for j in 1..4
    d = roll(d,"W")
    yn = (yn || d == d1)
  end
end

puts(yn ? "Yes" : "No")

Measured memory_bytes: 8728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();
        int[][] b = new int[H][W];
        for (int i = 0; i < b.length; i++) {
            String s = sc.next();
            for (int j = 0; j < b[i].length; j++) {
                if (s.charAt(j) == '.') {
                    b[i][j] = 0;
                } else {
                    b[i][j] = 1;
                }
            }
        }
        int counter = 0;
        for (int bit1 = 0; bit1 < (1<<H); bit1++) {
            int[][] copy = new int[H][W];
            for (int i = 0; i < copy.length; i++) {
                for (int j = 0; j < copy[i].length; j++) {
                    copy[i][j] = b[i][j];
                }
            }
            for (int i = 0; i < H; i++) {
                if ((bit1 & (1<<i)) != 0) {
                    for (int j = 0; j < copy[i].length; j++) {
                        copy[i][j] = -1;
                    }
                }
            }
            for (int bit2 = 0; bit2 < (1<<W); bit2++) {
                int[][] copy2 = new int[H][W];
                for (int i = 0; i < copy2.length; i++) {
                    for (int j = 0; j < copy2[i].length; j++) {
                        copy2[i][j] = copy[i][j];
                    }
                }
                for (int i = 0; i < W; i++) {
                    if ((bit2 & (1<<i)) != 0) {
                        for (int j = 0; j < copy2.length; j++) {
                            copy2[j][i] = -1;
                        }
                    }
                }
                int sum = 0;
                for (int i = 0; i < copy2.length; i++) {
                    for (int j = 0; j < copy2[i].length; j++) {
                        if (copy2[i][j] == 1) {
                            sum++;
                        }
                    }
                }
                if (sum == K) {
                    counter++;
                }
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 39492
from collections import defaultdict
import sys
N,M = map(int,input().split())
d = defaultdict(list)
for i in range(M):
    a,b = map(int,input().split())
    d[a].append(b)
for i in d[1]:
    if N in d[i]:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

Measured memory_bytes: 48144
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			R[] rs=new R[n];
			for(int j=0; j<n; j++){
				rs[j]=new R();
				rs[j].name=sc.next();
				for(int i=0; i<n-1; i++){
					switch(sc.nextInt()){
					case 0:
						rs[j].win--;
						break;
					case 1:
						rs[j].lose++;
						break;
					}
				}
			}
			Arrays.sort(rs);
			for(R r : rs){
				println(r.name);
			}
		}
	}

	class R implements Comparable<R>{
		int win, lose;
		String name;

		@Override
		public int compareTo(R r){
			if(win!=r.win){
				return win-r.win;
			}else{
				return lose-r.lose;
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
N = gets.to_i
l = gets.split.map(&:to_i)
$count = 0

# p l

def check(i,j,k)
  a = [i,j,k].sort
  $count += 1 if a[0] + a[1] > a[2] && a[1] - a[0] < a[2]
  # p [i,j,k] if a[0] + a[1] > a[2] && a[1] - a[0] < a[2]
end

for i in 0...N
  for j in (i+1)...N
    for k in (j+1)...N
      # p [i,j,k]
      check(l[i],l[j],l[k]) if l[i] != l[j] && l[i] != l[k] && l[j] != l[k]
    end
  end
end


puts $count


Measured memory_bytes: 14364
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Set<Integer> diameters = new HashSet<>();
			for (int i = 0; i < n; i++) {
				diameters.add(scanner.nextInt());
			}
			System.out.println(diameters.size());
		}
	}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  SORT(a);

  int ans = 0;
  rep(i, N - 1)
  {
    if (x >= a[i])
    {
      x -= a[i];
      ans++;
    }
  }
  if (x == a[N - 1])
    ans++;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;                       
typedef long long ll;
 int main()
 {  ll n,m,t,t1,t2,t3,t4;
     cin>>t;
     cin>>n>>m;
     t1=n/t;
     t3=n%t;
    if(t3==0)
    cout<<"OK"<<endl;
    else
    { t1++;
       if(t1*t<=m)
         cout<<"OK"<<endl;
		 else
		 cout<<"NG"<<endl; 
	}
}
     

Measured memory_bytes: 3648
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, n) for(int i = 0; i < n; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

LL E[3005*1005];
LL D[1005*1005];
LL cnt;
int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<LL> A(x), B(y), C(z);
    for(int i = 0; i < x; i++)
        cin >> A[i];
    for(int i = 0; i < y; i++)
        cin >> B[i];
    for(int i = 0; i < z; i++)
        cin >> C[i];
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    rep(i, x){
        rep(j, y)
            D[cnt++] = A[i]+B[j];
    }
    sort(D, D+cnt, greater<LL>());
    
    cnt = 0;
    rep(i, k){
        rep(j, z){
            E[cnt++] = D[i] + C[j];
        }
    }
    sort(E, E+cnt, greater<LL>());
    rep(i, k)
        cout << E[i] << "\n";
    return 0;
};

Measured memory_bytes: 31616
#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++)

int main(){
    int64_t A, B, N;
    cin >> A >> B >> N;
    int64_t a = N / B;
    int64_t b = B * a - 1;
    if(a == 0){
        b = N - 1;
    }
    if(N < B){
        b = N;
    }
    int64_t c = b / B;
    int64_t ans1 =  A * b / B - A * c;
    int64_t ans2 = 0;
    int64_t b2 = b - B;
    int64_t c2 = b2 / B;
    if(b2 > 0){
        ans2 = A * b2 / B - A * c2;
    }
    cout << max(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD =998244353;

     signed main(){
             cout << std::setprecision(15) ;
         int n,s;
         cin>>n>>s;
         int a[n];
         for(int i=0;i<n;i++)cin>>a[i];
         int dp[s+1][n];
         for(int i=0;i<=s;i++)dp[i][0]=0;
        if(a[0]<=s) dp[a[0]][0]=1;
        int ans=dp[s][0];
         for(int i=1;i<n;i++){
                 for(int j=0;j<=min(s,a[i]);j++)dp[j][i]=dp[j][i-1];
                 for(int j=a[i];j<=s;j++)dp[j][i]=(dp[j][i-1]+dp[j-a[i]][i-1])%MOD;

                
                 if(a[i]<=s)dp[a[i]][i]=(dp[a[i]][i]+i+1)%MOD;
                 ans=(ans+dp[s][i])%MOD;
         }
         
         cout<<ans;

         
}

        


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


void solve(std::string S){
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main()
{
	int h,w;
	while(cin >> h >> w){
		if(!h && !w)
			break;

		for(int i = 0;i<h;++i){
			for(int j=0;j<w;++j){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
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;}
int const INF = 1001001001;

struct UnionFind
{
    vector<int> par; //par[i]:= iの親の番号
    vector<int> siz; //siz[i]:= iの属する連結成分の大きさ
    UnionFind(int N) {
        par.resize(N);
        for(int i = 0; i < N; ++i) {
            par[i] = i;
        }
        siz.resize(N,1);
    }

    int root(int x){ // xが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        return root(x) == root(y);
    }

    bool unite (int x, int y) { // xとyの木を併合
        x = root(x); y = root(y);
        if (x == y) return false;
 
        if (siz[x] < siz[y]) swap(x, y); // merge technique 小を大にくっつける
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    int size(int x) { // xの属する木の大きさを得る
        return siz[root(x)];
    }
};

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

int n,k,l;
cin >> n >> k >> l;

UnionFind uf1(n),uf2(n);

rep(i,k) {
    int p,q;
    cin >> p >> q;
    --p; --q;
    uf1.unite(p,q);
}
rep(i,l) {
    int r,s;
    cin >> r >> s;
    --r; --s;
    uf2.unite(r,s);
}

map<pii, int> mp;
rep(i,n) {
    mp[pii(uf1.root(i), uf2.root(i))]++;
}

rep(i,n) {
    cout << mp[pii(uf1.root(i), uf2.root(i))] << " ";
}

return 0;
}

Measured memory_bytes: 15104
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var n = int.Parse(line[1]);
        var m = int.Parse(line[2]);
        var b =(int) Pow(m, 1d / n);
        var count = 0;
        for (int i = 1; i <= b; i++)
            if (getN(i, n) + a == i) count++;
        Console.WriteLine(count);
    }
    public static int getN (int a, int b)
    {
        var s = Pow(a, b).ToString();
        var res = 0;
        foreach (var x in s)
            res += int.Parse(x.ToString());
        return res;
    }
}




Measured memory_bytes: 16016
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int n, a[100000];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int l = -1, r = n-1;
    while (r - l > 1) {
        int m = (l + r) / 2, f = 1;
        ll c = a[m];
        for (int i = 0; i < n; i++) {
            if (i == m) continue;
            if (a[i] <= 2 * c)
                c += a[i];
            else f = 0;
        }
        if (f) r = m;
        else l = m;
    }
    cout << n-r << endl;
}

Measured memory_bytes: 640
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X, Y = lr()
dis = [[0] * (N+1) for _ in range(N+1)]
for i in range(1, N):
    for j in range(i+1, N+1):
        dis[i][j] = j - i
        dis[j][i] = j - i

dis[X][Y] = 1
dis[Y][X] = 1
for i in range(1, N):
    for j in range(i+1, N+1):
        dis[i][j] = min(dis[i][j], dis[i][X] + 1 + dis[Y][j])

answer = [0] * (N)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = dis[i][j]
        answer[d] += 1

print('\n'.join(map(str, answer[1:])))


Measured memory_bytes: 73948
N,M,K = map(int,input().split())
MOD = 998244353
if M==1:
    print(1 if K==N-1 else 0)
    exit()

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

cs = []
ms = [(M * pow(M-1, N-1-K, MOD)) % MOD]
for i in range(K+1):
    cs.append(comb(N-1, i))
    if i:
        ms.append((ms[-1] * (M-1)) % MOD)

ans = 0
for c,m in zip(cs, ms[::-1]):
    ans += c*m
print(ans%MOD)

Measured memory_bytes: 49964
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if((A+B)%2 == 0) {
			System.out.println((A+B)/2);
		}else {
			System.out.println("IMPOSSIBLE");
		}
	}

}


Measured memory_bytes: 22228
#include<iostream>

using namespace std;

int main(){

	int a;
	int b;
	int c;

	cin >> a;
	cin >> b;
	cin >> c;

	bool flag = false;

	if((a + b) == c){
		flag = true;
	}

	if((b + c) == a){
		flag = true;
	}

	if((c + a) == b){
		flag = true;
	}

	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
int main(){
//int n,a[100001]={0};
//cin>>n;
//cout<< <<endl;
int n;
int x,y;
int ans=0;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>x>>y;
	ans+=(y-x+1);
}
cout<<ans;
}


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

using namespace std;

int N, K;
vector<int> h;



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

	h = vector<int>(N);

	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}

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

	int less = 0;
	while (less < N && h.at(less) < K) {
		less++; 
	}

	int ans = N - less;
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll check(ll x, ll y, ll z){
  ll w=x*(x+y+z)+y*(y+z)+z*z;
  return w;
}

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

  ll n;
  cin>>n;

  map<ll,ll> ans;
  for(ll x=1; x*x<=n; x++){
    for(ll y=1; y*y<=n; y++){
      for(ll z=1; z*z<=n; z++){
        ll w=check(x,y,z);
        ans[w]+=1;
      }
    }
  }

  REP(i,n){
    cout<<ans[i+1]<<endl;
  }
}



Measured memory_bytes: 6068
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll a, b;
	cin >> a >> b;
	if (a < b) {
		for (i = 0; i < b; i++) {
			cout << a;
		}
	}
	else {
		for (i = 0; i < a; i++) {
			cout << b;
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var s, t string
  ans:=0
  fmt.Scan(&s, &t)
  for i:=0;i<len(s);i++{
    if s[i]!=t[i]{
      ans++
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 3384
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
// from https://www.geeksforgeeks.org/print-all-prime-factors-of-a-given-number/

vector<int> factorization[10000];
int reslcm[1000000];
vector<int> primes;

void prime_factors(int idx, int n)  
{  
    // Print the number of 2s that divide n  
  int temp = 0;
  while (n % 2 == 0)  
  {  
    temp++;
    n = n/2; 
    factorization[idx].push_back(2);
  }
  reslcm[2] = max(reslcm[2], temp);

  // n must be odd at this point. So we can skip  
  // one element (Note i = i +2)  
  for (int i = 3; i <= sqrt(n); i = i + 2)  
  {  
      // While i divides n, print i and divide n
    temp = 0;
    while (n % i == 0)  
    {  
      temp++;
      n = n/i;  
      factorization[idx].push_back(i);
      if(find(primes.begin(), primes.end(), i) == primes.end())
        primes.push_back(i);
    }
    reslcm[i] = max(temp, reslcm[i]);
  }  

  // This condition is to handle the case when n  
  // is a prime number greater than 2  
  if (n > 2)  
  {
    reslcm[n] = max(1, reslcm[n]);
    factorization[idx].push_back(n);
    if(find(primes.begin(), primes.end(), n) == primes.end())
      primes.push_back(n);
  }
}

int a[10000];

int main()
{
  int n;
  scanf("%d", &n);
  
  primes.push_back(2);

  for(int i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
    prime_factors(i, a[i]);
  }
  
  sort(primes.begin(), primes.end());

  ll res = 0;
  for(int i = 0; i < n; i++)
  {
    ll temp_lcm = 1;
    for(int j = 0; j < primes.size(); j++)
    {
      int temp_prime = reslcm[primes[j]];
      for(auto it = factorization[i].begin(); it != factorization[i].end();)
      {
        if(*it == primes[j])
        {
          it = factorization[i].erase(it);
          temp_prime--;
        }
        else
          break;
      }
      
      temp_lcm *= (ll)pow(primes[j], temp_prime) % mod;
      temp_lcm %= mod;
    }
    
    //printf("%lldaa\n", temp_lcm);
    res += temp_lcm % mod;
    res %= mod;
  }

  printf("%lld\n", res);
  return 0;
}

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

int main(){
  ll H,W,K;cin >> H >> W >> K;
  if(W==1){
    cout << 1 << endl;
    return 0;
  }
  K -= 1;
  vector<vector<ll>> M(H+1,vector<ll>(W,0));
  M[0][0] = 1;
  vector<ll> F(10,1);
  for(int f=2;f<10;f++){
    F[f] = F[f-1] + F[f-2];
  }
  for(int i=1;i<=H;i++){
    for(int j=0;j<W;j++){
      if(j==0){
        M[i][j] = (M[i][j] + M[i-1][j] * F[W-1]) % MOD;
        M[i][j] = (M[i][j] + M[i-1][j+1] * F[W-2]) % MOD;
      }else if(j==W-1){
        M[i][j] = (M[i][j] + M[i-1][j] * F[W-1]) % MOD;
        M[i][j] = (M[i][j] + M[i-1][j-1] * F[W-2]) % MOD;
      }else{
        M[i][j] = (M[i][j] + M[i-1][j-1] * F[j-1] % MOD * F[W-1-j]) % MOD;
        M[i][j] = (M[i][j] + M[i-1][j] * F[j] % MOD * F[W-1-j]) % MOD;
        M[i][j] = (M[i][j] + M[i-1][j+1] * F[j] % MOD * F[W-2-j]) % MOD;
      }
    }
  }
  cout << M[H][K] << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << (a < b ? 0 : 10) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
// #define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  unordered_map<ll, ll> mp;
  mp[A[0]]++; mp[0]++;
  for(int i = 1; i < N; i++){
    A[i] += A[i - 1];
    mp[A[i]]++;
  }

  ll ans = 0;
  for(auto itr : mp){
    ans += itr.second * (itr.second - 1) / 2;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10056
# A - Shik and Stone
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from collections import deque
def bfs(sy,sx):
    q = deque([[sy,sx]])
    visited[sy][sx]=0
    while q:
        y,x = q.popleft()
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            ny,nx = y+j,x+k
            if ny<0 or ny>h-1 or nx<0 or nx>w-1 or a[ny][nx]==".":
                continue
            if a[ny][nx]=="#" and visited[ny][nx]==-1:
                visited[ny][nx]=visited[y][x]+1
                q.append([ny,nx])
    ret=-1
    for i in range(h):
        for j in range(w):
            ret=max(visited[i][j],ret)
    return ret
h,w=nm()
a=[input() for i in range(h)]
visited = [[-1]*w for i in range(h)]
dist=0
dist=bfs(0,0)
cnt=0
for aa in a:
    cnt+=aa.count('#')
if dist==h+w-2 and dist==cnt-1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;

	if (N == 3) {
		cout << "2 3 25" << endl;
	}
	else {
		if (N == 4) cout << "2 3 9 10";
		else if (N == 5) cout << "2 3 6 9 10";
		else if (N == 6) cout << "2 3 4 8 9 10";
		else {
			cout << "2 3 4 8 9 10";
			N -= 6;
			int k = N / 2;
			if (k > 7497) k = 7497;
			N -= k * 2;

			int A[3][2] = { 2,10,3,9,4,8 };
			rep(i, k) {
				cout << " " << 12 * (i / 3 + 1) + A[i % 3][0];
				cout << " " << 12 * (i / 3 + 1) + A[i % 3][1];
			}
			rep1(i, N) cout << " " << 6 * i;
		}
		cout << endl;
	}

	Would you please return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
vector<long long> A;
typedef long long ll;

ll gcd(vector<ll>);
ll gcd(ll ,ll);

int main(void){
  long long N;
  cin >> N;

  A = vector<long long>(N);
  for(ll i=0;i<N;i++){
    cin >> A[i];
  }
  ll ans = gcd(A);
  cout << ans << endl;

  return 0;

}

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

ll gcd(vector<ll> data){
  ll ans = data[0];
  for(long i=0;i<data.size();i++){
    ans = gcd(ans,data[i]);
  }
  return ans;
}


Measured memory_bytes: 1792
from collections import deque
import sys
input = sys.stdin.readline
D, G = map(int, input().split())
solved = [0]*1001
for score in range(100, D*100+1, 100):
    p, c = map(int, input().split())
    q = deque()

    bkp = solved.copy()
    for j, s in enumerate(solved):
        val = s - j*score
        while q and q[-1][1] < val:
            q.pop()
        q.append((j, val))

        k, vmax = q[0]
        solved[j] = max(solved[j], vmax+j*score)
        if k == j-p:
            q.popleft()
        if j-p >= 0:
            solved[j] = max(solved[j], bkp[j-p]+p*score+c)

for i, s in enumerate(solved):
    if s >= G:
        print(i)
        exit()


Measured memory_bytes: 9568