akhauriyash/Code-Regression huggingface dataset:
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()

        spl := intSprit(line)

        if spl[1]%spl[0] == 0 {
                fmt.Println(spl[0] + spl[1])
        } else {
                fmt.Println(spl[1] - spl[0])
        }

}


Measured memory_bytes: 640
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int c[200][200];
int t[200][200];
int n,m;


void wf(){
    rep(k,m){
        rep(i,m){
            rep(j,m){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
                t[i][j]=min(t[i][j],t[i][k]+t[k][j]);

            }
        }
    }
}


int main(){
    while(cin>>n>>m){
        rep(i,200){
            rep(j,200){
                if(i==j){
                    c[i][j]=0;
                    t[i][j]=0;
                }
                else{
                    c[i][j]=INF;
                    t[i][j]=INF;
                }
            }
        }
        
        if(n==0 && m==0)break;
        
        rep(i,n){
            int a,b,z,d;
            cin>>a>>b>>z>>d;
            a--;b--;
            c[a][b]=z;
            c[b][a]=z;
            t[a][b]=d;
            t[b][a]=d;
        }
        wf();
        int k;
        cin>>k;
        rep(i,k){
            int p,q,r;
            cin>>p>>q>>r;
            if(r==0){
                cout<<c[p-1][q-1]<<endl;
            }
            else{
                cout<<t[p-1][q-1]<<endl;
            }
        }
        
    }

    return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int res = 0;
    for(int num = 0; num <= N; num++){
        string num_str = to_string(num);

        int tmp = 0;
        for(char n: num_str){
            tmp += (int)(n - '0');
        }
        if(A <= tmp &&  tmp <= B)res += num;
    }

    cout << res << endl;

}

Measured memory_bytes: 256
def onaji(n):
    l = []
    while n > 0:
        l.append(n%10)
        n = n//10
    if l[0] == l[1] == l[2]:
        return True
    else:
        return False
    
N = int(input())
while not(onaji(N)):
    N += 1
    
print(N)

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

typedef long long int64;
#define REP(i,n) for(int64 i=0;i<(int64)(n);i++)
#define REPD(i,n) for(int64 i=(int64)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int64 i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int64)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define GSORT(x) sort(ALL(x), greater<int64>());
#define SUM(x) accumulate(ALL(A), 0);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

void Main()
{
	int N;
	cin>>N;
	string result="No";
	vector<int> digits={N/100,(N%100)/10,(N%10)};
	for (int i = 0; i < digits.size(); ++i) {
		if(digits[i]==7)
			result="Yes";
	}
	cout<<result<<endl;

	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3660
def main():
    N, M = map(int, input().split())
    d = {}
    l = []
    for i in range(M):
        p, y = map(int, input().split())
        if p in d:
            d[p].append((y, i))
        else:
            d[p] = [(y, i)]
        l.append((p, y))
    d2 = {}
    for i in d:
        t = d[i]
        t.sort(key= lambda x: x[0])
        for y, v in enumerate(t, start=1):
            d2[(i, v[0])] = y
    for i in l:
        print(str(i[0]).zfill(6) + str(d2[i]).zfill(6))
main()


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

int main() {
  
  int A = 0, B = 0;
  
  cin >> A >> B;
  
  int ans = 0;
  int outlet = 1;
  
  while( outlet < B ) {
    
    --outlet;
    
    outlet += A;
    
    ++ans;
    
  }
  
  cout << ans << endl;
 
  return 0;
  
}


Measured memory_bytes: 256
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var abc = new int[3];
        for (int i = 0; i < 3; i++) abc[i] = int.Parse(line[i + 1]);
        var ans = getAns(n, abc);
        Console.WriteLine(ans);
    }
    static int getAns(int n, int[] abc)
    {
        var bam = new int[n];
        for (int i = 0; i < n; i++) bam[i] =  int.Parse(Console.ReadLine().Trim());
        var q = new Queue<string>();
        q.Enqueue("");
        var ans = int.MaxValue;
        while (q.Count() > 0)
        {
            var w2 = q.Dequeue();
            if (w2.Length == n)
            {
                var a = getAns2(w2, n, abc, bam);
                if (a != -1) ans = Min(ans, a);
            }
            else
            {
                for (int i = 0; i < 4; i++)
                    q.Enqueue(w2 + i.ToString());
            }
        }
        return ans;
    }
    static int getAns2(string s, int n, int[] abc, int[] bam)
    {
        var g = new int[3];
        var g2 = new int[3];
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(s[i].ToString());
            if (w <= 2) { g[w] += bam[i]; g2[w]++; }
        }
        var ans = 0;
        for (int i = 0; i < 3; i++)
        {
            if (g2[i] == 0) return -1;
            ans += (g2[i] - 1) * 10 + Abs(abc[i] - g[i]);
        }
        return ans;
    }
}

