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

const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}

int main()
{
  int n,K;
  scanf("%d%d",&n,&K);
  vector<int> a(K),b(K);
  for(int i=0;i<K;i++){
    scanf("%d%d",&a[i],&b[i]);
    a[i]--,b[i]--;
  }
  vector<long long> predp(n+1);
  predp[0]=1ll;
  for(int i=1;i<=n;i++){
    predp[i]=predp[i-1]*(2*i-1)%mod;
  }
  vector<vector<long long> > dp1(2*n,vector<long long>(2*n));
  vector<vector<int> > dc(2*n,vector<int>(2*n));
  long long ans=0;
  for(int i=0;i<2*n;i++){
    for(int t=1;i+t<2*n;t+=2){
      int j=i+t;
      bool F=true;
      int c=(t+1)/2;
      for(int x=0;x<K;x++){
	bool F1=(i<=a[x]&&a[x]<=j),F2=(i<=b[x]&&b[x]<=j);
	if(F1!=F2){
	  F=false;
	  break;
	}
	if(F1&&F2){
	  c--;
	}
      }
      if(!F){
	dp1[i][j]=0ll;
	dc[i][j]=-1;
      }
      else{
	dp1[i][j]=predp[c];
	dc[i][j]=c;
	for(int k=i+1;k<j;k+=2){
	  if(dc[i][k]!=-1){
	    mn(dp1[i][j],dp1[i][k]*predp[c-dc[i][k]]%mod);
	  }
	}
	ad(ans,dp1[i][j]*predp[n-K-c]%mod);
	//printf("%d %d %lld\n",i,j,dp1[i][j]);
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}

	  


Measured memory_bytes: 4480
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)

	if h == 1 || w == 1 {
		fmt.Println(1)
	} else {
		if (h * w) % 2 == 0 {
			fmt.Println(h * w / 2)
		} else {
			fmt.Println((h * w / 2) + 1)
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;


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

    cout << min(N % K, K - (N % K)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, m;
  char s[10];
  
  scanf("%s", s);
  
  m = (s[5] - '0')*10 + s[6] - '0';
  
  if(m <= 4){
    printf("Heisei\n");
  } else {
    printf("TBD\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {

	ll N = 0,C = 0;
	ll D[35][35] = { 0 };
	ll CC[35][3] = { 0 };
	ll CD[35][3] = { 0 };
	ll ans = LLONG_MAX;

	scanf("%lld%lld", &N,&C);
	for (ll i = 1; i <= C; i++) {
		for (ll j = 1; j <= C; j++) {
			scanf("%lld", &D[i][j]);
		}
	}

	for (ll i = 1; i <= N; i++) {
		for (ll j = 1; j <= N; j++) {
			ll a = 0;
			scanf("%lld", &a);
			CC[a][(i + j) % 3]++;
		}
	}

	for (ll i = 0; i <= 2; i++) {
		for (ll j = 1; j <= C; j++) {
			for (ll k = 1; k <= C; k++) {
				CD[j][i] += D[k][j] * CC[k][i];
			}
		}
	}
	
	for (ll i = 1; i <= C; i++) {
		for (ll j = 1; j <= C; j++) {
			for (ll k = 1; k <= C; k++) {
				if (i == j || j == k || i == k)
					continue;
				ans = min(ans, CD[i][0] + CD[j][1] + CD[k][2]);
			}
		}
	}
	printf("%lld\n", ans);

	return 0;
}



Measured memory_bytes: 256
/*input
3 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2000005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
ll inv(ll z){
    if(z==1) return 1;
    return (MOD-MOD/z)*inv(MOD%z)%MOD;
}
ll c(ll n,ll k){
    ll z=1;
    for(ll i=n-k+1;i<=n;i++) z=(z*i)%MOD;
    ll b=1;
    for(ll i=1;i<=k;i++) b=(b*i)%MOD;
    return z*inv(b)%MOD;
}
ll fac[maxn];
int main(){
    fac[1]=1;
    for(ll i=2;i<maxn;i++) fac[i]=(fac[i-1]*i)%MOD;
    int x,y;
    cin>>x>>y;
    ll ans=0;
    REP(i,(x+1)/2+1){
        int cnt=x-i*2;
        if(cnt>=0 and cnt*2+i==y){
            ans+=c(cnt+i,cnt);
            ans%=MOD;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include<vector>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define pri 1000000007
#define ss second
using namespace std;

int main() {
                 ll n,m;
                  cin>>n>>m;
                 ll sum=0;
                vector<pair<ll,ll>>v;
                for( ll i=0 ;i<n;i++)
                  { 
                         ll x,y;
                          cin>>x>>y;
                        v.PB(MP(x,y));
                }
                ll i=0;
                 sort(v.begin(),v.end());
                while(m>0)
              {
                  if(m-v[i].ss>=0)    
                     sum= sum+v[i].ff*v[i].ss;
                   else
                     sum= sum+v[i].ff*(m);
                   m=m-v[i].ss;
                    i++;                   
                }
              cout<<sum;
}

Measured memory_bytes: 2420
#include <stdio.h>

int main(void) {
	int n;
	int F[45];
	scanf("%d", &n);
	F[0] = F[1] = 1;
	for (int i = 2; i <= 44; i ++) {
		F[i] = F[i-1] + F[i-2];
	}
	printf("%d\n", F[n]);
	return 0;
}

Measured memory_bytes: 1024
import static java.lang.System.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public void solve() {

		/*
		 * N%KとKで考える
		 */
		long N = nextLong();
		long K = nextLong();

		out.println(Math.min(N%K, Math.abs(N%K-K)));
	}

	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	double sqrt(double x) {
		return Math.sqrt(x);
	}

	double pow(double x, double y) {
		return Math.pow(x, y);
	}
	int max(int a,int b) {
		return Math.max(a, b);
	}

	public static void main(String[] args) {
		Main m = new Main();

		m.solve();
	}

	public void println(Object o) {
		out.println(o);
	}

}


Measured memory_bytes: 21076
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
        s: [String; n],
    };
    let mut s: Vec<String> = s;
    s.sort();
    s.dedup();
    println!("{}", s.len());
}


Measured memory_bytes: 16932
#
# abc068 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    N = int(input())

    ans = 1
    ansn = 0
    for i in range(1, N+1):
        tmp = 0
        j = i
        while j % 2 == 0:
            tmp += 1
            j //= 2

        if tmp > ansn:
            ansn = tmp
            ans = i

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """32"""
        output = """32"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """100"""
        output = """64"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main() {
  int A, B, n;
  int x, y, z;

  while(1) {
    cin >> A >> B;
    if(A == 0 && B == 0) break;

    n = B - A;
    if(n / 1000 > 0) {
      x = n / 1000;
      n = n % 1000;
    }   
    else
      x = 0;
    if(n / 500 > 0) {
      y = n / 500;
      n = n % 500;
    }
    else
      y = 0;
    if(n / 100 > 0) {
      z = n / 100;
      n = n % 100;
    }
    else
      z = 0;

    cout << z << ' ' << y << ' ' << x << endl;
  }

  return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 2005;
int n, m, ve[mx][mx], ho[mx][mx], ans;
char s[mx][mx];
int main(){
    scanf("%d%d\n", &n, &m);
    rep(i,n){
        scanf("%s", s[i]);
        int t = 0;
        rep(j,m+1){
            if(s[i][j] != '.'){
                for(int u = j-t; t < j; t++){
                    ho[i][t] = u;
                }
                t++;
            }
        }
    }
    rep(i,m){
        int t = 0;
        rep(j,n+1){
            if(s[j][i] != '.'){
                for(int u = j-t; t < j; t++){
                    ve[t][i] = u;
                }
                t++;
            }
        }
    }
    rep(i,n)rep(j,m) ans = max(ans, ho[i][j] + ve[i][j] - 1);
    printf("%d\n", ans);
}

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

  struct input{
   public long N;
   public long M;
  }
  struct Cake{
   public long x;
   public long y;
   public long z;
   public Cake(long _x, long _y, long _z) { x = _x; y = _y; z = _z;}
  }

class MainClass {
  static input input; 

  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ').Select(int.Parse);
    input.N = temp.ElementAt(0);
    input.M = temp.ElementAt(1);
    var cakeList = new List<Cake>();
    var ansList = new List<long>();

    for(var i = 0; i < input.N; i++){
      var temp2 = Console.ReadLine().Split(' ').Select(long.Parse);
      cakeList.Add(new Cake(temp2.ElementAt(0), temp2.ElementAt(1), temp2.ElementAt(2)));
    }

    //正正正
    cakeList = cakeList.OrderByDescending(e => {return e.x + e.y + e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return e.x + e.y + e.z;}));
    //正正負
    cakeList = cakeList.OrderByDescending(e => {return e.x + e.y - e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return e.x + e.y - e.z;}));

cakeList = cakeList.OrderByDescending(e => {return e.x - e.y + e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return e.x - e.y + e.z;}));

