akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const ll INF=2e15;
const double PI=acos(-1);

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt=0;
    int r=n-1;
    rep(l,n) {
        if (s[l]=='W') {
            while (l<r) {
                if (s[r]=='R') {
                    ++cnt;
                    --r;
                    break;
                }
                --r;
            }
        }
        if (r<=l) break;
    }
    cout << cnt << endl;
    


    return 0;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
int main(){
    long int n, m, l, a[100][100], b[100][100], sum;
    cin >> n >> m >> l;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            sum = 0;
            for(int k=0;k<m;k++){
                sum += a[i][k] * b[k][j];
            }
            cout << sum;
            if(j != l-1){
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3244
#include<stdio.h>
#include<limits.h>
int main(){
  int price,i,j,k,ie,je,ke,max,p;
  do{
    scanf("%d",&price);
    if(!price) break;
    max=INT_MAX;
    for(i=0,ie=price/200+1;i<ie;i++){
      for(j=0,je=(price-i*200)/300+1;j<je;j++){
	if((price-i*200-j*300)%500==0){
	  k=(price-i*200-j*300)/500;
	  p=5*(int)(i/5)*380*8/10+(i%5)*380
	    +4*(int)(j/4)*550*85/100+(j%4)*550
	    +3*(int)(k/3)*850*88/100+(k%3)*850;
	  if(p<max) max=p;
	}
      }
    }
    printf("%d\n",max);
  }while(1);
  return 0;
}

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

int main()
{
	ll a, b;
	cin >> a >> b;
	ll c = a + b;
	if (c % 2 == 0)
		cout << c / 2;
	else
		cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
        
        public static class BIT {
                int[] dat;
                
                public BIT(int n){
                        dat = new int[n + 1];
                }
                
                public void add(int k, int a){ // k : 0-indexed
                        for(int i = k + 1; i < dat.length; i += i & -i){
                                dat[i] += a;    
                        }
                }
                
                public int sum(int s, int t){ // [s, t)
                        if(s > 0) return sum(0, t) - sum(0, s);
                        
                        int ret = 0;
                        for(int i = t; i > 0; i -= i & -i) {
                                ret += dat[i];
                        }
                        return ret;
                }
        }
                
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                
                final int n = sc.nextInt();
                final int q = sc.nextInt();

                BIT bit = new BIT(n);
                for(int tt = 0; tt < q; tt++){
                        final int op = sc.nextInt();
                        final int x  = sc.nextInt() - 1;
                        final int y  = sc.nextInt();

                        if(op == 0){
                                bit.add(x, y);
                        }else{
                                System.out.println(bit.sum(x, y));
                        }
                }
        }
}

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

int main(){
  ll x,ans,i;
  cin >> x;
  ans=x;
  for(i=2;i<=360;i++){
    ans+=x;
    if(ans%360==0){
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */
int main() {
    int N; cin >> N;
    vector<int> b(N);
    REP(i,N){
        cin >> b[i];
    }

    vector<int> ans;
    int len = N;
    bool ava = true;

    REP(i,N){
        int l = N - i;
        bool ref = false;
        REPr(j,l){
            if (b[j] == j+1){
                ans.PB(j+1);
                b.erase(b.begin()+j);
                ref = true;
                break;
            }
        }

        if (!ref) ava = false;
    }

    if (ava){
        reverse(ALL(ans));
        REP(i,N){
            cout << ans[i] << "\n";
        }
    }else {
        cout << -1 << endl;
    }

}


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

int main(){
    int n ; cin >> n ;
    long long mn = 10000000000 ;
    long long mx = -10000000000 ;
    long long a ; cin >> a ;
    mn = min(mn,a) ;
    for(int i=1;i<n;i++){
        cin >> a ;
        mx = max(mx,a-mn) ;
        mn = min(mn,a) ;
    }
    cout << mx << endl ;
}


Measured memory_bytes: 3108
n, K = map(int, input().split())
A = list(map(int, input().split()))


def Com_kai(n, r, mod):
    if (r < 0 or r > n or n < 0):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

A.sort()

Max_Sum = 0
Min_Sum = 0
Mod = 1000000007

for i in range(n):
    Min_Sum = (Min_Sum + (A[i] * Com_kai(n - (i + 1), K - 1, Mod)) % Mod) % Mod
    Max_Sum = (Max_Sum + (A[i] * Com_kai(i, K - 1, Mod)) % Mod) % Mod


print((Max_Sum - Min_Sum + Mod) % Mod)


Measured memory_bytes: 139864
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 1e5 + 10;
const int LOG = 30;
int n, L;
int x[N];
int jmp[N][LOG];

void build() {
    int far = 0;
    REP(i, n) {
        while(far+1 < n and x[far+1] - x[i] <= L) far++;
        jmp[i][0] = far;
    }
    FOR(log, 1, LOG) {
        REP(i, n) {
            jmp[i][log] = jmp[jmp[i][log-1]][log-1];
        }
    }
}

int main() {
    cin >> n;
    REP(i, n) cin >> x[i];
    cin >> L;

    build();

    int q;
    cin >> q;
    while(q--) {
        int source, dest;
        cin >> source >> dest;
        source--, dest--;
        if(source > dest) {
            swap(source, dest);
        }
        int ans = 0;
        for(int log = LOG-1; log >= 0; log--) {
            if(jmp[source][log] < dest) {
                source = jmp[source][log];
                ans += (1<<log);
            }
        }
        cout << ans+1 << '\n';
    }
}
























Measured memory_bytes: 12928
#X,Y,A,B,C = map(int, input().split())
#p = [int(x) for x in input().split()]
#q = [int(x) for x in input().split()]
#r = [int(x) for x in input().split()]
#p.sort(reverse = True)
#q.sort(reverse = True)
#r.sort(reverse = True)
#newp = p[:X]
#newq = q[:Y]
#lis = newp + newq
#lis.sort(reverse = True)
#s = sum(lis)
#for i in range(len(r)):
#    if lis[-i-1] < r[i]:
#        s = s - lis[-i-1] + r[i]
#    else:
#        break
#print(s)

X,Y,A,B,C = map(int, input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)
p = p[:X]
q = q[:Y]
ans = p+q+r
ans.sort(reverse = True)
print(sum(ans[:X+Y]))


Measured memory_bytes: 22592
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    p = LI()
    t = LI()
    dp = [inf] * (10**5)
    dp[0] = 0
    for i in range(10**5):
        for num,ti in enumerate(t):
            if i - ti >= 0:
                dp[i] = min(dp[i], dp[i - ti] + p[num])
    for i in range(10**5-1, 0, -1):
        dp[i - 1] = min(dp[i], dp[i - 1])
    print(dp[n])
    return

#B
def B():
    def yaku(n):
        res = 0
        if n == 0:
            return 0
        for i in range(1, int(math.sqrt(n-1)) + 1):
            if n % i == 0:
                res += 2
        if float.is_integer(math.sqrt(n)):
            res += 1
        return res
    q = II()
    ya = [yaku(i) for i in range(10 ** 5 + 1)]
    ya[0] = 0
    for i in range(1,10 ** 5 + 1):
        if ya[i] >= 5:
            ya[i] = 1
        else:
            ya[i] = 0
        ya[i] += ya[i - 1]
    for i in range(q):
        n = II()
        print(ya[n])
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()



Measured memory_bytes: 12404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<>();

    public static void main(String[] args) throws IOException {
        StringBuilder ans = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = new String[2];
       
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                sp = br.readLine().split(" ");
                if (sp[0].equals("insert")) {
                    list.addFirst(sp[1]);
                } else if (sp[0].equals("delete")) {
                    list.remove(sp[1]);
                } else if (sp[0].equals("deleteFirst")) {
                    list.removeFirst();
                } else if (sp[0].equals("deleteLast")) {
                    list.removeLast();
                }
            }
            if (!list.isEmpty()) {
                ans.append(list.getFirst());
                list.removeFirst();
            }
            while (!list.isEmpty()) {
                ans.append(" ").append(list.getFirst());
                list.removeFirst();
            }
            System.out.println(ans.toString());
       
    }
}



Measured memory_bytes: 228736
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5+5;
int N,M;
vector<int> edges[maxn];
stack<int >toporder;
int dp[maxn],vis[maxn];

void dfs(int node){
    vis[node] = 1;
    int n = edges[node].size();
    for(int i = 0; i < n; i++){
        int v = edges[node][i];
        if(!vis[v])dfs(v);
    }
    toporder.push(node);
}

void toposort(){
    for(int i = 1; i <= N; i++)if(!vis[i])dfs(i);
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N>>M;
    int x,y;
    for(int i = 0; i<M; i++){
        cin>>x>>y;
        edges[x].push_back(y);
    }
    
    
    memset(vis, 0, sizeof(vis));
    
    toposort();
    while(!toporder.empty()){
        auto node  = toporder.top();
        toporder.pop();
        for(auto v: edges[node]){
            dp[v] = max(dp[v], dp[node] +1);
        }
    }
    int ans = 0;
    for(auto i:dp)ans = max(ans, i);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int comb[1111][1111];
int calc2dp[1111][1111];
int dp[1111][1111];
int n, a, b, c, d;

ll calc2(int a, int b)
{
	if (calc2dp[a][b] >= 0) return calc2dp[a][b];
	ll res = 1;
	while (a > 0)
	{
		res *= comb[a-1][b-1];
		res %= MOD;
		a -= b;
	}
	return calc2dp[a][b] = res;
}

ll calc(int rem, int p, int group)
{
	ll res = comb[rem][p * group];
	res *= calc2(p * group, p);
	return res % MOD;
}

int solve(int p, int use)
{
	if (dp[p][use] >= 0) return dp[p][use];
	if (p == a - 1)
	{
		return use == 0;
	}
	if ((a + p) * (p - a + 1) / 2 * d < use) return 0;
	ll res = 0;
	res += solve(p - 1, use);
	FOR(i, c, d + 1)
	{
		if (use < p * i) break;
		res += calc(use, p, i) * solve(p - 1, use - p * i) % MOD;
		res %= MOD;
	}
	return dp[p][use] = res;
}

ll aa[1111][1111];
void init()
{
	REP(i, 1111)
	{
		aa[i][0] = aa[0][i] = 1;
	}
	FOR(i, 1, 1111)FOR(j, 1, 1111)
	{
		aa[i][j] = (aa[i - 1][j] + aa[i][j - 1]) % MOD;
	}
	REP(i, 1111)REP(j, i + 1) comb[i][j] = aa[i - j][j];
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	init();
	MS(dp, -1);
	MS(calc2dp, -1);
	cin >> n;
	cin >> a >> b >> c >> d;
	MS(dp, -1);
	cout << solve(b, n) << endl;
	return 0;
}

Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;


int main(){
    V L(6);
    rep(0,6,1)cin>>L[i];
    ll p=L[0];
    rep(1,6,1)p=min(p,L[i]);
    if(p==L[0])cout<<5;
    else{
        cout<<5+(L[0]-1)/p;
    }
    cout<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    char s[5];
    scanf("%s", s);
    for (int i=0; i<3; i++){
        if (s[i] == s[i+1]){
            printf("Bad");
            return 0;
        }
    }
    printf("Good");
    return 0;
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=m;i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){

    int n;
    cin>>n;

    int ac=0,wa=0,tle=0,re=0;

    rep(i,n){
        string tmp;
        cin>>tmp;

        if (tmp=="AC"){
            ac++;
        }
        else if (tmp=="WA"){
            wa++;
        }
        else if (tmp=="TLE"){
            tle++;
        }
        else if (tmp=="RE"){
            re++;
        }
    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;





}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int k,x;

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


Measured memory_bytes: 256
n,m=map(int,input().split())
mod=10**9+7
N=2*10**5
fac=[1]*(N+3)
inv=[1]*(N+3)
t=1
for i in range(1,N+3):
    t*=i
    t%=mod
    fac[i]=t
t=pow(fac[N+2],mod-2,mod)
for i in range(N+2,0,-1):
    inv[i]=t
    t*=i
    t%=mod
def comb(n,r):
    if r>n or r<0:
        return 0
    return fac[n]*inv[n-r]*inv[r]%mod
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
import collections
c=collections.Counter(prime_factorize(m))
ans=1
for i,j in c.items():
    ans*=comb(n+j-1,j)
    ans%=mod
print(ans)

Measured memory_bytes: 42096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	ll n;
	cin >> n;
	ll a[n];
	bool ok = false;
	for(ll i=0; i<n; i++){
		cin >> a[i];
	}
	ll ans = 1;
	for(int i=0; i<n; i++){
		if(a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	for(int i=0; i<n; i++){
		ans*=a[i];
		ll k = (unsigned ll)(1e18)/ans;
		if(i+1<n and a[i+1]>k){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
} 
//^-^

Measured memory_bytes: 4404
main = do
  li <- getLine
  let [n,m] = map read $ words li
  let ans = compute n m
  putStrLn $ unlines $ map (\(a,b) -> unwords [show a, show b]) ans

compute :: Int -> Int -> [(Int,Int)]
compute n m = take m $ genall n

gen a b
  | a+1 <= b = (a,b) : gen (succ a) (pred b)
  | otherwise = []

genall n = gen 1 (1+d) ++ gen (2+d) (1+d+d)
  where
    d = (n-1) `div` 2


Measured memory_bytes: 5984
import os
import sys

import numpy as np

# from libs.debug import debug

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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


N = int(sys.stdin.buffer.readline())
C = list(map(int, sys.stdin.buffer.readline().split()))

# @debug
# def f(S, T, C):
#     S = np.array(S, dtype=bool)
#     T = np.array(T, dtype=bool)
#     C = np.array(C, dtype=int)
#     costs = np.msort(C[S != T])
#     return int(np.dot(costs[::-1], np.arange(1, len(costs) + 1)))
#
#
# def test(N, C):
#     ans = 0
#     for s in itertools.product([True, False], repeat=N):
#         for t in itertools.product([True, False], repeat=N):
#             ans += f(s, t, C)
#             ans %= MOD
#     print(ans)
#
#
# test(N, C)

# R[d][i]: C が降順にソートされてるとして、C[i] が上から d 番目の大きさになる選び方の数
# R = np.zeros((N + 1, N), dtype=int)
# R[0] = 0
# R[1] = 1
# for r in range(2, N + 1):
#     for c in range(N):
#         R[r, c] = R[r - 1][:c].sum()
# # 自分より大きいのの選び方の総数
# print(R)
# # 順位かける
# print(R * np.arange(N + 1)[:, None])
# # 自分より小さいのの選び方をかける
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))
# # 順位が小さいのに大きいのをかける
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1])
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum())
# # 同じ選び方が 2**N 個ある
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum() * (2 ** N) % MOD)

# print()
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0))
# print(np.diff((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0)))