Measured memory_bytes: 23644
#include <stdio.h>
#include <math.h>
int main(void){
    while(1){
    int n,i;
    int S[1000];
    int sum=0;
    double sumsum=0;
    double ave,a;
    
    scanf("%d",&n);
    
    
    if(n==0){
        break;
        
    }
    
    else {
    
    for(i=1;i<=n;i++){
        scanf("%d",&S[i]);
    
        sum+=S[i];
    }
    
    ave=(double)sum/(double)n;
    
    for(i=1;i<=n;i++){
        a=(double)S[i]-ave;
        
        sumsum+=a*a;
        
    }
    
    printf("%f\n",sqrt(sumsum/n));
    }
        
}   
    
    
}



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

int main() {
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  if (K%2 == 1 && B-A < 1000000000000000000) {
    cout << B-A <<endl;
  }
  else if (A-B < 1000000000000000000) {
    cout << A-B <<endl;
  }
  else {
    cout << "unfair" <<endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  if(n<=999){
    cout << "ABC" << endl;
  }
  else{
    cout << "ABD" << endl;
  }
}


Measured memory_bytes: 256
num = int(input())
array = list(map(int,input().split()))

for i in range(num):
    v = array[i]
    j = i-1
    while j >=0 and array[j]>v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print(" ".join(map(str,array)))

Measured memory_bytes: 7652
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



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

    int H, W;
    cin >> H >> W;
    vector<vector<int>> mat(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> mat[i][j];
        }
    }

    // int total = 0;

    // for (int i = 0; i < H; ++i) {
    //     for (int j = 0; j < W; ++j) {
    //         total += mat[i][j];
    //     }
    // }


    vector<vector<int>> moves;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j + 1 < W; ++j) {
            if (mat[i][j] % 2) {
                moves.emplace_back(vector<int>{i, j, i, j + 1});
                mat[i][j] -= 1;
                mat[i][j + 1] += 1;
            }
        }
    }

    for (int i = 0; i + 1 < H; ++i) {
        if (mat[i][W - 1] % 2) {
            moves.emplace_back(vector<int>{i, W - 1, i + 1, W - 1});
            mat[i][W - 1] -= 1;
            mat[i + 1][W - 1] += 1;
        }
    }

    // {
    //     int cnt = 0;
    //     for (auto& V : mat) {
    //         for (auto x : V) {
    //             if (x % 2 == 0) {
    //                 ++cnt;
    //             }
    //         }
    //     }
    //     cout << cnt << '\n';
    // }

    cout << moves.size() << '\n';
    for (auto& M : moves) {
        cout << M[0] + 1 << ' ' << M[1] + 1 << ' ' << M[2] + 1 << ' ' << M[3] + 1  << '\n';
    }


    return 0;
}

Measured memory_bytes: 10032
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Graph Start
struct edge {
    int from, to;
    long long cost;
};
/// Graph End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(a,b);
    if(b%a==0){
        cout << a+ b<<nn;
    }else{
        cout << -a+b << nn;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int  mod = 1000000007;

int main(){
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	

	int n, m;
	cin>>n>>m;
	int dp[n][m];
	char grid[n][m];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin>>grid[i][j];
		     dp[i][j] = 0;
		} 
	}

	

	dp[0][0] = 1;
	for(int i=1; i<m; i++){
		if(grid[0][i]=='.') dp[0][i] = dp[0][i-1];
		else dp[0][i] = 0;
	}

	for(int i=1; i<n; i++)
	{
		if(grid[i][0]=='.') dp[i][0] = dp[i-1][0];
		else dp[i][0] = 0;
	}
	long long ans = 0;
	for(int i=1; i<n; i++){
		for(int j=1; j<m; j++){
			if(grid[i][j] != '#'){
				ans = dp[i-1][j] + (dp[i][j-1]);
			if(ans >= mod) ans -= mod;
			dp[i][j] = ans;
			}
		    
		}
	}

	
	cout<<dp[n-1][m-1]<<endl;

	return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>
