akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N,K;
	string s;
	while(cin>>N>>K) {
		vector<PII> w;
		REP(i, N) {
			ll a, b;
			cin>>a>>b;
			w.PB(MP(a, b));
		}
		sort(ALL(w));
		ll lb = 1;
		ll ans = 0;
		REP(i, N) {
			ll ub = lb+w[i].second-1;
			if(lb<=K&&K<=ub) {
				ans = w[i].first;
				break;
			}
			lb=ub+1;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2420
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var first = str[0];
            var last = str.Last().ToString();
            var betweenCount = str.Skip(1).Take(str.Length - 2).Count();
            Console.WriteLine($"{first}{betweenCount}{last}");
        }
    }
}

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

const int N = 200005;
const int INF = 1e9;

int n, q, res;
int f[2][N];
int it[2][4 * N];
vector< pair<int, int> > b;

void upd(int t, int i, int l, int r, int p, int x) {
	if (l == r) {
		it[t][i] = min(it[t][i], x); return;
	}
	int mid = (l + r) >> 1;
	if (mid >= p) upd(t, i << 1, l, mid, p, x);
	else upd(t, i << 1 | 1, mid + 1, r, p, x);
	it[t][i] = min(it[t][i << 1], it[t][i << 1 | 1]);
}

int get(int t, int i, int l, int r, int u, int v) {
	if (l > v || u > r) return INF;
	if (u <= l && r <= v) return it[t][i];
	int mid = (l + r) >> 1;
	return min(get(t, i << 1, l, mid, u, v), get(t, i << 1 | 1, mid + 1, r, u, v));
} 

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		for (int j = 0; j < 2; ++j) {
			f[j][i] = f[j][i - 1] + (x != j);
		}
	}
	cin >> q;
	for (int i = 1; i <= q; ++i) {
		int l, r; cin >> l >> r;
		b.push_back(make_pair(l, r));
	}
	sort(b.begin(), b.end());
	for (int i = 0; i < 4 * N; ++i) it[0][i] = it[1][i] = INF;
	upd(0, 1, 0, n, 0, 0);
	upd(1, 1, 0, n, 0, 0);
	res = f[0][n];
	for (int i = 0; i < q; ++i) {
		int tmp = INF;
		int l = b[i].first, r = b[i].second;
		tmp = min(tmp, get(0, 1, 0, n, l, r) + f[1][r]);
		tmp = min(tmp, get(1, 1, 0, n, 0, l - 1) + f[0][l - 1] + f[1][r] - f[1][l - 1]);
		upd(0, 1, 0, n, r, tmp - f[1][r]);
		upd(1, 1, 0, n, r, tmp - f[0][r]);
		res = min(res, tmp + f[0][n] - f[0][r]);
	}
	cout << res;
}