if N == 1:
    arr = np.ones(1, dtype=int)
else:
    arr = np.arange(N, dtype=int) * pow(2, N - 2, MOD) + pow(2, N - 1, MOD)
ans = arr % MOD * np.msort(C)[::-1] % MOD
print(sum(ans) % MOD * pow(2, N, MOD) % MOD)


Measured memory_bytes: 30996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n, m;

struct PP {
	int p, y;
	int ans, res;
	int pos;
	char s[15];
} a[maxx];

bool cmp(PP u, PP v) {
	if(u.p == v.p) return u.y < v.y;
	return u.p < v.p;
}

bool cmp0(PP u, PP v) {
	return u.pos < v.pos;
}

int Cnt(int x) {
	int dd = 0;
	while(x) {
		dd++;
		x /= 10;
	}
	return dd;
}

int main() {
	scanf("%d %d", &m, &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d %d", &a[i].p, &a[i].y);
		a[i].pos = i;
	}
	sort(a + 1, a + n + 1, cmp);
	a[1].ans = a[1].p, a[1].res = 1;
	int t = 1;
	for(int i = 2; i <= n; i++) {
		a[i].ans = a[i].p;
		if(a[i].p != a[i - 1].p) {
			t = 1;
			a[i].res = 1;
		}
		else {
			t++;
			a[i].res = t;
		}
	}
	sort(a + 1, a + n + 1, cmp0);
	for(int i = 1; i <= n; i++) {
		int l = a[i].ans, r = a[i].res;
		int c1 = Cnt(l), c2 = Cnt(r);
		int L = 6 - c1, R = 6 - c2;
		while(L--) printf("0");
		printf("%d", l);
		while(R--) printf("0");
		printf("%d\n", r);
	}
}

