akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll a = 1; a < n; ++a){
        if(n % a != 0){
            ans += n / a;
        }else{
            ans += (n - 1) / a;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int h=n/100;
    int i=n%100;
    int j=i/10;
    int k=i%10;
    if(100<=n&&n<=999){
      if((h==7)||(j==7)||(k==7)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

vector<ll> a,p;

ll f(ll n, ll x) {
  if (n==0) return x<=0 ? 0 : 1;
  else if (x <= 1+a[n-1]) return f(n-1, x-1);
  else return p[n-1] + 1 + f(n-1, x-2-a[n-1]);
}

void solve()
{
  a.push_back(1);
  p.push_back(1);
  ll n,x; cin>>n>>x;
  for (int i=0; i<n; i++) {
    a.push_back(a[i]*2 + 3);
    p.push_back(p[i]*2 + 1);
  }
  cout << f(n,x) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import bisect

N, K, C = map(int, input().split())
S = input()[::-1]
indices = []
last_set = []
flag = True
pre = 0
for i, s in enumerate(S):
  if i > pre + C:
    flag = True
  if s == 'o':
    indices.append(N-i)
    if flag and K>0:
      last_set.append(N-i)
      K -= 1
      flag = False
      pre = i

ans = []
last_set = last_set[::-1]
indices = indices[::-1]
pre = -1000000
for day in last_set:
  i = bisect.bisect_left(indices, day)
  if i == 0:
    ans.append(day)
    pre = day
  else:
    ii = indices[i-1]
    if abs(ii - pre) <= C:
      ans.append(day)
      pre = day
    else:
      iii = bisect.bisect_left(indices, pre+C+1)
      if iii < N:
        pre = min(indices[iii], ii)
      else:
        pre = ii

for day in ans:
  print(day)

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i, n) for (ll i=0; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */

signed main() 
{
  int a,b,c; cin>>a>>b>>c;
  int d = in();
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)) print("Yes");
  else print("No");
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,n) for(int i=0;i<n;i++)
char ca;
const int MOD = 1000000007;
ll  c = 0, d = 0, e = 0, f = 0,g=0, n, i, j, k, h, w, o, a[100005], b[10000] = {};
queue<ll> q;
string s;
pair<ll, ll> p[20][20];
vector<vector<ll>> v;
const int MAX = 2005;
long long fac[MAX], finv[MAX], inv[MAX];

int main() {
	cin >> n;
	for (i = 2; i <= n; i++) {
		h = i;
		for (j = 2; j * j <= h; j++) {
			while (h % j == 0) {
				b[j]++;
				h /= j;
			}
		}
		if (h != 1)b[h]++;
	}

	for (i = 2; i <= n; i++) {
	//	cout << b[i] << "\n";
		if (b[i] >= 2)c++;
		if (b[i] >= 4)d++;
		if (b[i] >= 24)e++;
		if (b[i] >= 74)f++;
		if (b[i] >= 14)g++;
	}
	w = f + (c - 1) * e+g*(d-1) + (c - 2) * d * (d - 1) / 2;

	cout << w;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.math;

void main() {
  int[int] counter;

  foreach (string line; lines(stdin)) {
    int i = line.chomp.to!int;
    counter[i]++;
  }

  int max = counter.values.reduce!(max);

  foreach (k; counter.keys.sort) {
    if (counter[k] == max) k.writeln;
  }
}

Measured memory_bytes: 1060
import numpy as np
n,w=map(int,input().split())
dp=np.zeros(w+1,dtype=np.int64)
for _ in range(n):
    we,v=map(int,input().split())
    if we > w:
        continue
    else:
        np.maximum(dp[we:],dp[:-we]+v,out = dp[we:])
print(dp[w])

Measured memory_bytes: 14600
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,a;
int main(){
	scanf("%d%d",&n,&a);
	printf("%d\n",n*n-a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
#include <unordered_map>
//#include <string>
//typedef long long LL;
using namespace std;

int main() {
    int N;
    cin >> N;
    int Nmax = 1e6;
 
    vector<vector<int>> to(N);
    vector<int> par_edg_col(N, -1);
    vector<pair<int, int>> eds;
    unordered_map<int, int> col_map;
 
    for (int i = 0; i < N - 1; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        to[s].push_back(t);
        to[t].push_back(s);
        int ss = max(s, t);
        int tt = min(s, t);
        eds.push_back(make_pair(ss, tt));
    }
 
    queue<int> que;
    que.push(0);
    par_edg_col[0] = 0;
 
    int maxcol = 0;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        int exc_col = par_edg_col[v];
        int tmp_col = 0;
        for (auto u : to[v]) {
            if (par_edg_col[u] == -1) {
                que.push(u);
                tmp_col++;        
                if (tmp_col == exc_col) tmp_col++;
                par_edg_col[u] = tmp_col;
                int uu = max(u, v);
                int vv = min(u, v);
                col_map[uu * Nmax + vv] = tmp_col;
            }
        }
        maxcol = max(maxcol, tmp_col);
    }
 
    cout << maxcol << endl;
    for (size_t i = 0; i < eds.size(); i++) {
        int u = eds[i].first;
        int v = eds[i].second;
        cout << col_map[u*Nmax + v] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 11380
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] s = new String[H];
		int whites = -1;
		for(int i=0;i<H;++i){
			s[i] = sc.next();
			for(int j=0;j<W;++j){
				if(s[i].charAt(j)=='.') whites++;
			}
		}
		
		int ans = solve(s,H,W);
		if(ans==-1) System.out.println(-1);
		else System.out.println(whites-ans);
		return;
	}
	
	public static int solve(String[] s,int h,int w){
		int count = 0;
		int[] dx = {1,0,-1,0};
		int[] dy = {0,1,0,-1};
		boolean[][] visited = new boolean[h][w];
		visited[0][0] = true;
		ArrayDeque<Integer> queX = new ArrayDeque<Integer>();
		ArrayDeque<Integer> queY = new ArrayDeque<Integer>();		
		queX.offer(0);
		queY.offer(0);
		
		int validWays = 1;
		while(!queX.isEmpty()){
			int ways = 0;
			for(int i=0;i<validWays;++i){
				int x = queX.poll();
				int y = queY.poll();
				if(x==w-1&&y==h-1) return count;
				for(int j=0;j<4;j++){
					if((x+dx[j]>=0&&x+dx[j]<w)&&(y+dy[j]>=0&&y+dy[j]<h)
							&& s[y+dy[j]].charAt(x+dx[j]) == '.' && !visited[y+dy[j]][x+dx[j]] ){
						visited[y+dy[j]][x+dx[j]] = true;
						queX.offer(x+dx[j]);
						queY.offer(y+dy[j]);
						ways++;
					}
				}
			}
			validWays = ways;
			count++;
		}
		return -1;
	}
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            Func<string, int[]> makeNumber = str =>
            {
                var dic = new Dictionary<char, int>();
                var n = new int[str.Length];
                for(var i = 0;i<str.Length;i++)
                {
                    var c = str[i];
                    if(!dic.ContainsKey(c))
                    {
                        dic.Add(c, dic.Count);
                    }
                    n[i] = dic[c];
                }
                return n;
            };

            if(makeNumber(S).SequenceEqual(makeNumber(T)))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

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

#define int long long
using namespace std;

signed main(void){
    int N;
    cin >> N;
    vector<int> m, p;
    m.reserve(N);
    p.reserve(N);
    int zc = 0;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(A > 0) p.push_back(A);
        else if(A < 0) m.push_back(-A);
        else{
            zc++;
        }
    }
    if(p.size() == 0){
        for(int i = 0; i < zc; i++) p.push_back(0);
    }else{
        for(int i = 0; i < zc; i++) m.push_back(0);
    }
    sort(p.begin(), p.end());
    sort(m.begin(), m.end());
    if(m.size() == 0){
        cout << accumulate(p.begin(), p.end(), 0) - 2 * p[0] << endl;
        int M = p[0];
        for(int i = 1; i < N - 1; i++){
            cout << M << " " << p[i] << endl;
            M -= p[i];
        }
        cout << p[N - 1] << " " << M << endl;
    }else if(p.size() == 0){
        cout << accumulate(m.begin(), m.end(), 0) - 2 * m[0] << endl;
        int M = -m[0];
        for(int i = 1; i < N - 1; i++){
            cout << M << " " << -m[i] << endl;
            M += m[i];
        }
        cout << M << " " << -m[N - 1] << endl;
    }else{
        cout << accumulate(p.begin(), p.end(), 0) + accumulate(m.begin(), m.end(), 0) << endl;
        int M = -m[0];
        for(int i = 0; i < p.size() - 1; i++){
            cout << M << " " << p[i] << endl;
            M -= p[i];
        }
        cout << p[p.size() - 1] << " " << M << endl;
        M = p[p.size() - 1] - M;
        for(int i = 1; i < m.size(); i++){
            cout << M << " " << -m[i] << endl;
            M += m[i];
        }
    }
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,T;
  cin >> N >> T;
  vector<int64_t> t(N);
  for(int i = 0; i < N; i++){
    cin >> t.at(i);
  }
  int64_t sum;
  for(int i = 0; i < N-1; i++){
    if(t.at(i+1)-t.at(i) < T){
      sum+= t.at(i+1)-t.at(i);
    }
    else{
      sum+= T;
    }
  }
  sum+= T;
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,k,s;
  std::cin>>n>>k>>s;

  rep(i,0,k){
    std::cout<<s<<" ";
  }

  rep(i,0,n-k){
    if(s<1e9){
      std::cout<<1000000000<<" ";
    }else{
      std::cout<<999999999<<" ";
    }
  }

  std::cout<<"\n";

  return 0;
}

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

const int MAX_N = 2005;

int H, W, A[MAX_N][MAX_N], hi[MAX_N];
char S[MAX_N][MAX_N];

int st[MAX_N];

int main() {
  scanf("%d%d", &H, &W);
  for (int i = 1; i <= H; ++i) {
    scanf("%s", S[i] + 1);
    for (int j = 1; j <= W; ++j)
      A[i][j] = (S[i][j] == '#') ^ (S[i][j - 1] == '#');
  }

  int res = H;

  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j)
      if (A[i][j] == A[i - 1][j]) hi[j]++;
      else hi[j] = 1;
    
    int top = 0;
    
    st[0] = 1;
    for (int j = 2; j <= W; ++j) {
      while (top > 0 && hi[st[top]] >= hi[j]) {
	res = max(res, (j - st[top - 1]) * hi[st[top]]);
	top--;
      }
      st[++top] = j;
    }

    while (top > 0) {
      res = max(res, (W - st[top - 1] + 1) * hi[st[top]]);
      top--;
    }
  }

  printf("%d\n", res);
  return 0;
}


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

int main(){
  string sr;cin>>sr;
  string s=sr;
  
  int n=s.size();
  reverse(sr.begin(),sr.end());
  int ans=0;
  if(s==sr)ans++;
  
  string sf=s.substr(0,(n-1)/2);
  string sfr=sf;reverse(sf.begin(),sf.end());
  if(sf==sfr)ans++;
  
  string se=sr.substr(0,(n-1)/2);
  string ser=se;reverse(se.begin(),se.end());
  if(se==ser)ans++;
  
  if(ans==3)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> res;
  for (ll i=2; i*i<=n; i++) {
    while (n%i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main()
{
  ll n,p; cin>>n>>p;

  map<ll, ll> mp = prime_factor(p);
  ll ans = 1;
  for (auto v:mp) {
    ll t = v.second / n;
    ans *= powl(v.first, t);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3696
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            Console.WriteLine(a*b%2 ==0?"No":"Yes");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
n,*a=map(int,open(0).read().split())
for x in range(n-1,0,-1):a[x-1]=(sum(a[x*2-1::x])+a[x-1])%2
print(a.count(1));print(*[i+1 for i in range(n)if a[i]],end=" ")

Measured memory_bytes: 11644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

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

	vector<int> ixR, ixG, ixB;
	rep(i,n) {
		if (s[i] == 'R') ixR.push_back(i);
		if (s[i] == 'G') ixG.push_back(i);
		if (s[i] == 'B') ixB.push_back(i);
	}

	ll ans = 0;
	for (int r : ixR) for (int g : ixG) {
		ans += ixB.size();
		if ((r+g) % 2 == 0 && s[(r + g) / 2] == 'B') ans--;
		if (0 <= 2*g-r && 2*g-r < n && s[2*g-r] == 'B') ans--;
		if (0 <= 2 * r - g && 2 * r - g < n && s[2*r-g] == 'B') ans--;
	}

	cout<< ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MAX 1e9
using namespace std;

typedef long long ll;

ll
gcd(ll a, ll b)
{
  ll res = a % b;
  while(res != 0){
    a = b;
    b = res;
    res = a % b;
  }
  return b;
}

int
main(void){

  ll a, b; cin >> a >> b;
  ll res = gcd(a,b);

  printf("%ld\n", (a*b)/res);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
//
ll mod_pow(ll,ll,ll);
int main(){
    vector<ll> bits(60);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        ll in;
        cin >> in;
        for(int j = 0; j < 60; j++){
            bits[j] += (in >> j & 1);
        }
    }
    vector<ll> div(60);
    for(int i = 0; i < 60; i++){
        div[i] = mod_pow(2, i, MOD);
    }
    ll ans = 0;
    for(int i = 0; i < 60; i++){
        ans = (ans + div[i] * bits[i] % MOD * (n - bits[i])) % MOD;
    }
    cout << ans;
}

/*⠀⠀⠀⠀⠀⢀⣀⣀⣀    
⠀⠀⠀⠰⡿⠿⠛⠛⠻⠿⣷
⠀⠀⠀⠀⠀⠀⣀⣄⡀⠀⠀⠀⠀⢀⣀⣀⣤⣄⣀⡀
⠀⠀⠀⠀⠀⢸⣿⣿⣷⠀⠀⠀⠀⠛⠛⣿⣿⣿⡛⠿⠷
⠀⠀⠀⠀⠀⠘⠿⠿⠋⠀⠀⠀⠀⠀⠀⣿⣿⣿⠇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠁

⠀⠀⠀⠀⣿⣷⣄⠀⢶⣶⣷⣶⣶⣤⣀
⠀⠀⠀⠀⣿⣿⣿⠀⠀⠀⠀⠀⠈⠙⠻⠗
⠀⠀⠀⣰⣿⣿⣿⠀⠀⠀⠀⢀⣀⣠⣤⣴⣶⡄
⠀⣠⣾⣿⣿⣿⣥⣶⣶⣿⣿⣿⣿⣿⠿⠿⠛⠃
⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡁
⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁
⠀⠀⠛⢿⣿⣿⣿⣿⣿⣿⡿⠟
⠀⠀⠀⠀⠀⠉⠉⠉
*/

//library//
ll mod_fact(ll a, ll mod){
    ll ans = 1;
    while(a > 1){
        ans = ans * a % mod;
        a--;
    }
    return ans; 
}
ll mod_pow(ll a, ll b, ll mod){
    ll ans = 1;
    while(b > 0){
        if(b & 1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod - 2, mod);
}


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


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
bool sortDescByFirst(const pair<int,int>&a, const pair<int,int>&b){
    return a.first>=b.first;
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        cout<<min(a+d,min(a+c,min(b+c,b+d)))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        String s = scan.next();
        if(s.equals("AAA") || s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  ll A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  ll res = 0;
  for (int i = 1; i < N; i++) {
    res += min((X[i] - X[i-1]) * A, B);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int next[5][4] = {
  {1, 2, 3, 4},
  {2, 3, 4, 0},
  {3, 4, 0, 1},
  {4, 0, 1, 2},
  {0, 1, 2, 3}
};
int main(){
  int W, H;
  while(cin >> W >> H && W){
    vector<string> grid(H);
    REP(i, H) cin >> grid[i];

    bool is_NA = false;
    int cnt[5] = {};
    REP(y, H) REP(x, W) if(isdigit(grid[y][x])) cnt[grid[y][x] - '1']++;
    REP(i, 5) REP(j, 5) if(i != j && cnt[i] + cnt[j] == 0) is_NA = true;
    if(is_NA){
      cout << "NA" << endl;
      continue;
    }

    int sx, sy, gx, gy;
    REP(y, H) REP(x, W) if(grid[y][x] == 'S') sx = x, sy = y;
    REP(y, H) REP(x, W) if(grid[y][x] == 'G') gx = x, gy = y;

    pair<int, int> ans(-1, INF);
    REP(offset, 5){
      queue<int> qx, qy, qn;
      static int dist[1000][1000][5];
      memset(dist, -1, sizeof(dist));
      qy.push(sy); qx.push(sx); qn.push(0);
      dist[sy][sx][0] = 0;
      while(!qx.empty()){
        int x = qx.front(); qx.pop();
        int y = qy.front(); qy.pop();
        int n = qn.front(); qn.pop();
        int d = dist[y][x][n];
        if(d >= ans.second) break;
        if(x == gx && y == gy && n == 4){
          ans = make_pair(offset + 1, d);
          break;
        }

        if(d + abs(x - gx) + abs(y - gy) >= ans.second) continue;

        REP(r, 4){
          int nx = x + dx[r];
          int ny = y + dy[r];
          if(!valid(nx, ny, W, H)) continue;

          int nn = n;
          if(n != 4 && (grid[ny][nx] - '1') == next[offset][n]) nn++;

          if(dist[ny][nx][nn] != -1) continue;
          dist[ny][nx][nn] = d + 1;
          qy.push(ny); qx.push(nx); qn.push(nn);
        }
      }
    }
    assert(ans.first != -1);
    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    vector<vector<char>> T(H, vector<char>(W));
    
    for(int i = 0; i < W+2; i++){
        S.at(0) += '.';
        S.at(H+1) += '.';
    }
    for(int i = 1; i < H+1; i++){
        cin >> S.at(i);
        S.at(i) = '.' + S.at(i) + '.';
    }
    
    int count = 0;
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (S.at(i+1).at(j+1) == '#'){
                T.at(i).at(j) = '#';
            }
            else{
                if (S.at(i+1).at(j) == '#') count++;
                if (S.at(i+2).at(j) == '#') count++;
                if (S.at(i).at(j+1) == '#') count++;
                if (S.at(i).at(j+2) == '#') count++;
                if (S.at(i).at(j) == '#') count++;
                if (S.at(i+1).at(j+2) == '#') count++;
                if (S.at(i+2).at(j+1) == '#') count++;
                if (S.at(i+2).at(j+2) == '#') count++;
                string counts = to_string(count);
                T.at(i).at(j) = counts.at(0);
                count = 0;
            }
            
        }
    }
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << T.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
vector<vector<ll>> matrixmul(int l, int m, int n, vector<vector<ll>> a, vector<vector<ll>> b){
	vector<vector<ll>> c(l, vector<ll>(n));
	for(int i=0; i<l; i++){
		for(int j=0; j<n; j++){
			for(int k=0; k<m; k++){
				(c[i][j]+=a[i][k]*b[k][j])%=MOD;
			}
		}
	}
	return c;
}
vector<vector<ll>> matrixpow(int n, vector<vector<ll>> a, ll k){
	vector<vector<ll>> ap=a, ans(n, vector<ll>(n));
	for(int i=0; i<n; i++) ans[i][i]=1;
	while(k){
		if(k&1) ans=matrixmul(n, n, n, ap, ans);
		ap=matrixmul(n, n, n, ap, ap);
		k>>=1;
	}
	return ans;
}
string s[1010];
string t[2020];
int h, w;
ll k;
int main()
{
	cin>>h>>w>>k;
	for(int i=0; i<h; i++) cin>>s[i];
	if(k==0){
		cout<<1<<endl;
		return 0;
	}
	int cnt=0, cnt1=0, cnt2=0;
	for(int i=0; i<h; i++) for(int j=0; j<w; j++) if(s[i][j]=='#') cnt++;
	for(int i=0; i<h; i++) if(s[i][0]=='#' && s[i][w-1]=='#') cnt1++;
	for(int j=0; j<w; j++) if(s[0][j]=='#' && s[h-1][j]=='#') cnt2++;
	if(cnt1 && cnt2){
		cout<<1<<endl;
		return 0;
	}
	if(!cnt1 && !cnt2){
		cout<<powmod(cnt, k-1)<<endl;
		return 0;
	}
	int x=cnt+max(cnt1, cnt2), y=cnt*max(cnt1, cnt2), a=0;
	if(cnt1){
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(s[i][j]=='#' && (j==w-1 || s[i][j+1]=='.')) a++;
			}
		}
	}else{
		for(int j=0; j<w; j++){
			for(int i=0; i<h; i++){
				if(s[i][j]=='#' && (i==h-1 || s[i+1][j]=='.')) a++;
			}
		}
	}
	vector<vector<ll>> mat(2, vector<ll>(2));
	mat[0][1]=1, mat[1][0]=MOD-y, mat[1][1]=x;
	auto matp=matrixpow(2, mat, k-1);
	cout<<(matp[0][0]+matp[0][1]*a)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);

int main(){
    ll n,k;cin >> n >>k;
    mint ans=1;
    rep(i,min(n-1,k)){
        mint res=comb(n,i+1);
        res*=comb(n-1,i+1);
        ans+=res;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int[] xa = new int[n];
        for (int i = 0; i < n; i++) {
            xa[i] = sc.nextInt();
            sum += xa[i];
        }
        long p = Math.round((double) sum / n);
        int ans = 0;
        for (int x : xa) {
            ans += Math.pow((x - p), 2);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_set>

using namespace std;


int main() {
  int N;
  cin >> N;
  int L[10];
  int Lmax = -1;
  int total = 0;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    total += L[i];
    if (Lmax < L[i]) {
      Lmax = L[i];
    }
  }

  total -= Lmax;
  if (total > Lmax)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

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

int main(){
    int n;
    cin >> n;
    int ans = inf;
    for(int i = 1; i <= n / 2; i++) {
        int a = i;
        int b = n - i;
        int anss = w(a) + w(b);
        ans = min(ans, anss);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  cout << (n*(n-1)/2)+((m-1)*m/2) << endl;
  return 0;
}
  

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
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() {
    string x;
    std::cin >> x;
    ll count = 0;
    ll t=0;
    ll s=0;
    for (int i = 0; i < x.length(); i++) {
        if(x[i] == 'S'){
            s++;
        }else{
            t++;
        }
        if(t>s){
            count += t-s;
            t = s;
        }
    }
    std::cout << count*2 << std::endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N + 1);
    for(int i = 0; i < N + 1; i++) cin >> A[i];
    long long ans = 0;
    if(A[0] > 1 || (N == 0 && A[0] == 0)){
        cout << -1 << endl;
        return 0;
    }
    vector<long long> B(N + 1, 0);//子あり
    B[0] = 1 - A[0];
    vector<long long> suma(N + 1);
    suma[N] = A[N];
    for(int i = 1; i < N + 1; i++){
        suma[N - i] = suma[N - i + 1] + A[N - i];
    }
    ans += 1;
    for(int i = 1; i < N + 1; i++){
        if(B[i - 1] * 2 < A[i]){
            cout << -1 << endl;
            return 0;
        }
        if(i != N) B[i] = min(B[i - 1] * 2 - A[i], suma[i + 1]);
        ans += A[i] + B[i];
    }
    cout << ans << endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	map<int, int> mp;
	long long sum = 0;
	for( int i = 0; i < N; i++ ) {
		mp[ A[i] ]++;
		sum += A[i];
	}

	int Q;
	cin >> Q;
	for( int i = 0; i < Q; i++ ) {
		int B, C;
		cin >> B >> C;
		long long num = mp[B];
		long long ans = sum - num * B + num * C;
		sum = ans;
		mp[B] = 0;
		mp[C] += num;
		cout << ans << endl;
	}
}


Measured memory_bytes: 8088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if ((A % 2) == 1) {
				cnt++;
			}
		}
		sc.close();

		String ans = "NO";
		if ((cnt % 2) == 0) {
			ans = "YES";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 32724
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;


int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(ll i=0;i<n;i++){
        cin >> h[i];
    }
    ll m = 0;
    ll cnt = 0;
    for(ll i=1;i<n;i++){
        if(h[i-1]>=h[i]) cnt++;
        else{
            if(m<cnt) m = cnt;
            cnt = 0;
        }
    }
    if(m<cnt) m = cnt;
    cout << m;
}

Measured memory_bytes: 1024
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,y=100000000000,m,w;
    	string s,t;
    	cin>>s>>t;
    	n=s.size();
    	k=t.size();
		ll dp[n+1][k+1];
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=k;j++)
			{
				if(i==0||j==0)
				dp[i][j]=0;
				else if (s[i-1]==t[j-1])
					dp[i][j]=1+dp[i-1][j-1];
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
			string ans="";
			while(n>0&&k>0)
			{
				if(dp[n][k]==dp[n-1][k])
				n--;
			else	if(dp[n][k]==dp[n][k-1])
				k--;
			else	
				{
					ans.pb(s[n-1]);
					n--;
					k--;
				}
			}
			reverse(ans.begin(),ans.end());
		cout<<ans;
	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int a, b;
    cin >> a >> b;
    cout << 6 - (a+b) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
//#define int long long
//#define double long double
#define pb push_back


const int N = 2e5 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

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

//gp_hash_table<int, int> table;

char c[2000][2000];
int dp[1000][1000];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }
    dp[1][1] = 1;
    for (int i = 2; i <= n; i++) if (c[i][1] != '#') dp[i][1]+= dp[i - 1][1];
    for (int i = 2; i <= m; i++) if (c[1][i] != '#') dp[1][i]+= dp[1][i - 1];
    for (int i = 2; i <= n; i++) {
        for (int j = 2; j <= m; j++) {
            if (c[i][j] == '#') continue;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j]%= MOD;
        }
    }
    cout << dp[n][m];
}


Measured memory_bytes: 6400
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>
 
#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>
 
#define cauto const auto&
#else
 
#endif
 
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
 
template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}
 
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
 
#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
 
int foo(char c1, char c2, int mn, string s, string t) {
    int ans = 0;
    int tmp = 0;
    mn *= -1;
    rep(i, s.size()) {
        if(s[i]==c1) tmp++;
        maxs(ans, tmp);
        if(t[i]==c2) tmp--;
        maxs(tmp, mn);
    }
    // cout << ans << endl;
    return ans;
}

void main2(){
    int H, W, N;
    cin >> H >> W >> N;
    int sr, sc;
    cin >> sr >> sc;
    string S, T;
    cin >> S >> T;
    bool fir = false;
    if (sc <= foo('L', 'R', W - sc, S, T)) {
        fir = true;
    }
    if (W - sc + 1 <= foo('R', 'L', sc - 1, S, T)) {
        fir = true;
    }
    if (H - sr + 1 <= foo('D', 'U', sr - 1, S, T)) {
        fir = true;

    }
    if (sr <= foo('U', 'D', H - sr, S, T)) {
        fir = true;

    }
    cout << (fir ? "NO" : "YES") << endl;
}
 
 
signed main() {
    main2();
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> value(N);
    vector<int> weight(N);
    for (int i = 0; i < N; ++i) cin >> value[i] >> weight[i];
    vector<int> dp(W+1);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W-weight[i]; ++j) {
            dp[j+weight[i]] = max(dp[j+weight[i]], dp[j]+value[i]);
        }
    }
    cout << dp[W] << endl;
    return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		for(int i = 1; i <= N; i++) {
			count += i;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 23764