Measured memory_bytes: 9712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  map<int,int> m;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
    m[a]++;
  }

  map<int,ll> mm;
  ll sum = 0;
  FOR(it,m){
    ll x = it->second;
    ll y = x*(x-1)/2;
    mm[it->first] = y;
    sum += y;
  }

  rep(i,v.size()){
    ll x = m[v[i]] - 1;
    ll xx = m[v[i]];
    ll y = x*(x-1)/2;
    ll yy = xx*(xx-1)/2;

    cout << sum - yy + y << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 16244
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

int main(int argc, char *argv[])
{
  int a,b,c;
  scanf("%d %d %d", &a,&b,&c);

  int count=0;
  if(b <= c){
    count += 2*b;
    if(a < c - b){
      count+=a+1;
    }else{
      count+=c-b;
    }
  }else{
    count+=c+b;
  }
  printf("%d\n", count);
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

class UnionFind{
private:
  vector<int> par, rank;
public:
  VI sz, dd;
  UnionFind(int n){
	par.assign(n, 0);
	rank.assign(n, 0);
	sz.assign(n, 1);
	for(int i=0;i<n;++i)
	  par[i] = i;
  }

  //find root of x
  int find(int x){
	if(par[x] == x)
	  return x;
	return (par[x] = find(par[x]));
  }

  void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(rank[x] < rank[y])
	  par[x] = y;
	else{
	  par[y] = x;
	  if(rank[x] == rank[y])
		++rank[x];
	}
	int tmp = sz[x] + sz[y];
	sz[x] = sz[y] = tmp;
	dd[x] = dd[y] = min(dd[x], dd[y]);
  }

  bool same(int x, int y){
	return find(x) == find(y);
  }
};

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

  LL N, M, T;
  cin >> N >> M >> T;
  vector<vector<PII>> es(T+1);
  vector<vector<PII>> G(N);
  REP(i,M){
	int a, b, t;
	cin >> a >> b >> t;
	--a;
	--b;
	es[t].EB(a,b);
	G[a].EB(b,t);
	G[b].EB(a,t);
  }
  VI dist(N, INF);
  dist[0] = 0;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
	int u = q.front();
	q.pop();
	for(auto&& e: G[u]){
	  if(dist[e.FF] == INF && dist[u] < e.SS){
		dist[e.FF] = dist[u] + 1;
		q.push(e.FF);
	  }
	}
  }

  UnionFind uf(N);
  uf.dd = dist;
  VL prv(N, T);
  for(auto&& e: es[T]){
	uf.unite(e.FF, e.SS);
  }

  VL ans(N, 0);
  for(int t=T-1;t>0;--t){
	map<PII,LL> buf;
	for(auto&& e: es[t]){
	  if(uf.same(e.FF, e.SS)) continue;
	  int r1 = uf.find(e.FF);
	  int r2 = uf.find(e.SS);
	  LL s1 = uf.sz[r1];
	  LL s2 = uf.sz[r2];
	  buf[e] = max((ans[r1] + (prv[r1] - t)*s1) * (uf.dd[r1] <= t),
				   ans[r2] + (prv[r2] - t)*s2 * (uf.dd[r2] <= t));
	}

	for(auto&& p: buf){
	  auto& e = p.FF;
	  uf.unite(e.FF, e.SS);
	  int r = uf.find(e.FF);
	  maxi(ans[r], p.SS);
	  prv[r] = t;
	}
  }

  int rt = uf.find(0);
  cout << ans[rt] + prv[rt] * N << endl;

  return 0;
}

Measured memory_bytes: 18744
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        C: [u64; 3],
    }
    let mut C = C;
    C.sort();
    println!("{}", if C[0]+C[1]==C[2]{"Yes"}else{"No"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	int ans=1;
	while(ans*2<=n) ans*=2;
	cout<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
  return (a*b)/gcd(a,b);
}
int  gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,e;
    cin>>a;
    for(int i=0;i<a.size();i++) cout<<"x";
    cout<<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
double a[8];
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7])!=EOF){
if(a[3]<a[5])printf("NO\n");
else if(a[1]>a[7])printf("NO\n");
else if(a[0]>a[6])printf("NO\n");
else if(a[2]<a[4])printf("NO\n");
else printf("YES\n");
}
return 0;
}

Measured memory_bytes: 0
A, B, C = list(map(int, input().split()))
K = int(input())
# A<B<C

for i in range(K):
    if A >= B:
        B = B * 2
        if A < B and B < C:
            print("Yes")
            break
        continue
    elif B >= C:
        C = C * 2
        if A < B and B < C:
            print("Yes")
            break
        continue
    else:
        print("Yes")
        break
else:
    print("No")



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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        // dp[i][j]：ｉ番目までの品物からいくつか選んで価値がｊとなるときの最小の重さ
        int[][] dp = new int[N+1][N * 1000 +1];
        int max = 0;
        Arrays.fill(dp[0], (int)Math.pow(10, 9)+1);
        dp[0][0] = 0;
        for(int i = 0; i < N; i++){
            int w = sc.nextInt();
            int v = sc.nextInt();
            for(int j = 0; j <= N * 1000; j++){
                if(j < v) dp[i+1][j] = dp[i][j];
                else dp[i+1][j] = Math.min(dp[i][j], dp[i][j-v] + w);
                if(dp[i+1][j] <= W && j > max) max = j;
            }
        }
        System.out.println(max);
        sc.close();

    }

}


