akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef vector< vector< int > > Matrix;
int Mod;

Matrix operator*(const Matrix& A, const Matrix& B)
{
  Matrix C(A.size(), vector< int >(B[0].size(), 0));
  for(int i = 0; i < A.size(); i++) {
    for(int k = 0; k < B.size(); k++) {
      for(int j = 0; j < B[0].size(); j++) {
        (C[i][j] += A[i][k] * B[k][j]) %= Mod;
      }
    }
  }
  return(C);
}
Matrix pow_mod(Matrix& A, int N)
{
  Matrix B(A.size(), vector< int >(A.size(), 0));
  for(int i = 0; i < A.size(); i++) B[i][i] = 1;
  while(N > 0) {
    if(N & 1) B = B * A;
    A = A * A;
    N >>= 1;
  }
  return(B);
}

int main()
{
  int N, A, B, C, T;
  while(cin >> N >> Mod >> A >> B >> C >> T, N) {
    Matrix x(N, vector< int >(N, 0)), y(N, vector< int >(1));
    for(int i = 0; i < N; i++) if(i > 0) x[i][i - 1] = A;
    for(int i = 0; i < N; i++) x[i][i] = B;
    for(int i = 0; i < N; i++) if(i + 1 < N) x[i][i + 1] = C;
    for(int i = 0; i < N; i++) cin >> y[i][0];
    x = pow_mod(x, T) * y;
    for(int i = 0; i < N; i++) cout << x[i][0] << (i != N - 1 ? " ": "\n");
  }
  
}

Measured memory_bytes: 1272
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
	// "strings"
)

var sc = bufio.NewScanner(os.Stdin)

// スライス内に指定した要素があるか判定
// 第1引数 : 要素, 第2要素 : スライス
// return : result, err
func contains(target interface{}, list interface{}) (bool, error) {
	switch list.(type) {
		case []int:
			revert := list.([]int)
			for _, r := range revert {
				if target == r {
					return true, nil
				}
			}
			return false, nil
			
		case []uint64:
			revert := list.([]uint64)
			for _, r := range revert {
				if target == r {
					return true, nil
				}
			}
			return false, nil
			
		case []string:
			revert := list.([]string)
			for _, r := range revert {
				if target == r {
					return true, nil
				}
			}
			return false, nil
		default:
			return false, fmt.Errorf("%v is an unsupported type", reflect.TypeOf(list))
	}

	return false, fmt.Errorf("processing failed")
}

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	str := []byte(nextLine())
	// var out_str string
	for i := 65; i <= 90;i++ {
		if int(str[0]) == i {
			fmt.Println("A")
			return
		}
	}
	fmt.Println("a")
}

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