cakeList = cakeList.OrderByDescending(e => {return e.x - e.y - e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return e.x - e.y - e.z;}));

cakeList = cakeList.OrderByDescending(e => {return -e.x + e.y + e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return -e.x + e.y + e.z;}));

cakeList = cakeList.OrderByDescending(e => {return -e.x + e.y - e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return -e.x + e.y - e.z;}));

cakeList = cakeList.OrderByDescending(e => {return -e.x - e.y + e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return -e.x - e.y + e.z;}));

cakeList = cakeList.OrderByDescending(e => {return -e.x - e.y - e.z;}).ToList();
    ansList.Add(cakeList.Take((int)input.M).Sum(e => {return -e.x - e.y - e.z;}));


    //ansList.Add(cakeList.ForEach(e => Console.WriteLine(e.x));
    Console.WriteLine(ansList.Max());
  }
}

Measured memory_bytes: 14048
namespace ABC126_A
{
    using static System.Console;
    using System.Linq;
    using System.Collections.Generic;

    public class Program
    {
        static void Main(string[] args)
        {
            var k = ReadInputsAsInt().Last();

            WriteLine(Solve(ReadLine(), k));
        }

        public static string Solve(string s, int k)
        {
            var r = s.ToCharArray();
            r[k - 1] = char.ToLower(s[k - 1]);

            return new string(r);
        }

        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String c = sc.next();
        List<String> vowel = new ArrayList<String>(Arrays.asList("a", "e", "i", "o", "u"));
        if(vowel.contains(c)) {
            System.out.println("vowel");
        } else {
            System.out.println("consonant");
        }
    }
}


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

