akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <limits.h>


int main(){

  int n, p[102],m[102][102];

  int i;

  int temp, temp2;


  int j, k, l;
  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&p[i]);
    scanf("%d",&temp);
  }

  p[n]=temp;


  for(i=1;i<=n;i++) m[i][i]=0;
    


  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      
      m[i][j]=INT_MAX;
      
      for(k=i;k<=j-1;k++){
	temp2=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];

	if(m[i][j]>temp2){
	  m[i][j]=temp2;
	}
      }
      
    }
  }

  printf("%d\n", m[1][n]);

  return 0;
}

int min(int a, int b){

  if(a<b) return a;
  else return b;
}



Measured memory_bytes: 2052
N = int(input())
P = list(map(int, input().split()))
 
left_bigger  = [0] + [i for i in range(N+1)]
right_bigger = [i+1 for i in range(N+1)] + [N+1]
 
E = [(v, i+1) for i, v in enumerate(P)]
E.sort()

ans = 0
for v,i in E:
    l0=left_bigger[i]
    l1=left_bigger[l0]
    r0=right_bigger[i]
    r1=right_bigger[r0]
    ans += ((r1-r0)*(i-l0) + (r0-i)*(l0-l1))*v
    left_bigger[r0]=l0
    right_bigger[l0]=r0
print(ans)




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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	cin >> s;
	int b = 0;
	for(int i = 1; i < (int)s.size(); i++)
		if(s[i-1] == 'W' && s[i] == 'B')
			b++;

	int ans = 0;
	if(s[0] == 'B')
		ans++;
	if(s[(int)s.size()-1] == 'B')
		ans++, b--;

	ans += 2*b;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
// #define __USE_MINGW_ANSI_STDIO 0

#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string str = "";
    str += s.substr(0,1);
    str += to_string(s.size()-2);
    str += s.substr(s.size()-1,1);
    cout << str << endl;
    // cout << itoa(s.size()) << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
co = []
for i in range(n):
    co.append(na())


def circumcircle(ax, ay, bx, by, cx, cy):
    if (bx-ax)*(cy-ay)-(by-ay)*(cx-ax) == 0:
        return None
    D = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
    X = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / D
    Y = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / D;
    R = math.sqrt((X - ax) * (X - ax) + (Y - ay) * (Y - ay))
    return X, Y, R


minr = 999999999999999
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            cc = circumcircle(co[i][0], co[i][1], co[j][0],co[j][1], co[k][0], co[k][1])
            if cc:
                x, y, r = cc
                if r > minr:
                    continue
                ok = True
                for u in co:
                    if (u[0]-x) * (u[0]-x) + (u[1]-y)*(u[1]-y) > r*r + 1e-9:
                        ok = False
                        break
                if ok:
                    minr = r

for i in range(n):
    for j in range(i+1, n):
        x, y, r = (co[i][0] + co[j][0])/2, (co[i][1]+co[j][1])/2, \
            math.sqrt((co[i][0]-co[j][0])*(co[i][0]-co[j][0]) +\
                      (co[i][1] - co[j][1]) * (co[i][1] - co[j][1])
                      )/2
        if r > minr:
            continue
        ok = True
        for u in co:
            if (u[0]-x) * (u[0]-x) + (u[1]-y)*(u[1]-y) > r*r + 1e-9:
                ok = False
                break
        if ok:
            minr = r

print("{:.14f}".format(minr))


Measured memory_bytes: 50924
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
int manhattan(int x1, int y1, int x2, int y2) {
    return abs(x1 - x2) + abs(y1 - y2);
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>> student(N, vector<int> (2));
    vector<vector<int>> vec(M, vector<int> (2));
    for (int i = 0; i < N; i++){
        cin >> student[i][0] >> student[i][1];
    }
    int tmp, cnt;
    for (int i = 0; i < M; i++){
        cin >> vec[i][0] >> vec[i][1];
    }
    for (int i = 0; i < N; i++) {
        tmp = 0;
        cnt = manhattan(vec[0][0], vec[0][1], student[i][0], student[i][1]);
        for (int j = 1; j < M; j++){
            if (manhattan(vec[j][0], vec[j][1], student[i][0], student[i][1]) < cnt){
                cnt = manhattan(vec[j][0], vec[j][1], student[i][0], student[i][1]);
                tmp = j;
            }
        }
        cout << tmp + 1 << endl;
    }
}