Measured memory_bytes: 82132
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    map<ll, ll> count = prime_factor(n);
    ll ans = 0;
    for (auto x : count)
    {
        ll temp = x.second;
        ll j = 1;
        while (temp >= j)
        {
            temp -= j;
            ans++;
            j++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3652
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
p = list(map(int, readline().split()))

ans = 0
ok = True
for i in range(n):
    if p[i] == i+1 and ok:
        ans += 1
        ok = False
    else:
        ok = True
print(ans)


Measured memory_bytes: 19140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,f,e) for(int (i)=(f); (i)<(e); (i)++)
#define repr(i,e,f) for(int (i)=(e-1); (i)>=(f); (i)--)

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    double N, M;
    cin >> N >> M;
    // P = (1/2)^M;
    // E = P*s + (1-P)*(s+E);
    // E = Ps + s + E - Ps - PE;
    // PE = s;
    // E = s / P;
    double s = 100*(N-M) + 1900*M;
    cout << s / pow(1.0/2.0,M);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;


signed main()
{
    int n;cin>>n;
    std::vector<int> inp(n),dp(n,0);
    for (int i = 0; i < n; ++i)
    {
    	/* code */
    	cin>>inp[i];
    }
    int ans=0;
    for(int i=n-2;i>=0;--i)
    {
    	if(inp[i]>=inp[i+1])
    	{
    		dp[i]=1+dp[i+1];
    	}
    	else
    	{
    		dp[i]=0;
    	}
    	ans=max(dp[i],ans);
    }
    cout<<ans<<"\n";
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i=0; i<n; i++) {
    cin >> s.at(i);
  }
  
  int sumac = 0;
  int sumwa = 0;
  int sumtle = 0;
  int sumre = 0;
  for (int i=0; i<n; i++) {
    if (s.at(i) == "AC") {
      sumac++;
    }
    else if (s.at(i) == "WA") {
      sumwa++;
    }
    else if (s.at(i) == "TLE") {
      sumtle++;
    }
    else if (s.at(i) == "RE") {
      sumre++;
    }
  }
  
  
  cout << "AC x " << sumac << endl;
  cout << "WA x " << sumwa << endl;
  cout << "TLE x " << sumtle << endl;
  cout << "RE x " << sumre << endl;
}

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

void rec(int n){
	int inner;
	cin >> inner;
	if(n > 2) rec(n-1);
	cout << inner << " ";
}

int main(){
	int n, firstNum;
	cin >> n >> firstNum;
	if(n > 1) rec(n);
	cout << firstNum << endl;
	return 0;
}

Measured memory_bytes: 3048
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int N;
	scanf("%d",&N);

	int a[100];
	int col[9];
	for(int i=0;i<9;i++) col[i] = 0;

	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		if(a[i]>=3200) col[8]++;
		else col[a[i]/400]++;
	}
	int cn = 0;
	for(int i=0;i<8;i++) if(col[i]>0) cn++;

	int min,max;
	if(cn==0){
		min = 1;
		max = col[8];
	}else{
		min = cn;
		max = cn + col[8];
	}

	printf("%d %d\n",min,max);

	return 0;
}


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

