akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, INF))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

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

  vec ct(10001, 0);
  REP(i,1,100){
    REP(j,1,100){
      REP(k,1,100){
        int tmp = i*i + j*j + k*k + i*j + j*k + k*i;
        if(tmp>10000) break;
        ct[tmp]++;
      }
    }
  }

  rep(i,n){
    prt(ct[i+1]);
  }
}


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

int main() {
	// your code goes here
     int n;
     cin>>n;
     string s;
     cin>>s;
     int r=0;
     for(int i=0;i<n;i++)
     {
     	if(s[i]=='R')
     	 r++;
     }
     int r1=0;
     for(int i=0;i<r;i++)
     {
     	if(s[i]=='R')
     	   r1++;
     }
     cout<<r-r1;
	return 0;
}

Measured memory_bytes: 3716
N,M = map(int,input().split())
G = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
cnt = [0]
def dfs(V,s):
    V[s] = 1
    if sum(V) == N:
        cnt[0] += 1
    else:
        for adj in G[s]:
            if V[adj] == 0:
                dfs(V[:adj] + [1] + V[adj + 1:], adj)
dfs([0] * N,0)
print(cnt[0])


Measured memory_bytes: 9216
#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++)
typedef long long ll;
const int MAX = 10000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    ll X, Y; cin >> X >> Y;
    if ((2 * Y - X) % 3 != 0 || (2 * X - Y) % 3){
        cout << 0 << endl;
        return 0;
    }
    else {
        COMinit();
        ll a = (2 * Y - X) / 3;
        ll b = (2 * X - Y) / 3;
        cout << COM(a+b, a) << endl;
    }
}



Measured memory_bytes: 234624
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    int A,B;
    cin >> A >> B;
    cout << max(A+B, max(A-B, A*B)) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

long long int MOD = 1000000007;

long long int pow2(long long int k)
{
  if(k == 0) return 1;
  long long int x = pow2(k/2);
  if(k & 1) return (((x*x)%MOD)*2)%MOD;
  else return (x*x)%MOD;
}

int main()
{
  int N;
  long long int h[100];
  long long int val[100];
  set<long long int> ss;
  set<long long int>::iterator it;
  map<long long int, int> mm;
  
  scanf("%d", &N);
  REP(i, 0, N-1)
  {
    scanf("%lld", &h[i]);
    ss.insert(h[i]);
  }
  
  int M = 0;
  for(it = ss.begin(); it != ss.end(); it++)
  {
    mm[*it] = M;
    val[M] = *it;
    M++;
  }
  // M = number of different heights
  
  long long int dp[100][101];
  
  long long int prevh = 1;
  REP(i, 0, M)
  {
    if(i == M) dp[0][i] = 2;
    else if(val[i] <= h[0]) dp[0][i] = ((pow2(val[i]-prevh+1)-2) * pow2(h[0]-val[i]))%MOD;
    else dp[0][i] = 0;
    prevh = val[i];
  }
  
  REP(j, 1, N-1)
  {
    REP(i, 0, M) dp[j][i] = 0;
    if(h[j] <= h[j-1])
    {
      REP(i, 0, M)
      {
        if(i < M && val[i] <= h[j]) dp[j][i] = (dp[j][i] + dp[j-1][i])%MOD;
        else dp[j][M] = (dp[j][M] + 2*dp[j-1][i])%MOD;
      }
    }
    else
    {
      long long int tot = 0;
      REP(i, 0, M)
      {
        if(i < M && val[i] <= h[j-1]) dp[j][i] = (dp[j][i] + dp[j-1][i]*pow2(h[j]-h[j-1]))%MOD;
        else tot = (tot+dp[j-1][i])%MOD;
      }
      REP(i, 0, M)
      {
        if(i < M && val[i] > h[j-1] && val[i] <= h[j]) dp[j][i] = (dp[j][i] + ((tot*(pow2(val[i]-val[i-1]+1)-2))%MOD) * pow2(h[j]-val[i]))%MOD;
        else if(i == M) dp[j][i] = (dp[j][i] + tot*2)%MOD;
      }
    }
  }
  
  long long int ans = 0;
  
  REP(i, 0, M) ans = (ans + dp[N-1][i])%MOD;
  
  cout << ans << endl;
  
    
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(i!=0)a[i]+=a[i-1];
  }
  long long ans=10000000000000;
  for(int i=0;i<n-1;i++)
  {
    ans=min(ans,abs(a[i]-(a[n-1]-a[i])));
  }
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}

using vi = vector<int>;
using vvi = vector<vi>;
using P = complex<double>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
const double EPS = 1e-8;
#define SIZE 1e4+5

