akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100002

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
lli dp[101][MAX],wt[101],v[101];
lli knap(lli n,lli w)
{
	if(n==0||w==0)	return 0;
	if(dp[n][w]!=(-1))	return dp[n][w];
	if(wt[n]>w)	return knap(n-1,w);
	else dp[n][w]=max(knap(n-1,w),v[n]+knap(n-1,w-wt[n]));
	return dp[n][w];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3;
    lli i,j,k,t,c,a,b,m,n,sum=0,ans=0,temp;
    lli w;
    for(i=0;i<101;i++)
    	for(j=0;j<MAX;j++)	dp[i][j]=(-1);
    cin >> n >> w;
    rep(i,1,n+1)	cin >> wt[i] >> v[i];
    knap(n,w);
    cout << dp[n][w] << endl;
    
    return 0;
}

















/* UJJWAL KESHRI */

Measured memory_bytes: 79232
#include<stdio.h>
#define ll long long
int main(){
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    ll p=a+b;
    ll q=n/p;
    ll r=n%p;
    ll ans=q*a;
    if(r<=a) ans+=r;
    else ans+=a;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
var lines = [];

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var tmp_0 = lines[0];
    var N = Number(tmp_0);
    var H = Array(N);

    var tmp_1 = lines[1].split(" ");
    for (var i = 0; i < N; i++) {
        H[i] = Number(tmp_1[i]);
    }

    var max = 0; var result = 0;

    for (var i = 0; i < N; i++) {
        if (max <= H[i]) { result++; max = H[i]; }
    }

    console.log(result);
});

Measured memory_bytes: 7628
n = int(input())

A = list(map(int,input().split()))

A.sort(reverse = True)

tot = A[0]
cnt = 2
j = 0
for i in range(1,n):
    if n >= cnt+2:
        tot +=A[i]*2
        cnt += 2
        j = i
        
if n >= cnt + 1:
    tot += A[j+1]
    cnt += 1
        
print(tot)

