akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] value = {0,6000,4000,3000,2000};
		while(stdIn.hasNext())
			System.out.println(value[stdIn.nextInt()]*stdIn.nextInt());
	}
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
long long ans, n, k, mod = 1e9+7;
int main(){
	scanf("%lld%lld", &n, &k);
	for(long long i=k; i<=n+1; i++) (ans += i * (n-i+1) + 1) %= mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
const char sp = ' ';

int A;
set<int>st;

int main() {
	for (int i = 0; i < 3; i++) {
		cin >> A;
		st.insert(A);
	}
	if (st.size() == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

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

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

    sort (a, a + N, greater<int>());

    int Alice = 0;
    int Bob = 0;

    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    vector<vector<int> > vec1;
    vector<int> vec2;
    vector<vector<int> >::iterator it;
    int i, n;
    double x, ave, sd;

    while(1) {
        cin >> n;
        if(n == 0) break;
        vec2.clear();
        for(i=0; i<n; ++i) {
            cin >> x;
            vec2.push_back(x);
        }
        vec1.push_back(vec2);
    }

    cout << fixed;
    cout.precision(4);
    for(it=vec1.begin(); it!=vec1.end(); ++it) {
        ave = 0;
        for(i=0; i<(*it).size(); ++i) {
            ave += (*it)[i];
        }
        ave /= (*it).size();
        sd = 0;
        for(i=0; i<(*it).size(); ++i) {
            sd += (((*it)[i] - ave) * ((*it)[i] - ave));
        }
        sd /= (*it).size();
        sd = sqrt(sd);
        cout << sd << endl;
    }

    return 0;
}

Measured memory_bytes: 3204
S = input()

for i in range(1,len(S)):
    L = len(S) - i*2
    s = ""
    for p in range(L//2):
        s += S[p]
    ss = ""
    for q in range(L//2):
        ss += S[p+1+q]

    if s == ss:
        print(L)
        exit()


Measured memory_bytes: 38768
N = int(input())
o, h = N%2, N//2
arr = [0]*h
for a in map(int, input().split()):
    if a > 0:
        arr[a//2 - o] += 1
if all(c == 2 for c in arr):
    print((1 << h) % (10**9 + 7))
else:
    print(0)

Measured memory_bytes: 10996
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main(){
    ll n;
    cin >> n;
    ll a = n / 1000, b = n / 100 % 10, c = n / 10 % 10, d = n % 10;
    if(a + b + c + d == 7){
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if(a + b + c - d == 7){
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if(a + b - c + d == 7){
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if(a + b - c - d == 7){
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    }
    else if(a - b + c + d == 7){
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if(a - b + c - d == 7){
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if(a - b - c + d == 7){
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else{
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

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

const ll mod = 1e9 + 7;


int main(){
    string a,b;
    cin >> a >> b;
    vector<string> ans(2);
    ans[0] = ""; ans[1] = "";
    for (int i = 0;i < stoi(b);i++) ans[0] += a;

    for (int i = 0;i < stoi(a);i++) ans[1] += b;
    sort(ans.begin(),ans.end());

    cout << ans[0] << endl;
}

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

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

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

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let n: usize = read();
    let mut ans: usize = 0;

    if h > w {
       ans = (n + h - 1) / h;
    } else {
       ans = ( n + w - 1) / w;
    }

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


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 500010


int main(){
  int n,a[SIZE],cc[3] = {};
  
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d",a+i);

    cc[a[i]%3]++;
  }

  if(cc[1]==0 && cc[2]==0){
    puts("1");
  }else{
    int ans = cc[0];
    
    while(cc[1] + cc[2] > 0 && cc[1] > 0 && cc[2] > 0){
      ans+=2;
      cc[1]--;
      cc[2]--;
    }
    
    ans += min(3,max(cc[1],cc[2]));

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

  
  return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;



int main(){
    ll x, n=1; cin >> x;
    while(1){
        if(n*(n+1)/2 >= x){
            cout << n << endl;
            return 0;
        }
        else n++;
    }
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) {
        is >> x;
    }
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int a, b;
    cin >> a >> b;

    int ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);

    cout << ans << endl;

    return 0;
}


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

int main() {
	// your code goes here
	long long n, k;
	cin >> n >> k;
	long long a[n + 1];
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	
	for(int i=k+1; i<=n; i++){
		if(a[i] == a[i-k]){
			cout << "No" << endl;
		}
		else if(a[i]/a[i-k] >= 1.0){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	

	
	return 0;
}

Measured memory_bytes: 5168
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    	int exp6,exp9;
    	Scanner sc = new Scanner(System.in);
         int value=sc.nextInt();
         
         for(exp6=1;Math.pow(6,exp6)<=value;exp6++);
 		for(exp9=1;Math.pow(9,exp9)<=value;exp9++);
 		exp6--;exp9--;
 		
         System.out.println(Math.min(pulloutcount(value,(int)Math.pow(6,exp6),1),pulloutcount(value,(int)Math.pow(9,exp9),1)));
         }

public static int pulloutcount(int value,int pullout,int count) {
	int exp6,exp9;
	value-=pullout;
	if(value<=5) {
		return value+count;
	}else {
		for(exp6=1;Math.pow(6,exp6)<=value;exp6++);
		for(exp9=1;Math.pow(9,exp9)<=value;exp9++);
		exp6--;exp9--;
		
		return Math.min(pulloutcount(value,(int)Math.pow(6,exp6),count+1),pulloutcount(value,(int)Math.pow(9,exp9),count+1));
	}
	
	
}


}

Measured memory_bytes: 22228
from collections import deque
n = int(input())
value = list(map(int, input().split(" ")))
value.sort()
value = deque(value)
que = deque()
ans = 0
a = value.popleft()
b = value.popleft()
c = (a+b)/2
que.append(c)
while value:
  a = value.popleft()
  c = que.popleft()
  c = (a+c)/2
  que.append(c)
ans = que[0]
print(ans)
  

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int n, m;
set<int>a, b, ors, ands;

int main(void)
{
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int aa; cin >> aa; a.insert(aa);
		ors.insert(aa);
	}
	for (int j = 0; j < m; ++j) {
		int aa; cin >> aa; b.insert(aa);
		ors.insert(aa);
	}
	for (int elm : a) {
		if (b.count(elm)) {
			ands.insert(elm);
		}
	}
	int A = ands.size();
	int B = ors.size();
	cout << A << " " << B << endl;
	for (int elm : ands) {
		cout << elm;
		cout << endl;
	}
	for (int elm : ors) {
		cout << elm;
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 25848
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	for(double x[4],y[4];cin>>x[0]>>y[0];){
		repi(i,1,4)
			cin>>x[i]>>y[i];
		if(abs((x[1]-x[0])*(x[3]-x[2])+(y[1]-y[0])*(y[3]-y[2]))<1e-10)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(void){
    char c;
    int ans=0;
    while(cin >> c){
        ans=(ans+(int)(c-'0'))%9;
    }
    if(ans==0)
        printf("Yes\n");
    else
    {
        printf("No\n");
    }
    
    return 0;
}

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

using namespace std;

long long INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n = 2;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long ans = 0;
    if (a[0] > 0) {
        ans = 1;
        for (auto v: a) {
            if (ans >= 2*INF/v) {
                ans = -1;
                break;
            } else {
                ans *= v;
            }
        }
        if (ans > INF) {
            ans = -1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
vector<long long int>v;
int main()
{
    long long int x,y,a,b,c,i,j,ans=0;
    cin>>x>>y>>a>>b>>c;
    long long int p[a],q[b],r[c];
    for(i=0;i<a;i++)cin>>p[i];
    for(i=0;i<b;i++)cin>>q[i];
    for(i=0;i<c;i++)cin>>r[i];

    sort(p,p+a,greater<>());
    sort(q,q+b,greater<>());
    sort(r,r+c,greater<>());
    for(i=0;i<x;i++)v.push_back(p[i]);
    for(i=0;i<y;i++)v.push_back(q[i]);
    for(i=0;i<c;i++)v.push_back(r[i]);
    sort(v.begin(),v.end(),greater<>());

    for(i=0;i<x+y;i++)ans+=v[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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


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

using namespace std;

int main() {
	int a, b, c;//変数a,b,cを宣言

	cin >> a >> b >> c;//変数a,b,cの入力

	if (b - a == c - b) {
		cout << "YES" << endl;//YESを出力
	}
	else {
		cout << "NO" << endl;//NOを出力
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			boolean r[][] = new boolean[n][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					r[i][j] = false;
			for (int i = 0; i < n; i++) {
				int m = sc.nextInt();
				for (int j = 0; j < m; j++) {
					int p = sc.nextInt();
					r[i][p - 1] = true;
				}
			}
			int k = sc.nextInt();
			boolean[] result = new boolean[n];
			for (int i = 0; i < n; i++)
				result[i] = true;
			for (int i = 0; i < k; i++) {
				int l = sc.nextInt();
				for (int j = 0; j < n; j++)
					result[j] = result[j] && r[j][l - 1];
			}
			int a = -1;
			for (int i = 0; i < n; i++) {
				if (result[i]) {
					if (a != -1) {
						a = -1;
						break;
					}
					a = i+1;
				}
			}
			System.out.println(a);
		}
		sc.close();
	}
}

Measured memory_bytes: 67596
#include <stdio.h>
int main(void){
    // Your code here!
    long long int a;
    float b;
    scanf("%lld %f", &a,&b);
    int c=b*100.001;
    //printf("%lld %.2f %d\n",a,b*100,c);
    printf("%lld",(long long int)((a*c)/100));
    return 0;
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int a, b;
  cin >> a >> b;

  cout << (a + b + 1) / 2 << endl;


  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
joshi_dic = {}
def add_dic(p):
    if not p in joshi_dic:
        joshi_dic[p] = 1
    else:
        joshi_dic[p] += 1

for i in a:
    add_dic(i)
for i in range(1, n+1):
    if not i in joshi_dic:
        print(0)
    else:
        print(joshi_dic[i])

Measured memory_bytes: 112208
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5+100;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int head[N],nxt[N],p[N],st[N];
int vis[N],in[N],f[N],cnt=1;

inline int F(int k) {
	++cnt;
	for (int i=head[k];i;i=nxt[i])
		vis[f[i]]=cnt;
	for (int i=0;;i++)
		if (vis[i]!=cnt)
			return i;
}

inline void dfs(int k) {
	for (int i=head[k];i;i=nxt[i])
		dfs(i);
	f[k]=F(k);
}

int main()
{
	
	int n=gi(),i,k,top=0,a,b;
	
	for (i=1;i<=n;i++) p[i]=gi();
	for (k=1;!vis[k];k=p[k]) vis[k]=true;
	while (k!=st[1]) in[st[++top]=k]=true,k=p[k];
	for (k=1;k<=n;k++) if (!in[k]) nxt[k]=head[p[k]],head[p[k]]=k;
	
	for (i=1;i<=top;i++) dfs(st[i]);
	for (k=1;k<=n;k++) if (in[k]) nxt[k]=head[p[k]],head[p[k]]=k;
	for (i=0;vis[i]==cnt;i++);a=i;
	for (++i;vis[i]==cnt;i++);b=i;

	f[st[top]]=a;
	for (i=1;i<top;i++) f[st[i]]=F(st[i]);
	if (f[st[top-1]]!=a) return puts("POSSIBLE"),0;
	f[st[top]]=b;
	for (i=1;i<top;i++) f[st[i]]=F(st[i]);
	puts(f[st[top-1]]==a?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}


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

#define ll long long
#define mx  100005
#define mod 1000000009
#define lim 10000000
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n,k;cin>>n>>k;
	ll cnt=0;

	if(k&1)
	{
		for(int i=1;i<=n;i++)
			if(i%k==0)cnt++;
		cnt=cnt*cnt*cnt;
	}
	else
	{
		ll cnt1=0,cnt2=0;
		for(int i=1;i<=n;i++)
		{
			if(i%k==0)cnt1++;
			else if(i%k==k/2)cnt2++;
		}
		cnt1=cnt1*cnt1*cnt1;
		cnt2=cnt2*cnt2*cnt2;
		cnt=cnt1+cnt2;
	}
	cout<<cnt<<"\n";
	return 0;
}



Measured memory_bytes: 256
S = input()
K = int(input())

num = 0
tmp = 1
flg = True
for i in range(1, len(S)):
    if S[i] == S[i-1]:
        tmp += 1
    else:
        num += tmp // 2
        if flg:
            fst = tmp   # 最初
            flg = False
        tmp = 1
num += tmp // 2

if flg: # 全部同じ
    ans = (len(S) * K) // 2
elif S[0] == S[-1] and tmp % 2 and fst % 2:
    ans = num * K + K - 1
else:
    ans = num * K 

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<vector>
#include<numeric>
#include <algorithm>
#include <functional>

using ll = long long;
using std::cin;
using std::cout;
using std::endl;
template<class T>
using vec=std::vector<T>;

int main(){
    cout.precision(10);
    ll N,Q;
    cin>>N>>Q;
    vec<vec<ll>> nbs(N);
    for(int i=0;i<N-1;++i){
        ll a,b;
        cin>>a>>b;
        nbs.at(a-1).push_back(b-1);
        nbs.at(b-1).push_back(a-1);
    }
    vec<ll> sta;
    struct Node{
        ll par=-1;
        vec<ll> childs;
        ll val=0;
    };
    vec<Node> nodes(N);
    sta.push_back(0);
    for(auto& nb:nbs.at(0)){
        nodes.at(0).childs.push_back(nb);
    }
    while(!sta.empty()){
        ll n=sta.back();
        sta.pop_back();
        for(auto& chi:nodes.at(n).childs){
            nodes.at(chi).par=n;
            sta.push_back(chi);
            for(auto& nbc:nbs.at(chi)){
                if(nbc!=n){
                    nodes.at(chi).childs.push_back(nbc);
                }
            }
        }
    }
    for(int i=0;i<Q;++i){
        ll p,x;
        cin>>p>>x;
        nodes.at(p-1).val+=x;
    }
    sta.clear();
    sta.push_back(0);
    while (!sta.empty()) {
        ll n=sta.back();
        sta.pop_back();
        ll val=nodes.at(n).val;
        for(auto& chi:nodes.at(n).childs){
            nodes.at(chi).val+=val;
            sta.push_back(chi);
        }
    }
    for(int i=0;i<N;++i){
        if(i>0)cout<<" ";
        cout<<nodes.at(i).val;
    }
    cout<<endl;
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, z, w;
  cin >> n >> z >> w;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  if(n==1){
    print(abs(a[0] - w));
    return 0;
  }
  ll sam1 = abs(a[n - 1] - w);
  ll sam2 = abs(a[n - 2] - a[n - 1]);
  ll ans = max(sam1, sam2);
  print(ans); 
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
int main(void){
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s < t){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
	int n;
	cin>> n;
	int day[n];
	int i;
	for (i=0; i<n; i++){
		cin>> day[i];
	}
	for (i=n-1; i>0 ; i--){
		cout<< day[i]<< " ";
	}
	cout << day[0]<< endl;
    return 0;
    }

Measured memory_bytes: 1160
def to_ruby_form(e)
    0 while e.gsub!(/([\w)])\s+([\w(])/, '\1*\2')
    e.gsub!(/\s+/, '')
    0 while e.gsub!(/([\w)])([a-z(])/, '\1*\2')
    0 while e.gsub!(/([a-z)])([\w(])/, '\1*\2')
    e.gsub!(?^, '**')
end

def sample(e, input)
    eval(e.tr('a-z', input))
end

N = 30
loop do
    e = gets.chomp
    break if e == ?.
    to_ruby_form(e)
    a = (0..9).to_a * 2 + (0..5).to_a
    inputs = (0..N-1).map { a.shuffle.join }
    outputs = inputs.map {|input| sample(e, input)}

    until (e = gets.chomp) == ?.
        to_ruby_form(e)
        if (0..N-1).all? {|i| sample(e, inputs[i]) == outputs[i]}
            puts 'yes'
        else
            puts 'no'
        end
    end
    puts ?.
end

Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
int a[210][210], col[210], n;
char s[210];
inline bool dfs(int x, int c) {
	col[x] = c;
	for(int i = 1; i <= n; ++ i) if(a[x][i] == 1) {
		if(col[i]) {
			if(col[i] + c != 3) return false;
		} else {
			if(dfs(i, 3 - c) == false) return false;
		}
	} return true;
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i) {
		scanf("%s", s + 1);
		for(int j = 1; j <= n; ++ j) {
			a[i][j] = s[j] - '0';
			if(!a[i][j] && i != j) a[i][j] = 1e9;
		}
	} if(dfs(1, 1) == false) return puts("-1"), 0;
	for(int k = 1; k <= n; ++ k) {
		for(int i = 1; i <= n; ++ i) {
			for(int j = 1; j <= n; ++ j) {
				a[i][j] = min(a[i][k] + a[k][j], a[i][j]);
			}
		}
	} int mx = 0;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 1; j <= n; ++ j) {
			mx = max(mx, a[i][j]);
		}
	} printf("%d\n", mx + 1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<long long>
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = 998244353;
const ll INF = (ll)1e18+1;
const ll N = 1e5;

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

bool check(int i, int j)
{
    if(i<0||j<0||i>=n||j>=m) return 0;
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif

    int d[50][50] = { 0 };
    cin >> n >> m;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            char ch;
            cin >> ch;
            if(ch=='#')
            {
                b++;
                d[i][j] = -1;
            }
        }
    }
    queue< pair<int, int> > q;
    q.push({0, 0});
    while(!q.empty())
    {
        auto cur = q.front();
        q.pop();
        for(int i=0; i<4; i++)
        {
            int nx = cur.F + dx[i];
            int ny = cur.S + dy[i];
            if(!check(nx, ny)||d[nx][ny]!=0) continue;
            d[nx][ny] = d[cur.F][cur.S]+1;
            q.push({nx, ny});
        }
    }
    if(d[n-1][m-1]==0)
    {
        cout << -1;
    }
    else
    {
        cout << n*m - b - d[n-1][m-1] - 1;
    }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int L = in.nextInt();

            int sum = 0;
            int min = Integer.MAX_VALUE;
            for (int i = 0; i < N; i++) {
                int score = L + i;
                sum += score;
                if (Math.abs(score) < Math.abs(min)) {
                    min = score;
                }
            }
            sum -= min;
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21844
N, M = map(int, input().split())
X = []
Y = []
for i in range(N):
    a, b = map(int, input().split())
    X.append((a, b))
for i in range(M):
    c, d = map(int, input().split())
    Y.append((c, d))


def dist(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])


for i in range(N):
    ans = 1e9
    anss = -1
    for j in range(M):
        if ans > dist(X[i], Y[j]):
            ans = dist(X[i], Y[j])
            anss = j + 1
    print(anss)


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

typedef unsigned int uint;
#define BUF_SIZE (20)

int main(void)
{
	char strA[BUF_SIZE];
	char strB[BUF_SIZE];
	char strC[BUF_SIZE];
	int lengthA;
	int lengthB;
	int lengthC;
	char strA_End;
	char strB_Begin;
	char strB_End;
	char strC_Begin;

	scanf("%s %s %s", strA, strB, strC);
	lengthA = strlen(strA);
	lengthB = strlen(strB);
	lengthC = strlen(strC);

	strA_End = strA[lengthA - 1];
	strB_Begin = strB[0];
	strB_End = strB[lengthB - 1];
	strC_Begin = strC[0];

	if((strA_End == strB_Begin) && (strB_End == strC_Begin)){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pii pair <int, int>
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
const int N = 200005;
const int mod = 1e9 + 7;

vector <int> a[N];
int used[N], subtree[N];

void DFS(int node){
    used[node] = 1;
    subtree[node] = 1;
    for(int i : a[node]){
        if(!used[i]){
            DFS(i);
            subtree[node] += subtree[i];
        }
    }
}

int main() {
    io;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!used[i]){
            DFS(i);
            ans = max(ans, subtree[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 28648
from collections import deque

h, w = map(int, input().split())

maze = [input() for i in range(h)]

ans = 0
for j in range(h):
    for i in range(w):
        if maze[j][i] == ".":
            cnt = [[0] * w for _ in range(h)] 
            q = deque([(j,i)])
            while q:
                y,x = q.popleft()
                for by,bx in ((0,1),(0,-1),(1,0),(-1,0)):
                    ny = y + by
                    nx = x + bx
                    if 0 <= ny < h and 0 <= nx < w:
                        if maze[ny][nx] == "." and cnt[ny][nx] == 0:
                            q += [(ny,nx)]
                            cnt[ny][nx] += cnt[y][x] + 1
                            ans = max(ans, cnt[ny][nx])
                if y == j and x == i:
                    cnt[y][x] = -1


print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
   T res = 1;
   for (; n; n >>= 1)
   {
      if (n & 1)
         res = res * a;
      a = a * a;
   }
   return res;
}



int check(int x)
{
   cout << x << endl;
   fflush(stdout);

   string ans;
   cin >> ans;
   if (ans == "Vacant")
   {
      exit(0);
   }
   else if (ans == "Male")
   {
      return 0;
   }
   else
   {
      return 1;
   }
}

signed main()
{
   cin.tie(0);ios::sync_with_stdio(false);
   int n;
   cin >> n;
   int i = 0, j = n-1;
   int l = check(i),r=check(j);

   while (1)
   {
      int mid = (i + j) / 2;
      int res = check(mid);
      if ((res == l)==((mid - i) % 2))
      {
         j = mid;
         r=res;
      }
      else
      {
         i = mid;
         l=res;
      }
   }
}


Measured memory_bytes: 852
// testcplusplus.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;



int main()
{
	int n;
	cin >> n;

	vector<int> dishes;

	for (int i = 0; i < n; i++) {
		int curr;
		cin >> curr;
		dishes.push_back(curr);
	}

	vector<int> points;

	for (int i = 0; i < n; i++) {
		int curr;
		cin >> curr;
		points.push_back(curr);
	}

	vector<int> bonusPoints;

	for (int i = 0; i < n - 1; i++) {
		int curr;
		cin >> curr;
		bonusPoints.push_back(curr);
	}

	int result = 0;

	int prev = dishes[0] - 1;

	result += points[prev];

	for (int i = 1; i < n; i++) {
		int curr = dishes[i] - 1;
		if (curr == prev + 1) result += bonusPoints[prev];
		result += points[curr];
		prev = curr;
	}

	cout << result;
}


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

using namespace std ; 
long long  one =0, tow=0;
long long  done[1000001], H[1000001];
int n ,k ;
long long  calc(int step){
 // cout<<Min <<endl;
  long long  Min=1e9;
   if(step==n-1)
    return 0 ;
   else if(step>=n)
    return 1e9;
   if(done[step]!=-1)  
    return done[step];
  for(int i =1;i<=k;i++){
   if(step+i<n){ 

      long long  one =calc(step+i)+abs(H[step]-H[step+i]);
      Min=min(one,Min); }
   }return done[step]=Min; 
}
int main () { 
  
  cin>>n>>k;
  
  memset(done ,-1,sizeof done);
  for(int i =0;i<n;i++){
    cin>>H[i];

  }
  cout<<calc(0);
  
  return 0;}

Measured memory_bytes: 20036
#include<bits/stdc++.h>
#define N 100005
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
struct Node{int l,r;}q[N];
int n,m,ans=0;
inline bool cmp(Node a,Node b){return a.r==b.r?a.l<b.l:a.r<b.r;}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;++i)q[i].l=read(),q[i].r=read();
	sort(q+1,q+m+1,cmp);
	int pos=q[1].r;
	ans=1;
	for(int i=2;i<=m;++i){
		if(q[i].l<pos)continue;
		else ++ans,pos=q[i].r;
	}
	printf("%d",ans);
	return 0;
}

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

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;

    vector<int> a(Q);
    vector<int> b(Q);
    vector<int> c(Q);
    vector<int> d(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;
    for (int i = 0; i < (1 << (N + M - 1)); i++)
    {
        bitset<32> bit(i);
        if ((int)bit.count() != M - 1)
        {
            continue;
        }

        vector<int> A(N);
        int current = 1;
        int idx = 0;
        for (int j = 0; j < N + M - 1; j++)
        {
            if (bit[j])
            {
                current++;
            }
            else
            {
                A[idx] = current;
                idx++;
            }
        }
        // for (int j = 0; j < N + M - 1; j++)
        // {
        //     cout << bit[j] << " ";
        // }
        // for (int aa : A)
        // {
        //     cout << aa;
        // }
        // cout << endl;
        int tmp = 0;
        for (int j = 0; j < Q; j++)
        {
            if (A[b[j]] - A[a[j]] == c[j])
            {
                tmp += d[j];
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll n; cin >> n;
   string s; cin >> s;

   Vi cnt(26, 0);
   REP(i, n){
      cnt[s[i] - 'a'] ++;
   }
   ll ans = 1;
   REP(i, 26) {
      ans *= cnt[i]+1;
      ans %= MOD;
   }
   cout << (ans + MOD - 1) % MOD << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
int main() {
	ll n, a[100001], count = 0;;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2)count++;
	}
	if (count % 2)cout << "NO" << endl;
	else cout << "YES" << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int a[26] = {0};
    for (int i = 0; s[i]; ++ i) {
        a[s[i] - 'a'] ++;
    }
    for (int i = 0; i < 26; ++ i) {
        if (a[i] % 2 != 0) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    
}

Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  vector<string> S {"Sunny", "Cloudy", "Rainy"};
  string s; cin >> s;
  auto it = find(S.begin(), S.end(), s);
  it++;
  if (it == S.end()) it = S.begin();
  cout << *it << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

#define NMAX 502
#define DIM 7920

int d[DIM], p[DIM];
long long sol[NMAX][NMAX];

void ciur(int n) {
    for (int i = 2; i <= n; i++) {
        if (d[i] == 0) {
            p[++p[0]] = i;
            for (int j = i + i; j <= n; j += i) {
                d[j] = 1;
            }
        }
    }
}

__int128 gcd(__int128 a, __int128 b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

__int128 lcm(vector <long long>& v) {
    __int128 l = 1;
    for (const long long x : v) {
        if (x == 0)
            continue;
        __int128 d = gcd(l, (__int128)x);
        l = l * x / d;

    }
    return (long long)l;
}

int main()
{
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    if (n == 2) {
        cout << "4 7\n23 10\n";
        return 0;
    }
    ciur(DIM - 1);

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            sol[i][j] = 1;
        }
    }

    int cnt = 1;
    for (int j = 1; j <= n; j += 2) {
        int col = j;
        for (int i = 1; i <= n; i++) {
            if (col > n)
                break;
            sol[i][col] *= p[cnt];
            col++;
        }
        cnt++;
    }

    for (int i = 3; i <= n; i += 2) {
        int lin = i;
        for (int j = 1; j <= n; j++) {
            if (lin > n)
                break;
            sol[lin][j] *= p[cnt];
            lin++;
        }
        cnt++;
    }

    for (int j = 1; j <= n; j += 2) {
        int col = j;
        for (int i = 1; i <= n; i++) {
            if (col <= 0)
                break;
            sol[i][col] *= p[cnt];
            col--;
        }
        cnt++;
    }

    for (int i = n; i > 1; i -= 2) {
        int lin = i;
        for (int j = n; j >= 1; j--) {
            if (lin > n)
                break;
            sol[lin][j] *= p[cnt];
            lin++;
        }
        cnt++;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if ((i + j) % 2 == 0)
                continue;
            vector <long long> v = {sol[i - 1][j], sol[i + 1][j], sol[i][j - 1], sol[i][j + 1]};
            sol[i][j] = lcm(v) + 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << sol[i][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 5120
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()

	dp := [55][55][3000]int{}
	dp[0][0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j < i+1; j++ {
			for x := 0; x < k+1; x++ {
				if j > 0 {
					dp[i+1][j-1][x+(j-1)*2] += dp[i][j][x]*j*j%MOD
					dp[i+1][j-1][x+(j-1)*2] %= MOD
				}
				dp[i+1][j][x+j*2] += dp[i][j][x] + dp[i][j][x]*j*2%MOD
				dp[i+1][j][x+j*2] %= MOD
				dp[i+1][j+1][x+(j+1)*2] += dp[i][j][x]
				dp[i+1][j+1][x+(j+1)*2] %= MOD
			}
		}
	}

	fmt.Fprintln(wr, dp[n][0][k])
}

// MOD constant
const MOD = 1000000007


Measured memory_bytes: 74112
#include <iostream>
using namespace std;
int main(){
	int n,m,i,l=-1,r=10000000,sum=0;
	cin>>n>>m;
	int a[m+1][2],b[100005];
	for(i=1;i<=m;i++)cin>>a[i][1]>>a[i][2];
	for(i=1;i<=m;i++){
		if(a[i][1]>l)l=a[i][1];
		if(a[i][2]<r)r=a[i][2];
	}
	for(i=l;i<=r;i++)
	if(i<=n)sum++;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ll N,X,T;

    cin>>N>>X>>T;

    ll d=N/X;
    ll r=N%X;

    ll total=d+(r>0?1:0);

    cout<<total*T<<"\n";

}


Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
odd = [0] * (N + 1)
evn = [0] * (N + 1)
for i in range(N):
    if i % 2 == 0:
        odd[i + 1] = odd[i] + A[i]
        evn[i + 1] = evn[i] - A[i]
    if i % 2 == 1:
        odd[i + 1] = odd[i] - A[i]
        evn[i + 1] = evn[i] + A[i]

for i in range(N):
    if i % 2 == 0:
        print(evn[i] + A[i] + odd[N] - odd[i + 1], end="")
    else:
        print(odd[i] + A[i] + evn[N] - evn[i + 1], end="")
    
    if i < N - 1:
        print(" ", end="")
    else:
        print()

Measured memory_bytes: 16216
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int a;
  cin >> a;
  const double pi = acos(-1.0);
  cout << 2*a*pi;
  hinata;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
const int N=110,M=1e5+10;
int a[N],sg[M];
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
	return x*f;
}
int main()
{
	int n=read(),K=read();
	for (register int i=1;i<=n;++i) a[i]=read();
	for (register int i=0;i<=K;++i)
	{
		sg[i]=0;
		for (register int j=1;j<=n;++j) if (i>=a[j]&&(!sg[i-a[j]])) {sg[i]=1;break;}
	}
	if (sg[K]) printf("First\n"); else printf("Second\n");
	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

s = 0
for i in range(K):
    s += A[i] + 1

ma = s
for i in range(K, N):
    s += A[i] + 1
    s -= A[i-K] + 1
    ma = max(ma, s)

print(ma / 2)

Measured memory_bytes: 25188
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
#include <functional>
using namespace std;

int main() {
	int n = 0;
	cin >> n;
	vector<int> nums(n, 0), sortNums(n, 0);
	for(int i = 0; i < n; i ++) {
		cin >> nums[i];
		sortNums[i] = nums[i];
	}
	sort(sortNums.begin(), sortNums.end());
	map<int, int> t;
	for(int i = 0; i < n; i ++)
		t.insert(make_pair(nums[i], i));
	for(int i = 0; i < n; i ++) {
		sortNums[i] = (i - t[sortNums[i]]) % 2;
	}
	int ret = 0;
	for(int i = 0; i < n; i ++) {
		if(sortNums[i] != 0)
			ret ++;
	}
	cout << ret / 2;
	return 0;
}


Measured memory_bytes: 5760
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, p;
  cin >> a >> p;
  cout << (a * 3 + p) / 2 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3600