Measured memory_bytes: 4992
#include<cstdio>
long long p,ans=1,n;
int main()
{
    scanf("%lld%lld",&n,&p);
    if (n==1)
    {
        printf("%lld\n",p);
        return 0;
    }
    for (long long i=2;i*i<=p;i++)
    {
        long long cnt=0;
        while (p%i==0) ++cnt,p=p/i;
        for (long long j=1;j*n<=cnt;j++) ans=ans*i;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <stdio.h>

void BubSort(int x[ ], int n)
{
    int i, j, temp;
	
    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {  /* 前の要素の方が大きかったら */
                temp = x[j];        /* 交換する */
                x[j] = x[j - 1];
                x[j - 1]= temp;
            }
        }	
    }
}

int main (void) {
	int i,count = 0;
	int num[3];
	
	scanf("%d", &count);
	for (i = 0; i < count; i++) {
		scanf("%d %d %d", &num[0], &num[1], &num[2]);
		BubSort(num, 3);
		if (num[0] * num[0] + num[1] * num[1] == num[2] * num[2]) {
			puts("YES");
		}else {
			puts("NO");
		}

	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    string a, b, c;
    cin >> a >> b >> c;

    char A = a[0] - 32;
    char B = b[0] - 32;
    char C = c[0] - 32;

    cout << A << B << C << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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


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

    int h,w; cin >> h >> w;
    int count = 0;
    for(int i = 0;i < h * w;i ++){
        char a;
        cin >> a;
        if(a == '#') count ++;
    }

    if(count == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    int cnt = 0;

    for(int i = 0; i < n/2; i++){
        if(s.at(i) != s.at(n-i-1)){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[110][110];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[110];
    rep(i, H) cin >> S[i];
    rep(i, 110) rep(j, 110)  dp[i][j] = INF;
    dp[0][0] = 0;
    if (S[0][0] == '#') dp[0][0]++;
    rep(i, H) {
        rep(j, W) {
            if (i + 1 < H && S[i][j] == '.' && S[i + 1][j] == '#') dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
            else if(i + 1 < H) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            
            if (j + 1 < W && S[i][j] == '.' && S[i][j + 1] == '#') dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
            else if(j + 1 < W) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
        }
    }
    // rep(i, H) {
    //     rep(j, W) {
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }
    cout << dp[H - 1][W - 1] << endl;

    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		int[] A = new int[N];
		Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));

		for (int t = 0; t < K; t++) {
			int[] range = new int[N + 2];
			for (int i = 0; i < N; i++) {
				var d = A[i];
				var from = i - d + 1;
				var to = i + d + 2;
				range[Math.max(0, from)]++;
				if (to <= N) range[to]--;
			}

			int[] B = new int[N + 2];
			B[0] = range[0];
			for (int i = 1; i < range.length; i++) {
				B[i] = B[i - 1] + range[i];
			}
			System.arraycopy(B, 1, A, 0, N);
			
			if (Arrays.stream(A).allMatch(i -> i == N)) {
				break;
			}
		}

		StringJoiner joiner = new StringJoiner(" ");
		for (int i = 0; i < N; i++) {
			joiner.add(String.valueOf(A[i]));
		}
		System.out.println(joiner);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 67296
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
}



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

int main(){
  int a,b,c,x;
  cin >> a>>b>>c>>x;
  int count=0;
  x=x/50;
  for(int i=0; i <=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        int ans =i*10 +j*2 + k;
        if(ans == x){ 
          count++;
        }
      }
    }
  }
  cout << count << '\n';
}


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

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