int main(){
  int n; cin >> n;
  double r, theta; cin >> r >> theta;
  theta *= M_PI/180.0;
  vector<P> ps(n);
  rep(i,n){
    double x, y; cin >> x >> y;
    ps[i] = P(x,y);
  }

  vector<vvi> can(n,vvi(n));
  rep(i,n) rep(j,n){
    if(i == j) continue;
    rep(k,n){
      if(j == k) continue;
      if(abs(arg((ps[j]-ps[i])/(ps[k]-ps[j]))) - EPS < theta){
	can[i][j].push_back(k);
      }
    }
  }

  vvvd dp(n+1, vvd(n, vd(SIZE)));
  dp[n][0][0] = r; // 前の場所がないことをn->で表す
  rep(k,SIZE-1) rep(i,n+1) rep(j,n){
    if(i == n){
      FOR(x,1,n) chmax(dp[j][x][k+1] , dp[i][j][k] - abs(ps[j]-ps[x]));
    }else{
      for(auto x : can[i][j]){
	chmax(dp[j][x][k+1] , dp[i][j][k] - abs(ps[j]-ps[x]));
      }
    }
  }
  int ans = 0;
  rep(i,n+1) rep(j,n) rep(k,SIZE){
    if(dp[i][j][k] > EPS){
      chmax(ans, k);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 37760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int c = 1;
		for (int i = 2; a > 1 && b > 1 && a >= i && b >= i;) {
			if (a % i == 0 && b % i == 0) {
				a /= i;
				b /= i;
				c *= i;
				// System.out.println(a + " " + b + " " + c);
			} else
				i++;
		}
		System.out.println((long) a * (long) b * (long) c);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int N, X; cin >> N >> X;
    vector<int> m(N); REP(i, N) cin >> m[i];

    sort(all(m));
    for(int i = 0; i < N; ++i) {
        if(i == 0) continue;
        X -= m[i];
    }

    int res = X / m[0];

    cout << res + (N - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int N_MAX = 100;
int main (void) {
    int N;
    int a[N_MAX];
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    sort(a, a + N);

    for (int i = 0; i < N - 1; i++) ans += a[i + 1] - a[i];

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
int h,n;
cin>>h>>n;
int a[n],b[n];
rep(i,0,n) cin>>a[i]>>b[i];
vl dp(h+1,inf);
dp[0]=0;
for(int i=1;i<=h;i++){
	for(int j=0;j<n;j++){
		dp[i]=min(dp[i],i-a[j]>0?dp[i-a[j]]+b[j]:b[j]);
	}
}
cout<<dp[h];
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



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

int main(){
  unsigned long int H;
  unsigned long int count = 0;
  unsigned long int ans = 1;
  unsigned long int bash = 1;
  cin >> H;
  while (H != 1){
    H /= 2;
    count++;
  }
  for (int i = 0; i < count; i++){
      bash *= 2;
      ans += bash;
  }
  cout << ans << endl;
}

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() {
  int n;
  cin >> n;
  ll c[n + 1], s[n + 1], f[n + 1], t[n + 1];
  for (int i = 0; i < n - 1; ++i) cin >> c[i] >> s[i] >> f[i];
  rep(i, n + 1) t[i] = 0;

  for (int j = 0; j < n - 1; ++j) {
    t[j] = s[j] + c[j];
    for (int i = j + 1; i < n - 1; ++i) {
      ll t2 = s[i];
      while (t[j] > t2) t2 += f[i];
      t[j] = t2 + c[i];
    }
  }

  rep(i, n) cout << t[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1000

void clear(char a[]) {
    int i;
    for (i = 0; i < MAX; i++)
        a[i] = '\0';
    return;
}

int max(int a, int b, int c) {
    if (a < b) a = b;
    if (a < c) a = c;
    return a;
}

int lcs(char a[], char b[]) {
    int table[MAX + 1][MAX + 1] = {{}};
    int i, j;
    for (i = 1; i <= strlen(a); i++) {
        for (j = 1; j <= strlen(b); j++) {
            int d = (a[i - 1] == b[j - 1])? 1 : 0;
            table[i][j] = max(table[i-1][j-1] + d, table[i-1][j], table[i][j-1]);
        }
    }
    return table[i - 1][j - 1];
}

int main (void)
{
    int q;
    char a[MAX];
    char b[MAX];
    scanf("%d", &q);
    int i;
    for (i = 0; i < q; i++) {
        scanf("%s %s", a, b);
        printf("%d\n", lcs(a, b));
        clear(a);
        clear(b);
    }
    return 0;
}


Measured memory_bytes: 5676
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b, c = inls()
print('YES' if int(a+b+c)%4==0 else 'NO')


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

int MAX = 3000;
long long modnum = 1e9 + 7;
std::vector< long long > fac(MAX);
std::vector< long long > finv(MAX);
std::vector< long long > inv(MAX);

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % modnum;
        inv[i] = modnum - inv[modnum%i] * (modnum / i) % modnum;
        finv[i] = finv[i - 1] * inv[i] % modnum;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % modnum) % modnum;
}

int main(){
    int N, K;
    std::cin >> N >> K;
    
    COMinit();
    
    long long blue = K;
    long long red = N - K;
    std::vector< long long > ans(K);
    for(int i=1; i<=K; i++){
        if(red + 1 < i){
            ans[i - 1] = 0;
        }else{
            long long b = COM(blue - 1, i - 1);
            long long r = COM(red + 1, i);
            ans[i - 1] = (b * r) % (long long)modnum;
        }
    }
    
    for(int i=0; i<K; i++){
        std::cout << ans[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 384
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**9)

def dfs(num):
    temp=K-len(way[num])
    
    for w in way[num]:
        if visited[w]==-1:
            visited[w]=temp
            temp+=1
            dfs(w)
    
    return 

N,K=map(int,input().split())

mod=10**9+7

visited=[-1]*N
way=[[] for i in range(N)]

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
    
color=[]
visited[0]=K
dfs(0)

#print(way)
#print(visited)
ans=1
for item in visited:
    ans*=item
    ans%=mod
print(ans)


Measured memory_bytes: 88108
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((ll) a.size())
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 + 1 ;
int g[5][5] ;
int main () {
    for(int i =0 ; i < 5 ;i++)
        for(int j =0 ; j < 5 ;j++)
            g[i][j]= 0 ;
    for(int i = 0 ; i < 3 ;i++) {
        int u , v ;
        cin >> u >> v ;
        g[u][v] = 1 ;
        g[v][u] = 1 ;
    }
    if(g[1][2] && g[2][3] && g[3][4]) cout<<"YES\n" ;
    else if(g[1][4] && g[4][3] && g[3][1]) cout<<"YES\n" ;
    else if(g[1][4] && g[4][2] && g[2][3]) cout<<"YES\n" ;
    else if(g[1][2] && g[2][4] && g[4][3]) cout<<"YES\n" ;
    else if(g[1][3] && g[3][4] && g[4][2]) cout<<"YES\n" ;
    else if(g[1][3] && g[3][2] && g[2][4]) cout<<"YES\n" ;
    else cout<<"NO\n" ;
    return 0 ;
}


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

int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=1; i<=n; i++){
        int tmp;
        cin >> tmp;
        mp[tmp]=i;
    }
    for(int i=1; i<=n; i++){
        cout << mp[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5504
l=[int(input()),int(input()),int(input()),int(input()),int(input())]

n=5
m=10
s=0
while n:
  s += (l[n-1]-1)//10*10+10
  a = l[n-1] % 10
  if a==0 : a =10
  if m>a : m = a
  n -= 1

print(s-10+m)


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

using namespace std;

const int infI=1e9+5;
const long long infL=1e18;
const int MOD=1e9+7;
const int MAX=1e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vl vector<vector<ll> >
#define vi vector<vector<int> >
#define eb emplace_back
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back();
#define se second
#define fi first

ll dp[2001][2001];

int main(){
    int n,k;
    ll ans=0;
    cin>>n>>k;
    forn(i,0,n+1){
        dp[i][0]=dp[i][i]=1;
    }
    forn(i,1,n+1){
        forn(j,1,i+1){
            dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
        }
    }
    forn(i,1,k+1){
        ans=dp[k-1][i-1]*dp[n-k+1][i];//we need non empty partitions for k balls, therefore, we have k-1 positions
        //for i-1 partitions, then we have n-k+1 positions to place these i partitions.
        ans%=MOD;
        cout<<ans<<endl;
    }
    return 0;
}

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



//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define ek cout<<1<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
//const ll fx[]={0,1,0,-1};
//const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/

void oka()
{

        ll i,j,k,n,m;
        cin>>n;
        ll dp[11][11];
        memset(dp,0,sizeof dp);
        for(i=1;i<=n;i++)
        {
            k=log10(i);
            k=i/pow(10,k);
            dp[i%10][k]++;
           // cout<<k<<endl;

        }
        ll sum=0;
        for(i=1;i<10;i++)
        {
            for(j=1;j<10;j++)
            {
                sum+=(dp[i][j]*dp[j][i]);

            }
        }
        cout<<sum<<endl;


}












int main()
{
  // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run
    ll t;
    t=1;
  //cin>>t;
    while(t--){

    oka();
    }



}


Measured memory_bytes: 4024
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

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

	int minv = R, maxv = -pow(10, 9);
	n -= 1;
	while (n--)
	{
		cin >> R;
		maxv = max(maxv, R - minv);
		minv = min(minv, R);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <vector>
#include <deque>

std::vector <int> e[110000];
int N, M;
bool vis[110000];
std::deque <int> d;

int main () {
	scanf ("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		int u, v;
		scanf ("%d%d", &u, &v);
		e[u - 1].push_back (v - 1);
		e[v - 1].push_back (u - 1);
	}
	int b = 0;
	d.push_back (b);
	vis[b] = true;
	bool f = true;
	while (f) {
		f = false;
		for (int i = 0; i < e[d.front ()].size (); i++) 
			if (!vis[e[d.front ()][i]]) {
				f = true;
				vis[e[d.front ()][i]] = true;
				d.push_front (e[d.front ()][i]);
				break;
			}
	}
	f = true;
	while (f) {
		f = false;
		for (int i = 0; i < e[d.back ()].size (); i++) 
			if (!vis[e[d.back ()][i]]) {
				f = true;
				vis[e[d.back ()][i]] = true;
				d.push_back (e[d.back ()][i]);
				break;
			}
	}
	printf ("%d\n", (int) d.size ());
	for (int i = 0; i < d.size (); i++)
		printf ("%d%c", d[i] + 1, " \n"[i == d.size () - 1]);
}



Measured memory_bytes: 7040
def main():
    _ = int(input())
    a = list(map(int, input().split()))
    odds = []
    for i in a:
        if i % 2 == 0:
            odds.append(i)

    for i in odds:
        if i % 3 != 0 and i % 5 != 0:
            print("DENIED")
            return

    print("APPROVED")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38484
#include<bits/stdc++.h>
void debug_impl(){std::cerr<<std::endl;}
template<class Head,class...Tail>void debug_impl(Head head, Tail... tail){std::cerr << " " << head;debug_impl(tail...);}
    template<class Container,class Value=typename Container::value_type,std::enable_if_t<!std::is_same<Container,std::string>::value,std::nullptr_t> = nullptr>
std::ostream&operator<<(std::ostream&os,Container const&v)
{os<<"{";for(auto it=v.begin();it!=v.end();it++){os<<(it!=v.begin()?",":"")<<*it;}return os<<"}";}
    template<template<class...>class Tuple,class...Args,std::size_t...Inds,std::size_t=std::tuple_size<Tuple<Args...>>::value>
std::ostream&tuple_output_impl(std::ostream&os,const Tuple<Args...>&tuple,std::integer_sequence<std::size_t,Inds...>)
{os<<"(";(void)std::initializer_list<int>{((void)(os<<(Inds>0?",":"")<<std::get<Inds>(tuple)),0)...};return os<<")";}
    template<template<class...>class Tuple,class...Args,std::size_t=std::tuple_size<Tuple<Args...>>::value>
std::ostream&operator<<(std::ostream&os,const Tuple<Args...>&tuple)
{return tuple_output_impl(os,tuple,std::index_sequence_for<Args...>());}
#define DEBUG 1
#if DEBUG
#define debug(...)do{std::cerr<<std::boolalpha<<"["<<#__VA_ARGS__<<"]:";debug_impl(__VA_ARGS__);std::cerr<<std::noboolalpha;}while(false)
#else
#define debug(...) {}
#endif
long long mod=1'000'000'007;
void add_eq(long long&x, long long y){x+=y;if(mod<=x)x-=mod;}
void sub_eq(long long&x, long long y){x-=y;if(x<0)x+=mod;}
void mul_eq(long long&x, long long y){x=x*y%mod;}
long long pow(long long a, long long b){
    long long ans=1;
    for(;b;b/=2){
        if(b&1ll)ans=ans*a%mod;
        a=a*a%mod;
    }
    return ans;
}
long long inverse(long long a){return pow(a,mod-2);}
int main(){
    int n,k;std::cin>>n>>k;
    k--;
    std::vector<long long>a(n);
    for(int i=0;i<n;i++)std::cin>>a.at(i);
    std::sort(a.begin(),a.end());
    for(long long&x:a)if(x<0)x+=mod;
    long long ans=0,coeff=1;
    for(int i=k;i<n;i++){
        debug(coeff,a.at(i));
        add_eq(ans,coeff*a.at(i)%mod);
        mul_eq(coeff,i+1);
        mul_eq(coeff,inverse(i-k+1));
    }
    std::reverse(a.begin(),a.end());
    coeff=1;
    for(int i=k;i<n;i++){
        debug(coeff,a.at(i));
        sub_eq(ans,coeff*a.at(i)%mod);
        mul_eq(coeff,i+1);
        mul_eq(coeff,inverse(i-k+1));
    }
    std::cout<<ans<<std::endl;
}



Measured memory_bytes: 1024
#include<iostream>
//#include<cmath>
using namespace std;

int main(){
    int a,b,c;
    //cout<<"please input 2 numbers.\n"<<endl;
    cin >>a>>b>>c;
    if ((a<b)&&(b<c)){
        cout<<"Yes"<<endl;
        }else {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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 _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N=in();
  vi v(N);
  vi c(N);
  rep(i,N){
    cin >> v[i];
  }
  rep(i,N){
    cin >> c[i];
  }
  ll val = 0;
  rep(i,N){
    v[i] -= c[i];
    val += max(0,v[i]);
  }
  cout << val << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long 
#define mem(a) memset(a,0,sizeof(a))
#define lb(x) (x&(-x))
const int inf=0x3f3f3f3f;
const int maxn=1e5+5;

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0); 
    std::cout.tie(0);
    int n;cin>>n;
    if(n%1000!=0) cout<<(n/1000+1)*1000-n<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3648
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      
     	boolean approved = true;
      	for(int i = 0 ; i < n ; i++){
      		int a = sc.nextInt();
      		if((a & 1) == 0){
      			if((a % 3) != 0 && (a % 5) != 0){
      				approved = false;
      			}
      		}
        }

        System.out.println(approved ? "APPROVED" : "DENIED");
    }
}

Measured memory_bytes: 23252
from collections import Counter
from functools import reduce
from operator import mul


def comb(n, r):
    """
    scipy.misc.comb または scipy.special.comb と同じ
    組み合わせの数 nCr
    :param int n:
    :param int r:
    :rtype: int
    """
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))


N, M = map(int, input().split())
A = list(map(int, input().split()))

# 累積和 mod M
cumsummod = [0]
cs = 0
for a in A:
    cs += a
    cs %= M
    cumsummod.append(cs)

# cumsummod が同じとこから L と r を選ぶ組み合わせの合計
print(sum([comb(cnt, 2) for cnt in Counter(cumsummod).values() if cnt >= 2]))


Measured memory_bytes: 16792
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int A, P;
	cin >> A >> P;
	cout << (3 * A + P) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 10005
using namespace std;

int n, s, ci, a[N], b[N], c[N], ans[N];
bool v[N];
vector<int> g[N];

void f(int p) {
	int i;
	if (v[p]) return;
	v[p] = 1;
	ans[p] = c[ci]; ci--;
	for (i = 0; i < g[p].size(); i++) f(g[p][i]);
}

int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n - 1; i++) {
		scanf("%d %d", &a[i], &b[i]);
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	for (i = 0; i < n; i++) scanf("%d", &c[i]);
	sort(c, c + n);
	ci = n - 1;
	f(1);
	for (i = 0; i < n - 1; i++) s += min(ans[a[i]], ans[b[i]]);
    cout << s << endl;
    for (i = 1; i <= n; i++) printf("%d ", ans[i]);
    return 0;
}

Measured memory_bytes: 1280
S = input()
mod2019 = [0]*len(S)

mod2019[-1] = int(S[-1])
keta_mod = 1
for i in range(len(S)-2,-1,-1):
    keta_mod = (keta_mod*10)%2019
    mod2019[i] = (mod2019[i+1] + int(S[i])*keta_mod)%2019

mod2019.extend([0])

answer = 0
count = [0 for _ in range(2020)]

for i in range(len(S)+1):
    answer += count[mod2019[i]]
    count[mod2019[i]] += 1
print(answer)


Measured memory_bytes: 16384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int number = input.nextInt();
		String word = input.next();
		String firstHalf = "";
		String secondHalf = "";
		if (word.length()%2 == 0 && number == word.length()) {
			for(int i = 0; i<(number/2); i++) {
				firstHalf = firstHalf + word.charAt(i);
				secondHalf = secondHalf + word.charAt(i+(number/2));
			}
			if (firstHalf.equals(secondHalf)) {
				System.out.println("Yes"); 
			}else {
				System.out.println("No"); 
			}
		}else {
			System.out.println("No");   
		}
    	
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <set>
using namespace std;

static const int NIL = -1;

struct Vertex {
    vector<int> link;
    int parent = NIL;
    int ord;
    int lowlink;
    bool is_visit = false;
};

class ArticulationPoint {
private:
    int n;
    vector<Vertex> graph;
    int timer = 1;

public:
    ArticulationPoint() {}

    ArticulationPoint(int n)
    {
        this->n = n;
        graph.resize(n);
        int edge;
        cin >> edge;
        int s, t;
        for (int e = 0; e < edge; e++)
        {
            cin >> s >> t;
            graph[s].link.push_back(t);
            graph[t].link.push_back(s);
        }
    }

    void dfs(int current)
    {
        graph[current].is_visit = true;
        graph[current].ord = graph[current].lowlink = timer;
        timer++;

        for(int next : graph[current].link)
        {
            if(!graph[next].is_visit)
            {
                graph[next].parent = current;
                dfs(next);
                graph[current].lowlink = min(graph[current].lowlink, graph[next].lowlink); // 3.
            }
            else if(next != graph[current].parent)
            {
                // １回の移動で行くことのできる訪問済みの頂点は，Backedgeを除けば自分の親しかいない
                // つまりこのブロックにくるのはnextがBackedgeを通った訪問済みの頂点のとき
                graph[current].lowlink = min(graph[current].lowlink, graph[next].ord);
            }

        }
    }

    void articulation_point()
    {
        set<int> art_point;
        int root = 0;

        dfs(root);

        int root_child_num = 0;
        for(int u = 0; u < n; u++)
        {
            int p = graph[u].parent;
            if(p == NIL) continue;
            if(p == root)
            {
                root_child_num++;
                if(root_child_num >= 2)
                    art_point.insert(root);
            }
            else if(graph[p].ord <= graph[u].lowlink)
            {
                art_point.insert(p);
            }
        }

        for(int x : art_point)
            cout << x << endl;
    }
};

int main()
{
    int n;
    cin >> n;
    ArticulationPoint articulationPoint(n);
    articulationPoint.articulation_point();
}


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

int main(void)
{
	int N,M,max=100010,h[max],good[max],count=0;
	for(int i=0;i<max;i++)
	{
		good[i]=true;
	}
	int A,B;
	cin>>N>>M;
	for(int i=1;i<=N;i++)
	{
		cin>>h[i];
	}
	for(int i=0;i<M;i++)
	{
		cin>>A>>B;
		if(h[A]<=h[B])good[A]=false;
		if(h[A]>=h[B])good[B]=false;
		
	}
	for(int i=1;i<=N;i++)
	{
		//cout<<i<<" "<<good[i]<<endl;
		if(good[i])count++;
	}
	cout<<count;
}

  

Measured memory_bytes: 4404
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  std::string returnString;
 
  //Read in instructions
  std::string instructions;
  std::cin >> instructions;
  
  //Parse instructions and update returnString
  for (int i = 0; i < instructions.length(); ++i) {
    if (instructions.at(i) == '0') {
      returnString += '0';
    } else if (instructions.at(i) == '1') {
      returnString += '1';
    } else {
      if (returnString.length() == 0) {
        continue;
      } else {
        returnString.pop_back();
      }
    }
  }
  
  //Output final string
  std::cout << returnString << std::endl;
  
}

Measured memory_bytes: 256
#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;
  
  int ans =0;
  int R =sqrt(N-1);
  
  for (int i = 1; i < N; i++) {
    
    int n=N-i;
    int k =0;
    
  
    for (int i = 1; i <= sqrt(n); i++) {
      if(n%i==0){
        k++;
      }
      else{
        k+=0;
      }
    }
    
    k*=2;
    ans += k;
  }
  
  ans -=R;
  cout << ans <<endl;
    
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    string S;
    bool result = 1;

    for (int i = 0; i < N ; i++) {
        cin >> S;
        if (S == "Y"){
            result = 0;
            break;
        }
    }

    if (result){
        cout << "Three" << endl;
    }
    
    else {
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 3568
//In the name of GOD
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define pb push_back
#define Mp make_pair
#define pll pair<ll, ll>
#define F first
#define S second

ll a, b;

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


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

vector<ll> divisor(ll n) {
	vector<ll> div;
	for(ll i=1;i*i<=n;++i) {
		if (n % i == 0) {
			div.push_back(i);
			if (i * i != n)	div.push_back(n/i);
		}
	}
	sort(div.begin(), div.end());
	return div;
}

ll cnt_digit(ll n) {
	return to_string(n).length();
}

int main() {
	ll n;
	cin >> n;
	vector<ll> div = divisor(n);
	ll size_div = div.size();
	ll ans = cnt_digit(n);
	rep(i,size_div) {
		//cout << div[i] << " " << div[size_div-i-1] <<  endl;
		ans = min(ans, max(cnt_digit(div[i]), cnt_digit(div[size_div-1-i])));
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    set<string> str;
    cin >> n;
    while(n--)
    {
        string s;
        cin >> s;
        str.insert(s);
    }
    
    cout << str.size() << endl;
    return 0;
}

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

std::vector<int> *adjacent_vertexes;
char *s;
int n, *max_length, *cnt;
long long ans;

void pre_dfs(int u, int parent) {
	max_length[u] = 0;
	cnt[u] = (s[u] == '1');
	for (int v: adjacent_vertexes[u]) {
		if(v != parent) {
			pre_dfs(v, u);
			max_length[u] = std::max(max_length[v] + 1, max_length[u]);
			cnt[u] += cnt[v];
		}
	}
	return;
}

void dfs(int u, int parent, int max_length_from_parent) {
	#ifdef DEBUG
	printf("dfs(%d, %d, %d)\n", u, parent, max_length_from_parent);
	#endif
	int first_max = 0, second_max = 0, first_max_rem;
	if(~parent) {
		first_max = max_length_from_parent;
		first_max_rem = parent;
	}
	for (int v: adjacent_vertexes[u]) {
		if(v != parent) {
			int tmp = max_length[v] + 1;
			if(tmp > first_max) {
				second_max = first_max;
				first_max = tmp;
				first_max_rem = v;
			}
			else if(tmp > second_max) {
				second_max = tmp;
			}
		}
	}
	int low_bound = n + 1;
	if(cnt[u] != cnt[0]) {
		low_bound = max_length_from_parent;
	}
	for (int v: adjacent_vertexes[u]) {
		if(v != parent) {
			int max_length_from_u = v == first_max_rem ? second_max : first_max, ok = 0;
			if(max_length_from_u >= max_length[v]) {
				if(cnt[v]) {
					ok = 1;
				}
			}
			if(max_length_from_u <= max_length[v]) {
				if(cnt[v] != cnt[0]) {
					ok = 1;
				}
			}
			ans += ok;
			dfs(v, u, max_length_from_u + 1);
			if(cnt[v]) {
				low_bound = std::min(low_bound, max_length[v] + 1);
			}
		}
	}
	if(s[u] == '1') {
		ans += second_max + 1;
	}
	else {
		if(low_bound <= second_max) {
			ans += second_max - low_bound + 1;
		}
	}
	return;
}

int main() {
	scanf("%d", &n);
	adjacent_vertexes = new std::vector<int>[n];
	max_length = new int[n];
	s = new char[n];
	cnt = new int[n];
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		adjacent_vertexes[--u].push_back(--v);
		adjacent_vertexes[v].push_back(u);
	}
	scanf("%s", s);
	pre_dfs(0, -1);
	dfs(0, -1, 0);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 27264
#include<stdio.h>

void scanmatrix(int matrix[100][100], int rows, int columns){
    int i, j;
    for (i = 0; i < rows;i++){
        for (j = 0; j < columns;j++){
            scanf("%d", &matrix[i][j]);
        }
    }
}

void multiple(int a[100][100], int b[100][100], long int c[100][100],int n, int m, int l){
    int i, j, k;
    for (i = 0; i < n;i++){
        for (k = 0; k < l; k++){
            for (j = 0; j < m;j++){
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
}

int main(void){
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);
    int a[100][100];
    int b[100][100];
    long int c[100][100];
    int i, j;
    for (i = 0; i < 100;i++){
        for (j = 0; j < 100;j++){
            c[i][j] = 0;
        }
    }
    scanmatrix(a, n, m);
    scanmatrix(b, m, l);
    multiple(a, b, c, n, m, l);
    for (i = 0; i < n;i++){
        printf("%ld", c[i][0]);
        for (j = 1; j < l; j++)
        {
            printf(" %ld", c[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define SZ(X) ((int)(X).size())

const int m = 1000000007;

int power(int a, int b){
    int ret = 1;
    for(int i = 0; i < b; ++i)ret = ret * a % m;
    return ret;
}

int32_t main(){
    int n;
    cin >> n;
    int ans = power(10, n) - 2*power(9, n) + power(8, n);
    cout << ((ans % m)+m)%m << '\n';
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
     ll n ; cin>>n ;
     ll val = 1 ;

        ll ans = 0 ;
        for( ll i = 0 ; i<n ; i++ ){
            val = ( val%inf * (n-i)%inf  * modexp((i+1),inf-2) )%inf ;
            ll x = (( modexp(9ll,n-i-1) - modexp(8ll,n-i-1) ) + inf  )%inf  ;
            ll y = ( val%inf * x )%inf ;

            ans = (ans%inf + y%inf)%inf ;
        }
     cout<<ans%inf;

  }

 return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
    int N;
  
    scanf("%d",&N);
  
    if(N<10) printf("%d\n",N);
    else if((N>=10)&&(N<100)) printf("9\n");
    else if((N>=100)&&(N<1000)) printf("%d\n",(N-99)+9);
    else if((N>=1000)&&(N<10000)) printf("909\n");
    else if((N>=10000)&&(N<100000)) printf("%d\n",(N-9999)+909);
    else printf("90909\n");
  
    return 0;
}


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

int main(){
  int a, b, c, min, mid, max;
  cin >> a >> b >> c;
  min = a;
  if (min > b){
    min = b; mid = a;
  } else{
    mid = b;
  }
  if (min > c){
    max = mid; mid = min; min = c;
  } else{
    if(mid < c){
      max = c;
    } else{
      max = mid; mid = c;
    }
  }
  cout << min << " " << mid << " " << max << "\n";
}

Measured memory_bytes: 1164
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		Scanner scn = new Scanner(System.in);
		int n=scn.nextInt();
		int ans=n%1000;
		if(ans!=0) {
			ans=1000-ans;
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 27060
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
    //cout.precision(10);
    int n;
    int m;
    cin >> n >> m;
    bool checker[100500];
    for(int i = 0; i <= n; i++){
        checker[i] = true;
    }
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        checker[a] = !checker[a];
        checker[b] = !checker[b];
    }
    for(int i = 1; i <= n; i++){
        if(!checker[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 384
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def multiply_primes(a, b):
    """素因数分解系のCounter型のa, bに対してa*bの素因数分解系を計算する"""
    res = Counter([])
    keys = a.keys() | b.keys()
    for k in keys:
        res[k] = a[k] + b[k]
    return res

N = int(input())

# 答えは N! の約数かつ
# 素因数分解が x^2 y^4 z^4 の形になるもの
# 素因数分解が x^74 の形になるもの
# 素因数分解が x^2 y^24 の形になるもの
# 素因数分解が x^4 y^14 の形になるもの
# しかない

f = Counter([])  # f が N! の素因数分解になる
for n in range(2, N+1):
    f = multiply_primes(f, Counter(prime_factorize(n)))

c2, c4, c14, c24, c74 = 0, 0, 0, 0, 0

for item in f.items():
    k = item[1]
    c2 += (k >= 2)
    c4 += (k >= 4)
    c14 += (k >= 14)
    c24 += (k >= 24)
    c74 += (k >= 74)

ans_2_4_4 = (c4 * (c4 - 1))//2 * (c2 - 2)
ans_74 = c74
ans_2_24 = c24 * (c2 - 1)
ans_4_14 = c14 * (c4 - 1)

ans = ans_2_4_4 + ans_74 + ans_2_24 + ans_4_14
print(ans)


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

int main(){
   ll a, b, k, x, y;
   cin >> a >> b >> k;
   x = a;
   y = b;
   
   if(a>=k) {
      a -= k;
      cout << a << ' ' << b << endl;
   }else{
      k -= a;
      a = 0;
      b -= k;
      if(b<0) b = 0;
      cout << a << ' ' << b << endl;
   }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, a[3];
int l[9];
int ans;
void dfs(int i, int k, int s){
    if(i==3){
        ans=min(ans, s);
        return;
    }
    int r=(1<<n)-1-k;
    if(r==0) return;
    for(int j=r; j>0; j=(j-1)&r){
        int t=0, ct=-10;
        for(int m=0; m<n; m++){
            if(j&(1<<m)){
                t+=l[m]; ct+=10;
            }
        }
        s+=abs(t-a[i]); s+=ct;
        dfs(i+1, k^j, s);
      s-=abs(t-a[i]); s-=ct;
    }
}
int main()
{
    cin>>n>>a[0]>>a[1]>>a[2];
  for(int i=0; i<n; i++) cin>>l[i];
    ans=1e9;
    dfs(0, 0, 0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
main(a,b,c,p,q,r,s,i){for(;scanf("%d%d%d",&a,&b,&c),a;){
	if(!c){
		a==1&&b<0?printf("1 0 %d %d\n",a,b):printf("%d %d 1 0\n",a,b);
		continue;
	}
	for(r=1;r*r<=a;r++)if(a%r==0)
		for(p=a/r,s=1;s<=abs(c);s++)if(c%s==0)
			for(i=0;i<2;i++,s=-s)if(q=c/s,p*s+q*r==b){
				if(p==r&&q<s)printf("%d %d %d %d\n",r,s,p,q);
				else printf("%d %d %d %d\n",p,q,r,s);
				goto next;
			}
	puts("Impossible");
next:;}exit(0);}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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


Measured memory_bytes: 256