int		main(void)
{
	int x, a, b;

	cin >> x >> a >> b;
	if (b <= a)
		cout << "delicious";
	else if (b <= a + x)
		cout << "safe";
	else
		cout << "dangerous";
	cout << endl;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<uint64_t>a(n); for(auto&&i:a)cin>>i;
	bool zero=!(find(a.begin(),a.end(),0)==a.end());
	if(zero){
		cout<<0<<"\n"s;
		return 0;
	}
	int64_t ans=a.front(); int64_t prev=ans;
	for(int i=1;i<n;++i){
		ans*=a.at(i);
		if(prev>ans||ans>1000000000000000000){
			cout<<-1<<"\n"s;
			return 0;
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3976
def li():
    return [int(x) for x in input().split()]

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

INF = 10 ** 60

G = defaultdict(list)

N, M = li()

for _ in range(M):
    x, y = li()
    G[x].append(y)

dp = [-1] * (10 ** 5 + 1)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for cv in G[v]:
        ret = max(ret, dfs(cv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(1, N+1):
    # print(dfs(v))
    ans = max(ans, dfs(v))

print(ans)

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

int main(){
    int keijiban = 1;
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        if(keijiban * 2 < keijiban + k){
            keijiban *= 2;
        }else{
            keijiban += k;
        }
    }
    cout << keijiban << endl;
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())

VACANT = 'Vacant'
FEMALE = 'Female'
MALE = 'Male'


def check(n):
    print(n, flush=True)
    s = sys.stdin.buffer.readline().decode().rstrip()
    if s == VACANT:
        exit()
    return s


l = 0
h = N
ls = check(l)
while abs(l - h) > 1:
    mid = (l + h) // 2
    ms = check(mid)
    if ((mid - l) % 2 == 0) == (ls == ms):
        l = mid
        ls = ms
    else:
        h = mid
check(h)
check(l)


Measured memory_bytes: 14148
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int q;cin>>q;
	rep(i,q){
		ll a,b;cin>>a>>b;
		if(a > b){
			ll tmp = a;
			a = b;
			b = tmp;
		}
		ll k = a*b;
		ll small = (ll)sqrt(k);
		ll big;
		if(small*small >= k){
			big = small;
			small--;
		}else if(small * (small+1) < k){
			big = small+1;
		}else{
			big = small;
		}

		ll ans = a-1;
		ans += max((ll)0,min(small-a, b-big));
		cout<<ans*2+1-(ll)(small==big)-(ll)(a==b)<<endl;
	}
	return 0;
}


Measured memory_bytes: 636
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    vector<lli> a(3);
    cin>>a[0]>>a[1]>>a[2];
    swap(a[0], a[1]);
    swap(a[0], a[2]);
    cout<<a[0]<<' '<<a[1]<<' '<<a[2];
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

int x;

int main() {
  cin >> x;
  cout << (x ? 0 : 1) << endl;
  return 0;
}


Measured memory_bytes: 3524
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;

int n, mn = INF, x, sum;

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

	cin >> n;
	for (int i = 1; i <= n; ++i){
        cin >> x;
        if (x > 0 && x % 10 != 0)
            mn = min(mn, x);
        sum += x;
	}
	if (sum % 10 == 0){
        if (mn != INF)
            cout << sum - mn;
        else
            cout << 0;
	}
	else{
        cout << sum;
	}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int min(int a, int b){
  if(a>=b){
    return b;
  }
  else{
    return a;
  }
}

int main(){
  char S[100010];
  fgets(S, sizeof(S), stdin);
  int N=strlen(S);
  N--;

  int count_0=0;
  int count_1=0;

  rep(i,N){
    if(S[i]=='0'){
      count_0++;
    }
    else{
      count_1++;
    }
  }

  int ans=min(count_0, count_1);

  printf("%d\n", ans*2);

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

double a, b, n, najx, vr;
int main() {
    IOS; cin >> a >> b >> n;
    vr = ll((n+1LL)/b);
    najx = ll(ll(vr * b))-1LL;
    --vr;

    //cout << vr << ' ';
    //cout << najx; return 0;
    ll maxi = 0LL;

    if(najx>=0.0) maxi = max(maxi, ll(floor(a/b*najx)-a*vr));
    //cout << maxi << endl;
    maxi = max(maxi, ll(floor(a/b*n)-a*floor(n/b)));
    //cout << maxi << endl;
    cout << maxi;
    return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
i,j;int main(){
	int n;
	double x[4],y[4];
	scanf("%d",&n);
	for(;i<n;i++,j=0){
		for(;j<4;)scanf("%lf %lf",&x[j++],&y[j]);
		printf("%s\n",(y[1]-y[0])/(x[1]-x[0])==(y[3]-y[2])/(x[3]-x[2])?"YES":"NO");
	}
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()


signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(0,min(b,d)-max(a,c))<<endl;
    return 0;
}

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    boolean[] prime = new boolean[50000];
	    Arrays.fill(prime, true);
	    prime[1]=prime[0]=false;
	    for(int i=2; i<Math.sqrt(50000); i++)
		if(prime[i])
		    for(int j=i*i; j<50000; j+=i)
			prime[j]=false;
	    int n, count;
	    while((n = Integer.valueOf(sc.readLine()))!=0){
		if(n%2==1)
		    if(prime[n-2])
			System.out.println(1);
		    else
			System.out.println(0);
		else{
		    count = 0;
		    for(int i=2; i<=n/2; i++)
			if(prime[i]&&prime[n-i])
			    count++;
		    System.out.println(count);
		}
	    }
    	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

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

int main() {
    int n; cin>>n;
    string s; cin>>s;
    int count = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'A'){
            string p = s.substr(i, 3);
            if(p == "ABC") count++;
        }
    }
    cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  val ref = "ATGC"
  val s = br.readLine().toCharArray()

  val ans = s.fold(Pair(0, 0)) { acc , si ->
    val (max, cnt) = acc
    if(ref.contains(si)) Pair(Math.max(max, cnt+1), cnt+1) else Pair(max, 0)
  }.first

  println(ans)
}

Measured memory_bytes: 31516
import sys
import math
sys.setrecursionlimit(500000)
INF = float('inf')

def main():
    n = input()
    sum_digits = 0
    for i in n:
        sum_digits += int(i)
    if sum_digits % 9 == 0:
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9228
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n, k, q; cin >> n >> k >> q;
	vi a(q); rep(i, q) cin >> a[i];

	vi ans(n, k);
	rep(i, q) {
		++ans[a[i] - 1];
	}

	rep(i, n) {
		if (ans[i] - q > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

const int INF = INT_MAX;

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);


	int n;string s;cin>>n>>s;int c=0;
	for(int i=0;i<=n-3;i++){
		if(s.substr(i,3)=="ABC") c++;
	}
	cout <<c;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  getline(cin, s);
  int n = s.size();
  rep(i, 0, n) {
    bool up = isupper(s[i]), lo = islower(s[i]);
    if (up)
      s[i] = tolower(s[i]);
    else if (lo)
      s[i] = toupper(s[i]);
  }
  cout << s << endl;
}



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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll a, b, h, m;
    ll p[200010];
    string s;
  
    cin >> a >> b >> h >> m;

    double rad = 2*PI*abs((30*h + 0.5*m) - 6*m) / 360;
    double ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
  	cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int X, N;cin>>X>>N;
	if(N == 0) die(X);
	vi p(N); vin(p);
	sort(all(p));
	int may = -1;
	int sa = 100000;
	int ans;
	for(int i = -1; i <= 101; i++){
		if(find(all(p), i) != p.end()) continue;
		int tmp = abs(X - i);
		if(tmp < sa) { ans = i; sa = tmp; }
	}
	out(ans);
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int b = 2;
    for (int i = 0; i < n; i++) {
        s[i] -= '1';
        if (s[i] == 1) b = 1;
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        r ^= (s[i] == b && (i & ~(n - 1)) == 0);
    }

    cout << r * b << endl;

    return 0;
}

Measured memory_bytes: 1948
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();
  vector<int> t(n);
  for (int i = 0; i < n; i++) t[i] = s[i] - '0';

  vector<vector<int> > next(10, vector<int>(2019));
  for (int i = 1; i <= 9; i++) {
    vector<bool> visited(2019);
    for (int j = 0; j < 2019; j++) next[i][j] = j;
    for (int j = 0; j < 2019; j++) {
      if (!visited[j]) {
        int now = j;
        while (!visited[now]) {
          visited[now] = true;
          next[i][now] = (now * 10 + i) % 2019;
          now = next[i][now];
        }
      }
    }
  }


  vector<int> dp1(2019);
  vector<int> dp2(2019);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (i & 1) {
      dp2.assign(2019, 0);
      for (int j = 0; j < 2019; j++) {
        dp2[next[t[i]][j]] += dp1[j];
      }
      dp2[t[i]]++;
      ans += dp2[0];
    }
    else {
      dp1.assign(2019, 0);
      for (int j = 0; j < 2019; j++) {
        dp1[next[t[i]][j]] += dp2[j];
      }
      dp1[t[i]]++;
      ans += dp1[0];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N,M;
    cin>>N>>M;
    pair<int,int> island[M];
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        island[i].S=a;
        island[i].F=b;
    }
    sort(island,island+M);
    int cnt=0;
    int ni=0;
    rep(i,M){
        if(ni<=island[i].S){
            cnt++;
            ni=island[i].F;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=100007,P=1000000007;
char S[N];
int F[N][13];
int main() {
	scanf("%s",S+1);
	int n=strlen(S+1);
	F[0][0]=1;
	For(i,1,n) {
		if(S[i]=='?') {
			For(j,0,9)
				For(k,0,12) {
					F[i][(k*10+j)%13]+=F[i-1][k];
					F[i][(k*10+j)%13]%=P;
				}
		}
		else {
			int j=S[i]-'0';
			For(k,0,12) {
				F[i][(k*10+j)%13]+=F[i-1][k];
				F[i][(k*10+j)%13]%=P;
			}
		}
	}
	printf("%d",F[n][5]);
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int64_t func(int64_t n,int64_t x) {
  if(n == -1) {
    return 0;
  }else {
    return n / x + 1;
  }
}
int main() {
  int64_t a,b,x;
  cin >> a >> b >> x;
  cout << func(b,x) - func(a - 1,x) << endl;
}

Measured memory_bytes: 256
def main():
    n = input()
    A = []
    for i in range(n):
        A.append(raw_input())
    B = A[:]
    
    quickSort(A,0,n-1)
    mergeSort(B,0,n)

    if A == B:
        print "Stable"
    else:
        print "Not stable"

    for item in A:
        print item


def quickSort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)

def partition(A,p,r):
    x = int(A[r][2:])
    i = p - 1
    for j in range(p,r):
        if int(A[j][2:]) <= x:
            i += 1
            a = A[i]
            A[i] = A[j]
            A[j] = a
    b = A[i+1]
    A[i+1] = A[r]
    A[r] = b
    return i+1


def merge(A,left,mid,right):
    n1 = mid - left
    n2 = right - mid
    L = [A[left+i] for i in range(n1)]
    L += ["L inf"]
    R = [A[mid+i] for i in range(n2)]
    R += ["R inf"]
    i = 0
    j = 0
    for k in range(left,right):
        if float(L[i][2:]) <= float(R[j][2:]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A,left,right):
    if left+1 < right:
        mid = (left+right)/2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			1000000007
#define MAX 		100005


typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

int main(){
	int N;cin>>N;
	vector<ll> a(N);
	REP(i,N)cin>>a[i];
	REP(i,N)a[i] -= (i+1);

	sort(a.begin(),a.end());
	int t = a[ceil(N/2)];
	
	ull ans = 0;
	REP(i,N)ans += abs(a[i]-t);

	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

#define NMAX 100000

int binarySearch(int[], int, int);

int main(){
  
  int S[NMAX], n, i, q, key;
  int sum = 0;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]); 

  scanf("%d", &q);
  
  for(i = 0; i < q; i++){
    scanf("%d", &key);
    
    if (binarySearch(S, n, key))
      sum++;
  }
  
  printf("%d\n", sum);
  
  return 0;
}

int binarySearch(int S[], int n, int key){
  
  int left = 0;
  int right = n;
  int mid;
  
  while(left < right){
    mid = (left + right) / 2;
    
    if(S[mid] == key)
      return 1;

    else if(key < S[mid])
      right = mid;
    
    else left = mid + 1; 
  }
  return 0;
}




Measured memory_bytes: 2172
use std::vec::Vec;

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> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

const MOD: u64 = 1_000_000_000 + 7;

fn main() {
    let (n, k) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };
    let mut a: Vec<Vec<u64>> = Vec::new();
    for _ in 0..n {
      let t: Vec<u64> = read_vec();
      a.push(t);
    }
    let tmp = matrix_pow(&a, k);
    let mut ans = 0;
    for i in 0..n {
      for j in 0..n {
        ans += tmp[i][j];
        ans %= MOD;
      }
    }

    println!("{}", ans);
}


fn matrix_mult(m: &Vec<Vec<u64>>, t: &Vec<Vec<u64>>) -> Vec<Vec<u64>> {
    let n = m.len();
    let mut res = vec![vec![0; n]; n];
    for i in 0..n {
      for j in 0..n {
        for k in 0..n {
          res[i][j] += (m[i][k] % MOD) * (t[k][j] % MOD);
          res[i][j] %= MOD;
        }
      }
    }

    res
}


fn matrix_pow(m: &Vec<Vec<u64>>, k: usize) -> Vec<Vec<u64>> {
  if k == 0 {
    let mut res = vec![vec![0; m.len()]; m.len()];
    for i in 0..m.len() {
      res[i][i] = 1;
    }

    return res;
  }

  if k % 2 != 0 {
    return matrix_mult(&m, &matrix_pow(&matrix_mult(&m, &m), (k - 1) / 2));
  } else {
    return matrix_pow(&matrix_mult(&m, &m), k / 2);
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

int main(void)
{
	using namespace std;
	int a,b;
	char op;
	int answer;
	bool flg_break = false;

	while(1){
		cin >> a;
		cin >> op;
		cin >> b;

		switch(op){
			case '+':
				answer = a + b;
				break;

			case '-':
				answer = a - b;
				break;

			case '*':
				answer = a * b;
				break;

			case '/':
				answer = a / b;
				break;

			case '?':
				flg_break = true;
				break;
		}

		if(flg_break) break;

		cout << answer << endl;
	}

	return 0;

}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

vector<bool> isComposite(100100);

signed main() {
    for (int j = 4; j < 100100; j += 2)isComposite[j] = true;
    for (int i = 3; i < 1000; i += 2) {
        if (!isComposite[i]) {
            for (int j = i * i; j < 100100; j += 2 * i) {
                isComposite[j] = true;
            }
        }
    }
    int x;
    cin >> x;
    for (int i = x; i < 100100; ++i) {
        if (!isComposite[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{
	int n,i,tmp,ans;
	int count;
	int ans_count_memo = -1;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		
		tmp=i;
		count = 0;
		while(tmp%2==0&&tmp>0){
			tmp/=2;
			count++;
		}
		if(count>ans_count_memo){
			ans_count_memo=count;
			ans=i;
		}
		
		
	}
	
	
	printf("%d\n",ans);
		
	return 0;
}
			
			
		

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  string s[3];
  rep (i, 3) {
    cin >> s[i];
  }
  rep (i, 3) {
    cout << (char)(s[i][0] + 'A' - 'a');
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 *  Author: sleepify
 */
#include <bits/stdc++.h>
// #include "prettyprint.h"
using namespace std;

#define LOG(x) cerr << "*** " << x << " ***" << endl;
#define wi(x) what_is(x, '\n')
#define wisp(x) what_is(x, ", ")
#define what_is(x, terminator) cerr << #x << " = " << x << terminator;

#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define REV_ALL(x) x.rbegin(), x.rend()
#define SZ(x) (int)x.size()
#define CONTAINS(cont, val) (cont.find(val) != cont.end())
#define endl '\n'
#define IO_SPEED_UP ios::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, s, e) for(ll i = s; i < e; i++)
#define leftmost_set(x) __builtin_clzll(x)
#define TWO_POWER(n) (1LL << (n))

// When root of a binary tree is 1
#define PARENT(n) ((n) >> 1LL)
#define LCHILD(n) ((n) << 1LL)
#define RCHILD(n) (((n) << 1LL) + 1LL)

typedef long long ll;typedef pair<ll, ll> ii;
typedef vector<ll> vi;typedef vector<bool> vb;
typedef vector<ii> vii;typedef vector<vi> vvi;

const int INF32 = 1E9;
const long long INF64 = 4E18;
const ll M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

int main() {
	IO_SPEED_UP; // Turn Off for Interactive Problems
	if(fopen("tupni.txt", "r")) {
		freopen("tupni.txt", "r", stdin);
		freopen("tuptuo.txt", "w", stdout);
	}
	int k; cin >> k;
	vi a(k);
	for (int i = 0; i < k; ++i) {
		cin >> a[i];
	}
	ll L = 2, R = 2;
	for (int i = k - 1; i >= 0; --i) {
		ll x = ceil(L/(double)a[i]) * a[i];
		ll y = floor(R/(double)a[i]) * a[i];
		if(x > y) {
			cout << -1;
			return 0;
		}
		L = x;
		R = y + a[i] - 1;
	}
	cout << L << " " << R;
	return 0;
}


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;
string h;
int a, b, k;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
ll arr[MAXN],ok1[MAXN],pre[MAXN],pre1[MAXN];

int main() {
    FAST
   string h;
    cin>>h;
    set<char>s;
    s.insert(h[0]);
    s.insert(h[1]);
    s.insert(h[2]);
    if(s.size()==1)
    {
        cout<<"No"<<endl;
    }
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256