akhauriyash/Code-Regression huggingface dataset:
import fractions
import sys
from functools import reduce

def lcm_base(x, y):
  return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

N=int(input())
alist=list(map(int,input().split()))

if N==1:
  print(1)
else:
  lcm_alist=lcm_list(alist)
  #print(lcm_alist)
  
  allsum=0
  for i in range(N):
    allsum+=lcm_alist//alist[i]
    
  #print(blist)
  print(allsum%(10**9+7))


Measured memory_bytes: 6108
A, B, C, D = list(map(int, list(input())))
if A + B + C + D == 7:
	print(str(A) + "+" + str(B)+ "+" + str(C) + "+" + str(D) + "=7")
elif A + B + C - D == 7:
	print(str(A) + "+" + str(B)+ "+" + str(C) + "-" + str(D) + "=7")
elif A + B - C + D == 7:
	print(str(A) + "+" + str(B)+ "-" + str(C) + "+" + str(D) + "=7")
elif A + B - C - D == 7:
	print(str(A) + "+" + str(B)+ "-" + str(C) + "-" + str(D) + "=7")
elif A - B + C + D == 7:
	print(str(A) + "-" + str(B)+ "+" + str(C) + "+" + str(D) + "=7")
elif A - B + C - D == 7:
	print(str(A) + "-" + str(B)+ "+" + str(C) + "-" + str(D) + "=7")
elif A - B - C + D == 7:
	print(str(A) + "-" + str(B)+ "-" + str(C) + "+" + str(D) + "=7")
else:
	print(str(A) + "-" + str(B)+ "-" + str(C) + "-" + str(D) + "=7")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;