vector<int> adj[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
    int n, a, b; cin >> n;

    for(int i = 1; i < n; ++i){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    queue<pair<int, int>> q;
    q.push(make_pair(1, 1));
    q.push(make_pair(n, 0));

    int whi = 0, bla = 0;

    bitset<100005> vis;
    vis[1] = vis[n] = 1;

    while(!q.empty()){
        int node = q.front().first, col = q.front().second;
        q.pop();
        col == 1 ? ++bla : ++whi;
        for(int nx : adj[node]){
            if(vis[nx]) continue;
            vis[nx] = 1;
            q.push(make_pair(nx, col));
        }
    }

    cout << (bla > whi ? "Fennec\n" : "Snuke\n");

    return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	ll D;
	cin >> D;
	vl C(26);
	for (i = 0; i < 26; i++) cin >> C[i];
	vll S(D, vl(26));
	for (i = 0; i < D; i++) {
		for (j = 0; j < 26; j++) {
			cin >> S[i][j];
		}
	}
	vl T(D);
	vl last(26, -1);
	for (i = 0; i < D; i++) {
		ll pre = 0;
		for (j = 0; j < 26; j++) {
			if (S[i][j] > S[i][pre]) {
				pre = j;
			}
		}
		T[i] = pre;
	}
	//exit(0);
	//debug用
	ans = -INF;
	for (ll loop = 0; loop < 10; loop++) {
		for (k = 0; k < D; k++) {
			ll pre2 = 0;
			for (l = 0; l < 26; l++) {
				T[k] = l;
				ll pre = 0;
				for (i = 0; i < D; i++) {
					pre += S[i][T[i]];
					last[T[i]] = i;
					for (j = 0; j < 26; j++) {
						pre -= C[j] * (i - last[j]);
					}
				}
				//debug(pre);
				if (ans < pre) {
					ans = pre;
					pre2 = l;
				}
			}
			T[k] = pre2;
		}
	}
	//debug(ans);
	for (i = 0; i < D; i++) {
		co(T[i]+1);
	}
}

Measured memory_bytes: 3716
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

void dfs(int start_node_id, vector<vector<int>>& g, vector<int>& visit_status,
         vector<int>& first_visit, vector<int>& last_visit, int& time) {
  visit_status[start_node_id] = 1;
  first_visit[start_node_id] = ++time;
  for (int i = 0; i < (int)g[start_node_id].size(); i++) {
    int node_id = g[start_node_id][i];
    if (visit_status[node_id] == 0) {
      dfs(node_id, g, visit_status, first_visit, last_visit, time);
    }
  }
  visit_status[start_node_id] = 2;
  last_visit[start_node_id] = ++time;
}

int main() {
  int n, k, u, v;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      g[i].push_back(v - 1);
      // g[v - 1].push_back(i);
    }
  }
  debug(g);
  vector<int> visit_status(n), first_visit(n), last_visit(n);
  int time = 0;
  for (int i = 0; i < n; i++) {
    if (visit_status[i] == 0) {
      dfs(i, g, visit_status, first_visit, last_visit, time);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << i + 1 << ' ' << first_visit[i] << ' ' << last_visit[i] << endl;
  }
  return 0;
}


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

int main() {
int l,r,d,count;
cin>>l>>r>>d;
int i;
count=0;
for(i=l;i<=r;i++)
{
	if(i%d==0)
	count++;
}
cout<<count<<endl;
}

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

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

  y = (x%100)%10;

  if (y == 2 || y == 4 || y == 5 || y == 7 || y == 9) {
    cout << "hon" << endl;
  }
  if (y == 0 || y == 1 || y == 6 || y == 8) {
    cout << "pon" << endl;
  }
  if (y == 3) {
    cout << "bon" << endl;
  }

}

Measured memory_bytes: 3632
N, L = map(int, input().split())
 
# 元々の味（等差数列の和の公式より）
s = N*(2*L+N-1) // 2
# 味の絶対値が最小になるリンゴの味を求める
if L+N-1 < 0: eat = L+N-1
elif L > 0: eat = L
else: eat = 0

# 食べる（最適なリンゴ）以外の味の和
print(s - eat)