int main(void)
{
	int X, Y;
	
	cin >> X >> Y;
	
	int turu, kame;
	
	for(int turu = 0; turu <= X; turu++)
	{
		for(int kame = 0; kame <= X; kame++)
		{
			int legs = 2 * turu + 4 * kame;
			
			if((legs == Y) && ((kame + turu) == X))
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		// int n=sc.nextInt();
		// int k=sc.nextInt();
		int a[]=new int[3];
		int b[]=new int[3];
		int c[]=new int[4];
		for(int i=0;i<3;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[a[i]-1]++;
			c[b[i]-1]++;
		}
		Arrays.sort(c);
		
		System.out.println(c[0]==1&&c[1]==1&&c[2]==2&&c[3]==2?"YES":"NO");
	
		
	}	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





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

int main(void){
    ll n;
    cin>>n;
    double a=sqrt((double)n);
    ll N=(ll)a;
    ll m=0;
    for(ll i=1;i<=N;i++){
        if(n%i==0) m=i;
    }
    ll ans=(m+n/m-2);
    cout<<ans<<endl;
}

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

namespace Atcoder
{
    public class Program
    {
        private static List<List<Tuple<int, int>>> l = new List<List<Tuple<int, int>>>();
        private static List<int> ans = new List<int>();

        static void Main(string[] args)
        {
            var n = Read().ToInt32();
            for (int i = 0; i < n; i++)
            {
                l.Add(new List<Tuple<int,int>>());
                ans.Add(0);
            }
            for (int i = 0; i < n - 1 ; i++)
            {
                var r = ReadSplit();
                var a1 = r[0].ToInt32() - 1;
                var a2 = r[1].ToInt32() - 1;
                l[a1].Add(new Tuple<int, int>(i, a2));
                l[a2].Add(new Tuple<int, int>(i, a1));
            }
            
            Write(l.Max(x => x.Count));
            Dfs(0, -1, -1);
            for (int i = 0; i < ans.Count -1; i++)
            {
                Write(ans[i]);
            }
            Read();
        }

        private static void Dfs(int s ,int from, int color)
        {
            var d = l[s];
            var c = 1;
            foreach (var item in d)
            {
                if (from == item.Item2) continue;
                if (color == c) c++;
                ans[item.Item1] = c;
                c++;
                Dfs(item.Item2, s, ans[item.Item1]);
            }
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 35992
#include<stdio.h>
int main( )
{
    long long int a , b , c , d ;
    scanf("%lld%lld%lld%lld" , &a , &b , &c , &d) ;
    
    long long int num[100] , i=0 , j , max;
    
    num[i] = a*c ;
    i++ ;
    max = num[0] ;
    
    num[i] = a*d ;
    i++ ;
    num[i] = b*c ;
    i++ ;
    num[i] = b*d ;
    
    j = ++i ;
    
    for( i = 0 ; i < j ; i++)
    {
        if( max < num[i])
            max = num[i] ;
    }
    
    printf("%lld\n" , max);
    
    return 0 ;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, cnt = 0;
    cin >> n;
    string s;
    cin >> s;
    if (n >= 2) {
        for (int i = 0; i <= n-3; i++) {
            if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n, d; cin >> n >> d;
  int x[20][20] = {};
  rep(i, n) rep(j, d) cin >> x[i][j];

  int ans = 0;
  rep(i, n-1) {
    for(int j = i+1; j < n; ++j) {
      int dist = 0;
      rep(k, d) {
        int tmp = abs(x[i][k]-x[j][k]);
        dist += tmp*tmp;
      }
      if(sqrt(dist) == (int)sqrt(dist)) ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;


int main(){
	int h,w,n;cin >> h >> w >> n;
	vector<int> a(n),b(n);
	map<P,int> mp;
	int dy[9] = {-2,-2,-2,-1,-1,-1,0,0,0};
	int dx[9] = {-2,-1,0,-2,-1,0,-2,-1,0};
	rep(i,n) {
		cin >> a[i] >> b[i];
		--a[i];--b[i];
		for(int j = 0;j < 9;j++){
			int ny = a[i]+dy[j];
			int nx = b[i]+dx[j];
			if(ny < 0 || nx < 0 || ny >= h-2 || nx >= w-2) continue;
			P p = make_pair(ny,nx);
			//cout << ny << " " << nx << endl;
			mp[p]++;
		}
	}
	vector<ll> ans(10,0);
	for(auto p:mp){
		//cout << p.first.first << " " << p.first.second << endl;
		ans[p.second]++;
	}
	ans[0] = ll(h-2)*ll(w-2);
	rep(i,9) ans[0] -= ans[i+1];
	rep(i,10) cout << ans[i] << endl;

	
} 


Measured memory_bytes: 60164
#include <stdio.h>
int fibonacci(int);
int f[44];
int main(){
  int n,i;

  for(i=0;i<44;i++) f[i]=0;
  scanf("%d",&n);
  fibonacci(n);
  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n){
  if(n==0 ||n==1) return f[n]=1;
  if(f[n]!=0) return f[n];
  return f[n]=fibonacci(n-1)+fibonacci(n-2);
}



Measured memory_bytes: 2112
#include <iostream>

int main()
{
  using namespace std;
  long long int IN = 0;
  long long int Total = 0;
  cin >> IN;
  for (long long int i = 1; i <= IN; i++)
  {
    if (i % 15 != 0 && i % 3 != 0 && i % 5 != 0)
    {
      Total += i;
      // cout << i << endl;
      // cout << "Total = " << Total << endl;
    }
  }
  // cout << IN << endl;
  cout << Total << endl;
  return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 1; i <= n; i++) if (s.substr(0, i) == s.substr(i)) {
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

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

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

using namespace std;
int main(){
  string s;
  cin >> s;

  int iCnt=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='2')iCnt++;
  }
  cout << iCnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    char s;
    cin >> s;
    if(s =='a' || s == 'e' || s == 'i' ||s == 'o' || s == 'u' ){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());//get the given number
            for(int i = 1; i < input+1; i++)//process for integer i under input+1
            {
                if (i % 3 == 0)
                {
                    Console.Write(" " + i);
                    continue;
                }
                char[] i0 = i.ToString().ToCharArray();
                int[] i1 = new int[i0.Length];
                for (int cycle = 0; cycle < i0.Length; cycle++)
                {
                    i1[cycle] = int.Parse(i0[cycle].ToString());
                    if (i1[cycle] == 3)
                    {
                        Console.Write(" " + i);
                        break;
                    }
                }

            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15972
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    double a, b, C, S, L, h;
    double PI = acos(-1);
    cin >> a >> b >> C;
    C = C*PI /180;
    h = b*sin(C);
    S = a*h/2;
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(C));
    cout << fixed << S << endl << fixed << L << endl << fixed << h << endl;
    
    return 0;
}


Measured memory_bytes: 3496
//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <bitset>
# include <queue>
# include <cstring>
# include <map>
# include <set>


#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
        
    int a[10005];
    int N;
    cin >> N;
    
    for(int i = 0; i < N+1; i++) a[i] = 0;
    
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                if(i*i+j*j+k*k+i*j+j*k+i*k <= 10000){
                    a[i*i+j*j+k*k+i*j+j*k+i*k]++;
                }
            }
        }
    }
    
    for(int i = 1; i < N+1; i++){
        cout << a[i] << "\n";
    }
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[100][100];
int main()
{
    int t,b;
    scanf("%d%d",&t,&b);
    for(int i=0;i<t;i++)
        cin>>a[i];
        bool flag=true;
    for(int i=0;i<b;i++)
    {
        for(int j=0;j<b;j++)
        {
            if(a[i][j]=='#' && a[i-1][j]!='#' && a[i+1][j]!='#' && a[i][j-1]!='#' && a[i][j+1]!='#')
                {
                    flag=false;
                    break;
                }
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;

class UnionFind {
private:
    vector<vector<int>> Graph; // {ID,Number,ParentID,Height}

    void flatten(int x, int rootid) {
        int parentid = Graph[x][0];
        while (Graph[parentid][0] != Graph[parentid][2]) {
            Graph[parentid][2] = rootid;
            int next = Graph[parentid][2];
            parentid = next;
        }
    }
public:
    void push(int x) {
        int i = Graph.size();
        Graph.push_back({ i,x,i,1 });
    }
    void unite(int x, int y) {
        int hx = Graph[root(x)][3];
        int hy = Graph[root(y)][3];
        if (hx < hy) {
            Graph[root(x)][2] = root(y);
            flatten(x, root(y));
        }
        else if(hx == hy){
            Graph[root(y)][2] = root(x);
            Graph[root(x)][3]++;
            flatten(y, root(x));
        }
        else {
            Graph[root(y)][2] = root(x);
            flatten(y, root(x));
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }

   
    int root(int x) {
        int parentid = Graph[x][0];
        while (Graph[parentid][0] != Graph[parentid][2]) {
            int next = Graph[parentid][2];
            parentid = next;
        }
       
        return parentid;
    }
};

int sub(int n, int m) {

    vector<vector<int>> edges; // {weight, from_id, to_id} both 0-indexed

    for (int i = 0; i < m; i++) {
        int a, b, cost; cin >> a >> b >> cost;
        edges.push_back({ cost,a,b });
    }

    sort(ALL(edges));
    int n_edges = 0;
    int TotalCost = 0;

    UnionFind uf;
    for (int i = 0; i < n; i++) uf.push(i);

    for (int i = 0; n_edges < n - 1; i++) {
        vector<int> edge = edges[i];
       
        if (uf.root(edge[1]) != uf.root(edge[2])) {
            uf.unite(edge[1], edge[2]);
            n_edges++;
            TotalCost += edge[0];
        }
    }


    return TotalCost;
}

int main() {
    int n, m;
    vector<int> ans;
    while (true) {
        cin >> n >> m;

        if (n == 0 && m == 0) {
            break;
        }
        else {
            ans.push_back(sub(n, m));
        }
    }

    for (int elem : ans) {
        cout << elem << endl;
    }
}


Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>

main(){

  int i, j;
  int n,q;
  int process[1000];
  char name[1000][11];
  int tmp, elapsed;
  char tmps[11];
  int finishFlag;

  scanf("%d %d",&n,&q);
  for(i=0; i<n; i++){
    scanf("%s %d",name[i],&process[i]);
  }

  elapsed = 0;
  for(i=0; n>0; i++){
    finishFlag = 0;

    // process
    process[0] -= q;
    elapsed += q;
    if(process[0] <= 0){
      elapsed = elapsed+process[0];
      printf("%s %d\n",name[0],elapsed);
      finishFlag = 1;
    }

    // go to end of queue
    tmp = process[0];
    strcpy(tmps,name[0]);
    for(j=1; j<n; j++){
      process[j-1] = process[j];
      strcpy(name[j-1],name[j]);
    }
    process[n-1] = tmp;
    strcpy(name[n-1],tmps);

    if(finishFlag){
      n--;
    }

  }

}

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

using namespace std;

int main() 
{
    int N,K;
    cin >> N;
    cin >> K;
    
    vector<int> p;
    for(int i=0;i<N;++i)
    {
        int a;
        cin >> a;
        p.push_back(a);
    }

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

    int sum = 0;
    for(int i =0;i<K;++i)     
    {
        sum += p[i];
    }

    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 3604
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

set<int>ev,od;
int x;
int a[M+4];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>x;
        a[i]=x;
        if(i%2==1)od.insert(x);
    }
    sort(a+1,a+n+1);
    int ses=0;
    f(i,1,n)
    {
        if(i%2==0)
        {
            if(od.find(a[i])!=od.end())ses++;
        }
    }
    cout<<ses<<endl;
    return 0;

}













Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 1 + 1e18;
const ll MAX = 5+ 100;

int N,K,a[MAX],dp[100005];


int main()
{
    cin >> N >> K;
    for(int i=1;i<=N;i++)
        cin >> a[i];
    for(int i=1;i<=K;i++)
    {
        for(int j=1; i - a[j] >=0 && j<=N;j++)
            if( dp[i - a[j]] == 0 )
        {
            dp[i] = 1;
            break;
        }
    }
    cout << ( dp[K] ? "First" : "Second" ) << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(x);
llin(a);
sal(x<a?0:10)
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> memo(21, Vec(pow2(21), -LINF));
ll n;
Vec2<ll> a;

ll f(ll m, ll b){
	if(m == n) return 1;
	if(memo[m][b] != -LINF) return memo[m][b];
	bitset<21> bit(b);
	ll res = 0;
	rep(i, n){
		if(bit[i] && a[m][i]){
			bit[i] = 0;
			res += f(m+1, bit.to_ullong());
			bit[i] = 1;
		}
	}
	return memo[m][b] = res%MOD;
}

int main(void){
	cin >> n;
	a.resize(n);
	rep(i, n) a[i].resize(n);
	rep(i, n) rep(j, n) cin >> a[i][j];

	co(f(0, pow2(n)-1));

	return 0;
}


Measured memory_bytes: 360832
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

//解説参考.
int main(){
	int n,a[3];
	cin>>n;
	REP(i,3) cin>>a[i];
	
	vector<string> s(n);
	REP(i,n) cin>>s[i];
	
	vi ans(n);
	REP(i,n){
		int p=s[i][0]-'A';
		int q=s[i][1]-'A';
		
		if(a[p]==0 and a[q]==0){
			cout<<"No"<<endl;
			return 0;
		}
		
		int tmp;
		if(a[p]==0) tmp=p;
		else if(a[q]==0) tmp=q;
		else if(a[p]==1 and a[q]==1){
			if(i==n-1) tmp=p;
			else{
				int pp=s[i+1][0]-'A';
				int qq=s[i+1][1]-'A';
				if(pp==p or qq==p) tmp=p;
				else tmp=q;
			}
		}else{
			if(a[p]<a[q]) tmp=p;
			else tmp=q;
		}
	
		a[tmp]++;
		a[p+q-tmp]--;
		ans[i]=tmp;
	}
	
	cout<<"Yes"<<endl;
	REP(i,n) cout<<char('A'+ans[i])<<endl;
}

Measured memory_bytes: 6692
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;

int main() {
ll x,y,a,b,c;
cin >> x >> y >> a >> b >> c;
vector<ll> p(a),q(b),r(c);
REP(i,a) {
  cin >> p[i];
}
REP(i,b) {
  cin >> q[i];
}
REP(i,c) {
  cin >> r[i];
}
sort(ALL(p),greater<ll>());
sort(ALL(q),greater<ll>());
sort(ALL(r),greater<ll>());
ll ans=0;
vector<ll> an;
REP(i,x) {
  an.push_back(p[i]);
}
REP(i,y) {
  an.push_back(q[i]);
}

sort(ALL(an));
int j=0;
while(1) {
  if(an[j]<r[j]) {
    an[j]=r[j];
  } else {
    break;
  }
  j++;
}
REP(i,x+y) {
  ans+=an[i];
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 4724
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.io.PrintWriter;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();

        if(A+B-1>N || A*B<N){
            System.out.println(-1);
            return;
        }

        List<Long> ansList = new ArrayList<>();
        long n=0,m=0,l=0;
        for(int i=1;i<=N;++i){
            if(N-i*B <= (A-i-1)+B){
                n=i;
                m=A-i-1;
                l=N-n*B-m;
                break;
            }
        }



        for(long i=0;i<n;++i){
            for(long j=B;j>0;--j)ansList.add(i*B+j);
        }
        for(long i=n*B+l;i>n*B;--i)ansList.add(i);
        for(long i=n*B+l+1;i<=N;++i)ansList.add(i);
        PrintWriter pw = new PrintWriter(System.out);
        for(int i=0;i<N;++i)pw.print(ansList.get(i)+(i==N-1 ? "\n":" "));
        pw.flush();pw.close();
    }
}

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

int main() {
  int x, n;
  cin >> x >> n;
  set<int> p;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    p.insert(y);
  }

  int diff = 0;
  while (p.count(x + diff) && p.count(x - diff)) {
    diff++;
  }

  if (!p.count(x-diff)) cout << x - diff << endl;
  else cout << x + diff << endl;

  return 0;
}

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

using namespace std;

int main() {
  int A[5], k;
  for (int i=0; i<5; i++) cin >> A[i];
  cin >> k;
  
  if (A[4] - A[0] > k) {
      cout << ":(";
      return 0;
  }
  
  cout << "Yay!";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 int i, j;
 for(i = 1;i < 10;i++){
  for(j = 1; j < 10;j++){
    printf("%dx%d=%d\n",i,j,i*j);
  }
 }

 return 0; 
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


int N, W;
const int MAX_N = 105;
const int MAX_V = 100005;
int w[MAX_N];
ll v[MAX_N];
ll dp[MAX_N][MAX_V];

void solve() {
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N)rep(j, MAX_V) dp[i][j] = INF;

    dp[0][0] = 0;
    rep(i, N+1){
        rep(j, MAX_V+1){
            if(j-v[i] < 0){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            }
        }
    }
    int res=0;
    rep(i, MAX_V) if(dp[N][i] <= W) res = i;
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.1415926535897932384626
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int r;
    cin >> r;
    cout << fixed << setprecision(10);
    cout << 2*r*PI;
}

Measured memory_bytes: 3740
import numpy as np

N = int(raw_input())
W = map(int, raw_input().split())

total = sum(W)

ans = total

total_r = total
total_l = 0
for i in range(N):
        total_r = total_r - W[i]
        total_l = total_l + W[i]
        ans_temp = np.abs(total_r - total_l)
        if ans > ans_temp:
                ans = ans_temp

print ans


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

int main() {
    int n, k; cin >> n >> k;
    int sum[n + 1] = {0};
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        sum[a - 1]++;
    }
    int tot = accumulate(sum, sum + n, 0);
    sort(sum, sum + n);
    reverse(sum, sum + n);
    int cnt = 0, t = 0;
    for (int i = 0; i < n; i++) {
        if (cnt < k) { 
            t += sum[i];
            cnt++;
        }
    }
    int ans = tot - t; 
    cout << ans << endl;
}

Measured memory_bytes: 1024
# @author 

import sys

class RWalk:
    def solve(self):

        MOD = 10 ** 9 + 7

        def mult(A, B):
            n, m, p = len(A), len(A[0]), len(B[0])
            assert(len(B) == m)
            C = [[0] * p for _ in range(n)]
            for i in range(n):
                for j in range(p):
                    for k in range(m):
                        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD

            return C

        def pow(A, k):
            n, m = len(A), len(A[0])
            if k == 0:
                return [[1 if i == j else 0 for j in range(m)] for i in range(n)]

            if k % 2 == 0:
                return pow(mult(A, A), k // 2)

            return mult(A, pow(A, k - 1))


        n, k = [int(_) for _ in input().split()]
        a = []
        for i in range(n):
            a.append([int(_) for _ in input().split()])

        print(sum([sum(line) for line in pow(a, k)]) % MOD)

solver = RWalk()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 42732
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[3*n];
	for(int i=0; i<3*n; i++) cin >> a[i];
	sort(a, a+3*n, greater<ll>());
	ll ans=0;
	for(int i=1; i<=2*n-1; i+=2) ans+=a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
   using namespace std;
     
	 int main() {
	 int n,s;
	 char z;
	 bool card[5][15]={false};
	 cin>>n;
	 for(int i=0;i<n;i++){
		 cin>>z>>s;
		 if(z=='S'){
			 card[0][s]=true;
		 }else if(z=='H'){
			 card[1][s]=true;
		 }else if(z=='C'){
			 card[2][s]=true;
		 }else{
			 card[3][s]=true;
		 }
	 }

	 for(int i=0;i<4;i++){
		 for(int j=1;j<=13;j++){
			 if(card[i][j]==false){
				 if(i==0){
					 cout<<"S "<<j<<endl;
				 }else if(i==1){
					 cout<<"H "<<j<<endl;
				 }else if(i==2){
					 cout<<"C "<<j<<endl;
				 }else{
					 cout<<"D "<<j<<endl;
				 }
			 }
		 }
	 }
   return 0;
   }
 


Measured memory_bytes: 3076
#include <iostream>
#include <string>
//#include <algorithm>
using namespace std;

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

  int len = (int)(c.length());

  int value = 0;
  int tmpValue = 0;

  for(int i = 0; i < len; i++){
    if(c[i] == 'A' || c[i] == 'T' || c[i] == 'C' || c[i] == 'G'){
      tmpValue++;
    }else{
      value = max(value, tmpValue);
      tmpValue = 0;
    }
  }

  value = max(value, tmpValue);

  cout << value << endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <numeric>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	int i, j, a, b;
	int lhs = 0;
	int rhs = n;
	int cnt = 0;
	for (i = 0; i < n; i++) {
		a = x[i];
		for (j = i; j < n; j++) {
			if (a != x[j]) {
				b = x[j];
				break;
			}
			lhs++;
			rhs--;
		}
		if (lhs == rhs) {
			cnt = 1 + (b - a - 1);
			break;
		}
		if (lhs > rhs) {
			break;
		}
		i = j - 1;
	}

	cout << cnt << endl;
	return(0);
}





Measured memory_bytes: 640
use std::cmp::min;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let input = read::<String>();
    let ans = input.chars().fold(0,|x,y| {
        match y {
            'o' => x + 1,
            _ => x,
        }
    });
    println!("{}",700 + 100 *ans);
}

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

using namespace std;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    
    int a, b, c, k, res = 0, ans = 0;
    cin >> a >> b >> c >> k;
    res = max(a, max(b, c));
    ans = a + b + c + (res * ((1 << k ) - 1));
    cout << ans;
}

Measured memory_bytes: 3628
import numpy as np
from numba import njit

n = int(input())
a = list(map(int, input().split()))
MAX = 10 ** 6

nums = np.zeros(MAX + 1, np.int64)
for e in a:
    nums[e] += 1


@njit
def solve(nums):
    mx = 0
    for i in range(2, MAX + 1):
        cnt = nums[i::i].sum()
        mx = max(mx, cnt)

    return mx


mx = solve(nums)

if nums[1] == n:
    ans = "pairwise"
elif mx == n:
    ans = "not"
elif mx == 1:
    ans = "pairwise"
else:
    ans = "setwise"

ans += " coprime"

print(ans)


Measured memory_bytes: 209044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int f[4];

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	FOR(i,0,3){
		int a=read()-1,b=read()-1;
		f[a]++;f[b]++;
	}
	int a=0,b=0;
	FOR(i,0,4){
		if(f[i]==1)a++;
		if(f[i]==2)b++;
	}
	if(a==2&&b==2)Tone("YES")
	else Tone("NO")
	return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().trim.toInt
  var root: Node = null
  val buff = ListBuffer.empty[String]
  case class Node(key: Int, var parent: Node, var left: Node, var right: Node){
    private def getDefaultKey(p: Node) = if(p == null) -1 else p.key
    override def toString: String = s"Node($key, ${getDefaultKey(parent)} ${getDefaultKey(left)} ${getDefaultKey(right)})"
  }
  
  (0 until n).foreach { _ =>
    val command = StdIn.readLine()
    command.split(' ') match {
      case Array("insert", key) => insert(Node(key.toInt, null, null, null))
      case _ => {
        // print
        inorder(root)
        buff += f"%n"
        preorder(root)
        buff += f"%n"
      }
    }
  }
  
  
  def insert(z: Node) = {
    var y:Node = null
    var x:Node = root
    while(x != null){
      y = x
      if(z.key < x.key){
        x = x.left
      } else {
        x = x.right
      }
    }
    z.parent = y
    
    if(y == null){
      root = z
    } else if(z.key < y.key){
      y.left = z
    } else {
      y.right = z
    }
  }
  
  def preorder(n: Node): Unit = {
    buff += " " + n.key
    if(n.left != null) preorder(n.left)
    if(n.right != null) preorder(n.right)
  }

  def inorder(n: Node): Unit = {
    if(n.left != null) inorder(n.left)
    buff += " " + n.key
    if(n.right != null) inorder(n.right)
  }
  
  print(buff.mkString(""))
}


Measured memory_bytes: 488220
#include<stdio.h>
const int Tmax = 3000;
int mmax(int a,int b){
  if(a>b) return a;
  return b;
}
int dp1[3000][3000];
int dp2[3000][3000];
int N,T,A[3000],B[3000];
int main(){
  int i,j,ans,tmp;
  scanf("%d%d",&N,&T);
  for(i=0;i<N;i++){
    scanf("%d%d",A+i,B+i);
  }
  
  for(j=0;j<A[0];j++){
    dp1[0][j] = 0;
  }
  for(;j<T;j++){
    dp1[0][j] = B[0];
  }
  for(i=1;i<N;i++){
    for(j=0;j<A[i];j++){
        dp1[i][j] = dp1[i-1][j];
    }
    for(;j<T;j++){
      dp1[i][j] = mmax(dp1[i-1][j],dp1[i-1][j-A[i]]+B[i]);
    }
  }
  
  for(j=0;j<A[N-1];j++){
    dp2[N-1][j] = 0;
  }
  for(;j<T;j++){
    dp2[N-1][j] = B[N-1];
  }
  for(i=N-2;i>=0;i--){
    for(j=0;j<A[i];j++){
        dp2[i][j] = dp2[i+1][j];
    }
    for(;j<T;j++){
      dp2[i][j] = mmax(dp2[i+1][j],dp2[i+1][j-A[i]]+B[i]);
    }
  }
  ans = 0;
  for(i=0;i<N;i++){
    if(i==0) tmp = dp2[1][T-1];
    else if(i==N-1) tmp = dp1[N-2][T-1];
    else{
      tmp = 0;
      for(j=0;j<T;j++){
        tmp = mmax(tmp,dp1[i-1][j]+dp2[i+1][T-1-j]);
      }
    }
    ans = mmax(ans,tmp+B[i]);
  } 
  printf("%d",ans);
}

Measured memory_bytes: 70528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100005
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);
  int q;
  scanf("%d", &q);
  int t, f;
  char c;

  int si = strlen(s);

  char head[2*MAX] , rear[2*MAX];
  int hi = 2*MAX-1, ri = 0;
  int rev = 0;

  rep(i, 0, q) {
    scanf("%d", &t);
    if ( t == 1 ) rev = abs(rev-1);
    else {
      scanf("%d %c", &f, &c);
      if ( f == 1 ) {
        if ( rev ) { // 反転している
          rear[ri++] = c;
        } else {
          head[hi--] = c;
        }
      } else {
        if ( rev ) { // 反転している
          head[hi--] = c;
        } else {
          rear[ri++] = c;
        }
      }
    }
  }
  if ( rev ) {
    for ( int i = ri-1; i >= 0; i-- ) 
      printf("%c", rear[i]);
    for ( int i = si-1; i >= 0; i-- ) 
      printf("%c", s[i]);
    for ( int i = 2*MAX-1; i > hi; i-- ) 
      printf("%c", head[i]);
  } else {
    for ( int i = hi+1; i < 2*MAX; i++ ) 
      printf("%c", head[i]);
    for ( int i = 0; i < si; i++ ) 
      printf("%c", s[i]);
    for ( int i = 0; i < ri; i++ ) 
      printf("%c", rear[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += (N - 1) / i;
	}
	cout << ans;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<bool> visited(n);

    function<void(int)> dfs = [&](int v) {
        visited[v] = true;
        for (int a : adj[v]) {
            if (!visited[a]) {
                dfs(a);
            }
        }
    };

    int cnt1 = 0, cnt2 = 0;
    dfs(0);
    for (int i = 0; i < n; i++) {
        if (visited[i]) cnt1++;
    }
    dfs(1);
    for (int i = 0; i < n; i++) {
        if (visited[i]) cnt2++;
    }
    cnt2 -= cnt1;
    int rem = n - (cnt1 + cnt2);
    (cnt1 >= cnt2 ? cnt1 : cnt2) += rem;
    long long es = 1ll * cnt1 * (cnt1 - 1) / 2 + 1ll * cnt2 * (cnt2 - 1) / 2;
    cout << es - m << endl;
}

Measured memory_bytes: 10368
N=int(input())
MOD=10**9+7
if N==1:
    print(0)
else:
    a=pow(9,N)
    b=pow(9,N)
    c=pow(8,N)
    Ans=a+b-c
    ans=pow(10,N)-Ans
    print(ans%MOD)

Measured memory_bytes: 12164