akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    int a, b; cin >> a >> b;
    
    bool fst = true;
    if((b - a) % 2 == 1){
        fst = false;
    }

    cout << (fst ? "Alice":"Borys") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin>>t;
  string s;
  cin>>s;
  for(int i=0;s[i];++i)
  {
    s[i]=(s[i]-'A'+t)%26+'A';
  }
  cout<<s;
}


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

bool search(int arr[], int arr_len, int key)
{
  arr[arr_len + 1] = key;
  int i = 0;

  while (arr[i] != key) ++i;

  if (i == arr_len + 1) return false; // Not found
  else return true;                   // Found
}

int main()
{
  int n;
  cin >> n;
  int S[n + 1];
  int s;
  for (int i = 0; i < n; ++i)
  {
    cin >> s;
    S[i] = s;
  }

  int q;
  cin >> q;

  int t;
  int count = 0;
  for (int i = 0; i < q; ++i)
  {
    cin >> t;
    if (search(S, n, t)) ++count;
  }

  cout << count << endl;

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  s[5]=s[13]=' ';
  cout<<s<<endl;
  return 0;
}


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


int a1[10], a2[100], a3[1000];
int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    for (int i = 0; i < N; i++){
        int num = S[i] - '0';
        for (int k2 = 0; k2 < 100; k2++){
            if (a2[k2]){
                //if (!a3[k2 * 10 + num]){
                //    cout << k2 * 10 + num << endl;
                //}
                    
                a3[k2 * 10 + num]++;
            }
        }            
        for (int k = 0; k < 10; k++){
            if (a1[k]){
                a2[k * 10 + num]++;
            }
        }
        a1[num]++;
    }
    int ans = 0;
    for (int i = 0; i < 1000; i++){
        if (a3[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <ios>
#include <iostream>
#include <iterator>
#include <vector>
#include <unordered_map>
#include <set>

using namespace std;

class UnionFind {
  unordered_map<int, int> graph_;
  unordered_map<int, int> sizes_;
public:
  int Root(int key) {
    if (graph_.count(key) == 0 || graph_[key] == key) {
      return key;
    } else {
      return graph_[key] = Root(graph_[key]);
    }
  }

  bool Same(int key1, int key2) {
    return Root(key1) == Root(key2);
  }
  
  /**
   * key1とkey2の根が違う場合
   * key1の根をkey2の根にする
   */
  void Unite(int key1, int key2) {
    if (Same(key1, key2)) {
      return;
    }
    
    int root1 = Root(key1);
    int root2 = Root(key2);
    int size = Size(root1) + Size(root2);
    graph_[root1] = root2;
    sizes_[root2] = size;
  }

  int Size(int key) {
    int root = Root(key);
    return sizes_.count(root) > 0 ? sizes_[root] : 1;
  }
};

int main(int argc, const char *argv[])
{
  // n 人が登録
  // m 組の友達関係
  // k 組のブロック関係
  int n, m, k;
  cin >> n >> m >> k;

  vector<set<int>> blocks(n);
  vector<set<int>> friends(n);
  UnionFind uf;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    friends[a].insert(b);
    friends[b].insert(a);
    uf.Unite(a, b);
  }

  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (uf.Same(a, b)) {
      blocks[a].insert(b);
      blocks[b].insert(a);
    }
  }

  for (int i = 0; i < n; i++) {
    cout << uf.Size(i) - blocks[i].size() - friends[i].size() - 1
      << (i == n - 1 ? "\n" : " ");
  }

  return 0;
}

Measured memory_bytes: 36144
from collections import Counter
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
x=Counter()
for i in a:
  x[i]+=1
maxi=0
for i in x.keys():
  maxi=max(maxi,x[i])
ans=[]
for i in x.keys():
  if maxi==x[i]:
    ans.append(i)

ans.sort()
print(*ans,sep='\n')



Measured memory_bytes: 35824
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;

int cnt[26];

signed main()
{
    int N; cin >> N;
    string S; cin >> S;

    rep(i, N) {
        if ('a' <= S[i] && S[i] <= 'z') cnt[S[i] - 'a']++;
    }

    int ans = 0;

    bool f = true;

    rep1(i, 9) {
        int a = count(cnt, cnt + 26, i);

        if (a == 0) continue;

        if (!f) ans++;
        f = false;

        ans += 2 * a - 1;
        if (i > 1) {
            if (a > 1) ans += 2;
            ans += 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1204
import copy


n = int(input())
h = list(map(int, input().split()))
a = 0
i = 0
while i < n:
    if h[i] > 0:
        j = copy.copy(i)
        k = h[i]
        while h[j] > 0:
            if h[j] < k:
                k = h[j]
            j += 1
            if j == n:
                break
        for l in range(i, j):
            h[l] -= k
        a += k
    else:
        i += 1
print(a)

Measured memory_bytes: 3444
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
a = [LI() for i in range(3)]

A = []
B = []
c = 0
d = 0

for i in range(N):
    if i % 2 == 0:
        if a[0][i] % 6 == 1 and a[1][i] % 6 == 2 and a[2][i] % 6 == 3:
            A.append(a[1][i]//6)
        elif a[0][i] % 6 == 3 and a[1][i] % 6 == 2 and a[2][i] % 6 == 1:
            c += 1
            A.append(a[1][i]//6)
        else:
            print('No')
            exit()
    else:
        if a[0][i] % 6 == 4 and a[1][i] % 6 == 5 and a[2][i] % 6 == 0:
            B.append(a[1][i]//6)
        elif a[0][i] % 6 == 0 and a[1][i] % 6 == 5 and a[2][i] % 6 == 4:
            d += 1
            B.append(a[1][i]//6)
        else:
            print('No')
            exit()


class SegmentTree():
    def __init__(self,init_value,seg_func,unit_elt):
        n = len(init_value)
        self.seg_func = seg_func
        self.unit_elt = unit_elt
        self.num = 1 << (n-1).bit_length()  # n以上の最小2冪
        self.tree = [unit_elt]*(2*self.num)
        for i in range(n):
            self.tree[self.num + i] = init_value[i]
        for i in range(self.num-1,0,-1):
            self.tree[i] = self.seg_func(self.tree[2*i],self.tree[2*i+1])
    def update(self,i,x):  # i(0-index)番目の値をxに更新
         i += self.num
         self.tree[i] = x
         while i > 1:
             i >>= 1
             self.tree[i] = self.seg_func(self.tree[2*i],self.tree[2*i+1])
    def quary(self,p,q):  # [p,q)に関するseg_funcの結果を返す(p,qは0-index)
        p += self.num
        q += self.num
        res = self.unit_elt
        while p < q:
            if p & 1:
                res = self.seg_func(res,self.tree[p])
                p += 1
            if q & 1:
                res = self.seg_func(res,self.tree[q-1])
            p >>= 1
            q >>= 1
        return res

def seg_func(x,y):
    return x + y

seg1 = SegmentTree([0]*(len(A)),seg_func,unit_elt=0)
seg2 = SegmentTree([0]*(len(B)),seg_func,unit_elt=0)

a = 0  # Aの転倒数
for i in range(len(A)):
    a += i-seg1.quary(0,A[i])
    seg1.update(A[i],1)
b = 0  # Bの転倒数
for i in range(len(B)):
    b += i-seg2.quary(0,B[i])
    seg2.update(B[i],1)

if (a-d) % 2 == 0 and (b-c) % 2 == 0:
    print('Yes')
else:
    print('No')

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

int main(){
        int n;
        cin >> n;
        vector<int> vec(n);
        for(int i = 0; i < n; i++){
                cin >> vec[i];
        }
        for(int i = 1; i <= n; i++){
                if(i == n){
                        cout << vec[n - i] << endl;
                        return 0;
                }
                cout << vec[n - i] << " ";
        }
}

Measured memory_bytes: 3112
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		for (int i = 1; i <= 26; i++) {
			out(i);
		}
		for (int i = 27; i <= 365; i++) {
			int num = (int) (Math.random() * 26.0);
			out(num + 1);
		}

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static void debug() {
		out("---");
	}

	static void debug(long a) {
		out("-------");
		out(a);
		out("-------");
	}

	static void debug(String a) {
		out("-------");
		out(a);
		out("-------");
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static long min(long d, long e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 36396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int x;
    cin >> x;
    if(x==7||x==5||x==3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    int n;
    cin>>n;
    bool han=1;
    int i=1;
    while(han){
        if(n>=i*2)i*=2;
        else break;
    }
    cout<<i<<endl;
}

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

using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b;
  
  for(int i = 1; i <= 3; i++)
  {
    c = i;
    if(a*b*c % 2 == 1)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
//
// D - Walk and Teleport
//

#include <iostream>

using namespace std;

int main() {

    long N, A, B;
    cin >> N >> A >> B;

    long ans = 0;

    int Xp;
    cin >> Xp;

    for (int i = 0; i < N - 1; i++) {
        int Xn;
        cin >> Xn;
        ans += min((Xn - Xp) * A, B);
        Xp = Xn;
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>

using namespace std;

#define int long long

signed main() {
	int a;

	cin >> a;

	string s;

	cin >> s;

	if (a >= 3200) {
		cout << s;
	}
	else {
		cout << "red";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

const int maxn = 203;

int n, l, a[maxn], ans;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	for (int i = 1; i <= 2 * n; i+=1)
	{
		a[i] = gi();
	}
	sort(a + 1, a + 1 + 2 * n);
	for (int i = 1; i <= 2 * n; i+=2)
	{
		ans += a[i];
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	REP(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n>>m>>l;

	COUT((n+m)*l/2);

}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3624
# https://atcoder.jp/contests/dp/tasks/dp_f?lang=ja

# get LCS length
def lcs_len(s1,s2):
    n1,n2 = len(s1),len(s2)
    dp = [ [0]*(n2+1) for _ in range(n1+1) ]
    for i in range(1,n1+1):
        for j in range(1,n2+1):
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]) 
            if s1[i-1] == s2[j-1]: dp[i][j] = dp[i-1][j-1]+1
    return dp[-1][-1]

# get LCS string
def lcs_str(s1,s2):
    n1,n2 = len(s1),len(s2)
    dp = [ [0]*(n2+1) for _ in range(n1+1) ]
    for i in range(1,n1+1):
        for j in range(1,n2+1):
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]) 
            if s1[i-1] == s2[j-1]: dp[i][j] = dp[i-1][j-1]+1
    ansr = []
    i,j = n1,n2
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]: i -= 1
        elif dp[i][j] == dp[i][j-1]: j -= 1
        else: 
            ansr.append(s1[i-1])
            i -= 1
            j -= 1
    ans = ansr[::-1]
    return ''.join(ans)


s1 = input()
s2 = input()
ans = lcs_str(s1,s2)
print(ans,flush=True)

Measured memory_bytes: 144232
s = input()
K = int(input())
substring = []
# print(s, K)
for i in range(len(s)):
    for j in range(1, min(K+1, len(s)+1)):
        # print(s[i:i+j])
        substring.append(s[i:i+j])

substring = list(set(substring))
substring.sort()

# print(substring)
print(substring[K-1])

Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
int n,k,sum;
int main()
{
	cin>>n>>k;
	int a[n];
	for(int i=0; i<n; i++)
	cin>>a[i];
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			if(a[i]>a[j])
			swap(a[i],a[j]);
		}
	}
	for(int i=0; i<k; i++)
	sum+=a[i];
	cout<<sum<<endl;

 return 0;
}

Measured memory_bytes: 256
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 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
ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n,m=LI()

## Segment Tree ##

## Initializer Template ##
# Range Sum:        sg=SegTree(n,0)
# Range Minimum:    sg=SegTree(n,inf,min,inf)

class SegTree:
    seg=[]
    num=0  # num:n以上の最小の2のべき乗
    ide_ele=0  # 単位元
    def segfun():
        return

    def __init__(self,n,init_val,segfun=sum,ide=0):
        self.ide_ele=ide
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num
        self.segfun=segfun
        #set_val
        for i in range(n):
            self.seg[i+self.num-1]=init_val
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=segfun(self.seg[2*i+1],self.seg[2*i+2]) 
    
    def update(self,k,x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfun(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfun(res,self.seg[p])
            if q&1 == 1:
                res = self.segfun(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfun(res,self.seg[p])
        else:
            res = self.segfun(self.segfun(res,self.seg[p]),self.seg[q])
        return res


ans=inf

s=[int(i) for i in input()]

def dp(b,m): # N log (N)
    N=len(b)-1
    n=N+1
    global seg
    global num
    sg=SegTree(n,inf,min,inf)

    sg.update(0,0)

    dp=[0]+[inf]*(N)
    for i in range(N):
        if b[i+1]==1:
            continue
        dp[i+1]=sg.query(max(i-m+1,0),i+1)+1
        sg.update(i+1,dp[i+1])
        #show(seg)
        #show(dp)
    return dp

dp1=dp(s,m)
step=dp1[n]
if step==inf:
    print(-1)
    exit()

dp2=dp(s[::-1],m)[::-1]

move=[0]
ans=[]
j=1
for i in range(step,0,-1): # N
    while j<=n and dp2[j]!=i-1:
        j+=1
    move.append(j)

for i in range(len(move)-1):
    ans.append(move[i+1]-move[i])
print(*ans)



Measured memory_bytes: 94804
#include <stdio.h>
#include <queue>
#include <math.h>
#include <utility>
#define delta 1e-7
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, l, m;
  scanf("%lld%lld", &n, &k);
  ll x[n], y[n], c[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld%lld", &x[i], &y[i], &c[i]);
  double he = 0.0, ta = 500000.0, r;
  for(m = 0; m < 50; ++m) {
    r = (he + ta) / 2.0;
    queue< pair<double, double> > q;
    for(i = 0; i < n; ++i) q.push(make_pair((double)x[i], (double)y[i]));
    for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) 
      if((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= (r / c[i] + r / c[j]) * (r / c[i] + r / c[j]) + delta && (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) >= (r / c[i] - r / c[j]) * (r / c[i] - r / c[j]) + delta) {
      double a = x[j] - x[i], b = y[j] - y[i], r1 = r / c[i], r2 = r / c[j];
      if(y[j] != y[i]) {
        double t = -a / b, s = (a * a + b * b + r1 * r1 - r2 * r2) / (2 * b);
        double d = sqrt(t * t * s * s - (1 + t * t) * (s * s - r1 * r1)), xt = (-t * s + d) / (1 + t * t);
        q.push(make_pair(xt + x[i], t * xt + s + y[i]));
        xt = (-t * s - d) / (1 + t * t);
        q.push(make_pair(xt + x[i], t * xt + s + y[i]));
      } else {
        double xt = (a * a + r1 * r1 - r2 * r2) / (2 * a);
        double yt = sqrt(r1 * r1 - xt * xt);
        q.push(make_pair(xt + x[i], yt + y[i])), q.push(make_pair(xt + x[i], -yt + y[i]));
      }
    }
    while(q.size()) {
      ll cnt = 0;
      for(i = 0; i < n; ++i) {
        if((x[i] - q.front().first) * (x[i] - q.front().first) + (y[i] - q.front().second) * (y[i] - q.front().second) <= r / c[i] * r / c[i] + delta) cnt++;
      }
      if(cnt >= k) {
        ta = r;
        break;
      }
      q.pop();
    }
    if(!q.size()) he = r;
  }
  printf("%lf", r);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],t[200005],b[200005],sum;
signed main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)scanf("%d",&a[i]),t[a[i]]++;
	for(int i=1; i<=n; i++)
		if(t[i]>1)
		{
			int q=t[i];
			t[i]=(t[i]-1)*t[i]/2;
			sum+=t[i];
			if(t[i]==1)b[i]=1;
			else b[i]=q-1;
		}
	for(int i=1; i<=n; i++)cout<<sum-b[a[i]]<<endl; 
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2);
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
ll gcd(ll x, ll y){
  if(x<y){return gcd(y,x);}
  if(y==0 || x==y) {return x;}
  else {return gcd(y, x%y);}
}

int main(void) {
  int n;
  cin >> n;
  arr(a,n);

  ll ans=a[0];
  rep(i,n){
    ll tmp=a[i];
    ans = gcd(ans, tmp);
  }

  prt(ans);

}


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

using namespace std;

using ll = long long;
struct Edge {
    int dst;
    ll w;
    Edge() {}
    Edge(int d, ll w) : dst(d), w(w) {}
};
using Graph = vector<vector<Edge>>;
struct Cube { ll p[3]; };


Graph MakeGraph(const int n, const int s, vector<Cube> &c) {
    Graph g(n);
    ll d[3];

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = 0; k < 3; ++k)
                d[k] = s + ((c[i].p[k] < c[j].p[k]) ? (c[i].p[k] - c[j].p[k]) : (c[j].p[k] - c[i].p[k]));

            if (d[0] <= 0 || d[1] <= 0 || d[2] <= 0) continue;

            ll w = 2 * d[0] * d[1] + 2 * d[0] * d[2] + 2 * d[1] * d[2];
            g[i].emplace_back(Edge(j, w));
            g[j].emplace_back(Edge(i, w));
        }
    }

    return g;
}

int MinimumArea(const int n, const int k, const int s, const Graph &g) {
    vector<bool> used(n, false);
    ll res = -1;

    for (int u = 0; u < 2 * n; ++u) {
        if (used[u % n] || (u < n && g[u % n].size() == 2)) continue;

        const int v = u % n;

        vector<int> sub;
        int cur = v;
        while (true) {
            used[cur] = true;
            sub.push_back(cur);
            if (1 <= g[cur].size() && !used[g[cur][0].dst])
                cur = g[cur][0].dst;
            else if (g[cur].size() == 2 && !used[g[cur][1].dst])
                cur = g[cur][1].dst;
            else
                break;
        }

        const int size = sub.size();
        if (size < k) continue;

        ll sum = 0;
        for (int i = 0; i < k - 1; ++i)
            sum += ((g[sub[i]][0].dst == sub[i + 1]) ? g[sub[i]][0].w : g[sub[i]][1].w);

        const bool is_cycle = (g[sub[0]].size() == 2);
        if (size == k && is_cycle) {
            sum += ((g[sub[0]][0].dst == sub[size - 1]) ? g[sub[0]][0].w : g[sub[0]][1].w);
            res = max(res, sum);
            continue;
        }
        res = max(res, sum);

        const int lim = (is_cycle ? size - 1 : size - k);
        for (int i = 1; i <= lim; ++i) {
            sum -= ((g[sub[i]][0].dst == sub[i - 1]) ? g[sub[i]][0].w : g[sub[i]][1].w);
            const int j1 = (i + k - 2) % size, j2 = (i + k - 1) % size;
            sum += ((g[sub[j1]][0].dst == sub[j2]) ? g[sub[j1]][0].w : g[sub[j1]][1].w);
            res = max(res, sum);
        }
    }

    return (res == -1) ? -1 : 6 * k * s * s - res;
}

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

    int n, k, s;

    while (cin >> n >> k >> s, n) {
        vector<Cube> cube(n);
        for (auto &c : cube)
            for (int i = 0; i < 3; ++i) cin >> c.p[i];

        cout << MinimumArea(n, k, s, MakeGraph(n, s, cube)) << '\n';
    }

    return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        string s;
        cin>>s;
        if(n<3200)
        {
            cout<<"red";
        }
        else cout<<s;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
const ll inf = 1e18;
ll h[maxn];
ll DP[maxn];
int N;

ll dis(int i , int j){
    return abs(h[i] - h[j]);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> h[i];
        DP[i] = inf;
    }
    DP[1] = 0;
    for(int i = 2; i <= N; ++i){
        if(i - 1 >= 1)DP[i] = min(DP[i] , DP[i - 1] + dis(i , i - 1));
        if(i - 2 >= 1)DP[i] = min(DP[i] , DP[i - 2] + dis(i , i - 2));
    }
    cout << DP[N] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a==b&&b==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    ll a, b, x, cnt;
    cin >> a >> b >> x;
    
    if(a==0){
        cnt = (b/x+1);
    }
    else{
        cnt = (b/x+1)-((a-1)/x+1);
    }

    out(cnt);
}

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

int main(){
	int a, b, c, info = 0;
	cin >> a >> b >> c;
	for (;;){
		if (c % a == 0){
			info += 1;
		}
		a += 1;
		if (a > b){
			break;
		}
	}

	cout << info << endl;
}


Measured memory_bytes: 3116
N = int(input().strip())
A = list(sorted(map(int, input().strip().split())))

if N % 2 == 0:
  for i in range(0, N, 2):
    if A[i] != A[i+1]:
      print(0)
      break
  else:
    print(2**(N // 2) % 1000000007)
else:
  if A[0] != 0:
    print(0)
  else:
    for i in range(1, N, 2):
      if A[i] != A[i+1]:
        print(0)
        break
    else:
      print(2**((N-1)//2) % 1000000007)

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

typedef long long ll;

string S;
vector<ll> strget( string str ){
  vector<ll> ret;
  int pr = 0;
  for(int i=0;i<(int)str.size();i++){
    if( str[i] == '.' ){
      ret.push_back( atoi( str.substr(pr,i-pr).c_str() ) );
      pr = i+1;
    }
  }
  ret.push_back( atoi( str.substr(pr).c_str() ) );
  return ret;
}

void view(vector<ll> v){
  for(int i=0;i<(int)v.size();i++) cout << v[i] << " "; 
  cout << endl;
}

ll maya[]={13,20,20,18,20};

ll getdayM(vector<ll> v){
  ll ret = 0;
  ll sum = 1;
  for(int i=v.size()-1;i>-1;i--){
    ret += v[i] * sum;
    sum *= maya[i];
  }
  return ret;
}


ll years[]={365,366};
ll month[2][12]={ {31,28,31,30,31,30,31,31,30,31,30,31},
                  {31,29,31,30,31,30,31,31,30,31,30,31} };

bool isuruu(int y){
  if( y%400 == 0) return true;
  if( y%100 == 0) return false;
  if( y%4 == 0 ) return true;
  return false;
}

ll getdayS(int y,int m,int d){
  ll ret = 0;
  if( y > 400 ) {
    ret = getdayS( (y-1)%400+1, m, d ) + getdayS( 400, 12,31 )*((y-1)/400);
  } else {
    for(int i=1;i<y;i++){
      if( isuruu(i) ) ret += years[1];
      else ret += years[0];
    }
    for(int i=1;i<m;i++){
      if( isuruu(y) ) ret += month[1][i-1];
      else ret += month[0][i-1];
    }
    for(int i=1;i<=d;i++)
      ret ++;
  }
  // cout << y << " "<< m << " " << d <<" " << ret << endl;
  return ret;
}

vector<ll> setdayM(ll day){
  vector<ll> ret;
  for(int i=4;i>-1;i--){
    ret.push_back( day%maya[i] );
    day/=maya[i];    
  }
  reverse(ret.begin(),ret.end());
  return ret;
}

vector<ll> setdayS(ll day){
  ll sd = getdayS( 400,12,31 );
  vector<ll> ret(3);
  if( day > sd ){
    ret[0] = day/sd*400;
    vector<ll> st = setdayS( day % sd );
    ret[0] += st[0];
    ret[1] = st[1]; ret[2] = st[2];
  } else{
    for(int y=1;y<=400;y++){
      for(int m=1;m<=12;m++){
        for(int d=1;d<=month[isuruu(y)][m-1];d++){
          day--;
          if( day == 0 ) {
            ret[0] = y;
            ret[1] = m;
            ret[2] = d;
            return ret;
          }
        }
      }
    }
  }
  return ret;
}

int main(){
  while( getline( cin,S ) ){
    if( S=="#" ) break;
    vector<ll> v = strget( S );
    if( v.size() == 3 ){
      ll a = getdayS( v[0], v[1], v[2] ) - getdayS( 2012, 12, 21 );
      vector<ll> res = setdayM( a );
      for(int i=0;i<5;i++){
        if( i ) cout << ".";
        cout << res[i];
      }
    } else {
      ll a = getdayM( v ) + getdayS( 2012,12,21);
      vector<ll> res = setdayS( a );
      for(int i=0;i<3;i++){
        if( i ) cout << ".";
        cout << res[i];
      }
        
    }
    cout << endl;
  }
}

Measured memory_bytes: 1220
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	static int n;
	static ArrayList<Integer> G[];
	static int []color;
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		int m = scan.nextInt();
		G = new ArrayList[n];
		color = new int[n];
		for(int i = 0; i < n; i++) {
			G[i] = new ArrayList<Integer>();
		}
		for(int i = 0; i < m; i++) {
			int s = scan.nextInt();
			int t = scan.nextInt();
			G[s].add(t);
			G[t].add(s);
		}

//		for(int i = 0; i < n; i++) {
//			System.out.print(i +" ");
//			for(int j = 0; j < G[i].size(); j++) {
//				System.out.print(G[i].get(j) +" ");
//			}
//			System.out.println();
//		}
		assignColor();
		int q = scan.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < q; i++) {
			int s = scan.nextInt();
			int t = scan.nextInt();
			if(color[s] == color[t] && color[s] != -1) {
				sb.append("yes");
				sb.append("\n");
			}else {
				sb.append("no");
				sb.append("\n");
			}
		}
		scan.close();
		System.out.print(sb.toString());

	}
	static void dfs(int r, int c) {
		Deque<Integer> stack = new ArrayDeque<Integer>();
		stack.push(r);
		while(!stack.isEmpty()) {
			int u = stack.pop();
			for(int i = 0; i < G[u].size(); i++) {
				int v = G[u].get(i);
				if(color[v] == -1) {
					color[v] = c;
					stack.push(v);
				}
			}
		}
	}
	static void assignColor() {
		int id = 1;
		for(int i = 0; i < n; i++) {
			color[i] = -1;
		}
		for(int u = 0; u < n; u++) {
			if(color[u] == -1) dfs(u, id++);
		}
	}
}


Measured memory_bytes: 114932
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


signed main() {
	int t=1;
	//cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		cout<<a*b;
		
	}
	
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
using namespace std;
int main(){
  int x[5];
 for(int i=0;i<5;i++){
  scanf("%d",&x[i]);
  if(x[i]==0){
   printf("%d\n",i+1);
   return 0;
  }
 }
return 0;}


Measured memory_bytes: 3820
N = int(input())

dp = [[[0.0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]

dic = {}
dic[0] = 0
dic[1] = 0
dic[2] = 0
dic[3] = 0
for a in map(int, input().split(" ")):
    dic[a] += 1


for k in range(dic[3]+1):
    for j in range(dic[2]+1+dic[3]-k):
        for i in range(dic[1]+1+dic[2]-j+dic[3]-k):
            if i == 0 and j == 0 and k == 0:
                continue
            res = 0.0
            if i > 0:
                res += dp[i-1][j][k] * i
            if j > 0:
                res += dp[i+1][j-1][k] * j
            if k > 0:
                res += dp[i][j+1][k-1] * k
            res += N
            res *= (1.0 / (i+j+k))
            dp[i][j][k] = res

print(dp[dic[1]][dic[2]][dic[3]])

Measured memory_bytes: 253960
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v, u;
        map<int, int> m, m2;
        for (int i = 0; i < n; ++i) {
            int k;
            scanf("%d", &k);
            v.emplace_back(k);
            m[k]++;
        }
        for (int i = 1; i <= 2*n; ++i) {
            if(!m[i]) {
                u.emplace_back(i);
                m2[i]++;
            }
        }
        sort(u.begin(), u.end());
        int t = 0, x = 0, p = n, q = n;
        while(p && q){
            int z = 0;
            if(t == 0) {
                for (int i = x+1; i <= 2*n; ++i) {
                    if(m[i]) {
                        p--;
                        m[i]--;
                        x = i;
                        z = 1;
                        break;
                    }
                }
                if(!z) x = 0;
            }else {
                for (int i = x+1; i <= 2*n; ++i) {
                    if(m2[i]) {
                        q--;
                        m2[i]--;
                        x = i;
                        z = 1;
                        break;
                    }
                }
                if(!z) x = 0;
            }
            t ^= 1;
        }
        cout << q << "\n" << p << "\n";
    }
    
    return 0;
}



Measured memory_bytes: 3240
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var array = Array.ConvertAll(ReadLine().Split(' '),int.Parse);
        var ave = array.Sum() / num;
        var result1 = 0;
        var result2 = 0;
        for(var i = 0; i < num; i++)
        {
            result1 += (array[i] - ave) * (array[i] - ave);
            result2 += (array[i] - (ave + 1)) * (array[i] - (ave + 1));
        }
        WriteLine(Min(result1, result2));
    }
}

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

const int mod = 1e+9 + 7;

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans = ans * i % mod;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

char a, b;

signed main()
{
    cin >> a >> b;
    if(a == b) { printf("H\n"); }
    else { printf("D\n"); }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

constexpr ll N_MAX = 2000;
constexpr ll N_MAX2 = N_MAX * 2 + 2;
constexpr ll M = 2000;

bool match(char x, char y) {
  return x == y || x == '?' || y == '?';
}
bool ab[100000];
bool bc[100000];
bool ac[100000];

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(string, a);
  invar(string, b);
  invar(string, c);
  
  int A = a.size();
  int B = b.size();
  int C = c.size();
  
  //a vs bなどで，合っているかの結果
  //デフォルトはFalseで，これは合っているということ
  
  //まず，この比較結果を予め計算しておくことが思いつかなかった（なので間に合わないと思った）
  //c.f. https://rustforbeginners.hatenablog.com/entry/panasonic2020_e
  //各a vs bなどの差を検出
  //i - jという差に関する全組み合わせを調べる．（i = jなら，AとBと同じ位置に置いて比較したということ
  //O(N^2)
  //マイナス側が，Bを左にずらしたということ
  rep(i, A) rep(j, B) if(!match(a[i], b[j])) ab[i - j + 50000] = true;
  rep(i, A) rep(j, C) if(!match(a[i], c[j])) ac[i - j + 50000] = true;
  rep(i, B) rep(j, C) if(!match(b[i], c[j])) bc[i - j + 50000] = true;
  
  //後は全探索
  //A * B * C
  //Bずらし，CずらしでMATCH．
  //B vs Cは，差分
  ll mv = INT_MAX;
  for(int i=-2*M; i<=2*M; ++i) {
    for(int j=-2*M; j<=2*M; ++j) {
      //!ずらし量だから，bcの添字は正負が逆になる
      if(!ab[i + 50000] && !ac[j + 50000] && !bc[j - i + 50000]) {
        //match
        //差分
        ll v = max(A, max(i+B, j+C)) - min(0, min(i, j));
        chmin(mv, v);
      }
    }
  }
  
  fin(mv);
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <utility>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	ll n,d;	cin>>n>>d;
	vector<pair<ll,pair<ll,ll> > > in;
	rep(i,n){
		ll x,y,b;	cin>>x>>y>>b;
		in.push_back(make_pair(b,make_pair(x,y)));
	}
	sort(in.begin(),in.end());
	deque<ll> left,right,up,down;
	int s=0;
	ll ans=0;
	rep(t,n){
		//left
		while(!left.empty()&&in[t].second.first<left.back())	left.pop_back();
		left.push_back(in[t].second.first);
		//right
		while(!right.empty()&&in[t].second.first>right.back())	right.pop_back();
		right.push_back(in[t].second.first);
		//up
		while(!up.empty()&&in[t].second.second>up.back())	up.pop_back();
		up.push_back(in[t].second.second);
		//down
		while(!down.empty()&&in[t].second.second<down.back())	down.pop_back();
		down.push_back(in[t].second.second);
		//????°??????????
		while(in[t].first-in[s].first>d){
			//left
			if(left.front()==in[s].second.first)	left.pop_front();
			//right
			if(right.front()==in[s].second.first)	right.pop_front();
			//up
			if(up.front()==in[s].second.second)	up.pop_front();
			//down
			if(down.front()==in[s].second.second)	down.pop_front();
			s++;
		}
		ans=max(ans,(right.front()-left.front())*(up.front()-down.front()));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9216