int main(){
  int a[10],i,j,tmp;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<9;i++){
    for(j=9;j>i;j--){
      if(a[j] > a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",a[i]);
  }
  return (0);
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC162
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var n = Next();

            Console.WriteLine(n.Contains('7') ? "Yes" : "No");
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 25904
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const long long MOD = 1e9 + 7;


class Combination {
    //a^p%mod
    ll powmod(ll a, ll p) {
        ll ans = 1LL;
        ll mul = a;
        // p >>=1 <-> p=(p >> 1)
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    ll mod;
    vector<ll> fact;
    vector<ll> revFact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    ll get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

  int cnte = 0;
  int cnto = 0;

  for(int i=0;i<N;i++){
    if(a[i]%2==0) cnte++;
    else cnto++;
  }
  //cout << "cnte=" << cnte << endl;
  //cout << "cnto=" << cnto << endl;

  Combination comb = Combination(50,MOD);
  ll ans = 0LL;
  if(P==1){
    for(int i=1;i<=cnto;i+=2){
      //cout << cnto << "C" << i <<endl;
      ans += comb.get(cnto,i);
    }
    ans *= (1LL << cnte);
  } else {
    for(int i=0;i<=cnto;i+=2){
      //cout << cnto << "C" << i <<endl;
      ans += comb.get(cnto,i);
    }
    ans *= (1LL << cnte);
  }

  cout << ans << endl;
}

Measured memory_bytes: 764
def read_input():
    a, b = map(int, input().split())
    return a, b

if __name__ == '__main__':
    a, b = read_input()

    result = 0

    if a > b:
        result += a
        a -= 1
    else:
        result += b
        b -= 1

    if a > b:
        result += a
        a -= 1
    else:
        result += b
        b -= 1

    print(result)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int a[300000];
int main(){
	int n;cin>>n;
	set<P>se;
	rep(i,n){
		scanf("%d",&a[i]);
		se.insert(P(a[i],i));
	}
	rep(i,n){
		if(se.rbegin()->second==i){
			printf("%d\n",(++se.rbegin())->first);
		}
		else printf("%d\n",se.rbegin()->first);
	}
}

Measured memory_bytes: 11776
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>

class UnionFind {

public:
	using size_type = std::uint_fast32_t;

private:
	std::vector<std::pair<bool, size_type>> tree;

public:
	UnionFind(const size_type size) : tree(size, std::make_pair(1, 1)) {}
	size_type find(const size_type x) {
		assert(x < size());
		if (tree[x].first)
			return x;
		return tree[x].second = find(tree[x].second);
	}
	bool unite(size_type x, size_type y) {
		assert(x < size());
		assert(y < size());
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x].second < tree[y].second)
			std::swap(x, y);
		tree[x].second += tree[y].second;
		tree[y] = std::make_pair(0, x);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return tree[find(x)].second;
	}
	size_type size() const noexcept { return tree.size(); }
	bool empty() const noexcept { return tree.empty(); }
};

#include <cstddef>
#include <functional>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

template <class GraphContainer, class UnionFindDataStructure>
std::vector<typename GraphContainer::size_type> TarjansOfflineLCA(
	const GraphContainer &graph, const typename GraphContainer::size_type root,
	const std::vector<std::pair<typename GraphContainer::size_type,
	typename GraphContainer::size_type>> &queries) {
	using size_type = typename GraphContainer::size_type;
	const size_type size_ = graph.size();
	UnionFindDataStructure uft(size_);
	std::vector<size_type> ret(queries.size(), size_), anc(size_);
	std::vector<std::vector<std::size_t>> qset(size_);
	std::stack<std::pair<size_type, size_type>> st;

	for (std::size_t i = 0; i < queries.size(); ++i) {
		qset[queries[i].first].emplace_back(i);
		qset[queries[i].second].emplace_back(i);
	}

	st.emplace(root, 0);

	std::function<void(const size_type, const size_type)> dfs =
		[&](const size_type v, const size_type prev) {
		anc[v] = v;
		for (const auto e : graph[v]) {
			if (e.to != prev) {
				dfs(e.to,v);
				uft.unite(v, e.to);
				anc[uft.find(v)] = v;
			}
		}
		for (const auto e : qset[v])
			if (ret[e] == size_)
				ret[e] = v;
			else
				ret[e] = anc[uft.find(ret[e])];
	};
	dfs(root, size_);
	return ret;
}

#include <cstddef>
#include <vector>

struct edge {
	using cost_type = int;
	using size_type = std::size_t;

	std::size_t to;
};

template <class Edge> using Graph = std::vector<std::vector<Edge>>;

#include<cstdio>
int main() {
	using uint = unsigned int;
	uint n;
	scanf("%u", &n);
	Graph<edge> g(n);
	for (uint i = 0;i < n;++i) {
		uint k, c;
		scanf("%u", &k);
		while (k--) {
			scanf("%u", &c);
			g[i].push_back({ c });
		}
	}
	uint q;
	scanf("%u", &q);
	using S = typename Graph<edge>::size_type;
	std::vector<std::pair<S, S>> Q;
	while (q--) {
		uint u, v;
		scanf("%u%u", &u, &v);
		Q.emplace_back(u, v);
	}
	const auto &&ans=TarjansOfflineLCA<Graph<edge>, UnionFind>(g, 0, Q);
	for (const auto e : ans)
		printf("%u\n", e);
	return 0;
}


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

#define ff first
#define ss second
#define endl '\n'

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

	ll a, b, k;
	cin >> a >> b >> k;

	ll t = min(a, k);
	a -= t;
	k -= t;

	if (!a) {
		b -= k;
      	if (b < 0) {
          b = 0;
        }
	}

	cout << a << ' ' << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<string>
#include<map>
using namespace std;
int x, y, num;
char c;
int *a;
long long N, M,Y[100000],P[100000];
string s;
map<long long, long long>m;
int main(){
	cin >> N >> M;
	cin >> s;
	if (s[M - 1] == 'A')s[M - 1] = 'a';
	if (s[M - 1] == 'B')s[M - 1] = 'b';
	if (s[M - 1] == 'C')s[M - 1] = 'c';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b;
  int c, d, e;
  scanf("%d%d", &a, &b);
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d && c>=e) printf("%d\n",c);
  else if(d>=c && d>=e) printf("%d\n",d);
  else printf("%d\n",e);
  return 0;
}

