akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#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 long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

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

    int k;
    string s;
    cin >> k >> s;
    if(sz(s)<=k) {
        cout << s;
        return 0;
    }
    cout << s.substr(0,k) << "...";

    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			System.out.println(in.equals("a")? "vowel"
							  :in.equals("e")? "vowel"
    						  :in.equals("i")? "vowel"
							  :in.equals("o")? "vowel"
							  :in.equals("u")? "vowel"
							  :"consonant");

		}
	}
}


Measured memory_bytes: 25172
#include <cstdio>
#include <string>
#define N 10050
using namespace std;

int main()
{
	char ch[200];
	scanf("%s",ch);
	if(ch[0]=='S')
		printf("Cloudy");
	else if(ch[0]=='C')
		printf("Rainy");
	else
		printf("Sunny");
	return 0;
}

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

/*	ASCII Code of A=65
  	ASCII Code of a=97	*/

#define kill(N) cout<<N<<'\n';

int N,arr[4]; string s;
string topic[4]={"AC","WA","TLE","RE"};

int main(){
	cin>>N;
	for(int i=0; i<N; i++){
		cin>>s;
		if(s=="AC"){
			arr[0]++;
		}else if(s=="WA"){
			arr[1]++;
		}else if(s=="TLE"){
			arr[2]++;
		}else if(s=="RE"){
			arr[3]++;
		}
	}
	for(int i=0; i<4; i++){
		cout<<topic[i]<<" x "<<arr[i]<<'\n';
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int MAX = 1000000;

int main(){
    int r;
    cin >> r;
    cout << r*2* M_PI << endl;
    return 0;
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] p = new int[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = Integer.parseInt(sc.next());

		}
		int ans = 0;
		for (int i = 1; i < p.length - 1; i++) {
			if ((p[i] > p[i - 1] || p[i] > p[i + 1]) && (p[i] < p[i - 1] || p[i] < p[i + 1])) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    a = x % 10;
    b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
}

signed main() {
    int K, N;
    vector<int> A;
    cin >> K >> N;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int ans = K + 1;
    rep(i, N) {
        int head = i + 1;
        int end = i - 1;
        int dis1 = 0;
        if (head == N) {
            head = 0;
            dis1 = A[i] - A[head];
            ans = min(dis1, ans);
        } else {
            dis1 = A[head] - A[i];
            ans = min(abs(K - dis1), ans);
        }
        int dis2 = 0;
        if (end == -1) {
            end = N-1;
            dis2 = A[end] - A[i];
            ans = min(dis2, ans);
        } else {
            dis2 = A[i] - A[end];
            ans = min(abs(K - dis2), ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
import itertools
# import sys

N = int(input())
P = tuple([int(x) for x in input().split()])
Q = tuple([int(x) for x in input().split()])


# print(N)

so = [x + 1 for x in range(N)]

# print(so)

a = 0
b = 0
count = 1
for v in itertools.permutations(so, N):
    if v == P:
        a = count

    if v == Q:
        b = count
    
    count = count + 1

print(abs(a - b))



Measured memory_bytes: 3064
input = readlines()

n, d = input.shift.chomp.split("\s").map{|x| x.to_i}

coords = []
input.each do |l|
  vals = l.chomp.split("\s").map{|x| x.to_i}
  coords.push(vals)
end

cnt = 0
coords.each_with_index do |v1, i1|
  coords.each_with_index do |v2, i2|
    next if i1 >= i2
    sum = 0
    v1.each_with_index do |x1, i3|
      sum += (x1 - v2[i3])**2
    end
    cnt += 1 if Math.sqrt(sum) == Math.sqrt(sum).to_i
  end
end

puts cnt


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

int main(){
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B < C + D){
    cout <<"Right"<<endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  ll A, B; scanf("%lld %lld", &A, &B);
  vector<ll> X(N + 1, 0);
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &X[i]);
  }
  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    if ((X[i + 1] - X[i]) * A < B) {
      ans += (X[i + 1] - X[i]) * A;
    }
    else {
      ans += B;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define per(i , b , a) for(int i = b ; i >= a ; i --)
#define int long long 
using namespace std;
const int N = 3e5 + 10;
int far[N];
int find(int x)
{
	if(x == far[x]) return x;
	return far[x] = find(far[x]);
}
map<int , int>ha;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int n , m ; 
	cin >> n >> m;
	rep(i , 1 , n) far[i] = i;
	rep(i , 1 , m)
	{
		int u , v;
		cin >> u >> v;
		int x = find(u) , y = find(v);
		if(x < y) far[x] = y;
		else far[y] = x; 
	}
	rep(i , 1 , n) ha[find(i)] ++ ;
	int ma = 0;
	for(auto i : ha) ma = max(ma , i.second);
	cout << ma << '\n';
	return 0;
}

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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n, 0);
  for (long long i = 0; i < n; i++) {
    cin >> a.at(i);
    if (i % 2 == 0) b.at(0) += a.at(i);
    else b.at(0) -= a.at(i);
  }
  b.at(0) /= 2;
  for (long long i = 1; i < n; i++)
    b.at(i) = a.at(i - 1) - b.at(i - 1);
  for (long long i = 0; i < n - 1; i++)
    cout << 2 *b.at(i) << " ";
  cout << 2 * b.at(n - 1) << endl;
}

Measured memory_bytes: 2944
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		int[][] dp1 = new int[N+1][T+1];
		int[][] dp2 = new int[N+1][T+1];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < T; j++) {
				if(j+A[i] < T)
					dp1[i+1][j] = Math.max(dp1[i][j], dp1[i][j+A[i]]+B[i]);
				else
					dp1[i+1][j] = dp1[i][j];				
			}
		}
		for(int i = N; i > 0; i--) {
			for(int j = 0; j < T; j++) {
				if(j+A[i-1] < T)
					dp2[i-1][j] = Math.max(dp2[i][j], dp2[i][j+A[i-1]]+B[i-1]);
				else
					dp2[i-1][j] = dp2[i][j];				
			}
		}
		int ans = 0;
		for(int i = 0; i < N; i++)
			for(int j = 0; j < T; j++)
				ans = Math.max(ans, dp1[i][j]+dp2[i+1][T-1-j]+B[i]);
		System.out.println(ans);

	}

}

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