Measured memory_bytes: 31692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    unordered_map<char, vector<int>> vmp;

    int n = s.size();
    rep(i, n){
        vmp[s[i]].push_back(i);
    }
    for (auto v : vmp){
        vector<int> vtmp = v.second;
        int m = vtmp.size();
        if (m <= 1) continue;
        else {
            rep(j, m - 1) {
                if (vtmp[j+1] - vtmp[j] <= 2){
                    cout << vtmp[j]+1 << " " << vtmp[j+1]+1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << endl;

    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

// 3乗で通したお詫びにO(NlogN)で通します
// 参考 : https://twitter.com/SayakaAmemiya/status/1249515024541859842

// optimized for small mod
template<int mod, int proot> struct NTT {
	int get_mod() { return mod; }
	int pow(int a, int b) {
	int res = 1;
		for (; b; b >>= 1) {
			if (b & 1) res = res * a % mod;
			a = a * a % mod;
		}
		return res;
	}
	int inv(int i) { return pow(i, mod - 2); }
	void ntt(std::vector<int> &a, bool inverse) {
		int n = a.size();
		assert((n & -n) == n);
		int h = pow(proot, (mod - 1) / n);
		if (inverse) h = inv(h);
		
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k > (i ^= k); k >>= 1);
			if (j < i) std::swap(a[i], a[j]);
		}
		for (int i = 1; i < n; i <<= 1) {
			int base = pow(h, n / i / 2);
			int w = 1;
			
			std::vector<int> ws(i);
			for (int j = 0; j < i; j++) ws[j] = w, w = w * base % mod;
			
			for (int j = 0; j < n; j += i << 1) {
				for (int k = 0; k < i; k++) {
					int u = a[k + j];
					int d = a[k + j + i] * ws[k] % mod;
					a[k + j] = u + d >= mod ? u + d - mod : u + d;
					a[k + j + i] = d > u ? u + mod - d : u - d;
				}
			}
		}
		if (inverse) {
			int ninv = inv(a.size());
			for (auto &i : a) i = i * ninv % mod;
		}
	}
};

int main() {
	int n = ri();
	int back[3] = { 0 };
	int forward[3] = { 0 };
	std::vector<int> a(n);
	{
		char tmp[4096];
		scanf("%s", tmp);
		for (int i = 0; i < n; i++) {
			a[i] = tmp[i] == 'R' ? 0 : tmp[i] == 'G' ? 1 : 2;
			back[a[i]]++;
		}
	}
	
	int64_t res = 0;
	// j - i != k - jを無視したの
	for (int j = 0; j < n; j++) {
		back[a[j]]--;
		res += forward[(a[j] + 1) % 3] * back[(a[j] + 2) % 3];
		res += forward[(a[j] + 2) % 3] * back[(a[j] + 1) % 3];
		forward[a[j]]++;
	}
	// j - i == k - jで相異なるものを引く
	int n2 = 1;
	for (; n2 < n + n - 1; n2 <<= 1);
	NTT<40961, 3> ntt;
	std::vector<int> count[3];
	for (auto &i : count) i.resize(n2);
	for (int i = 0; i < n; i++) count[a[i]][i]++;
	for (auto &i : count) ntt.ntt(i, false);
	
	std::vector<int> conved[3]; // conved count[i], count[(i + 1) % 3]
	for (int i = 0; i < 3; i++) {
		auto &cur = conved[i];
		cur.resize(n2);
		for (int j = 0; j < n2; j++) cur[j] = count[i][j] * count[(i + 1) % 3][j] % 40961;
		ntt.ntt(cur, true);
	}
	for (int j = 0; j < n; j++) res -= conved[(a[j] + 1) % 3][j + j];
	
	printf("%" PRId64 "\n", res);
	
	return 0;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define MAXN 1000000

using namespace std;

int a[MAXN + 1];
//int b[3 * MAXN + 1];

int main() {
   // fstream cin("A.in");
   // ofstream cout("A.out");
    int i,n,p;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++)
        cin >> a[i];
   for(i = n; i >= 1; i -= 2)
        cout << a[i] << " ";
   if(n % 2 == 0)
      p = 1;
   else
      p = 2;
   for(i = p; i <= n; i += 2)
    cout << a[i] << " ";
   cout << endl;
 //   cin.close();
 //   cout.close();
    return 0;
}


Measured memory_bytes: 2944
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
vi vec;

signed main(){
    io();
    cin>>n;
    vec.resize(n);
    rep(i,n) cin>>vec[i];
    int ans=0;
    rep(i,n)
        ans += vec[i]-1;
        
    cout<<ans<<endl;

    return 0;
}


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

int main(){
	 long long int n ,b;
    long long int p=1;
    int i;
    cin>>n;
    b=pow(10,18);
    long  int a[n];
    for (i=0;i<n;i++){
		cin>>a[i];
		if (a[i]==0){
			b=1;
			p=0;
			break;}
		b=b/a[i];
		p=p*a[i];
			
		}	
				
	if (b==0){
		cout<<-1;
		}
	else{
		cout<<p;
		}
	return 0;
}


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

int main() {
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i = 0; i<N;i++){
    cin >> A.at(i);
  }
  int c = 0;
  for(int i = 0;i<N;i++){
    for(int j = 0;j<1000;j++){
      if(A.at(i) * j +1 <= D) c++;
      if(A.at(i) * j +1 > D) break;
    }
  }
  cout << c + X << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int solve(int x, int y)
{
    for (int i = 1; 2*i <= x; ++i){
        if (!solve(x-2*i, y)) return 1;
    }
    for (int i = 1; 2*i <= y; ++i){
        if (!solve(x, y-2*i)) return 1;
    }
    return 0;
}
int main(void)
{
    ios::sync_with_stdio(false), cin.tie(0);
//    for (int i = 1; i <= 50; ++i){
//        for (int j = 1; j <= 50; ++j){
//            printf("x %d y %d ", i, j);
//            if (solve(i, j)) cout << "Alice" << endl;
//            else cout << "Brown" << endl;
//        }
//    }
    long long x, y;
    cin >> x >> y;
    if (abs(x-y) == 0 || abs(x-y) == 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<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 main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  cout << n/2-(n%2==0) << endl;
  return 0;
}

Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class ACookieExchanges {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a,b,c;
        in>>a>>b>>c;
        if(a%2==0 && a==b && b==c && c==a){
            out<<-1<<endl;
            return;
        }
        ll cnt=0;
        while(a%2==0 && b%2==0 && c%2==0){
            ll aa,bb,cc;
            aa=a/2;
            bb=b/2;
            cc=c/2;
            a=bb+cc;
            b=aa+cc;
            c=aa+bb;
            ++cnt;
        }
        out<<cnt<<endl;
	}
};


int main() {
	ACookieExchanges solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String strBegin = str.substring(0, 1);
		String strEnd = str.substring(str.length()-1, str.length());
		int count = str.length() - 2;
		System.out.println(strBegin + count + strEnd);
	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

vector<int> Imos(int mx, vector<pair<int,int>> area) {
  /* O(mx + area.size()) */
  vector<int> d(mx+2), sum(mx+1);
  for(auto a : area) {
    assert(a.first <= a.second);
    d[a.first]++, d[a.second + 1]--; /* inclusive (a.first, a.second) */
  }
  sum[0] = d[0];
  for(int i=1; i<=mx; ++i) sum[i] = sum[i-1] + d[i];
  return sum;
}

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

  rep(r,k) {
    vector<int> d(n+1);
    rep(i,n) {
      int l = max(i - a[i], 0), r = min(i + a[i],n-1); 
      d[l]++;
      d[r+1]--;
    }
    a[0] = d[0];
    rep(i,1,n) a[i] = a[i-1] + d[i];
    bool all_n = true;
    rep(i,n) if (a[i]!=n) {all_n = false; break;}
    if(all_n) break;
  }
  rep(i,n) cout << a[i] << ((i==n-1) ? "\n" : " ");
}


Measured memory_bytes: 4792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		int n = Console.ReadLine().ToInt();
		
		var str = Console.ReadLine();
		int[] s = new int[n];
		long rightwa = 0;
		for(int i = 0; i < n; i++)
		{
			s[i] = (str[i] == 'W' ? -1 : 1);
			if(s[i] == 1)
				rightwa++;
		}
		long leftwa = 0;
		long r = 9999999999;
		for(int i = 0; i < n; i++)
		{
			r = Math.Min(r, leftwa + rightwa - ((s[i] == 1) ? 1 : 0));
			rightwa -= (s[i] == -1) ? 0 : 1;
			leftwa += (s[i] == -1) ? 1 : 0;
		}
		Console.WriteLine(r);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 13280
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
R=[]
B=[]

for i in range(n):
    a,b=LI()
    R.append((a,b))

for i in range(n):
    a,b=LI()
    B.append((a,b))

RR=[]
B.sort(key=lambda x:x[0])
R.sort(key=lambda x:-x[0])
ans=0

for c,d in B:
    while R and R[-1][0]<c:
        RR.append(R.pop())
    
    RR.sort(key=lambda x:-x[1])
    for a,b in RR:
        if a<c and b<d:
            ans+=1
            RR.remove((a,b))
            break
        
print(ans)

#show(d)



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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

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

const ll MAX = 2000200;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll bpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b & 1)
            res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    ll i, j, k;
    ll K;
    string S;
    cin >> K >> S;
    COMinit();
    ll s = S.length();
    ll N = K + s;
    ll ans = 0;
    for(i = 0; i < K + 1; i++) {
        ll subans = 1;
        subans = (subans * bpow(26LL, i)) % MOD;
        subans = (subans * COM(N - 1 - i, s - 1)) % MOD;
        subans = (subans * bpow(25LL, K - i)) % MOD;
        ans = (ans + subans) % MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 51204
#include <iostream>
#include <algorithm>
using namespace std;
  long gcd(long a, long b){
    if (a%b==0) return b;
    else return gcd(b,a%b);
  }
long lcm(long a ,long b){
  return a*b/gcd(a,b);
}
int main(){
  long A,B;
  cin>>A>>B;
cout<<lcm(A,B)<<endl;
}
  
    
    


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    int si=s.size();
    int k=0;
    for(int i=0;i<si-1;i++){
        if(s[i]==s[i+1])k++;
    }
    if(k==0)cout<<"Good";
    if(k!=0)cout<<"Bad";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 109
ll n,m,i,j,k,l,t,dp[sz][sz][5];
char c[sz][sz];
ll dpdp(ll le,ll dow,ll cnt)
{
    ll &ret=dp[le][dow][cnt];
    if(ret!=-1)
        return ret;
    if(c[le][dow]=='#')
    {
        if(cnt==0)
            ret=1;
        else
            ret=0;
          if(le==n-1 || dow==m-1)
          {
              if(le==n-1 && dow==m-1)
                return ret;
              if(le==n-1)
                return ret+=dpdp(le,dow+1,1);
              return ret+=dpdp(le+1,dow,1);
          }
          return ret+=min(dpdp(le,dow+1,1),dpdp(le+1,dow,1));
    }
    ret=0;
     if(le==n-1 || dow==m-1)
          {
              if(le==n-1 && dow==m-1)
                return ret;
              if(le==n-1)
                return ret+=dpdp(le,dow+1,0);
              return ret+=dpdp(le+1,dow,0);
          }
          return ret+=min(dpdp(le,dow+1,0),dpdp(le+1,dow,0));
}
int main()
{
   scanf("%lld %lld",&n,&m);
   for(i=0;i<n;i++)
    scanf("%s",&c[i]);
   memset(dp,-1,sizeof dp);
   l=dpdp(0,0,0);
   printf("%lld\n",l);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, c, k;
int a[100000];

int main() {
    scanf("%d%d%d", &n, &c, &k);
    forn(i, n) scanf("%d", a + i);
    sort(a, a + n);
    int ans = 0;
    for (int beg = 0; beg < n; ) {
        int end = beg + 1;
        while (end < n && a[end] - a[beg] <= k && end - beg < c) {
            ++end;
        }
        ++ans;
        beg = end;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,ans=0;
  cin >> N;
  vector<int>v(N);
  for (int i=0; i<N; i++) cin >> v.at(i);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i=0; i<N; i++){
    if(i%2==0) ans += v.at(i);
    else ans -= v.at(i);
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 100005;

int N, M, A, B;
vector<int> graph[MX];
vector<ll> p;

void solve() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
		cin >> A >> B;
		graph[A].push_back(B);
		graph[B].push_back(A);
	}
	
	p.assign(MX, -1);
	queue<int> q;
	q.push(1);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto child : graph[v]) {
			if (p[child] == -1) {
				p[child] = v;
				q.push(child);
			}
		}
	}
	
	for (int i = 2; i <= N; i++) {
		if (p[i] == -1) {
			cout << "No";
			break;
		}
	}
	
	cout << "Yes\n";
	for (int i = 2; i <= N; i++) {
		cout << p[i] << "\n";
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 10520
N, K = [int(i) for i in input().split(' ')]

D = [int(i) for i in input().split(' ')]

c = N

while True:
    s = [int(i) for i in list(str(c))]

    flg = False

    for i in s:
        if i in D:
            flg = False
            break
        else:
            flg = True
    
    if flg:
        print(c)
        break
    else:
        c += 1

Measured memory_bytes: 3060
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

l,r = inp
dp = Array.new(60){Array.new(2){Array.new(2){Array.new(2,0)}}}
ls = l.to_s(2)
rs = r.to_s(2)
ls = "0"*100 + ls
rs = "0"*100 + rs
ls.reverse!
rs.reverse!
dp[59][0][0][0] = 1
ans = na3(2,2,2,0)
(0..59).to_a.reverse.each do |keta|
  2.times do |i|
    2.times do |j|
      2.times do |k|
        now = dp[keta][i][j][k]
        next if(now == 0)
        2.times do |x|
          2.times do |y|
            next if(y<x)
            nx=i
            ny=j
            nb=k
            next if(k==0 and x!=y)
            next if(i==0 and x==0 and ls[keta].to_i == 1)
            next if(j==0 and y==1 and rs[keta].to_i == 0)
            nb = 1 if(x == y and x == 1)
            ny = 1 if(y < rs[keta].to_i)
            nx = 1 if(ls[keta].to_i < x)
            if(keta == 0)
              ans[nx][ny][nb] += now
            else
              dp[keta-1][nx][ny][nb] += now
              dp[keta-1][nx][ny][nb] %= (10**9+7)
            end
          end
        end
      end
    end
  end

end
p ans.flatten.inject{|m,u|(m+u)%(10**9+7)}


Measured memory_bytes: 1788
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}


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

	int t;
	cin>>t;
	loop(i,-200,200)loop(j,-200,200){
		int a=i*i*i*i*i;
		int b=j*j*j*j*j;
		if(a-b==t){
			cout<<i<<" "<<j<<endl;
			return 0;
		}
	}
}


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

int main()
{
  int r,c,sum;
  int rc[101][101];
  cin>>r>>c;
  for(int i=0;i<r;i++){
    sum=0;
    for(int j=0;j<c;j++){
      cin>>rc[i][j];
      sum+=rc[i][j];
    }
    rc[i][c]=sum;
  }
  for(int j=0;j<c+1;j++){
    sum=0;
    for(int i=0;i<r;i++){
      sum+=rc[i][j];
    }
    rc[r][j]=sum;
  }
  for(int i=0;i<r+1;i++){
    for(int j=0;j<c;j++)cout<<rc[i][j]<<" ";
    cout<<rc[i][c]<<endl;
  }
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for( int i = 0; i < n - 2; ++i ) {
        if( s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' ) {
            ++cnt;

        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
use std::f64::consts::PI;
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let r: f64 = line.trim().parse().unwrap();
    let (area, circum) = (r.powi(2) * PI, r * 2.0 * PI);
    println!("{:.*} {:.*}", 5, area, 5, circum);
}



Measured memory_bytes: 5100
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    H, W = list(map(int, sys.stdin.readline().split()))
    L = [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

    NL = []
    for l in L:
        if "#" in l:
            NL.append(l)

    # リストの転置
    # https://note.nkmk.me/python-list-transpose/
    L = list(zip(*NL))
    NL2 = []
    for l in L:
        if "#" in l:
            NL2.append(l)

    # もとに戻す
    L = list(zip(*NL2))
    for l in L:
        print("".join(l))

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

public class Main {
	public static void main(String[] args) throws IOException {
     Scanner sc = new Scanner(System.in);
     int monsters = sc.nextInt(); 
     int specialMove = sc.nextInt(); 
     int health[] = new int[monsters]; 
     
     for(int i = 0;i<monsters; i++) {
    	 health[i] = sc.nextInt(); 
     }
     
     Arrays.sort(health);
     if(specialMove > monsters) {
    	 Arrays.fill(health, 0);
     }
     else {
          for(int i = 1; i<=specialMove; i++) {
    	    health[monsters-i] = 0; 
           }
     }
    long ans = 0; 
    for(int i = 0; i<monsters; i++) {
    	ans += health[i]; 
    }
    System.out.println(ans); 
	}
}


Measured memory_bytes: 63668
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

int main(){
  li n,k; cin >>n >>k;
  vector<int> a(n);
  rep(i,n){
    cin >>a[i];
  }
  int flag=0;
  rep(i,k){
    vector<int> tmp(n+2,0);
    rep(j,n){
      int l=j-a[j],r=j+a[j]+1;
      if(l<0)l=0; if(r>n)r=n;
      tmp[l]++; tmp[r]--;
    }
    flag=1;
    li s=0;
    rep(j,n){
      s+=tmp[j];
      a[j]=s;
      if(a[j]!=n)flag=0;
    }
    if(flag) break;
    if(df)print(i,a);
  }
  print(a);
}


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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var count = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if(s[i] == 'o')
                {
                    count++;
                }
            }

            Console.WriteLine(15 - s.Length >= 8 - count ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 25608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N < 1000) Console.WriteLine("ABC");
            else Console.WriteLine("ABD");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

char sub(char a, char b) {
	if (a < b) return (26 + a - b);
	return (a - b);
}

char add(char a, char offset) {
	return ((((a - 'a') + offset) % 26) + 'a');
}

int main() {
	char offset;
	int num;
	std::string str;
	while (getline(std::cin, str)) {
		offset = 0;
		num = 0;
		for (int i=0; i<str.length(); i++) {
			if ('a' <= str[i] && str[i] <= 'z') {
				num++;
				if (i < str.length() - 1) {
					continue;
				}
				i++;
			}
			if ((num == 3
			&& sub(str[i-3], str[i-2]) == 12
			&& sub(str[i-3], str[i-1]) == 15)
			|| (num == 4
			&& sub(str[i-4], str[i-3]) == 12
			&& sub(str[i-4], str[i-2]) == 11
			&& sub(str[i-4], str[i-1]) == 1)
			|| (num == 4
			&& sub(str[i-4], str[i-3]) == 12
			&& sub(str[i-4], str[i-2]) == 19
			&& sub(str[i-4], str[i-1]) == 0))
			{
				offset = sub(str[i-num], 't');
				break;
			}
			num = 0;
		}
		for (int i=0; i<str.length(); i++) {
			if ('a' <= str[i] && str[i] <= 'z') {
				str[i] = add(str[i], 26 - offset);
			}
		}
		std::cout << str << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3112
S = input()
s = ''
answer = 0
for i in range(1 << len(S)-1):
  s = S[0]
  for j in range(len(S)-1):
    if ((i >> j) & 1) == 1:
      s = s + '+' +S[j+1]
    else:
      s += S[j+1]
  answer += eval(s)
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
typedef tuple<ll,int,int> T;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
int main(){
int n;
cin>>n;
int nod=n;
vector<vector<int>> graph(n+1);
if(n%2==1)nod--;
int cnt=0;
int center=nod/2;
vector<P> tmp;
for(int take=2;take<=center;take++){
    graph[1].push_back(take);
    graph[1].push_back(nod-take+1);
    graph[take].push_back(nod);
    graph[nod-take+1].push_back(nod);
    tmp.push_back(P(take,nod-take+1));
    cnt+=4;
}
for(int i=0;i<tmp.size();i++){
    P s=tmp[i];
    for(int j=i+1;j<tmp.size();j++){
        P t=tmp[j];
        int a=s.fi,b=s.se,c=t.fi,d=t.se;
        graph[min(a,c)].push_back(max(a,c));
        graph[min(a,d)].push_back(max(a,d));
        graph[min(b,c)].push_back(max(b,c));
        graph[min(b,d)].push_back(max(b,d));
        cnt+=4;
    }
}
if(nod!=n){
    graph[1].push_back(n);
    graph[nod].push_back(n);
    cnt+=2;
for(int i=0;i<tmp.size();i++){
  int a=tmp[i].fi,b=tmp[i].se;
   graph[a].push_back(n);
    graph[b].push_back(n);
    cnt+=2;
}
}
cout<<cnt<<endl;
for(int i=1;i<=n;i++){
    sort(all(graph[i]));
    for(int j=0;j<graph[i].size();j++)cout<<i<<" "<<graph[i][j]<<endl;
}
}

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

typedef struct node_s node;

struct node_s{
  int key;
  node *prev;
  node *next;
};

node *head;

void insert(int x){
  node *t=malloc(sizeof(node));
  t->key=x;
  t->next=head->next;
  t->prev=head;
  head->next->prev=t;
  head->next=t;
}
void delete(node *n){
  if (n==NULL)return;
  n->prev->next=n->next;
  n->next->prev=n->prev;
  free(n);
}

node *find(int key){
  node *p;
  for (p=head->next;p->key!=-1;p=p->next){
    if (p->key==key){
      return p;
    }
  }
  return NULL;
}

int main(){
  int i,n,x;
  char cmd[16];
  node *tp;
    
  head = malloc(sizeof(node));
  head->key=-1;
  head->prev=head;
  head->next=head;
  
  scanf("%d",&n);

  for (i=0;i<n;i++){
    scanf("%s", &cmd);
    if (cmd[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if (cmd[0]=='d'&&cmd[6]=='\0'){
      scanf("%d",&x);
      delete(find(x));
    }else if (cmd[0]=='d'&&cmd[6]=='F'){
      delete(head->next);
    }else if (cmd[0]=='d'&&cmd[6]=='L'){
      delete(head->prev);
    }
  }
  for (tp=head->next;tp->next->key!=-1;tp=tp->next)
    printf("%d " ,tp->key);
  printf("%d\n" ,tp->key);
  
  return 0;
}



Measured memory_bytes: 32992
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<pair<long long, long long>> v;
    for (int i = 0; i < n; i++) {
        long long c, d; cin >> c >> d;
        v.emplace_back(d, c);
    }
    sort(v.begin(), v.end());
    long long curr = 0;
    for (int i = 0; i < n; i++) {
        curr += v[i].second;
        if (curr > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6520
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007

int n;
int t[100000];
int a[100000];

int ma[100000];
int sure[100000];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	rep(i, n)cin >> t[i];
	rep(i, n)cin >> a[i];

	bool ok = true;

	rep(i, n)ma[i] = 1 << 30;
	rep(i, n)sure[i] = -1;
	//sure[0] = t[0];
	for (int i = 0; i < n;i++) {
		if (i==0 || t[i-1] < t[i]) {
			if (sure[i] != -1 && sure[i] != t[i])ok = false;
			sure[i] = t[i];
		}
		else {
			ma[i] = min(ma[i], t[i]);
		}
	}

	//sure[n-1] = a[n-1];
	for (int i = n-1; i >= 0; i--) {
		if (i==n-1 || a[i] > a[i + 1]) {
			if (sure[i] != -1 && sure[i] != a[i])ok = false;
			sure[i] = a[i];
		}
		else {
			ma[i] = min(ma[i], a[i]);
		}
	}

	rep(i,n) {
		if (sure[i] != -1 && sure[i] > ma[i])ok = false;
	}


	if (ok) {
		long long ans = 1;
		rep(i,n) {
			if (sure[i] == -1)ans = (ans * ma[i]) % MOD;
		}
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}


	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m = 0, a[200005] = {}, p[200005] = {}, sosu[100005], sum = 0, d, w, h;
	long long dp[200005] = {}, memo[200005] = {};
	cin >> n;
	a[0] = 200001;
	dp[0] = 1;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i] = dp[i - 1];
		if (a[i] != a[i - 1]) {
			dp[i] += memo[a[i]];
			memo[a[i]] += dp[i-1];
			memo[a[i]] %= 1000000007;
		}
		dp[i] %= 1000000007;
	}
	cout << dp[n];
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, Q;
    string S;
    cin>>N>>S>>Q;
    
    rep(l,Q){
        int K; cin>>K;
        ll sum_D=0, sum_M=0, sum_DM=0;
        ll DMC=0;
        
        rep(i,N){
            char c=S[i];
            if(c=='D'){
                sum_D++;
            }else if(c=='M'){
                sum_M++;
                sum_DM+=sum_D;
            }else if(c=='C'){
                DMC+=sum_DM;
            }
            if(i-K+1>=0){
                c=S[i-K+1];
                if(c=='D'){
                    sum_D--;
                    sum_DM-=sum_M;
                }else if(c=='M'){
                    sum_M--;
                }
            }
        }
        cout1(DMC);
    }
}

Measured memory_bytes: 1948
n = int(input())
l = list(map(int, input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(l[1]-l[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
print(dp[n-1])

Measured memory_bytes: 13928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            List<long> name = new List<long>();

            do
            {
                if (N % 26 != 0)
                {
                    name.Add(N % 26);
                    N = N / 26;
                }
                else
                {
                    name.Add(26);
                    N = N / 26 - 1;
                }
            } while (N > 0);

            name.Reverse();

            string answer = string.Empty;

            for(int i = 0; i < name.Count(); i++)
            {
                answer += (char)('a' + name[i] - 1);
            }

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 28184
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<bitset>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,k;
	vector<int> v;
	ll ans = 0;
	int aa = 0;

	cin >> n >> k;


	ll a[n],b[n];
	ll kk = k;
	
	
	REP(i,n)
	{
		cin >> a[i] >> b[i] ;
	}
	
	while(kk /= 2,kk > 0)
	{
		aa++;
	}

	cerr << aa << endl;
	cerr << static_cast<bitset<20> >(k) << endl;

	REP(i,aa+1)
	{
		if(k & (1 << i))
		{
			ll tmp = (k ^ (1 << i)) | ((1 << i) - 1);
			cerr << static_cast<bitset<20> >(tmp) << endl;
			
			ll hikaku = 0;
			
			REP(j,n)
			{
				if((tmp | a[j]) == tmp)
				{
					hikaku += b[j];
				}
			}
			
			ans = max(ans,hikaku);
		}
	}
	
	ll hikaku = 0;
	
	REP(j,n)
	{
		if((k | a[j]) == k)
		{
			hikaku += b[j];
		}
	}
	
	ans = max(ans,hikaku);
	
	
	cout << ans << endl;
	
	return 0;
}

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

int main() {
    int k;
    cin>>k;
    ll ans = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int p=1;p<=k;p++){
                ll tmp2 = gcd(j,p);
                ll tmp = gcd(i, tmp2);
                ans+=tmp;
            }
        }
    }
    cout<<ans<<endl;
}
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += k - max(k-a, 0LL);
    k = max(k-a, 0LL);
    k = max(k-b, 0LL);
    ans -= k - max(k-c, 0LL);

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

Measured memory_bytes: 3572
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int sum(int x) {
  int ret = 0;
  while (x > 0) {
    ret += (x % 10);
    x /= 10;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  int ans = INT_MAX;
  FOR (a, 1, n/2 + 1) {
    int b = n - a;
    ans = min(ans, sum(a) + sum(b));
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 888
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc =new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int X = sc.nextInt();
int Y = sc.nextInt();
int total = 0;
if(N <= K){
total = N * X;
}else{
total = K * X + ( N - K ) * Y;
}
System.out.println(total);

}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<string> S(H);

	for (int i = 0; i < H; i++)
		cin >> S[i];

	for (int i = 0; i < H + 2; i++)
	{
		for (int j = 0; j < W + 2; j++)
		{
			if (i == 0 || i == H + 1 || j == 0 || j == W + 1)
				cout << "#";
			else
				cout << S[i - 1][j - 1];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256