Measured memory_bytes: 128
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func intAbs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	io := NewIo()
	defer io.Flush()
	//N := 50
	//dp := make([][]bool, N + 1)
	//for i := 0; i <= N; i++ {
	//	dp[i] = make([]bool, N + 1)
	//}
	//for i := 2; i <= N; i++ {
	//	for x := 0; x <= i; x++ {
	//		y := i - x
	//		ok := false
	//		for k := 1; 2 * k <= x; k++ {
	//			if dp[x-2*k][y+k] == false {
	//				ok = true
	//			}
	//		}
	//		for k := 1; 2 * k <= y; k++ {
	//			if dp[x+k][y-2*k] == false {
	//				ok = true
	//			}
	//		}
	//		if ok {
	//			dp[x][y] = ok
	//		}
	//	}
	//}
	//for i := 0; i <= N; i++ {
	//	for j := 0; j <= N; j++ {
	//		if dp[i][j] {
	//			io.Printf("o")
	//		} else {
	//			io.Printf(" ")
	//		}
	//	}
	//	io.PrintLn()
	//}
	X := io.NextInt()
	Y := io.NextInt()
	if intAbs(X - Y) <= 1 {
		io.PrintLn("Brown")
	} else {
		io.PrintLn("Alice")
	}
}


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

int main()
{
    int X, Y;
    bool flag = false;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++) {
        if (2 * i + 4 * (X - i) == Y)
            flag = true;
    }

    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF

int main(){
  string s,ans;
  long long k;
  cin >> s >> k;
  int i='a';
  int j;
  int f=0;
  int g=0;
  vector<int> a(26,0);
  for(int i=0;i<s.size();i++){
    a[s[i]-'a']++;
  }
  reverse(s.begin(),s.end());
  while(s.size()>0&&k>0){
    f=0;
    for(i=int('a');i<=int('z')&&f==0;i++){
      for(j=0;j<s.size()&&j<=k&&a[i-'a']>0&&f==0;j++){
        if(s[s.size()-j-1]==i){
          k=k-j;
          f=1;
        }
      }
    }
    i--;
    j--;
    ans.push_back(i);
    s.erase(s.end()-j-1);
    a[i-'a']--;
  }
  reverse(s.begin(),s.end());
  ans=ans+s;
  cout << ans << endl;
}