using namespace std;
using ll = long long;


int main()
{
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    cout << accumulate(a.begin(), a.begin() + k, 0) << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int counter = 0;


void solve(){
	int a,b;
	char ch;
	cin>>a>>ch>>b;
	if(ch == '-')
		cout<<a-b;
	else
		cout<< a+b;
}



int main()
{
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  int n; cin>>n; for (counter = 0; counter < n; ++counter)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

using namespace std ;

const int Lim=1000000 ;

int n , k ;
int main ()
{
	int i ;
	scanf("%d%d",&k,&n);
	for ( i=max(-Lim,n-k+1) ; i<=Lim && i<=n+k-1 ; i++ ) printf("%d ",i);
	return 0 ;
}


Measured memory_bytes: 128
from collections import deque

S = deque(list(input()))

Q = int(input())

cnt = 0
for i in range(Q):
    l = list(map(str,input().split()))
    if int(l[0]) == 1:
        cnt += 1
    else:
        if int(l[1]) == 1:
            if cnt % 2 == 1:
                S.append(l[2])
            else:
                S.appendleft(l[2])
        else:
            if cnt % 2 == 1:
                S.appendleft(l[2])
            else:
                S.append(l[2])

if cnt % 2 == 1:
    S = list(S)[::-1]
print(''.join(S))

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

int main() {
  int N,T;
  cin >> N >> T;
  vector<int> c(N),t(N);
  for (int i=0;i<N;i++) {
    cin >> c.at(i) >> t.at(i);
  }
  
  int count=0,cost=1001;
  for (int i=0;i<N;i++) {
    if (t.at(i)<=T) {
      count++;
      if (c.at(i)<cost) {
        cost=c.at(i);
      }
    }
  }
  
  if (count==0) {
    cout << "TLE" << endl;
  }
  
  else {
    cout << cost << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  sp(n) fixed<<setprecision(n)
const int mod = 1e9+7;
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ------------------------------------------------------- */
const int maxn = 1e6+5;
void solve(int tc)
{
    int n,i,j,k,m,q;
    cin>>n;
    if(n>=400 && n<=599)
        cout<<8;
    else
    if(n>=600 && n<=799)
        cout<<7;
    else
    if(n>=800 && n<=999)
        cout<<6;
    else
    if(n>=1000 && n<=1199)
        cout<<5;
    else
    if(n>=1200 && n<=1399)
        cout<<4;
    else
    if(n>=1400 && n<=1599)
        cout<<3;
    else
    if(n>=1600 && n<=1799)
        cout<<2;
    else
    if(n>=1800 && n<=1999)
        cout<<1;
}
signed main()
{
    RAGE;
  //  db();       
    int t=1;
    //  cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
 //   timeit();
    return 0;
}

Measured memory_bytes: 3672
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)

int main()
{
    fast;
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
    {
        cout << 1;
    }
    else
    {
        cout << (h * w + 1) / 2;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Vec(Rr,lli,N+1,0);
  Vec(Rl,lli,N+1,0);
  rep(i,0,N)Rl[i+1]^=Rl[i]^P[i];
  rrep(i,N,0)Rr[i]^=Rr[i+1]^P[i];
  rep(i,0,N)Out((Rr[i+1]^Rl[i]));
}

Measured memory_bytes: 7872
(declaim (optimize (speed 3) (debug 0) (safety 0)))

(let ((a (read))
      (b (read))
      (k (read)))

  (defun small (p q &optional (acc nil))
    (if (= q 0)
      acc
      (small (1+ p) (1- q) (cons p acc))))


  (defun big (p q &optional (acc nil))
    (if (= q 0)
      acc
      (big (1- p) (1- q) (cons p acc))))


  (defun range (p q &optional (acc nil))
    (if (> p q)
      acc
      (range (1+ p) q (cons p acc))))


  (defun delete-small (p lst)
    (mapcar #'(lambda (x)
                (if (< x p)
                  p
                  x))
            lst))


  (defun delete-big (p lst)
    (mapcar #'(lambda (x)
                (if (> x p)
                  p
                  x))
            lst))


  (format t "~{~A~%~}"
          (sort (remove-duplicates (append (delete-big b (small a k))
                                           (delete-small a (big b k))))
                #'<)))


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

int main(){
    vector<char> V(4);
    for(int i=0; i<4; ++i){
        cin >> V[i];
    }

    int x= (V[0] - '0') * 10 + V[1] - '0';
    int y= (V[2] - '0') * 10 + V[3] - '0';
    
    if(x == 0 && y == 0){
        cout << "NA" << endl;
    }else if(x == 0 && y >= 13){
        cout << "NA" << endl;
    }else if(x >= 13 && y == 0){
        cout << "NA" << endl;
    }else if(1 <= x && 12 >= x && 1 <= y && 12 >= y){
        cout << "AMBIGUOUS" << endl;
    }else if(1 <= x && 12 >= x && 0 <= y && 99 >= y){
        cout << "MMYY" << endl;
    }else if(0 <= x && 99 >= x && 1 <= y && 12 >= y){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long a[n+10];
    int i,j;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    vector<long long>rect;
    vector<long long>square;
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            rect.push_back(a[i]);
        }
    }
    int rects=rect.size();
    for(i=2;i<rects;i++)
    {
        if(rect[i]==rect[i-1]&&rect[i]==rect[i-2])
        {
            square.push_back(rect[i]);
        }
    }
    int sq=square.size();
    long long ans1=0,ans2=0;
    if(sq>=1)
    {
        ans1=square[sq-1]*square[sq-1];
    }
    if(rects>=2)
    {
        int x=0;
        for(i=rects-2;i>=0;i--)
        {
            if(rect[i]!=rect[rects-1])
            {
                x=1;
                break;
            }
        }
        if(x==1)
        {
            ans2=rect[rects-1]*rect[i];
        }
    }
    if(ans1>ans2)
    {
        printf("%lld\n",ans1);
    }
    else
    {
        printf("%lld\n",ans2);
    }
    return 0;

}


Measured memory_bytes: 3316
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 1000000000;
const int MOD = 1000000007;
int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main(){
  ll n,m;
  cin>>m>>n;
  cout<<modPow(m,n,MOD)<<endl;
}


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


int main() {
    int x;cin >> x;
    if (x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100010, Mod = 1e9 + 7;
char st[N]; int s[N];
int main() {
	int n, ans = 1; cin >> n >> st + 1;
	for (int i = 1; i <= n; i++) s[st[i] - 'a']++;
	for (int i = 0; i < 26; i++)
		ans = 1ll * ans * (s[i] + 1) % Mod;
	cout << (ans + Mod - 1) % Mod << "\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main
{
	static int H, W, N;
	static int[] ai;
	static int[][] field;

	public static void main(String[] args)
	{
		try(Scanner sc = new Scanner(System.in))
		{
			H = sc.nextInt();
			W = sc.nextInt();
			N = sc.nextInt();
			field = new int[W][H];
			for(int i = 0; i < W; i++)
			{
				for(int j = 0; j < H; j++)
				{
					field[i][j] = -1;
				}
			}
			ai = new int[N];
			for(int i = 0; i < N; i++)
			{
				ai[i] = sc.nextInt();
			}
		}

		int[] in = new int[W*H];
		int pos = 0;
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < ai[i]; j++)
			{
				in[pos++] = i + 1;
			}
		}

		int posx = 0, posy = 0;
		int dx = 1;

		for(int i = 0; i < W*H; i++)
		{
			field[posx][posy] = in[i];
			if(posx + dx >= W)
			{
				posy++;
				dx = -1;
			}
			else if(posx + dx < 0)
			{
				posy++;
				dx = 1;
			}
			else
			{
				posx += dx;
			}
		}

		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				System.out.print(field[j][i] + " ");
			}
			System.out.println();
		}


	}


}


Measured memory_bytes: 33196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>
#include <unordered_map>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	unordered_map<char,function<string(string)>> inv;
	inv['J']=[](string s){
		rotate(s.begin(),s.end()-1,s.end());
		return s;
	};
	inv['C']=[](string s){
		rotate(s.begin(),s.begin()+1,s.end());
		return s;
	};
	inv['E']=[](string s){
		rep(i,s.size()/2) swap(s[i],s[(s.size()+1)/2+i]);
		return s;
	};
	inv['A']=[](string s){
		return string(s.rbegin(),s.rend());
	};
	inv['P']=[](string s){
		char ds[]="9012345678";
		rep(i,s.size()) if(isdigit(s[i])) s[i]=ds[s[i]-'0'];
		return s;
	};
	inv['M']=[](string s){
		char ds[]="1234567890";
		rep(i,s.size()) if(isdigit(s[i])) s[i]=ds[s[i]-'0'];
		return s;
	};
	
	int tc; cin>>tc;
	while(tc--){
		string m,s; cin>>m>>s;
		reverse(all(m));
		for(char c:m)
			s=inv[c](s);
		cout<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1236
let rec read () =
  let n, p = Scanf.scanf "%d,%d\n" (fun x y -> (x, y)) in
  if n = 0 && p = 0 then []
  else (n, p) :: read ()

let rec setRank r = function
  | [] -> []
  | (n, p) :: [] -> [(n, p, r)]
  | (n1, p1) :: (n2, p2) :: rest -> if p1 = p2 then (n1, p1, r) :: setRank r ((n2, p2) :: rest)
                                    else (n1, p1, r) :: setRank (r+1) ((n2, p2) :: rest)

let find tbl n = let (_,_,r) = List.find (fun (m, p, r) -> n = m) tbl in r

let _ =
  let tbl =setRank 1 (List.sort (fun (n1,p1) (n2,p2) -> compare p2 p1) (read ())) in
  try
    while true do
      let r = Scanf.scanf "%d\n" (fun x -> find tbl x) in
      Printf.printf "%d\n" r
    done
  with
    End_of_file -> ()

Measured memory_bytes: 2324
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    S, T = input().split()
    A, B = mis()
    U = input()
    if U==S:
        print(A-1,B)
    else:
        print(A,B-1)



main()


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

int N;
int64_t K;
int64_t sum{};
std::vector<int64_t> A;

bool able(int64_t);

int main()
{
	scanf("%d%lld", &N, &K);
	A.resize(N);
	for (auto& e: A)
	{
		scanf("%lld", &e);
		sum += e;
	}
	int64_t max{};
	for (int64_t div{1}; div * div <= sum; div++)
	{
		if (sum % div) continue;
		if (able(div))
			max = std::max(max, div);
		if (able(sum / div))
			max = std::max(max, sum / div);
	}
	printf("%lld\n", max);

	return 0;
}

bool able(int64_t div)
{
	int64_t rest{sum / div};
	for (auto& e: A) rest -= e / div;
	int64_t count{};
	std::sort(A.begin(), A.end(), [&](auto& a, auto& b) { return a % div < b % div; });
	for (int64_t i{}; i < N - rest; i++)
		count += A[i] % div;
	return count <= K;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    V<ll> val(N), cost(N);
    for(ll &e : val) cin >> e;
    for(ll &e : cost) cin >> e;
    ll ans = 0;
    for(ll i = 0; i < N; i++) {
        if(val[i] <= cost[i]) continue;
        ans += val[i] - cost[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int count = 0;

            for(int i=0;i<S.Length;i++)
            {
                if (S[i] != T[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 17984
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  stack<string> s;
  string tmp="abc";
  string prev;
  int v1,v2;
  string val;
  int ret = 0;
  ostringstream oss;
  while(cin >> tmp){
    //cout << tmp << endl;
    s.push(tmp);
    if(tmp == "+"){
      //cout << tmp << endl;

      s.pop();
      val = s.top();
      v1 = atoi(val.c_str());
      s.pop();
      val = s.top();
      v2 = atoi(val.c_str());
      s.pop();

      ret = v1 + v2;
      oss << ret;

      s.push(oss.str());

    }
    if(tmp == "-"){
      s.pop();
      val = s.top();
      v1 = atoi(val.c_str());
      s.pop();
      val = s.top();
      v2 = atoi(val.c_str());
      s.pop();
      ret = v2 - v1;
      //cout << v1 << " " << v2 << " "<< ret << endl;
      oss << ret;
      s.push(oss.str());
      
    }

    if(tmp == "*"){
      s.pop();
      val = s.top();
      v1 = atoi(val.c_str());
      s.pop();
      val = s.top();
      v2 = atoi(val.c_str());
      s.pop();
      ret = v1 * v2;

      oss << ret;
      s.push(oss.str());
    }

    oss.str("");
  }

  cout << s.top() << endl;
    
  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MAX=2e5+5;
int p[MAX];
int rozmiar[MAX];
int Find(int u){
  if (p[u]!=u)p[u]=Find(p[u]);
  return p[u];
}

void Union(int u,int v){
  rozmiar[Find(v)]+=rozmiar[Find(u)];
  p[Find(u)]=Find(v);
}
int32_t main(){
  BOOST;
  int n,m;
  cin>>n>>m;
  for (int i=1;i<=n;i++)p[i]=i,rozmiar[i]=1;
  for (int i=1;i<=m;i++){
    int a,b;
    cin>>a>>b;
    if (Find(a)!=Find(b))Union(a,b);
  }
  int ans=0;
  for (int i=1;i<=n;i++)ans=max(ans,rozmiar[Find(i)]);
  cout<<ans;
  return 0; 
}


Measured memory_bytes: 12888
abcdek=[]
for i in range(6):
  abcdek.append(int(input()))
ans="Yay!"
k=abcdek[5]
for i in range(5):
  p=abcdek[i]
  for j in range(i+1,5):
    q=abcdek[j]
    if q-p>k:
      ans=":("
      break
print(ans)

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

using namespace std;

const int MAX_N = 5000;

// dp[i][j] := i を含み, 公差 v[i]-v[j] の数列の長さ
vector<vector<int>> dp(MAX_N, vector<int>(MAX_N, 0));

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  map<int, int> pos;
  for (int i = 0; i < n; i++) pos[v[i]] = i;
  int ret = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int dif = v[i] - v[j];
      if (pos.count(v[j] - dif)) {
        int p = pos[v[j] - dif];
        dp[i][j] = dp[j][p] + 1;
      } else {
        dp[i][j] = 2;
      }
      ret = max(ret, dp[i][j]);
    }
  }
  cout << ret << endl;
}



Measured memory_bytes: 101080
#include<bits/stdc++.h>
#define ll long long
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;
vector<pii > v;
vector<int> ans;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	For(i,1,n){
		int x;
		scanf("%d",&x);
		v.PB(pii(x,i));
	}
	int p1=-1,p2;
	For(i,1,k+1){
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		For(j,0,v.size()-1){
			if (v[j].se!=p1){
				p2=v[j].se;
				ans.PB(v[j].se);
				if (--v[j].fi<0)
					return puts("-1"),0;
			}
		}
		p1=p2;
	}
	printf("%d\n",ans.size());
	For(i,0,ans.size()-1)
		printf("%d ",ans[i]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[3010], n;
bool cmp(int x, int y) {
	return x > y;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	a[n] = 10000;
	ll ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++) {
			int u1 = lower_bound(a, a+n+1, a[j]-a[i]) - a;
			while (a[u1] <= a[j]-a[i]) u1++;
			int u2 = lower_bound(a, a+n+1, a[j]+a[i]) - a;
			while (a[u2] >= a[j]+a[i]) u2--;
			int t = 0;
			if (a[i] >= a[u1] && a[i]<=a[u2]) t++;
			if (a[j] >= a[u1] && a[j]<=a[u2]) t++;
			ans += max(0, u2-u1-t+1);
		}
	}
	printf("%lld\n", ans/3);
	return 0;
}

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

using namespace std;

int main(void) {
    int N, L, min = 1000, min_i, taste_sum = 0;
    scanf("%d %d", &N, &L);
    for (int i = 0; i < N; i++) {
        int taste = L + i;
        taste_sum += taste;
        if (abs(taste) < min) {
            min = abs(taste);
            min_i = i;
        }
    }
    taste_sum -= L + min_i;
    cout << taste_sum << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    sc.Split(bufio.ScanWords)
    n, a, b := nextInt(), nextInt(), nextInt()

    blue := n / (a + b) * a

    if n % (a + b) > a {
        blue += a
    } else {
        blue += n % (a + b)
    }

    fmt.Println(blue)
}




//===========================
//
// Library
//
//===========================

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

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

func gcd(x, y int) int {
    if y == 0 {
        return x
    }

    return gcd(y, x%y)
}

//====================
//  var q Queue
//  q.Enqueue(n)
//  n := q.Dequeue()
//====================
type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

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

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

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}



Measured memory_bytes: 640
#include <vector>
#include <array>
#include <map>
#include <string>
#include <algorithm>
#include <iostream>
#include <set>
#include <random>
#include <cassert>
#include <fstream>

const int MOD = 1e9 + 7;
using namespace std;
bool is_prime(int n) {
    for (int i = 2; i < n; ++i) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> primes;
    for (int i = 2; i <= n; ++i) {
        if (is_prime(i)) {
            primes.push_back(i);
        }
    }
    vector<int> cnt;
    for (int prime : primes) {
        cnt.push_back(0);
        for (int i = 2; i <= n; ++i) {
            int x = i;
            while (x % prime == 0) {
                x /= prime;
                ++cnt.back();
            }
        }
    }
    int64_t ans = 1;
    for (int i = 0; i < primes.size(); ++i) {
        ans *= (cnt[i] + 1);
        ans %= MOD;
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,M=0,sum=0;
  cin>>N;
  int L[N];
  for(int i=0;i<N;i++){
    cin>>L[i];
    M=max(M,L[i]);
    sum+=L[i];
  }
  if(sum-M>M) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<LL> V;
typedef vector<V> VV;
const int mod=1e9+7;
int main(){
    int N,M;
    cin>>N>>M;
    VV g(N+1);
    VV c(N+1);
    REP(i,M){
        int l,r,x;
        cin>>l>>r>>x;
        g[r].pb(l);
        c[r].pb(x);
    }
    VV dp(N+1,V(N+1,0));
    dp[0][0]=1;
    REP(i,N){
        VV nxt(N+1,V(N+1,0));
        REP(a,N){
            FOR(b,a,N){
                nxt[a][b]+=dp[a][b];
                nxt[b][i]+=dp[a][b];
                nxt[a][i]+=dp[a][b];
            }
        }
        for(auto &it:nxt)for(auto &jt:it)jt%=mod;
        int m=g[i+1].size();
        REP(j,m){
            REP(a,N){
                FOR(b,a,N){
                    int cnt=1;
                    if(a>=g[i+1][j])cnt++;
                    if(b>=g[i+1][j])cnt++;
                    if(c[i+1][j]!=cnt)nxt[a][b]=0;
                }
            }   
        }
        swap(dp,nxt);
    }
    LL res=0;
    for(auto &it:dp)for(auto &jt:it)res+=jt;
    cout<<res%mod<<endl;
    return 0;
}


Measured memory_bytes: 1792
import time
start = time.time()

import random
from collections import defaultdict


def get_score(day, contest, prev_list, loss_list, satisfied_matrix):
    plus = satisfied_matrix[day][contest]
    minus = 0
    for type, prev in enumerate(prev_list):
        if type == contest:
            continue
        spend = day - prev
        minus += loss_list[type] * spend

    return plus - minus


def calc_score_by_contest(contest, contest_schedule, loss_base, satisfied_matrix):
    plus = 0
    minus = 0
    for day in contest_schedule:
        plus += satisfied_matrix[day][contest]

    diff = [0] + contest_schedule[:-1]
    loss_base = loss_list[contest]
    for prev, open in zip(diff, contest_schedule):
        spend = open - prev
        loss = loss_base * spend * (spend + 1) // 2
        minus += loss

    return plus - minus


def update(day, old, new, loss_list, satisfied_matrix):
    if old == new:
        return None


def schedule_to_dict(schedule):
    dict = defaultdict(list)
    for day, contest in enumerate(schedule):
        dict[contest].append(day)

    for contest in range(26):
        dict[contest].append(364)

    return dict


def calc_score(schedule, loss_list, satisfied_matrix):
    schedule_dict = schedule_to_dict(schedule)
    plus = 0
    minus = 0
    for contest in range(26):
        day_list = schedule_dict[contest]
        for day in day_list:
            plus += satisfied_matrix[day][contest]

        diff = [0] + day_list[:-1]
        loss_base = loss_list[contest]
        for prev, open in zip(diff, day_list):
            spend = open - prev
            loss = loss_base * spend * (spend+1) // 2
            minus += loss

    return plus - minus


days = int(input())
loss_list = list(map(int, input().split()))
satisfied_matrix = [list(map(int, input().split())) for _ in range(days)]


maxim_loss_contest = loss_list.index(max(loss_list))

ans = [i % 26 for i in range(365)]
prev = calc_score(ans, loss_list, satisfied_matrix)


while time.time() - start < 1.7:
    target_day = random.randint(3, 360)
    pairs = [target_day-3, target_day-2, target_day-1, target_day+1, target_day+2, target_day+3]

    for pair in pairs:
        ans[target_day], ans[pair] = ans[pair], ans[target_day]
        new_score = calc_score(ans, loss_list, satisfied_matrix)
        if new_score < prev:
            ans[target_day], ans[pair] = ans[pair], ans[target_day]
        else:
            prev = new_score
            break


for contest in ans:
    print(contest + 1)


Measured memory_bytes: 87432
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int c[3][3];

int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
	
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int k=0;k<=100;k++){
				if((c[0][0]-i==c[1][0]-j&&c[1][0]-j==c[2][0]-k)&&
				   (c[0][1]-i==c[1][1]-j&&c[1][1]-j==c[2][1]-k)&&
				   (c[0][2]-i==c[1][2]-j&&c[1][2]-j==c[2][2]-k)){
					   cout<<"Yes"<<endl;
					   return 0;
				   }
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

typedef int32_t i32;
typedef int64_t i64;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  const i32 m = 100000;
  i64 *d = ALLOC (m + 1, i64);
  for (i32 i = 1; i <= m; ++i) {
    d[i] = 1;
  }
  for (i32 i = 1; i <= m; ++i) {
    for (i32 j = 2 * i; j <= m; j += i) {
      d[j] = MIN (d[j] * i, 2 * m);
    }
  }
  for (i32 i = 1; i <= m; ++i) {
    d[i] = d[i] >= 2 * i ? 1 : 0;
  }
  for (i32 i = 2; i <= m; ++i) {
    d[i] += d[i - 1];
  }
  i32 q;
  scanf ("%" SCNi32, &q);
  while (q--) {
    i32 n;
    scanf ("%" SCNi32, &n);
    printf ("%" PRIi64 "\n", d[n]);
  }
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 2640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int H = s[0];
            int W = s[1];

            string ans = "";
            for (int i = 0; i < H; i++)
            {
                string[] input = ReadLine().Split(' ');
                for (int j = 0; j < W; j++)
                {
                    if (input[j] == "snuke")
                    {
                        ans += Convert.ToChar('A' + j).ToString() + (i + 1);
                        break;
                    }
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
include Math

class Point
  attr_accessor :x, :y
  def initialize(x = 0.0, y = 0.0)
    @x = x
    @y = y
  end

  def dump
    puts "%.8f %.8f" % [@x, @y]
  end
end

def koch_curve(n, p1, p2)
  return if n == 0
  
  s = Point.new
  s.x = (2 * p1.x + p2.x) / 3
  s.y = (2 * p1.y + p2.y) / 3
  t = Point.new
  t.x = (2 * p2.x + p1.x) / 3
  t.y = (2 * p2.y + p1.y) / 3
  u = Point.new
  u.x = (t.x - s.x) * cos(PI / 3) - (t.y - s.y) * sin(PI / 3) + s.x
  u.y = (t.x - s.x) * sin(PI / 3) + (t.y - s.y) * cos(PI / 3) + s.y
  
  koch_curve(n-1, p1, s)
  s.dump
  koch_curve(n-1, s, u)
  u.dump
  koch_curve(n-1, u, t)
  t.dump
  koch_curve(n-1, t, p2)
end

n = gets.to_i
p1 = Point.new
p2 = Point.new(100.0, 0.0)

p1.dump
koch_curve(n, p1, p2)
p2.dump

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

const int MAX = 500000 + 25;
struct Query {
  int l, r, idx;

  bool operator<(Query rhs) const {
    return r < rhs.r;
  }
} queries[MAX];
int bit[MAX];


void update(int idx, int val, int n) {
  for (; idx <= n; idx += idx & -idx)
    bit[idx] += val;
}

int query(int idx) {
  int sum = 0;
  for (; idx > 0; idx -= idx & -idx)
    sum += bit[idx];
  return sum;
}

int arr[MAX], ans[MAX], last_visit[MAX];
void solve(std::istream &in, std::ostream &out) {
  int n, q;
  in >> n >> q;
  for (int i = 0; i < n; ++i) {
    in >> arr[i];
  }
  for (int i = 0; i < q; ++i) {
    in >> queries[i].l >> queries[i].r;
    --queries[i].l;
    --queries[i].r;
    queries[i].idx = i;
  }
  sort(queries, queries+q);
  memset(last_visit, -1, sizeof last_visit);

  int query_counter = 0;
  for (int i = 0; i < n; i++) {
    if (last_visit[arr[i]] != -1)
      update(last_visit[arr[i]] + 1, -1, n);

    last_visit[arr[i]] = i;
    update(i + 1, 1, n);

    while (query_counter < q && queries[query_counter].r == i) {
      ans[queries[query_counter].idx] =
        query(queries[query_counter].r + 1) -
        query(queries[query_counter].l);
      query_counter++;
    }
  }

  for (int i = 0; i < q; i++)
    cout << ans[i] << endl;
}

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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
	int N, M; cin>>N>>M;
	struct Bite {
	    int a,b;
	    bool operator<(const Bite& x) const {return b < x.b;}
	    operator int() const {return a;}
	};
	vector<Bite> bites(N);
	for (auto& b : bites)
	    cin>>b.a >> b.b;

	sort(bites.begin(), bites.end(), [](auto l, auto r) {return l.a < r.a;});
	priority_queue<Bite> bq;
	size_t ans = 0;
	auto i = 0;
	for (int day = M-1; day >= 0; day--) {
	    while (i < N and bites[i].a <= M-day)
	        bq.push(bites[i++]);
        if (bq.empty())
            continue;
        auto p = bq.top(); bq.pop();
        ans += p.b;
	}
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 2168