Measured memory_bytes: 9096
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 505
#define maxm 4010
#define inf 1000000007
#define mod 998244353
#define inv 499122177
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
typedef long double ld;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
pii a[maxn];
int ans[maxn*maxn];
int main() 
{
    n=read();
    for(int i=1;i<=n;i++)  a[i]=mp(read(),i);
    sort(a+1,a+n+1);
    int now=1;
    for(int i=1;i<=n;i++)
    {
        if(ans[a[i].fi])
        {
            puts("No");
            return 0;
        }
        ans[a[i].fi]=a[i].se;
        for(int j=1;j<a[i].se;j++)
        {
            while(ans[now])  now++;
            if(now>a[i].fi)
            {
                puts("No");
                return 0;
            }
            ans[now]=a[i].se;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n-a[i].se;j++)
        {
            while(ans[now])  now++;
            if(now<a[i].fi)
            {
                puts("No");
                return 0;
            }
            ans[now]=a[i].se;
        }
    }
    puts("Yes");
    for(int i=1;i<=n*n;i++)  printf("%d ",ans[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		//二つの行列の行と列を宣言
		int row = scan.nextInt();
		int columnRow = scan.nextInt();
		int column = scan.nextInt();

		//二つの行列(二次元配列)を宣言
		int[][] matrixA = new int[row][columnRow];
		int[][] matrixB = new int[columnRow][column];
		long[][] matrixC = new long[row][column];

		//行列Aのためのループ
		for(int rowI = 0 ;rowI < row;rowI++){
			for(int columnRowI =0 ;columnRowI < columnRow ;columnRowI++){
				//行列Aの入力
				matrixA[rowI][columnRowI] = scan.nextInt();
			}
		}

		//行列Bのためのループ
		for(int columnRowI = 0 ;columnRowI < columnRow;columnRowI++){
			for(int columnI =0 ;columnI < column ;columnI++){
				//行列Bの入力
				matrixB[columnRowI][columnI] = scan.nextInt();
			}
		}

		//行列Cの計算のためのループ
		for(int rowI = 0 ;rowI < row;rowI++){
			for(int columnRowI =0 ;columnRowI < column ;columnRowI++){
				for(int columnI =0 ;columnI < columnRow ;columnI++){

					//行列Cの入力
					matrixC[rowI][columnRowI]
							+= matrixA[rowI][columnI] * matrixB[columnI][columnRowI];
				}
			}
		}
		for(int rowI = 0 ;rowI < row;rowI++){
			for(int columnI = 0 ;columnI < column ;columnI++){
				if(columnI+ 1 == column){
					System.out.println(matrixC[rowI][columnI]);
				}else if(columnI < column){
					System.out.print(matrixC[rowI][columnI] + " ");
				}
			}
		}
		scan.close();
	}
}



Measured memory_bytes: 54300
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
	int a,b,h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << "\n";
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	string n; cin >> n;
	int k, l; cin >> k;
	l = n.size();
	vector<vector<ll>> dp0(l+1, vector<ll>(k+1, 0));
	vector<vector<ll>> dp1(l+1, vector<ll>(k+1, 0));
	dp0[1][0] = 1;
	dp0[1][1] = (n[0] - '0') - 1;
	dp1[1][1] = 1;
	for (int i=2; i<l+1; i++) {
		int c = n[i-1] - '0';
		for (int j=0; j<k+1; j++) {
			dp0[i][j] += dp0[i - 1][j];
			if (j>0) dp0[i][j] += 9 * dp0[i - 1][j - 1];
			if (c==0) {
				dp1[i][j] = dp1[i - 1][j];
			} else {
				if (j>0) {
					dp1[i][j] += dp1[i - 1][j - 1];
					dp0[i][j] += (c - 1) * dp1[i - 1][j - 1];
				}
				dp0[i][j] += dp1[i- 1][j];
			}
		}
	}
	cout << dp0[l][k] + dp1[l][k] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = numeric_limits<int>::infinity();
const int E = numeric_limits<int>::min();

int main(void)
{
    LL A, B;
    cin >> A >> B;
    printf("%lld", A * B);

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s;
int a, b;

int main(){
	while (cin >> s&&s != "0"){
		a = 0, b = 0;
		FOR(i, 1, s.size()){
			if (s[i] == 'A') a++;
			else b++;
		}
		if (a > b) a++;
		else b++;
		cout << a << " " << b << endl;
		REP(i, 2){
			a = 0, b = 0;
			cin >> s;
			FOR(j, 1, s.size()){
				if (s[j] == 'A') a++;
				else b++;
			}
			if (a > b)a++;
			else b++;
			cout << a << " " << b << endl;
		}
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;
int main(){
    int N, P;
    string S;
    cin >> N;
    vector<tuple<string, int, int>> vec(N);
    for(int i=0; i<N; i++){
        cin >> S >> P;
        vec[i] = make_tuple(S, -P, i+1);
    }
    sort(vec.begin(), vec.end());

    for(int i=0; i<N; i++){
        cout << get<2>(vec[i]) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string AIZUNYAN = "AIZUNYAN";
string AIDUNYAN = "AIDUNYAN";
bool check(string s){
  sort(s.begin(),s.end());
  string tmp = AIDUNYAN;
  sort(tmp.begin(),tmp.end());
  return tmp==s;
}
int main(){
  string s;
  cin>>s;
  string ans = s;
  for(int i=0;i+7<s.size();i++){
    if(check(s.substr(i,8))){
      for(int j=0;j<8;j++){
        ans[i+j]=AIZUNYAN[j];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1212
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9+7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
#define int long long
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
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;
}

signed main() {
    int n;
    cin >> n;
    string res = "";
    while (n) {
        n -= 1;
        res += (char)('a' + (n % 26));
        n /= 26;
    }
    reverse(ALL(res));
    print(res);
}





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

using namespace std;

void solve() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int next = 1;
  for (int n : a) {
    if (next == n) {
      ++next;
    }
  }
  if (next == 1) {
    cout << -1 << endl;
  } else {
    cout << (N - next + 1) << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

// PRACTICE //

int AB, BC, CA;

int main() {
    cin >> AB;
    cin >> BC;
    cin >> CA;
    if (AB >= BC and AB >= CA) {
        cout << BC  * CA / 2;
    } else if (BC >= AB and BC >= CA) {
        cout << AB * CA / 2;
    } else if (CA >= AB  and CA >= BC) {
        cout <<  AB * BC / 2;
    }
    return 0;
}

Measured memory_bytes: 256
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int n,m,vis[404040],t[404040],dt[404040],l;
vector<pair<int,int> >v[404040];
vector<int>col[1010101],v2[404040];
queue<int>q;
int main()
{
	cin>>n>>m;
	l=n;
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		v[a].push_back(make_pair(c,b));
		v[b].push_back(make_pair(c,a));
		col[c].push_back(a);
		col[c].push_back(b);
	}
	for(int i=1;i<=n;i++)
	{
		sort(v[i].begin(),v[i].end());
	}
	for(int i=1;i<=1e6;i++)
	{
		if(col[i].size()==0)
		{
			continue;
		}
		for(int j=0;j<col[i].size();j++)
		{
			if(vis[col[i][j]]==i)
			{
				continue;
			}
			q.push(col[i][j]);
			vis[col[i][j]]=i;
			vector<int>vv;
			vv.clear();
			vv.push_back(col[i][j]);
			while(!q.empty())
			{
				int x=q.front();
				q.pop();
				while(t[x]<v[x].size())
				{
					if(v[x][t[x]].first!=i)
					{
						break;
					}
					if(vis[v[x][t[x]].second]!=i)
					{
						vis[v[x][t[x]].second]=i;
						q.push(v[x][t[x]].second);
						vv.push_back(v[x][t[x]].second);
					}
					t[x]++;
				}
			}
			l++;
			for(int k=0;k<vv.size();k++)
			{
				v2[l].push_back(vv[k]);
				v2[vv[k]].push_back(l);
			}
		}
	}
	for(int i=0;i<404000;i++)
	{
		dt[i]=-2;
	}
	dt[1]=0;
	q.push(1);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<v2[x].size();i++)
		{
			if(dt[v2[x][i]]!=-2)
			{
				continue;
			}
			dt[v2[x][i]]=dt[x]+1;
			q.push(v2[x][i]);
		}
	}
	cout<<dt[n]/2<<endl;
	return 0;
}

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

using ll = long long; 

/*
given two strings, return their longest common subsequence
axyb
abyxb

axb

recursion / dp
dp[i][j] = max(dp[i-1][j], dp[i][j-1], 1 + dp[i-1][j-1])

dp[i][j] means consider subsequence a up to i and subsequence b up to j 
dp[i][j] will be a string 
*/

string max_by_len(string a, string b) {
    if (a.length() > b.length()) {
        return a;
    }
    else {
        return b;
    }
}

int main() {
    string a;
    string b;
    cin >> a >> b;
    
    //scanf("%s%s", &a.c_str(), &b.c_str());
    int n = a.length();
    int m = b.length();
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(m+1, vector<int>(3)));
    // {length, parent_r, parent_c}
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            vector<int> skip_a = dp[i][j+1];
            vector<int> skip_b = dp[i+1][j];
            vector<int> match = dp[i][j];
            int match_len = a[i] == b[j] ? match[0] + 1 : 0;
            if (skip_a[0] >= skip_b[0] && skip_a[0] >= match_len) {
                dp[i+1][j+1] = {skip_a[0], i, j+1};
            }
            else if (skip_b[0] >= skip_a[0] && skip_b[0] >= match_len) {
                dp[i+1][j+1] = {skip_b[0], i+1, j};
            }
            else {
                dp[i+1][j+1] = {match_len, i, j};
            }
        }
    }
    
    string ans;
    int r = n;
    int c = m;
    while (r >= 1 && c >= 1) {
        //cout << r << " " << c << endl;
        vector<int> parent = {dp[r][c][1], dp[r][c][2]};
        
        if (parent[0] == r-1 && parent[1] == c-1) {
            ans.push_back(a[r-1]);
        }
        r = parent[0];
        c = parent[1];
    }
    reverse(ans.begin(), ans.end());
	cout << ans << endl;
	//cout << dp[n][m][0] << endl;
	
	return 0;
}

/*
  a b y x b
a 1 1 1 1 1
x 0 0 0 2 2 
y 0 0 1 2 2
b 0 1 0 0 3
*/






Measured memory_bytes: 495104
n,*x=map(int,open(0).read().split());y=[x[0]-i for i in x];m=n*max(x);d=[[0]*m*2 for _ in[0]*-~n];d[0][0]=1
for i in range(1,n+1):
	for s in range(-m,m):d[i][s]=d[i-1][s]+d[i-1][s-y[i]]
print(d[n][0]-1)

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  string s, t; cin>>t>>s;
  int ans = 0;
  rep(i,0,t.size()){
    int n=0;
    if(i+s.size()-1==t.size()) break;
    rep(j,0,s.size()){
      if(t[i+j]==s[j]) n++;
    }
    chmax(ans, n);
  }
  cout<<s.size()-ans<<endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
int k;
int b;
int c;//現在の和
int d;//最高値
while(cin>>n){
if(n==0){break;}
cin>>k;
int a[n];
b=0;
while(b<n){
cin >>a[b];
b=b+1;}
c=0;
b=0;
while(b<k){
c=c+a[b];
b=b+1;}
d=c;
while(b<n){
c=c-a[b-k]+a[b];
if(c>d){d=c;}
b=b+1;}
cout << d<<endl;}
}

Measured memory_bytes: 1548
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair < int , int >

string s;
map < string ,int > dp;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	LL ans = 0;
	cin >> n;
	for ( int i = 0; i < n; i++ ){
		cin >> s;
		sort(s.begin(),s.end());


		ans += dp[s];
		dp[s]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

ll ans = INT_MAX;
int n, m, v[12][12], c[12];

void solve(ll curr, int prev, int n, int m, int x, vector <int> sum) {
    int flag = 1;
    for (int i = 0; i < m; i++) {
        if (sum[i] < x) {
            flag = 0;
            break;
        }
    }
   // cout << curr <<endl;
    if (flag) {
        ans = min(ans, curr);
        return;
    }
    else {
        vector <int> olds(m);
        for (int i = 0; i < m; i++) olds[i] = sum[i];
        for (int i = prev + 1; i < n; i++) {
            for (int j = 0; j < m; j++) {
                sum[j] += v[i][j];
            }
            solve(curr+c[i], i, n, m, x, sum);
            for (int i = 0; i < m; i++) sum[i] = olds[i];
        }
    }
}

int main() {
    int x;
    cin >> n >> m >> x;
    vector <int> sum(m);
    for (int i = 0; i< m; i++) sum[i] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m+1; j++) {
            if (j == 0) {
                cin >> c[i];
            }
            else {
                cin >> v[i][j-1];
            }
        }
    }
    int flag = 0;
    for (int j = 0; j < m; j++) {
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += v[i][j];
        }
        if (sum < x) {
            flag = 1;
            break;
        }
    }
    if (flag) cout << -1 << endl;
    else {
        solve(0, -1, n, m, x, sum);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3640
def spin(p):
  ret = [[None] * 8 for _ in range(8)]
  for i in range(8):
    for j in range(8):
      ret[i][j] = p[7 - j][i]
  return ret

def print_p(p):
  for line in p:
    print("".join(line))

p = [input() for _ in range(8)]

print(90)
p = spin(p)
print_p(p)

print(180)
p = spin(p)
print_p(p)

print(270)
p = spin(p)
print_p(p)


Measured memory_bytes: 5560
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, l,j, k, p, q, r, x, y, u, v, n, m;
    n=4;
    vc a(n);
    Ff(i,0,n)
    cin>>a[i];

    ll maxi=-1e18;
    Ff(i,0,2)
    {
      Ff(j,2,n)
      {
        maxi=max(maxi,a[i]*a[j]);
      }
    }
    cout<<maxi<<"\n";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10656