Measured memory_bytes: 3544
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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


int main()
{
    int x, n;
    cin >> x >> n;
    
    map<int, bool > p;
    rep(i, n)
    {
        int x;
        cin >> x;
        if (p[x] == false) p[x] = true;
    }


    rep(i, 200)
    {
        int tmp = x;
        if (p[tmp - i] == false)
        {
            cout << tmp-i << endl;
            return 0;
        }
        else if (p[tmp + i] == false)
        {
            cout << tmp + i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<string>
using namespace std;int f,n;main(){string u;map<string,int>s;for(cin>>n;n--;s[u]=1)cin>>u;for(cin>>n;cin>>u;)cout<<(s[u]?++f&1?"Opened by ":"Closed by ":"Unknown ")<<u<<'\n';}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vi in(n,-1);
		while(m--){
			char c;
			cin>>c;
			if(c=='s'){
				int a,b;
				cin>>a>>b;
				rep(i,n){
					bool h=true;
					loop(j,i,i+b)if(j>=n||in[j]!=-1)h=false;
					if(h){
						loop(j,i,i+b)in[j]=a;
						cout<<i<<endl;
						goto end;
					}
				}
				cout<<"impossible"<<endl;
				end:;
			}else{
				int a;
				cin>>a;
				rep(i,n)if(in[i]==a)in[i]=-1;
			}
		}
		cout<<"END"<<endl;
	}
}

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

int main(){
    int tmp,j,N;
    cin >> N;
    int array[N];
    for(int i = 0; i < N; ++i){
        cin >> array[i];
    }
    for(int i = 0; i < N; ++i){
        cout << array[i];
        if(i != N - 1) cout << " " ;
    }
    cout << endl;
    for(int i = 1; i < N; ++i){
        tmp = array[i];
        j = i - 1;
        while(j >=0 && array[j] > tmp){
            array[j + 1] = array[j];
            j--;
        }
        array[j+1] = tmp;
        for(int k = 0; k < N; ++k){
            cout << array[k];
            if(k != N - 1) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = pair<int, ll>;
using graph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
	string s;cin >>s;
	s[5]=' ';
	s[13]=' ';
	cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,t,a;
  cin>>n>>t>>a;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  t*=1000;a*=1000;
  auto calc=[&](Int x){return abs((t-x*6)-a);};
  
  Int ans=0;
  for(Int i=0;i<n;i++)
    if(calc(h[i])<calc(h[ans])) ans=i;
 
  //for(Int i=0;i<n;i++) cout<<calc(h[i])<<endl;
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 1e9 + 7;

int power(int x, int y) {
    int res = 1;
    while(y) {
        if(y & 1) 
            res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        int a[n], b[n];
        int zero = 0, za = 0, zb = 0;
        map<pair<int, int>, int> mp[2][2];
        vector<pair<int, int> > v;
        for(int i = 0; i < n; i++) {
            cin >> a[i] >> b[i];
            
            if(a[i] == 0 && b[i] == 0)
                zero++;
            else if(a[i] == 0)
                za++;
            else if(b[i] == 0)
                zb++;
            else {
                bool f = a[i] > 0;
                bool s = b[i] > 0;
                a[i] = abs(a[i]);
                b[i] = abs(b[i]);
                int g = __gcd(a[i], b[i]);
                a[i] /= g;
                b[i] /= g;
                mp[f][s][{a[i], b[i]}]++;
                v.push_back({a[i], b[i]});
                v.push_back({b[i], a[i]});
            }
        }

        sort(v.begin(), v.end());
        auto it = unique(v.begin(), v.end());
        v.resize(distance(v.begin(), it));

        int ans = 1;
        for(auto p : v) {
            int c00 = mp[0][0][{p.first, p.second}];
            int c01 = mp[0][1][{p.second, p.first}];
            int c10 = mp[1][0][{p.second, p.first}];
            int c11 = mp[1][1][{p.first, p.second}];

            int cnt = power(2, c00 + c11) + power(2, c01 + c10) - 1;
            ans = ans * cnt % mod;
        }

        int cnt = power(2, za) + power(2, zb) - 1;
        ans = ans * cnt % mod;
        ans = (ans + zero - 1 + mod) % mod;
        
        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 112508
#include <stdio.h>

int main() {
  int a,b,i;
  scanf("%d%d",&a,&b);
  
  int result = 0;
  for(i = a; i <= b; i++){
    if(i/10000 == i%10 && i%10000/1000 == i%100/10){
      result++;
    }
  }
  printf("%d\n", result);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    vector<char>fr,ba;
    ll q;
    cin>>q;
    ll flag = 0;
    ll t,f,c;
    while(q--){
        cin>>t;
        if(t == 1){
            flag = !flag;
        }
        else{
            cin>>f;
            char c;
            cin>>c;
            if(f == 2){
                if(flag){
                    fr.push_back(c);
                }
                else{
                    ba.push_back(c);
                }
            }
            else{
                if(!flag){
                    fr.push_back(c);
                }
                else{
                    ba.push_back(c);
                }
            }
        }
    }
    if(!flag){
    for(int i = fr.size()-1 ; i >= 0 ; i--)
        cout<<fr[i];
        cout<<s;
        for(int i = 0 ; i < ba.size() ; i++)
        cout<<ba[i];
    }
    else{
        for(int i = ba.size()-1 ; i >= 0 ; i--)
        cout<<ba[i];
        reverse(s.begin(),s.end());
        cout<<s;
        for(int i = 0 ; i < fr.size() ; i++)
        cout<<fr[i];
    }
    cout<<endl;

}


Measured memory_bytes: 1024
N = int(input())
chars = 'AGCT'

dp = {}
for c1 in chars:
    for c2 in chars:
        for c3 in chars:
            dp[c1+c2+c3] = 1
dp['AGC'] = dp['ACG'] = dp['GAC'] = 0

def isValid(s):
    return not (s[1:] == 'AGC' or
                s[1:] == 'ACG' or
                s[1:] == 'GAC' or
                (s[0] == 'A' and s[3] == 'C' and 'G' in s[1:3]) )
	
for i in range(N-3):
    dp_new = {k:0 for k in dp}
    for k in dp:
      	for c in chars:
            if isValid(k+c):
                dp_new[k[1:]+c] += dp[k]
    dp = dp_new

print(sum([v for k,v in dp.items()]) % 1000000007)

Measured memory_bytes: 3064
// 8クィーン問題
#include<iostream>
#include<cassert>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1
//  行方向,  列方向,  左下方向,         右下方向
int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

// 初期化処理
void initialize()
{
    for(int i = 0; i < N; i++)
    {
        row[i] = FREE;
        col[i] = FREE;
    }

    for(int i = 0; i < 2 * N - 1; i++)
    {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

// 表示用の処理
void printBoard()
{
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if( X[i][j] )
            {
                if( row[i] != j )
                {
                    // 初期配置に対応しているかを調べる
                    // 題意の並べ方に対応するまで検索を継続する
                    return;
                }
            }
        }
    }

    // 結果の表示をする
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            cout << ( ( row[i] == j ) ? "Q" : ".");
        }

        cout << endl;
    }
}

// 各行について, クィーンを置くことが可能な列を検索する関数
// i : クィーンを置く行のNo.
void recursive(int i)
{
    if( i == N )
    {
        // クィーンの配置に成功
        printBoard();
        return;
    }

    for(int j = 0; j < N; j++)
    {
        // 横方向に検索していく
        if( NOT_FREE == col[j] ||
            NOT_FREE == dpos[i + j] ||
            NOT_FREE == dneg[i - j + N - 1] )
        {
            // (i, j)が他のクィーンに襲撃されている場合は無視
            continue;
        }

        // (i, j)にクィーンを配置する
        // i行目の j列 の位置にクィーンを配置する
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;

        // 次の行に移動
        recursive(i + 1);

        // -------------------------------------------------------
        // ここに来た時は, 検索に失敗した時
        // 再帰呼び出しをしているので、i, j の状態は, recursive(i + 1) のCall前に戻っている
        // -------------------------------------------------------

        // ----- バックトラックの操作 -----
        // (i, j)に配置されているクィーンを取り除く
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }

    // クィーンの配置に失敗した時にここにくる
    return;
}

int main()
{
    initialize();

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            X[i][j] = false;
        }
    }

    int k;

    cin >> k;

    for(int i = 0; i < k; i++)
    {
        int r, c;

        cin >> r >> c;

        // 初期配置を保存する
        X[r][c] = true;
    }

    // 並べ方の検索を開始する
    recursive(0);

    return 0;
}



Measured memory_bytes: 3100
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
s=SI()
n=len(s)
u=s[0:n-8]
print(u)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int K, A, B; cin >> K >> A >> B;

    for(int i=A; i<=B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

}

Measured memory_bytes: 3640
#include <iostream>
typedef long long ll;
using namespace std;

int a[310];
ll mod=998244353, dp[310][90010]={}, ep[310][90010]={};

int main(void){
    int N;
    cin >> N;
    ll ans=1;
    for(int i=0; i<N; ++i){
        cin >> a[i];
        (ans *= 3) %= mod;
    }
    dp[0][0]=ep[0][0]=1;
    int sum=0;
    for(int i=0; i<N; ++i){
        for(int j=0; j<=sum; ++j){
            (dp[i+1][j] += dp[i][j]*2%mod) %= mod;
            (dp[i+1][j+a[i]] += dp[i][j]) %= mod;
            (ep[i+1][j] += ep[i][j]) %= mod;
            (ep[i+1][j+a[i]] += ep[i][j]) %= mod;
        }
        sum += a[i];
    }
    for(int i=(sum+1)/2; i<=sum; ++i){
        (ans += mod-dp[N][i]*3%mod) %= mod;
    }
    if(sum%2==0){
        (ans += ep[N][sum/2]*3%mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 424192
n=int(input())
s=input()

mod=10**9+7
ruijo_5=[1]
ruijo_6=[1]

lim=n+len(s)+10

for i in range(n):
    ruijo_5.append(ruijo_5[i]*25%mod)
    ruijo_6.append(ruijo_6[i]*26%mod)

#print(ruijo_5)
#print(ruijo_6)

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod


factorial = [1]
for i in range(1, lim):
    factorial.append(factorial[i-1]*i%mod)

inverseFactorial = [0] * lim
inverseFactorial[lim-1] = power(factorial[lim-1], mod-2)
for i in range(lim-2, -1, -1):
    inverseFactorial[i] = inverseFactorial[i+1] * (i+1) % mod

def combi(i, j):
    return factorial[i] * inverseFactorial[j] * inverseFactorial[i-j] % mod


#print(len(factorial))
#print(len(inverseFactorial))

kai=len(s)-1
#print(kai)
s=0

for i in range(n+1):
    #print(combi(kai+i,i),ruijo_5[i],ruijo_6[n-i])
    tasu=combi(kai+i,i)*ruijo_5[i]%mod
    tasu*=ruijo_6[n-i]
    tasu%=mod
    s+=tasu
    s%=mod

print(s)

Measured memory_bytes: 311456
#ABC089-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
count={"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(n):
    h=S()[0]
    if h in count:
        count[h]+=1

cl=list(count.values())
ans=0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans+=cl[i]*cl[j]*cl[k]
print(ans)

Measured memory_bytes: 45400
#include<stdio.h>
#include<math.h>
#define ROW 1000
#define COLUM 1000
#define infinity 10000000
//動的計画法を用いた連鎖行列積
//行列のテーブルを作ってi番目からj番目までの行列をかけた際最小のコスト
int main(){
    int i,j,k,num,mat[ROW+1][COLUM+1],length,q,p[ROW+1],minimum;
    scanf("%d",&num);
    //初期化
    for(i=0;i<num;i++){
        mat[i][i]=0;
    }
    for(i=1;i<=num;i++){
        scanf("%d%d",&p[i-1],&p[i]);
    }
    for(i=1;i<=num;i++){
    //printf("確認：%d番目:%d,%d\n",i,p[i-1],p[i]);
    }
    /* MatrixChainOrder */
    //MatrixchainOrderの実装
for(length=2;length<=num;length++){
    for(i=1;i<=num-length+1;i++){
        j=i+length-1;
         mat[i][j]=infinity;
        for(k=i;k<=j-1;k++){
            q=mat[i][k]+mat[k+1][j]+(p[i-1]*p[k]*p[j]);
            //printf("計算結果: %d\n",q);
            if(q<mat[i][j]){
                mat[i][j]=q;
            }
        }
    }
}
/*
for(i=0;i<num;i++){
    for(j=0;j<num;j++){
        printf("%d行%d列目：%d\n",i,j,mat[i][j]);
    }
  }*/
  printf("%d\n",mat[1][num]);
    return 0;
}
/* わかったこと
二次元配列は10000個の要素は用意できない
無限大を使う際はINFINITYは使わない方がいい */


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<((a==b&&b==c)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,R[200000];
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> R[i];
    }

    int maxv = R[1] - R[0];
    int minv = R[0];

    for (int i = 1; i < n; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
}

Measured memory_bytes: 3888
#include<stdio.h>
#define N 101
#define INF -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,G[N][N]={},d[N]={};
int color[N];
int Q[N];
int head,tail;

void enqueue(int s){
    Q[tail]=s;
    tail=tail+1;
}

int dequeue(void){
    int x=Q[head];
    head=head+1;
    return x;
}

void bfs(int s){
    int i,u;
    for(i=1;i<=n;i++){
        color[i]=WHITE;
        d[i]=INF;
    }
    color[s]=GRAY;
    d[s]=0;
    enqueue(s);
    while(head!=tail){
        u=dequeue();
        int v;
        for(v=1;v<=n;v++){
            if(G[u][v]==1){
            if(color[v]==WHITE){
                color[v]=GRAY;
                d[v]=d[u]+1;
                enqueue(v);
            }
        }
        }
        color[u]=BLACK;
    }
}

int main(){
    int i,j,x;
    int id,a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&id,&a);
        for(j=0;j<a;j++){
            scanf("%d",&x);
            G[id][x]=1;
        }
    }
    bfs(1);
    for(i=0;i<n;i++){
        printf("%d %d\n",i+1,d[i+1]);
    }
    return 0;
}



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

typedef pair<ll, ll> res;

int N;
vector<ll> A, S;

// [l, r)
res minimize(int l0, int r0) {
  ll s = S[r0] - S[l0];
  int l = l0, r = r0;
  while(r - l > 1) {
    int m = (l+r)/2;
    if(S[m+1] - S[l0] <= s/2) {
      l = m;
    } else {
      r = m;
    }
  }
  if(r0 > l + 2 && abs(2*S[l+1]- S[l0] - S[r0]) > abs(2*S[l+2]- S[l0] - S[r0])) l++;
  ll x = S[l+1] - S[l0];
  ll y = S[r0] - S[l+1];
  return res(min(x,y), max(x,y));
}

int main () {
  cin >> N;

  A.resize(N), S.resize(N+1, 0);
  rep(i,N) {
    cin >> A[i];
    S[i+1] = S[i] + A[i];
  }

  ll ans = 1e15;
  res rl, rr;
  for(int i = 1; i < N-2; i++) {
    rl = minimize(0, i+1);
    rr = minimize(i+1, N);
    ans = min(ans, max(rl.second, rr.second) - min(rl.first, rr.first));
  }

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


Measured memory_bytes: 3328
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[110],t[110];
int main(){
	int T,i,j,k,ca=0,n,m,K;
	//cout<<setprecision(9)<<fixed;
	scanf("%d%s%s",&n,s,t);
	per(i,1,n+1){
		k=n-i;int ok=1;
		rep(j,0,i)if(s[k+j]!=t[j]){ok=0;break;}
		if(ok){
			printf("%d\n",2*n-i);return 0;
		}
	}
	printf("%d\n",2*n);
	//cerr<<clock()*1./CLOCKS_PER_SEC<<"ms\n";
	return 0;
}

Measured memory_bytes: 256
N=int(input())
cnt=[0 for _ in range(N+1)]
for i in range(1,N+1):
    cnt[i]=cnt[i-1]+1
    a=6
    while i-a>=0:
        cnt[i]=min(cnt[i],cnt[i-a]+1)
        a*=6
    a=9
    while i-a>=0:
        cnt[i]=min(cnt[i],cnt[i-a]+1)
        a*=9
print(cnt[N])


Measured memory_bytes: 9788
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N,K=mi()
    P=list(mi())
    P.sort()


    print(sum(P[:K]))


if __name__ == "__main__":
  main()

Measured memory_bytes: 9248