int main()
{
	int W,H;
	while(cin >> W >> H, (W||H))
	{
		int cnt=0, p[35][35],tp[35][35],v[35][35];
		char f[35][35];
		
		string t;
		getline(cin, t);
		for(int i=0; i<H; i++)
		{
			getline(cin, t);
			for(int j=0; j<W; j++)
			{
				f[j][i]=t[j];
				p[j][i]=-1;
				if(f[j][i]=='E') p[j][i]=0;
				if(f[j][i]=='N') p[j][i]=1;
				if(f[j][i]=='W') p[j][i]=2;
				if(f[j][i]=='S') p[j][i]=3;
				
				if(p[j][i]!=-1) cnt++;
			}
		}
		
		int ret=0;
		for(; ret<=180; ret++)
		{
			if(cnt==0) break;
			
			for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
			{
				tp[j][i]=-1;
				v[j][i]=-1;
				
				if(p[j][i]!=-1)
				{
					int next=p[j][i];
					for(int k=0; k<4; k++)
					{
						int d=(p[j][i]+k+3)%4;
						int tx=j+dx[d], ty=i+dy[d];
						if(tx<0||ty<0||tx>=W||ty>=H) continue;
						if(f[tx][ty]=='#'||p[tx][ty]!=-1) continue;
						
						next=d;
						break;
					}
					
					p[j][i]=next;
				}
			}
			
			for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
			{
				if(p[j][i]!=-1)
				{
					int tx=j+dx[p[j][i]], ty=i+dy[p[j][i]];
					if(f[tx][ty]=='#'||p[tx][ty]!=-1) v[j][i]=p[j][i];
					else if(v[tx][ty]==-1) v[tx][ty]=p[j][i];
					else if((v[tx][ty]+2)%4>(p[j][i]+2)%4) v[tx][ty]=p[j][i];
				}
			}
			
			for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
			{
				if(p[j][i]!=-1)
				{
					int tx=j+dx[p[j][i]], ty=i+dy[p[j][i]];
					if(f[tx][ty]=='#'||p[tx][ty]!=-1) tp[j][i]=p[j][i];
					else if(v[tx][ty]==p[j][i]) tp[tx][ty]=p[j][i];
					else tp[j][i]=p[j][i];
				}
			}
			
			for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
			{
				p[j][i]=tp[j][i];
				if(f[j][i]=='X'&&p[j][i]!=-1)
				{
					cnt--;
					p[j][i]=-1;
				}
			}
		}
		
		if(ret>180) cout << "NA" << endl;
		else cout << ret << endl;
	}
}