int p[5005],c[5005];
int main(void)
{
    cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>p[i];
    for(int i=1;i<=n;++i)
        cin>>c[i];
    ll ans=-1e18;
    for(int i=1;i<=n;++i)
    {
        vector<int> v;
        bool vis[5005]={0};
        int now=i;
        while(1)
        {
            if(vis[now]) break;
            vis[now]=true;
            v.push_back(now);
            now=p[now];
        }
        int len=v.size();
        if(k>len)
        {
            ll loopsum=0;
            for(int j=0;j<len;++j)
                loopsum+=c[p[v[j]]];
            if(loopsum>0)
            {
                ll loopcnt=k/len-1;
                ll kk=k-len*loopcnt;
                ll tmp=loopcnt*loopsum;
                int index=0;
                while(kk)
                {
                    tmp+=c[p[v[index]]];
                    ans=max(ans,tmp);
                    index=(index+1)%len;
                    kk--;
                }
            }
            else
            {
                ll tmp=0;
                for(int j=0;j<len;++j)
                    tmp+=c[p[v[j]]],ans=max(ans,tmp);
            }
        }
        else
        {
            ll tmp=0;
            for(int j=0;j<k;++j)
                tmp+=c[p[v[j]]],ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {

	int N, M;
	cin >> N >> M;

	priority_queue<int> A;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		A.push(tmp);
	}

	while (M > 0) {
		//金額が一番大きいものに割引券を使用
		int tmp = A.top() / 2;
		A.pop();
		M--;

		//更新
		A.push(tmp);
	}

	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += A.top();
		A.pop();
	}

	cout << ans << endl;



	return 0;
}

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


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

                long long amari = N % K;
                if (amari == 0) {
                        cout << "0" << endl;
                        exit(0);
                }
                long long tmp = abs(K - amari);
                if (amari < tmp) {
                        cout << amari << endl;
                }
                else {
                        cout << tmp << endl;
                }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

ll get_v(ll n, ll k) {
	if(n < k) return n;
	if(n % k == 0) return get_v(n / k, k);
	else return n % k;
} 
int main() {fio;
	ll n;
	cin >> n;
	if(n == 2) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 2;
	for(ll r = 2; r * r <= (n - 1); r++) {
		if((n - 1) % r == 0) {
			ans++;
			if(r * r != n - 1) ans++;
		}
	}
	cerr << ans << endl;
	for(ll fac = 2; fac * fac <= n; fac++) {
		if(n % fac) continue;
		if(fac * fac != n) {
			ans += get_v(n, n / fac) == 1;
		}
		ans += get_v(n, fac) == 1;
	}
	cout << ans << endl;
    return 0;
}

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

int main()
{
    int i;
    cin >> i;
    if(i>0 && i<=111){
        cout << "111" << endl;
    }
    else if (i > 111 && i <= 222)
    {
        cout << "222" << endl;
    }
    else if (i > 222 && i <= 333)
    {
        cout << "333" << endl;
    }
    else if (i > 333 && i <= 444)
    {
        cout << "444" << endl;
    }
    else if (i > 444 && i <= 555)
    {
        cout << "555" << endl;
    }
    else if (i > 555 && i <= 666)
    {
        cout << "666" << endl;
    }
    else if (i > 666 && i <= 777)
    {
        cout << "777" << endl;
    }
    else if (i > 777 && i <= 888)
    {
        cout << "888" << endl;
    }
    else if (i > 888 && i <= 999)
    {
        cout << "999" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
struct D{int a,b,c;};
main(){
  int a,b,c,N,i,w,x,y,z,m[301];
  D t[1001];
  for(;std::cin>>a>>b>>c>>N,a;){
    for(i=301;i>0;)m[--i]=2;
    for(;N-->0;){
      std::cin>>w>>x>>y>>z;
      D d={w,x,y};
      if(z)m[w]=m[x]=m[y]=1;
      else t[i++]=d;
    }
    for(;i-->0;){
      if((m[t[i].a]&1)+(m[t[i].b]&1)+(m[t[i].c]&1)==2){
	m[t[i].a]&=1;
	m[t[i].b]&=1;
	m[t[i].c]&=1;
      }
    }
    for(i++;i++<a+b+c;)printf("%d\n",m[i]);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h;
    cin >> h;
    ll ans = 0; ll level = 1;
    while(h != 0)
    {
        h = h / 2;
        ans += level;
        // cout << "ans: " << ans << endl;
        level = level * 2;
        // cout << "level : " << level << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
INT n, a[200020], b[200020];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i], b[i] = a[i];
    sort(b, b+n);
    for(int i = 0 ; i < n ; i++ )
    {
        if( a[i] > b[(n-1)/2] ) cout<<b[(n-1)/2]<<endl;
        else cout<<b[n/2]<<endl;
    }
    return 0;
}




Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(),i.end()
#define debug(i) std::cout << i << "\n"

const ll INF = 100000000;
const ll MOD = 1000000007;


int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
    ll n;
    std::cin>>n;
    std::vector<P> p(n);
    rep(i,0,n){
        ll a,b;
        std::cin>>a>>b;
        p[i]=P(b,a);
    }
    std::sort(all(p));
    ll tempa=0;
    bool ans=true;
    rep(i,0,n){
        tempa+=p[i].second;
        if(tempa>p[i].first){
            ans=false;
        }
    }
    if(ans){
        std::cout<<"Yes";
    }else{
        std::cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define mod1 1000000007LL
#define mod2 1000000009LL
#define base1 19
#define base2 31
#define base3 137
#define MAX 1e12
#define MIN -10000000000
#define pi acos(-1)
#define esp 1e-6
#define memz(x) memset(x, 0, sizeof x)
#define memn(x) memset(x, -1, sizeof x)
#define pb push_back
#define nai string::npos
#define in1(a) scanf("%lld", &a)
#define in2(a,b) scanf("%lld%lld", &a, &b)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(i) printf("Case #%lld: ", ++i)
#define FILE    freopen("input.txt", "r", stdin); freopen("out.txt", "w", stdout);
using namespace std;
const ll N = 300010;
ll a, b, c;
int main()
{
    cin>>a>>b>>c;
    cout<<c-min(c, a-b)<<endl;
    return 0;
}



Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> M(5);
    map<char, ll> T = {
        {'M', 0},
        {'A', 1},
        {'R', 2},
        {'C', 3},
        {'H', 4}
    };
    rep (i, N) {
        string S;
        cin >> S;
        if (T.count(S[0])) {
            M[T[S[0]]] += 1;
        }
    }
    ll ans = 0;
    rep (i, 1 << 5) {
        ll tmp = 1;
        ll cnt = 0;
        rep (j, 5) {
            if ((i >> j) & 1) {
                tmp *= M[j];
                ++cnt;
            }
        }
        if (cnt == 3) {
            ans += tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
l = []
for h in range(H):
    l.append(input())

j = True
for h in range(H):
    if not j:
        break
    for w in range(W):
        if l[h][w] == "#":
            j = False
            if h != 0:
                if l[h - 1][w] == "#":
                    j = True
            if h != H - 1:
                if l[h + 1][w] == "#":
                    j = True
            if w != 0:
                if l[h][w - 1] == "#":
                    j = True
            if w != W - 1:
                if l[h][w + 1] == "#":
                    j = True
            if not j:
                break
if j:
    print("Yes")
else:
    print("No")


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

int main(){
    int i, n;
    double a, result = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a;
        result += 1.0/a;
    }
    printf("%.5lf", 1.0/result);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b;
    char op;

    scanf("%d %c %d", &a, &op, &b);

    if (op == '+') {
        printf("%d\n", a + b);
    } else if (op == '-') {
        printf("%d\n", a - b);
    }
    return 0;
} 


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

using namespace std;

const double EPS = 1e-7;
const int N = 4e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
typedef long long ll;

int gcd(int a, int b){
    if(b)   return gcd(b, a%b);
    else return a;
}

ll fixMod(ll a, ll b){
    return (a%b + b)%b;
}

void pushBack(ll& h, ll base, ll mod, char c){
    h = ((h*base)%mod + c)%mod;
}

void pushFront(ll& h, ll p, ll mod, char c){
    h = (h + (c*p)%mod)%mod;
}

void popFront(ll& h, ll p, ll mod, char c){
    h = fixMod((h - (p*c)%mod), mod);
}

void popBack(ll& h, ll inv, ll mod, char c){
    h = (fixMod(h-c, mod)*inv)%mod;
}

ll power(ll a, ll b, ll m){
    if(!b)  return 1;
    ll t = power(a, b>>1, m);
    return ((t*t)%m * (b&1 ? a : 1))%m;
}



int main(){
//    freopen("araf_bara.txt", "wt", stdout);
int n; cin>>n;
double x;
for(int i=1; i<=n; i++){
    if(i&1)x++;

}
cout<<fixed<<setprecision(10)<<x/n<<endl;

}


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

#define mod 1000000007
#define modd 998244353
#define PI 3.1415926
#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
#define couts(ans) cout<< ans <<" "
#define coutss(a,b) cout<< a <<" "<< b << "\n"
#define coutsm(a,b,c) cout<< a <<" "<< b <<" "<< c << "\n"
#define maxx *max_element
#define minn *min_element


void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}

void solve()
{      
    int n;cin>>n;
    ld p[n];
    forn(i,0,n)
    {
        cin>>p[i];
    }
    ld dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    forn(i,1,n+1)
    {
        forn(j,0,i+1)
        {
            if(j)
                dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
            else
                dp[i][j]=dp[i-1][j]*(1-p[i-1]);
        }
    }
    ld ans=0;
    forn(i,1,n+1)
    {
        if(i>(n-i))
        {
            ans+=dp[n][i];
        }
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;

}


int main()
{   
    speed();
    int tc=1;
    // cin>>tc;
    while(tc--)
    {
        solve();
    }
}

Measured memory_bytes: 144428
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main() {
  unsigned int N;
  int ans = 0;
  cin >> N;
  unsigned int N2 = 1;
  for(int i=0;i<N;i++) N2 *= 2;
  int A[N], B[N][N-1][2], C[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    for(int j=0;j<A[i];j++){
      cin >> B[i][j][0] >> B[i][j][1];
    }
  }
  for(int i=1;i<N2;i++){
    int casescore = 0;
    int ca = i;
    for(int j=0;j<N;j++){
      C[j] = ca % 2;
      ca /= 2;
    }
    for(int i=0;i<N;i++){
      if(C[i] == 0) continue;
      for(int j=0;j<A[i];j++){
        if(C[B[i][j][0]-1] != B[i][j][1]) goto NEXT;
      }
    }
    for(int i=0;i<N;i++) casescore += C[i];
    ans = max(ans, casescore);
    NEXT:;
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// return gcd(a,b)
long long gcd(long long a, long long b) {
    // O(log min(a,b))
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

    int a, b, k;
    cin >> a >> b >> k;

    int d = gcd(a, b);
    int count = 0;
    RREP(i, d) {
        if (d % i == 0) {
            count++;
        }
        if (count == k) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  double h;
  double max=0,min=10000000;

  while(cin>>h){

    if(h>max)max=h;
    if(h<min)min=h;
  }
  cout<<max-min<<endl;

  return 0;
  
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){   
    string s;
    cin>>s;
    for(int i=0;i<=5;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<ll> d(1001, 0);
    rep (i, 1, n+1) {
        int p = i;
        for (int j = 2; j * j <= i; ++j) {
            while (p % j == 0) {
                d[j]++;
                p /= j;
            }
        }
        d[p]++;
    }
    ll mod = 1e9 + 7;
    ll ans = 1;
    rep (i, 2, 1001) {
        ans *= d[i] + 1;
        ans %= mod;
    }
    cout << ans << endl;
}


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


def is_prime(n, i=2):
    if (n % i == 0):
        return False
    elif (i * i > n):
        return True

    return is_prime(n, i + 1)


if x > 3:
    while(is_prime(x) == False):
        x += 1

print(x)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (size_t i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  p.back() = p.back() / 2;
  int a = 0;
  for (size_t i = 0; i < N; i++) {
    a = a + p[i];
  }
  cout << a << endl;
  return 0;
}

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

class FastReader{
	BufferedReader br;
	StringTokenizer tok;
	
	FastReader(){
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next() {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(this.next());
	}
	String nextLine() {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}
}

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt(), k=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		for(int i=1; i<n; i++) {
			dp[i] = Integer.MAX_VALUE;
			for(int j=1; j<=k; j++)
				if((i-j)>=0)
					dp[i] = Math.min(dp[i], dp[i-j]+Math.abs(arr[i]-arr[i-j]));
		}
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 36096
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let s = scn.chars();
        let t = scn.chars();
        let n: usize = t.len();
        let mut ans = 1 << 30;
        for i in 0..s.len() - n + 1 {
            let mut result = 0;
            for j in 0..n {
                if s[i + j] != t[j] {
                    result += 1;
                }
            }
            ans = std::cmp::min(result, ans);
        }
        println!("{}", ans);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2264
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[20];
int mat[20][20];
int n,m;
ll ans;
void recur(int pos,int used[])
{

    int cnt=0;
    for(int i=1; i<=m; i++)
    {
        int sum=0;
        for(int j=1; j<=n; j++)
        {
            if(mat[i][j] && used[j])
                sum++;
        }
        sum%=2;
        if(sum!=arr[i])
            break;
        cnt++;
    }
    if(cnt==m)
    {
        ans++;
    }

    for(int i=pos; i<=n; i++)
    {
        if(!used[i])
        {
            used[i]=1;
            recur(i+1,used);
            used[i]=0;
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        int k;
        cin>>k;
        for(int j=1; j<=k; j++)
        {
            int a;
            cin>>a;
            mat[i][a]=1;
        }
    }
    for(int i=1; i<=m; i++)
        cin>>arr[i];
    int used[20]= {0};
    recur(1,used);
    cout<<ans<<endl;


    return 0;
}


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

int main() {
    int a;
    cin >> a;
    int b[a];
    for(int i=0;i<a;i++){
    	cin >> b[i];
    }
    int c[a];
    for(int i=0; i<a; i++){
    	cin >> c[i];
    }
    int ans = 0;
    for(int i=0; i<a; i++){
    	if(b[i]>c[i]){
    		ans += b[i]-c[i];
    	}
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      HashSet<String> hs = new HashSet<String>();
      
      for(int k = 0; k < n; k++){
         hs.add(f.readLine());
      }
      
      out.println(hs.size());
      
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 66864
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int arr[N];

int minCost(int n) {
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);

    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
    }

    return dp[n - 1];
}

int main()
{
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    cout << minCost(n);
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> switchList(M, vector<int>(0));
  for(int i = 0; i < M; i++){
    int tk;
    cin >> tk;
    for(int j = 0; j < tk; j++){
      int ts;
      cin >> ts;
      switchList.at(i).push_back(ts-1);
    }
  }
  vector<int> p(M);
  for(int i = 0; i < M; i++) cin >> p.at(i);
  
  int temp = 1;
  for(int i = 0; i < N; i++) temp *= 2;
  vector<vector<int>> allList(temp, vector<int>(N, 0));
  for(int i = 0; i < temp; i++){
    int tr = temp;
    for(int j = 0; j < N; j++){
      tr /= 2;
      int tq = i % (tr*2);
      if(tq/tr==1) allList.at(i).at(j) = 1;
    }
  }
  
//  for(int i = 0; i < temp; i++){
//    cout << "(";
//    for(int j = 0; j < N-1; j++) cout << allList.at(i).at(j) << " ";
//    cout << allList.at(i).at(N-1) << ")" << endl;
//  }
  
  int ans = 0;
  for(int i = 0; i < temp; i++){
    bool isAllOn = true;
    for(int j = 0; j < M; j++){
      int ts = 0;
      for(int k = 0; k < switchList.at(j).size(); k++){
        ts += allList.at(i).at(switchList.at(j).at(k));
      }//k
      if(ts%2 != p.at(j)){
        isAllOn = false;
        break;
      }
    }//j
    if(isAllOn) ans++;
  }//i
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

ll dp[3000][3000];

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;

  for(int j = 0; j < N; j++) dp[0][j] = 1;

  for(int i = 0; i < N; i++){
    ll sum[N + 1];
    sum[0] = 0;
    for(int j = 1; j <= N; j++) sum[j] = sum[j - 1] + dp[i][j - 1];

    if(s[i] == '<'){
      for(int j = 0; j < N; j++){
        dp[i + 1][j] = sum[N] - sum[j + 1];
        dp[i + 1][j] %= MOD;
      }
    }
    else {
      for(int j = 0; j < N - i - 1; j++){
        dp[i + 1][j] = sum[j + 1] - sum[0];
        dp[i + 1][j] %= MOD;
      }
    }
  }

  cout << dp[N - 1][0] << endl;
  return 0;
}


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

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

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

Measured memory_bytes: 3592
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int a, b;
    int ans = 0;
    a = (S[0] - '0') * 10 + (S[1] - '0');
    b = (S[2] - '0') * 10 + (S[3] - '0');
    if (1 <= a && a <= 12) {
        ans += 1;
    }
    if (1 <= b && b <= 12) {
        ans += 2;
    }
    switch (ans) {
        case 0:
            cout << "NA" << endl;
            break;
        case 1:
            cout << "MMYY" << endl;
            break;
        case 2:
            cout << "YYMM" << endl;
            break;
        case 3:
            cout << "AMBIGUOUS" << endl;
            break;
    }
    getchar(); getchar();
}

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

int main() {
	//解説参考

	int n;
	cin >> n;


	int t = n, c = 0;

	while (t > 0) {
		c += t % 10;
		t /= 10;
	}


	cout << ((n%c == 0) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
word_list = []
count = 0
top_b = 0
bottom_a = 0
ba = 0

for i in range(n):
    s = input()
    word_list.append(s)

for i in word_list:
    if i[0] == 'B' and i[-1] == 'A':
        ba += 1
    elif i[0] == 'B':
        top_b += 1
    elif i[-1] == 'A':
        bottom_a += 1
    for j in range(len(i)-1):
        if i[j] == 'A' and i[j+1] == 'B':
            count += 1

if ba:
    if top_b == 0 and bottom_a == 0:
        count += (ba - 1)
    else:
        count += min(ba + top_b, ba + bottom_a)
else:
    count += min(bottom_a, top_b)

print(count)

Measured memory_bytes: 3700
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 100003;
const int cons = 100001;
const double pi = 3.141592653589793;



int main()
{
	int n;
	scanf("%d", &n);

	int arr[302];
	for (int i = 0; i < 2*n; i++)
	{
		scanf("%d", arr + i);
	}

	sort(arr, arr + 2 * n);

	int ans = 0;

	for (int i = 0; i < 2*n; i+= 2)
	{
		ans += arr[i];
	}

	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto& i : v) cin >> i; }

int main() {
  int A;

  cin >> A;
  
  int kisuu = (A+1) / 2;

  cout << (double)kisuu / (double)A << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << ((n[0] == '7' || n[1] == '7' || n[2] == '7') ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>

#define black first
#define white second

using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;

const int nax = 1e5 + 5;

int mod;
int n, a, b;

int add(int a, int b){
    return (a + b) % mod;
}
int mul(int a, int b){
    return (ll) a * b % mod;
}


vector<int> edges[nax], children[nax];
vector<pair<int, int>> downs[nax], pref[nax], suf[nax];
pair<int, int> down[nax], up[nax];

pair<int, int> merge(const pair<int, int>& a,const pair<int, int>& b){
    pair<int, int> p;
    p.first = mul(a.first, b.first);
    p.second =  add(mul(a.second, add(b.first, b.second)), mul(a.first, b.second));
    return p;
}

pair<int, int> process(pair<int,int> p){
    return {p.first, add(p.first, p.second)};
}


void dfsOne(int a, int parent){
    pair<int, int> p{1, 0};
    for(int b : edges[a]){
        if(b != parent){
            children[a].push_back(b);
            dfsOne(b, a);
            p = merge(p, down[b]);
            downs[a].push_back(down[b]);
        }
    }
    down[a] = process(p);
}

void dfsTwo(int a, int parent){
    for(int i = 0; i < children[a].size(); i++){
        pair<int, int> p{1, 0};
        if(i != 0){
            p = merge(p, pref[a][i -1]);
        }
        if(i != downs[a].size() - 1){
            p = merge(p, suf[a][i + 1]);
        }
        if(a != 1){
            p = merge(p, up[a]);
        }
        int b = children[a][i];
        up[b] = process(p);
        dfsTwo(b, a);
    }
}



#define all_white first
#define sth_is_black second

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n >> mod;
    
    for(int i = 0; i < n - 1; i++){
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfsOne(1, -1);
    for(int a = 1; a <= n; a++){
        int k = downs[a].size();
        pair<int, int> p{1, 0};
        for(int i = 0; i < k; i++){
            p = merge(p, downs[a][i]);
            pref[a].push_back(p);
        }
        p = {1, 0};
        for(int i = k - 1; i >= 0; i--){
            p = merge(p, downs[a][i]);
            suf[a].push_back(p);
        }
        reverse(suf[a].begin(), suf[a].end());
    }
    
    dfsTwo(1, -1);
    for(int a = 1; a <= n; a++){
        pair<int, int> p{1,0};
        if(a != 1){
            p = merge(p, up[a]);
        }
        if(!children[a].empty()){
            p = merge(p, pref[a].back());
        }
        p = process(p);
        cout << p.second << "\n";
    }
}


Measured memory_bytes: 35328
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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


int main(){
	
	int n;
	cin>>n;
	
	rep(loop, n){
		int m=10;
		int in[10];
		bool ans = false;
		rep(i,m)cin>>in[i];
		rep(i,(1<<m)){
			vector<int> a;
			vector<int> b;
			rep(j,m){
				if((i&(1<<j))>0)a.push_back(in[j]);
				else b.push_back(in[j]);
			}
			
			bool ok=true;
			rep(j,a.size()-1)if(a[j]>a[j+1])ok=false;
			rep(j,b.size()-1)if(b[j]>b[j+1])ok=false;
			if(ok)ans=true;
		}
		if(ans)puts("YES");
		else puts("NO");
	}
	
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
int ans,n;
int a[6];
int maxn(int x,int y)
{
    if(x>y)return x;
    return y;
}
signed main()
{
    cin>>n;
    for(int i=1;i<=5;i++)cin>>a[i];
    for(int i=1;i<=5;i++)ans=maxn(ans,n/a[i]+(n%a[i]>0));
    cout<<ans+4;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t N;
  cin>>N;
  int64_t X=N;
  vector<int64_t>A={};
  for(int64_t i=2;i*i<=N;i++){
  if(X%i==0){
  int64_t a=0;
    while(X%i==0){
    X/=i; a++;
    }A.push_back(a);
  }
  }if(X!=1)A.push_back(1);
  int64_t ans=0;
  int M=A.size();
  for(int i=0;i<M;i++){
  int64_t n=sqrt(2*A.at(i));
    if(2*A.at(i)<n*(n+1))
      n--;
    ans+=n;
  
  }cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3724
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.Bits
-- import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
trace _ = id

solve :: Int -> [Int] -> [Int] -> Bool
solve n ps xs = func 1 /= Nothing
  where

  tree = trace ("tree" ++ show tree0) tree0
  tree0 = V.create $ do
    vec <- VM.replicate (n+1) []
    forM_ (zip [2..] ps) $ \(c, p) -> VM.modify vec (c :) p
    return vec

  vx = VU.fromListN (n+1) (0 : xs)

  func :: Int -> Maybe (Int, Int)
  func i = trace ("func " ++ show(i,a)) a
    where a = func' i
  func' i = mapM func (tree V.! i) >>= g (vx VU.! i)
    where
    g :: Int -> [(Int, Int)] -> Maybe (Int, Int)
    g xi pqs | finBit == 0    = Nothing
             | otherwise = Just (xi, finSum - y)
      where
      (finBit, finSum) = foldr op (1, 0) pqs
      mask :: Integer
      mask = 2 ^ (xi + 1) - 1
      op :: (Int, Int) -> (Integer, Int) -> (Integer, Int)
      op (p, q) (bit, sum)
        = (mask .&. (shift bit p .|. shift bit q), sum + p + q)
      y = head $ [i | i <- [xi,xi-1..0], testBit finBit i]

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Bool
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      ps = map readBInt line2
      line3:remLines3 = remLines2
      xs = map readBInt line3
  in solve n ps xs

outAnswer :: Bool -> IO ()
outAnswer x = putStrLn (if x then "POSSIBLE" else "IMPOSSIBLE")

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    if(w==x*2 && h==y*2)
    {
        cout<<(long double)w*h/2<<" "<<1;
    }
    else
    {
        cout<<(long double)w*h/2<<" "<<0;
    }
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
ll e10 = 1e10 + 10;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	vector<int> d(N, -1);
	priority_queue<i_i, vector<i_i>, greater<i_i> > pq;
	int K; cin >> K;
	while (K--) {
		int v, p; scanf("%d%d", &v, &p);
		v--;
		d[v] = p;
		pq.push(i_i(p, v));
	}
	while (!pq.empty()) {
		i_i p = pq.top(); pq.pop();
		int u = p.second;
		for (int v: G[u])
			if (d[v] == -1) {
				d[v] = d[u] + 1;
				pq.push(i_i(d[v], v));
			}
	}
	rep(u, N)
		for (int v: G[u])
			if (abs(d[u] - d[v]) != 1) {
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	rep(u, N) printf("%d\n", d[u]);
}


Measured memory_bytes: 7924
n = int(input())
*A, = input().split()
B = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
print(*A)
print("Stable")

for i in range(n):
    mj = i
    for j in range(i, n):
        if B[j][1] < B[mj][1]:
            mj = j
    B[i], B[mj] = B[mj], B[i]
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 7676
def main():
    antenna = []
    for _ in range(5):
        antenna.append(int(input()))
    k = int(input())
    result = True
    for i in range(5):
        for j in range(i + 1, 5):
            if antenna[j] - antenna[i] > k:
                result = False
    if result:
        print("Yay!")
    else:
        print(":(")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int n,m,l,i,j,k;
    int a[100][100],b[100][100];
    long int c;
    cin >> n >> m >> l ;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> a[i][j] ;
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin >> b[i][j] ;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            c=0;
            for(k=0;k<m;k++){
                c+=a[i][k]*b[k][j];
            }
            cout << c;
            if(j==l-1) cout << endl;
            else cout << " ";
        }
    }
    
}


Measured memory_bytes: 3188
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N):
    mod = 10 ** 9 + 7
    a = 10 ** N - (9 ** N + 9 ** N - 8 ** N)
    print(a % mod)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # Ai = [int(i) for i in input().split()]
    # Bi = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 11392
import java.util.Arrays;
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long a[] = new long[N];
            long b[] = new long[N];
            long s[] = new long[N];
            long ans = 0;
            
            for(int i=0; i<N; i++) {
            	a[i] = sc.nextLong();
            	b[i] = sc.nextLong();
            	s[i] = a[i] + b[i];
            	ans -= b[i];
            }
            Arrays.sort(s);
            
            for(int i=N-1; i>=0; i-=2) {
            	ans += s[i];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 93408
case class Adj(u: Int, k: Int, vs: Seq[Int]) {
  def convertToMat(n: Int): Seq[Int] = gen(1, n, vs, Nil)

  def print(n: Int): Unit = println(convertToMat(n).mkString(" "))

  private def gen(i: Int, n: Int, vs: Seq[Int], line: Seq[Int]): Seq[Int] = {
    if (i > n) {
      line
    } else if(vs.headOption.contains(i)) {
      gen(i + 1, n, vs.tail, line :+ 1)
    } else {
      gen(i + 1, n, vs, line :+ 0)
    }
  }
}

object Adj {
  def apply(line: String): Adj = {
    val input = line.split(' ')
    Adj(input(0).toInt, input(1).toInt, input.drop(2).map(_.toInt).distinct.sorted)
  }
}

object Main extends App {
  private val lines = io.Source.stdin.getLines.toSeq
  private val n = lines.head.toInt

  lines.tail.foreach(Adj(_).print(n))
}

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

int main(){
  vector<int> v(9, 0);
  for(int i = 0; i < 9; i++){
    cin >> v[i];
  } 
  int a1 = 1;
  int a2 = 1 + v[3] - v[0];
  int a3 = 1 + v[6] - v[0];
  int b1 = v[0] - 1;
  int b2 = b1 + v[1] - v[0];
  int b3 = b1 + v[2] - v[0];
  bool f = true;
  if(v[4] != a2 + b2){f = false;}
  else if(v[5] != a2 + b3){f = false;}
  else if(v[7] != a3 + b2){f = false;}
  else if(v[8] != a3 + b3){f = false;}

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


Measured memory_bytes: 256
package main

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

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

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

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

func main() {
	n := readInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		x := readInt()
		m[x]++
	}

	ans := 0
	for _,v := range m {
		if v % 2 == 1 { ans++ }
	}
	fmt.Println(ans)
}

Measured memory_bytes: 7296
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for s in range(n)]
B=[list(map(int,input().split())) for t in range(m)]
for i in range(n):
    C=[]
    for j in range(l):
        c=0
        for k in range(m):
            c+=A[i][k]*B[k][j]
        C.append(c)
    
    print(' '.join(map(str,C)))
        


Measured memory_bytes: 6308
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s;
  cin >> s;

  int N = s.size();
  map<char, int> m;
  REP(i, N){
    m[s[i]]++;
  }

  int ans = N*(N-1)/2+1;
  for(auto p : m){
    ans -= p.second*(p.second-1)/2;
  }

  cout << ans << endl;

  return 0;
}

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

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


int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> w_sum(n+1,0), e_sum(n+1,0);

    if(s.at(0) == 'W') w_sum.at(0) = 1;
    else e_sum.at(0) = 1;

    for(int i=1; i < n; i++) {
        if(s.at(i) == 'W') {
            w_sum.at(i) = w_sum.at(i-1) + 1;
            e_sum.at(i) = e_sum.at(i-1);
        } else {
            w_sum.at(i) = w_sum.at(i-1);
            e_sum.at(i) = e_sum.at(i-1) + 1;
        }
    }

    int ans = INT_MAX;
    rep(i, n) {
        // 0~i時点までの西向きの人と、i~nまでの東向きの人が対象
        // 自分自身は考えなくて良い
        int tmp;
        if(i == 0) tmp = e_sum.at(n-1) - e_sum.at(i);
        else if(i != n-1) tmp = w_sum.at(i-1) + (e_sum.at(n-1) - e_sum.at(i));
        else tmp = w_sum.at(i-1);
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;

}

/**
2
WE
**/

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

int main() {
  int N;
  cin >> N;
  if(1 == N){
  	cout << 1 << endl;
    return 0;
  }else if(N < 4){
  	cout << 2 << endl;
    return 0;
  }else if(N < 8){
  	cout << 4 << endl;
    return 0;
  }else if(N < 16){
    cout << 8 << endl;
    return 0;
  }else if(N < 32){
  	cout << 16 << endl;
    return 0;
  }else if(N < 64){
  	cout << 32 << endl;
    return 0;
  }else {
  	cout << 64 << endl;
    return 0;
  }
}

Measured memory_bytes: 256