Measured memory_bytes: 256
using System;

using System.Collections.Generic;

class Program {
    static void Main(string[] args) {

        string[] AB = Console.ReadLine().Split(' ');

        int A = int.Parse(AB[0]);
        int B = int.Parse(AB[1]);

        int result = -1;

        if (A < 10 && B < 10) {
            result = A * B;
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
 		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

 		int counta = 0;
        while(C-B>0){
            C -= B;
                counta++;
        }
        int countt = 0;
        while(A-D>0){
            A -= D;
                countt++;
        }
        if(counta<=countt){
        System.out.println("Yes");
        }else{
        System.out.println("No");            
        }
	}
}

Measured memory_bytes: 35708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  ll n,d,ans = 0;
  cin >> n >> d;

  vt<ll> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];

  rep(i,n){
    if(d*d >= x[i]*x[i]+y[i]*y[i])
    ans++;
  }

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


Measured memory_bytes: 6368
#include<stdio.h>



int main()
{
	int n ;
	int win ,draw ;

	scanf( "%d" ,&n ) ;

	do
	{
		int score[ 10 ] = { 0 } ;
		char team[ 10 ][ 40 + 1 ] ;


		int i ,j ;
		for( i = 0 ; i < n ; ++i )
		{
			scanf( "%s %d %d %d" ,team[ i ] ,&win ,&draw ,&draw ) ;


			score[ i ] = ( win * 3 ) + draw ;
		}



		int rank[ 10 ] = { 0 } ;

		for( i = 0 ; i < n ; ++i )
		{
			for( j = 0 ; j < n ; ++j )
			{
				if( i != j && score[ i ] < score[ j ] )
				{
					++rank[ i ] ;
				}
			}
		}



		int k = 0 ;

		while( k < n )
		{
			for( i = 0 ; i < n ; ++i )
			{
				if( rank[ i ] == k )
				{
					printf( "%s,%d\n" ,team[ i ] ,score[ i ] ) ;
				}
			}

			++k ;
		}


		scanf( "%d" ,&n ) ;

		if( n != 0 )
		{
			puts( "" ) ;
		}

	}while( n != 0 ) ;


	return 0 ;
}

Measured memory_bytes: 612
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut bits: u32 = 0xffffffff;
    for _ in 0..n {
        let k: u8 = read(&mut stdin_lock, &mut buf, b' ');
        let mut mask: u32 = 0;
        for _ in 0..(k - 1) {
            let a: u8 = read(&mut stdin_lock, &mut buf, b' ');
            mask |= 1 << (a - 1);
        }
        let a: u8 = read(&mut stdin_lock, &mut buf, b'\n');
        mask |= 1 << (a - 1);
        bits &= mask;
    }
    let mut ans = 0;
    for i in 0..m {
        if ((bits >> i) & 1) == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
s=raw_input()
tmp=[s[0], s[1]]
chk=len(s)
if tmp[0]==tmp[1]:
    print 1,2
elif chk==3 and len(set(list(s)))<3:
    print 1,3
elif chk<4:
    print -1,-1
else:
    for i in range(2,chk):
        if len(tmp)==3:
            tmp.pop(0)
        tmp.append(s[i])
        if len(set(tmp))<3:
            print i-1,i+1
            exit()
    else:
        print -1,-1

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

#define int            long long 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

}

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

	int ans = 0;

	ans += pow(n,1) + pow(n,2) + pow(n,3);

	cout<<ans<<endl;
}

int32_t main()
{
	c_p_c();

	// int t;
	// cin>>t;

	// while(t--)
	// {
		solution();
	//}

	return 0;
}


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

constexpr long long MOD = 1'000'000'007;