Measured memory_bytes: 0
var fs = require('fs')
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');

function main(){
	a=input[0].split(' ').map(Number);
	console.log(a[0]<a[1]&&a[1]<a[2]?'Yes':'No');
}

main();


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

char c[30][30];

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

int dd(char c){
	if( c == 'U' || c == '^') return 1;
	if( c == 'D' || c == 'v') return 3;
	if( c == 'L' || c == '<') return 0;
	if( c == 'R' || c == '>') return 2;
	return -1000;
}

char ddd(int n){
	if(n == 0 ) return '<';
	if(n == 1 ) return '^';
	if(n == 2 ) return '>';
	if(n == 3 ) return 'v';
}
int main(){
	int T;
	cin >> T;
	while(T--){
		int H,W;
		cin >> H >> W;
		for(int i = 0 ; i < 30 ; i++)
			for(int j = 0 ; j < 30 ; j++)
				c[i][j] = '#';
		
		for(int i = 1 ; i <= H ; i++){
			for(int j = 1 ; j <= W ; j++){
				cin >> c[i][j];
			}
		}
		int N;
		cin >> N;
		for(int _ = 0 ; _ < N ; _++){
			char s;
			cin >> s;
			int sx = 0 , sy = 0;
			for(int j = 1 ; j <= H ; j++)
				for(int k = 1 ; k <= W ; k++)
					if( c[j][k] == 'v' || c[j][k] == '^' || c[j][k] == '<' || c[j][k] == '>'){
						sx = k;
						sy = j;
					}
			if( s == 'S' ){
				int dir = dd(c[sy][sx]);
				int X = sx + dx[dir];
				int Y = sy + dy[dir];
				while(c[Y][X] != '#' && c[Y][X] != '*'){
					X += dx[dir];
					Y += dy[dir];
				}
				if( c[Y][X] == '*' ) c[Y][X] = '.';
			}else{
				//cout << s << " " << dd(s) << " " << ddd(dd(s)) << endl;
				c[sy][sx] = ddd(dd(s));
				
				int dir = dd(c[sy][sx]);
				int X = sx + dx[dir];
				int Y = sy + dy[dir];
				if( c[Y][X] == '.'){
					c[Y][X] = c[sy][sx];
					c[sy][sx] = '.';
				}
			}

		}
		for(int i = 1 ; i <= H ; i++){
			for(int j = 1 ; j <= W ; j++){
				cout << c[i][j];
			}
			cout << endl;
		}
		if( T )cout << endl;

		
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m[4][3][10]={};
  int n;
  cin>>n;
  for(int i=0;i<n;++i){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    --a,--b,--c;
    m[a][b][c]+=d;
  }
  for(int i=0;i<4;++i){
    if(i) cout<<"####################"<<endl;
    for(int j=0;j<3;++j){
      for(int k=0;k<10;++k) cout<<" "<<m[i][j][k];
      cout<<endl;
    }
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
#define int long long
const int MOD=1e9+7;
const int N=1e5+5;
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
int invmod(int x) {return power(x,MOD-2);}
int32_t main()
{
	
	double n,k;
	cin>>n>>k;
	double sum=0.0;
	for(double i=1;i<=n;i++)
	{

		
		int p=i;
		int count=0;
		while(p<k)
		{
			p*=2;
			count++;
		}
		sum+=(1/(n*(1<<count)));

	}
	printf("%0.12lf\n",sum);
	




}

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

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 10000,temp = 0;
		String s,t;
		String str;
		str = bf.readLine();
		s = str;
		str = bf.readLine();
		t = str;
		for(int i = 0;i < s.length()-t.length()+1;++i) {
			temp = 0;
			for(int j = 0;j < t.length();++j) {
				if(!s.substring(i+j, i+j+1).equals(t.substring(j, j+1))) {
					temp++;
				}
			}
			if(ans > temp) {
				ans = temp;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50116
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


p = int(input())
a = list(map(int, input().split()))

### 素数の逆元とCombination

M = p
N = 10**4 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M
ans = [0]*p
for i,num in enumerate(a):
    if num==0:
        continue
    for j in range(p):
        ans[j] += -cmb(p-1,j,M) * pow(-i,p-1-j,M)
        ans[j] %= M
    ans[0] += 1
for i in range(p):
    ans[i] %= M
write(" ".join(map(str, ans)))

Measured memory_bytes: 75480
<?php
  const DIRS = "RDLU";
  $h[] = "000000";
  $v[] = "0000000";
  for($i=0;$i<4;$i++) {
      $h[] = "0".trim(fgets(STDIN))."0";
      $v[] = "0".trim(fgets(STDIN))."0";
  }
  $h[] = "0".trim(fgets(STDIN))."0";
  $v[] = $v[0];
  $h[] = $h[0];

  $x = 2; $y = 1; $dir = 0;
  $path = 'R';
  $stepx =  array(1,0,-1,0);
  $stepy = array(0,1,0,-1);

  while(!($x==1 && $y==1)) {
    for($i=0;$i<4;$i++) {
      $d = ($dir+$i)%4;
      $d2 = ($d+3)%4;
      if(($d==0 && $v[$y-1][$x]) || ($d==1 && $h[$y][$x])
        || ($d==2 && $v[$y][$x]) || ($d==3 && $h[$y][$x-1])) {
        $x += $stepx[$d2];
        $y += $stepy[$d2];
        $dir = $d2;
        break;
      }
    }
    $path .= DIRS[$dir];
  }

  echo $path.PHP_EOL;

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

using namespace std;
	
int main(){
	int n, k, s = 0;
	cin >> n >> k;
	long long counter = 0;
	if (k%2==0){
		s = k/2;
		for(int a=s; a<=n; a+=k){
			counter++;
		}
		counter = counter*counter*counter;
	}
	long long counter2 = 0;
	for(int a=k; a<=n; a+=k){
		counter2++;
	}
	counter2 = counter2*counter2*counter2;
	counter += counter2;

	cout << counter << endl;

	return 0;
}


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

int main(){
    int N;
    cin>>N;
    int a[200000],b[200000],c[200000];
    for(int i=1;i<=N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    int dp[200000][4];
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(int i=2;i<=N;i++){
        for(int j=1;j<=3;j++){
            if(j==1) dp[i][j]=max(dp[i-1][2],dp[i-1][3])+a[i];
            else if(j==2) dp[i][j]=max(dp[i-1][1],dp[i-1][3])+b[i];
            else dp[i][j]=max(dp[i-1][1],dp[i-1][2])+c[i];
        }
    }

    cout<<max(dp[N][1],max(dp[N][2],dp[N][3]))<<endl;

    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;
    string s; cin >> s;

    ll sum_b[n+1] = {};
    ll sum_w[n+1] = {};

    reps(i, 1, n+1){
        if(s[i-1] == '.'){
            sum_w[i] = sum_w[i-1] + 1;
            sum_b[i] = sum_b[i-1];
        }
        else{
            sum_b[i] = sum_b[i-1] + 1;
            sum_w[i] = sum_w[i-1];
        }
    }

    // rep(i, n+1){
    //     cout << sum_w[i] << " " << sum_b[i] << endl;
    // }

    ll ans = 1e18;

    // bool allsame = true;
    rep(i, n+1){
        ans = min(ans, sum_b[i] + sum_w[n] - sum_w[i]);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>

int main(void)
{
    int i,k,h,w;
   
	while(1)
	{
        scanf("%d %d",&h,&w);
        
		if(h == 0 && w == 0)
		{
			break;
		}
        
		for(i = 0; i < h; i ++ )
		{
            for(k = 0; k < w; k ++ )
			{
                if(i % 2 == 0)
				{
                    if(k % 2 == 0)printf("#");
                    else printf(".");
                }
                else 
				{
                    if(k % 2 == 0)printf(".");
                    else printf("#");
                }
            }
            
			printf("\n");
        }
        
		printf("\n");
    }
    
	return 0;
}

Measured memory_bytes: 572
import functools
import math

def gcd(x,y):
    a,b = max(x,y), min(x,y)
    while b != 0:
        a,b = b,a%b

    return a

def lcm2(x,y):
    return x*y // gcd(x,y)
    
N = int(input())
T = []
for i in range(N):
    ti = int(input())
    T.append(ti)

result = 1
for t in T:
    result = lcm2(result, t)

print(result)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define MAXN 100000

using namespace std;

int cnt[MAXN + 1];
bool red[MAXN + 1];

int main() {
  //  ifstream cin("A.in");
  //  ofstream cout("A.out");
    int i, n, m, x, y;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        cnt[i] = 1;
    red[1] = 1;
    for(i = 1; i <= m; i++) {
        cin >> x >> y;
        if(cnt[x] > 0) {
            cnt[x]--;
            cnt[y]++;
            if(red[x] == 1)
                red[y] = 1;
            if(cnt[x] == 0)
                red[x] = 0;
        }
    }
    int ans = 0;
    for(i = 1; i <= n; i++)
        ans += red[i];
    cout << ans << endl;
   // cin.close();
   // cout.close();
    return 0;
}


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

int N, K, a;
string s;

int main() {
  cin >> N >> K;
  cin >> s;
  
  for (int i = 1; i < N; i++) {
    if (s[i] != s[i-1]) {
      a++;
    }
  }
  a = N - a - 1;
  cout << min(N-1, a + 2*K);
}

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

signed main () {
    int n;
    cin >> n;
    vector < int > a(n + 1, 0);
    int64_t ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i - 1] && a[i]) {
            ++ans;
            --a[i];
        }
        ans += a[i] / 2;
        a[i] %= 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#define MAX 1000000

using namespace std;

bool prime[MAX+1];

void eratos(){
  for(int i=0;i<=MAX;i++) prime[i]=false;
  for(int i=3;i<=MAX;i+=2) prime[i]=true;
  prime[2]=true;
  int limit=(int)sqrt((double)MAX)+1;
  for(int i=3;i<=limit;i+=2){
    if(!prime[i]) continue;
    for(int j=i+i;j<=MAX;j+=i){
      prime[j]=false;
    }
  }
}

main(){
  eratos();
  int n, x;
  while(1){
    cin >> n >> x;
    if(n==0 && x==0) break;

    int items[30];
    for(int i=0;i<n;i++){
      cin >> items[i];
    }

    int max=-1;

    bool can[MAX+1];
    for(int i=0;i<=x;i++) can[i]=false;
    can[0]=true;
    for(int i=0;i<=x;i++){
      if(can[i]){
	int tmp;
	for(int j=0;j<n;j++){
	  tmp=i+items[j];
	  if(tmp<=x){
	    can[tmp]=true;
	  }
	}
      }
    }
    for(int i=x;i>=0;i--){
      if(i==0) cout << "NA" << endl;
      if(can[i] && prime[i]){
	cout << i << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      char c;
      cin >> c;
      if((int)c > 96){
            cout << "a";
      }else {
            cout << "A";
      }
}


Measured memory_bytes: 3604
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int N = Integer.parseInt(br.readLine());
        long[] A = Stream.of(br.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
        
        long sum = 0;
        int minusValueCount = 0;
        int absMin = (int) 1e9 + 1;
        
        for(int i = 0; i < N; i++){
            if( A[i] < 0 ) minusValueCount++;
            absMin = Math.min(absMin, (int)Math.abs(A[i]));
            sum += Math.abs(A[i]);
        }
        
        if( minusValueCount % 2 == 0){
            System.out.println(sum);
        } else {
            System.out.println(sum - absMin * 2);
        }
        
    }
}


Measured memory_bytes: 49156
import collections
d=collections.deque()
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:d.appendleft(e.split()[1])
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in d:d.remove(m)
  elif len(e)%2:d.popleft()
  else:d.pop()
print(*d)


Measured memory_bytes: 69732
ans = 1
n = input()
n = int(n)
nums = input().split()
for i in range(n):
    mul = int(nums[i])
    if mul == 0:
        print(0)
        exit()


for i in range(n):
    mul = int(nums[i])
    ans = ans * mul
    if ans > 10**18:
        print(-1)
        exit()

if ans > 10**18:
    print(-1)
else:
    print(ans)

exit()

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

int main() {
  int x,y,z,tmp;
  cin>>x>>y>>z;

  swap(x,y);swap(x,z);
  
  cout <<x<<" "<<y<<" "<<z<< endl;
  
  return 0;
}

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

int main()
{
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;

	int numDivisors = 0;
	for(int i = a; i <= b; i++)
	{
		if(c % i == 0){ numDivisors++; }
	}
	cout << numDivisors << endl;

	return 0;
}

Measured memory_bytes: 3088