int main(){
	
	long long n, k;
	long long ans = 1;
	
	cin>>n>>k;
	

	for(int i = 0; i < n; i++){
		ans *= k - i;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3116
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;
    cin >> N;

    int ans = INF;
    for (int i = 1; i * i <= N; i++) {
        if (N % i != 0) continue;
        int t = N / i;
        ans = min(ans, t);
    }

    int res = 0;
    while (ans > 0) {
        res++;
        ans /= 10;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
/*
@samaranand
*/
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';

// [0, 1, 1, #, 0, 0, 0, 0, 0,]
// [1, 2, 3, 3, 3, 3, 3, 3, 3,]
// [1, 3, #, 3, 6, #, 3, 3, 0,]
// [#, 3, 3, 3, 0, 0, , 0, 0,]
// [0, 0, 0, 0, 0, 0, , 0, 0,]
// [0, 0, 0, 0, 0, 0, , 0, 0,]
// [0, 0, 0, 0, 0, 0, , 0, 0,]
const int mod = 1e9 + 7;

int calc(int res[], char input[][1010], int h, int w) {
	for1(i, w) {
		if (input[0][i] == '#') break;
		res[i] = 1;
	}
	bool f = 0;
	for (int i = 1; i < h; i++) {
		if (input[i][0] == '#') {
			f = 1;
		}
		res[0] = 1 ^ f;
		for (int j = 1; j < w; j++) {
			if (input[i][j] == '#') res[j] = 0;
			else res[j] = (res[j - 1] % mod + res[j] % mod) % mod;
		}
	}
	return res[w - 1];
}



int main() {
	int h, w;
	cin >> h >> w;
	char input[1010][1010];
	for0(i, h) {
		for0(j, w) {
			cin >> input[i][j];
		}
	}
	int res[1010] = {0};

	int ans = calc(res, input, h, w);
	cout << ans;

	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
 
using namespace std;
 
void BuildStairs()
{
  int n;
  cin >> n;
  int h;
  int pre;
  bool flag = true;
  
  cin >> pre;
  for (int i = 1; i < n; i++)
  {
    cin >> h;
    if (pre - h > 1)
    {
      flag = false;
      break;
    }
    else if (pre - h == 1)
    {
      h = h + 1;
    }
    pre = h;
  }
  
  if (flag == true)cout << "Yes" << endl;
  else cout << "No" << endl;
}
 
int main()
{
  BuildStairs();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Possible" << endl;
}

void no(){
  cout << "Impossible" << endl;
  exit(0);
}

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

  yes();
  FOR(i, 1, last){
    cout << i << endl;
  }
  IFOR(i, last+1, N){
    cout << i << endl;
  }
  cout << last << endl;
}



Measured memory_bytes: 1664
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll N, M;
    cin >> N >> M;

    VB red(N + 1, false);
    VL bnum(N + 1, 1);
    red[1] = true;

    REP(i, M) {
        ll x, y;
        cin >> x >> y;
        bnum[x]--;
        bnum[y]++;

        if (red[x]) {
            red[y] = true;
            if (bnum[x] == 0) {
                red[x] = false;
            }
        }
    }

    ll ans = 0;
    NREP(i, N) {
        if (red[i]) ans++;
    }

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

Measured memory_bytes: 1024
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	unsigned long long n;
	unsigned long long base = 26ULL; 
	
	stack<char> result; 
	
	string add_char; 
	unsigned long long last_digit = 0; 
	// string result (); 
	
	cin >> n; 
	
	while(n > 0) {
		if( n%base == 0 ) {
			last_digit = 26; 
		} else {
			last_digit = n%base; 
		}
		// cout << (n%base) << " " << (char)((n%base)+('a'-1)) << endl; 
		result.push((last_digit)+('a'-1)); 
		n = (n - last_digit) / base; 
	}
	
	while(result.size() > 0) {
		cout << result.top(); 
		result.pop(); 
	}
	cout << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3632
N, K = map(int, input().split())
if K % 2 == 1:
    print((N // K) ** 3)
else:
    cnt = 0
    for i in range(1, N + 1):
        if i % K == K // 2:
            cnt += 1
    print((N // K) ** 3 + cnt ** 3)

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

template<class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1, INF);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    chmin(dp[i], dp[i - 1] + 1);
    for (int j = 1; ; j++) {
      if (i >= pow(6, j)) chmin(dp[i], dp[i - pow(6, j)] + 1);
      else break;
    }
    for (int j = 1; ; j++) {
      if (i >= pow(9, j)) chmin(dp[i], dp[i - pow(9, j)] + 1);
      else break;
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 4028
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
d = 10**10
ans = -1
for i, x in enumerate(h):
  di = abs((t - x * 0.006) - a)
  if di < d:
    d = di
    ans = i + 1
print(ans)


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

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

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int x;
    cin >> x;
    if(x) cout << 0;
    else cout << 1;
}

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

using namespace std;
typedef long long llong;

int main(){
  vector<int> v;
  int n; cin >> n;
  for(int i=0;i<n;i++){
    int x; cin >> x;
    v.push_back(x);
  }
  sort(v.begin(),v.end(),greater<int>());
  //sides of the rectangle
  llong a[2];
  int i=0,j=0;
  while(j<=1){
    if(i+1>=n){
      a[0]=0; a[1]=0;
      break;
    }
    if(v[i]==v[i+1]){
      a[j]=v[i];
      i++; j++;
    }
    i++;
  }
  cout << a[0]*a[1] << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n, h, w;
  cin >> n >> h >> w;
  cout << (n - h +1) * (n -w+1) << endl;
    return 0;
}


Measured memory_bytes: 3588
#![allow(non_snake_case)]

fn main() {
    // let s = std::io::stdin();
    // let mut sc = Scanner { stdin: s.lock() };
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let D:usize = sc.read();
    let C:Vec<i64> = sc.vec(26);
    let S: Vec<Vec<i64>> = (0..D).map(|_| sc.vec(26)).collect();
    let mut past: Vec<i64> = (0..26).map(|_| -1).collect();
    let mut ANS:Vec<usize> = Vec::new();
    let mut point:i64 = 0;
    for i in 0..D{
        let mut m:i64 = -1000000000;
        let mut ind:usize = 0;
        for j in 0..26{
            let mut temp_point:i64 = point+S[i][j];
            for k in 0..26{
                if k == j{
                    continue
                }
                temp_point -= C[k]*((i as i64)-past[k]);
            }
            if m < temp_point{
                ind = j;
                m = temp_point;
            }
        }
        ANS.push(ind);
        point = m;
        past[ind] = i as i64;
    }
    let deadline = 20;
    for i in 0..deadline{
        let oldest:usize = ANS[i];
        for j in 0..26{
            if j == oldest {
                continue
            }
            let old = ANS[i];
            ANS[i] = j;
            let temp_point = check_point(D,&S,&ANS,&C);
            if point < temp_point{
                // println!("!!!!!! {} < {}",point, temp_point);
                point = temp_point;
            }else{
                ANS[i] = old;
            }
        }
    }
    
    for i in 0..D{
        println!("{}", ANS[i]+1);
    }
    // for i in 0..D{
    //     ans += S[i][T[i]-1];
    //     past[T[i]-1] = i as i64;
    //     for j in 0..26{
    //         ans -= C[j]*((i as i64)-past[j]);
    //     }
    //     println!("{}", ans);
    // }
}

fn check_point(D:usize, S:&Vec<Vec<i64>>, T:&Vec<usize>,C:&Vec<i64>) -> i64{
    let mut ans:i64 = 0;
    let mut past: Vec<i64> = (0..26).map(|_| -1).collect();
    for i in 0..D{
        ans += S[i][T[i]];
        past[T[i]] = i as i64;
        for j in 0..26{
            ans -= C[j]*((i as i64)-past[j]);
        }
    }
    ans
}

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);


impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}





Measured memory_bytes: 2264
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

class union_find:
  def __init__(self, n):
    self.par = [-1] * n
    self.rank = [0] * n
    self.size = [1] * n
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    if x == y:
      return
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
      self.size[y] += self.size[x]
    else:
      self.par[y] = x
      self.size[x] += self.size[y]
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
  def root(self, x):
    if self.par[x] == -1:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  def comp_size(self, x):
    x = self.root(x)
    return self.size[x]
  def same(self, x, y):
    return self.root(x) == self.root(y)
  def comp_sizes(self):
    return [self.size[i] for i in range(len(self.par)) if self.root(i) == i]

N, M = reads()
edges = []
for _ in range(M):
  A, B = reads()
  edges.append((A-1, B-1))
edges.reverse()

def tri(k):
  return k * (k - 1) // 2

uf = union_find(N)
conv = 0
total = tri(N)
ans = []
for A, B in edges:
  ans.append(total - conv)
  if not uf.same(A, B):
    a = uf.comp_size(A)
    b = uf.comp_size(B)
    uf.unite(A, B)
    conv += tri(uf.comp_size(A)) - tri(a) - tri(b)
ans.reverse()
print("\n".join(map(str, ans)))


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int shisu(int a,int b){
  if (b==0) return a;
  else{rep(i,b) a*=10;
  return a;
  }
}
int main() {
  int n,j,ans;
  cin >> n;
  j=0;
  REP(i,1,n+1){
    if (i < shisu(1,j+1) && shisu(1,j) <= i ){
        ans++;
       if (i+1 == shisu(1,j+1)){
         j+=2;
       }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int N = int(2e3 + 10);
int dis[N][N];
int cnt[N];

int main(){
	int n, x, y;

	scanf("%d %d %d", &n, &x, &y);

	const int inf = int(1e9);

	for(int i = 1 ; i <= n ; i++){
		for(int j = i + 1 ; j <= n ; j++){
			dis[i][j] = min({abs(i - x) + 1 + abs(y - j), abs(i - y) + 1 + abs(x - j), abs(i - j)});
		
			cnt[dis[i][j]]++;
		}
	}

	for(int i = 1 ; i < n ; i++){
		printf("%d\n", cnt[i]);
	}

	return 0;
}

Measured memory_bytes: 15360
import itertools
n = int(input())
p =tuple(map(int,input().split()))
q =tuple(map(int,input().split()))
l = list(itertools.permutations(range(1,n+1),n))
l.sort()
for k,t in enumerate(l):
  if t==p:
    px = k+1
  if t==q:
    qx = k+1
print(abs(px-qx))

Measured memory_bytes: 8052
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var tmp = input.split(" ");

  var r = parseInt( tmp[0], 10 );
  var d = parseInt ( tmp[1], 10 );
  var x0 = parseInt( tmp[2], 10 );

  var current_x = x0;
  for ( var i = 0; i < 10; i++ ){
    current_x = r * current_x - d;
    console.log(current_x + '\n');
  }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_Q = 100000;
int N, Q;
string S;
int l[MAX_Q], r[MAX_Q];
int sum[MAX_N+1];

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

  cin >> N >> Q;
  cin >> S;
  rep(i, Q) cin >> l[i] >> r[i];

  for (int i = 0; i+1 < S.size(); ++i) {
      if (S.substr(i, 2) == "AC") {
          sum[i+1] = sum[i]+1;
      } else {
          sum[i+1] = sum[i];
      }
  }

  for (int q = 0; q < Q; ++q) {
      cout << sum[r[q]-1] - sum[l[q]-1] << endl;
  }

  return 0;
}


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

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;

    int sum = 0, minv = 100000, maxv = -1;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      if (s < minv) minv = s;
      if (s > maxv) maxv = s;
      sum += s;
    }
    sum -= minv + maxv;
    int ave = sum / (n - 2);
    
    cout << ave << endl;
  }

  return 0;
}


Measured memory_bytes: 3096
N, M = map(int, input().split())

#N = n[0]
#M = n[1]
n_list = []
m_list = []

for i in range(int(N)):
    tmp_n_list = []
    num = input()
    tmp_num = num.split()
    tmp_n_list.append(int(tmp_num[0]))
    tmp_n_list.append(int(tmp_num[1]))
    n_list.append(tmp_n_list)

for j in range(int(M)):
    tmp_m_list = []
    num = input()
    tmp_num = num.split()
    tmp_m_list.append(int(tmp_num[0]))
    tmp_m_list.append(int(tmp_num[1]))
    m_list.append(tmp_m_list)

for k in range(int(N)):
    for l in range(int(M)):
        if l==0:
            dis = abs(n_list[k][0]-m_list[l][0])+abs(n_list[k][1]-m_list[l][1])
            point = l
        else:
            tmp_dis = abs(n_list[k][0]-m_list[l][0])+abs(n_list[k][1]-m_list[l][1])
            if dis>tmp_dis:
                dis = tmp_dis
                point = l
    print(point+1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b;
    cin >> a  >> b;
    if(a+b<10){
        cout << a+b << endl;
    }else{
        cout << "error" << endl;
    }
    return 0;
}


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

static void B_GreatOceanView();

int main()
{

	B_GreatOceanView();

	fflush(stdout);
	return 0;
}

static void B_GreatOceanView()
{
	int N = 0;
	int H[100] = { 0 };

	scanf(" %d", &N);

	for (int i = 0; i < N; i++) {
		scanf(" %d", &H[i]);
	}

	int viewable = 1;
	int maxHeight = H[0];
	for (int i = 1; i < N; i++) {
		if (H[i] >= maxHeight) {
			viewable++;
			maxHeight = H[i];
		}
	}

	printf("%d\n", viewable);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int sum = 0;
		if(n>k) {
			System.out.println(k * x + (n - k) * y);
		}
		if(n <= k) {
			System.out.println(n * x);
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    CIN(N);CIN(C);
    vector<vector<int>> color;
    REP(a,C){
        I v;
        REP(b,C){
            CIN(c);
            v.push_back(c);
        }
        color.push_back(v);
    }
    V<I> vec(3, vector<int>(100,0));
    REP(a,N){
        REP(b,N){
            CIN(c);
            vec.at((a+b+2)%3).at(c-1)++;
        }
    }
    LL ans = LINF;
    for(int a = 0;a < C;a++){
        for(int b =0;b < C;b++){
            for(int c = 0;c < C;c++){
                if(a==b||a==c||b==c)continue;
                LL ins = 0;
                for(int w = 0;w < C;w++){
                    ins += color.at(w).at(a) * vec.at(0).at(w);
                }
                for(int w = 0;w < C;w++){
                    ins += color.at(w).at(b) * vec.at(1).at(w);
                }
                for(int w = 0;w < C;w++){
                    ins += color.at(w).at(c) * vec.at(2).at(w);
                }
                ans = min(ans,ins);
            }
        }
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
program kadai
implicit none

integer  ::  come(3)
integer  ::  x(10)
integer  ::  i

read(*,*) come

x(1)=come(1)*come(3)-come(2)

do i=1,9
x(i+1)=come(1)*x(i)-come(2)
end do

do i=1,10
write(*,*) x(i)
end do




end program kadai

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod =1e9+7;
int n,ans=1;
int w[100001];
void way() {
	printf("0\n");
	exit(0);
}
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) {
		int x;
		scanf("%d",&x);
		++w[x];
	}
	if(n&1) {
		if(w[0]!=1)way();
		for(int i=2; i<n; i+=2) {
			if(w[i]!=2)way();
			ans*=2;
			ans%=mod;
		}
	} else {
		for(int i=1; i<n; i+=2) {
			if(w[i]!=2)way();
			ans*=2;
			ans%=mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
from math import ceil
count=0
n=int(input())
bus=[int(input()) for i in range(5)]
# cur=n
# for i in range(5):
#     a=ceil(cur/bus[i])
#     if i!=4:
#         ne=max((a-1)*(bus[i]-bus[i+1]),0)
#         cur=ne+min(bus[i],cur)
#     count+=a
# print(count)
print(ceil(n/min(bus)+4))

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int s;
	int count=0;
	int num;

	cin >> s;

	num = s;

	for(int i=0;i<3;i++){
		if(num%10==1){
			count++;
		}
		num = num/10;
	}

	cout << count << endl;

}

Measured memory_bytes: 3604
import java.util.Scanner;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                for(int i=1;i<10001;i++){
                        String val=scan.nextLine();
                        if(val.equals("0")){
                                System.exit(0);
                        }
                        System.out.println("Case "+i+": "+val);
                }
        }
}

Measured memory_bytes: 59264
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const int maxn = 1e5+5;
int a[maxn];
std::vector<int> v;
int main()
{
	ll n;
	scanf("%lld",&n);
	while(n)
	{
		int x = (n - 1) % 26;
		n = (n - 1) / 26;
		v.pb(x);
	}
	for (int i = v.size() - 1; i >= 0; i -- )
	{
		printf("%c",v[i] + 'a');
	}
	printf("\n");

}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int a = Integer.parseInt(strArr[0]) - 1;
            int b = Integer.parseInt(strArr[1]) - 1;
            System.out.println(a * b);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
typedef long long int ll;

int main(){
    int n , m , ans;
    cin >> n ;
    if (n % 1000 == 0){cout<< 0 << endl;
    }
    else{
    m = n / 1000;
    ans = 1000-abs((m *1000) - n) ;
    cout << ans  <<  endl;
    }
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

/*************************************************************************/

const int N = 3005;
const int M = 3005;

int dp[M][N][2];

void add(int &x, int v) {
    x += v;
    if (x >= MOD) x -= MOD;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    
    FOR(i,0,n) {
        dp[0][i][i == 0] = 1;
    }
    
    FOR(i,0,m-1) FOR(red,0,n) FOR(visZero,0,1) FOR(red1,0,1) FOR(red2,0,1) {
        if (red == 0 && red1) continue;
        if (red == n && !red1) continue;
        
        int redNew = red + 1 - red1 - red2;
        int visZeroNew = visZero || (red == red1);
        
        add(dp[i+1][redNew][visZeroNew], dp[i][red][visZero]);
    }
    
    int total = 0;
    FOR(red,0,n) {
        add(total, dp[m][red][1]);
    }
    
    cout << total;

    return 0;
}

/*************************************************************************/


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  string s;
  getline(cin, s);
  rep(i,s.size()) {
    if (isalpha(s[i])) {
      if (islower(s[i])) {
        s[i] = toupper(s[i]);
      } else {
        s[i] = tolower(s[i]);
      }
    }
  }
  cout << s << endl;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

const long long INF = 1LL << 60;
const ll MOD = ll(1e9)+7;


int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll vector_finder(vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  if (itr == vec.end()) {
    return -1;
  }
  size_t index = std::distance( vec.begin(), itr );
  return index;
}


int main() {
  ll N;
  cin >> N;

  ll div_min = 2;

  vector<ll> A(N);
  for(ll i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  ll ans = 0;
  sort(A.begin(), A.end());

  ll max_num = A.at(N-1);

  vector<bool> dp(max_num+1, true);

  ll tmp;
  ll loop = 0;

  for (ll i = 0; i < N; i++) {
    loop = 2;
    tmp = A.at(i);
    while(tmp < max_num) {
      if(A.at(i)*loop > max_num) break;
      dp.at(A.at(i)*loop) = false;
      loop++;
    }

    if(i == 0){
      if(N >=2){
        if(A.at(i) == A.at(i+1)) {
          dp.at(A.at(i)) = false;
          continue;
        }
      }
    } else if(i >= 1 && i != N-1) {
      if(A.at(i) == A.at(i+1) || A.at(i) == A.at(i-1)) {
        dp.at(A.at(i)) = false;
        continue;
      }
    } else if (i == N-1) {
      if(A.at(i) == A.at(i-1)) {
        dp.at(A.at(i)) = false;
        continue;
      }
    }

  }

  for (ll i = 0; i < A.size(); i++) {
    if(dp.at(A.at(i)) == true) {
      ans++;
    }
  }

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

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

int main()
{
    int N;
    cin >> N;
    int used[100007] = {};
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (!used[a]) {
            ans++;
            used[a]++;
        }
    }

    cout << (ans % 2 == 1 ? ans : (ans - 1)) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main(void){
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if(S[0] ==S[1] && S[1]!= S[2] && S[2] ==S[3]){
    cout << "Yes" << endl;
  } else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b,c;
    int x,y;
    cin>>a>>b>>c>>x>>y;
    int ab=min(c*2,a+b);
    int ans=0;

    int k;


    k=min(x,y);
    ans+=k*ab;
    x-=k;
    y-=k;

    if(x){
        ans+=min(ab,a)*x;
    }
    if(y){
        ans+=min(ab,b)*y;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256