akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#define llong long long
using namespace std;

int n, m, cnt, a[100000];
llong ans;
vector<int> g[100000], e[100000], res;
bool v[100000];

void dfs(int x)
{
	v[x]=true;
	e[cnt].push_back(a[x]);

	for (int u : g[x])
		if (!v[u]) dfs(u);
}

int main()
{
	int i, j, x, y;
	cin >> n >> m;

	for (i=0; i<n; ++i)
		cin >> a[i];

	for (i=0; i<m; ++i)
	{
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	if (n<(n-m-1)*2)
	{
		cout << "Impossible" << endl;
		return 0;
	}

	for (i=0; i<n; ++i)
		if (!v[i])
		{
			dfs(i);
			sort(e[cnt].begin(), e[cnt].end());
			ans+=(llong)e[cnt][0];

			for (j=1; j<e[cnt].size(); ++j)
				res.push_back(e[cnt][j]);

			++cnt;
		}

	if (cnt==1)
	{
		cout << '0' << endl;
		return 0;
	}

	sort(res.begin(), res.end());

	for (i=0; i<n-m-2; ++i)
		ans+=(llong)res[i];

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

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

P f(int x){
	int a = x%10;
	int b=0;
	while(x){
		b = x;
		x /= 10;
	}
	return P(a,b);
}

int main(){
	int N;
	cin >> N;
	
	map<P,int> mp;
	for(int i=1; i<=N; i++){
		P p = f(i);
		mp[p]++;
	}
	ll ans = 0;
	for(int i=1; i<=N; i++){
		P p = f(i);
		P q(p.second,p.first);
		ans += mp[q];
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	ll k, s, x, y, z, ans = 0;

	cin >> k >> s;
	
	for(x = 0; x <= k; x++){
		for(y = 0; y <= k; y++){
			z = s - x - y;
			if(0 <= z && z <= k){
				ans++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<sstream>
using namespace std;
stack <int> st;
int solve(string c){
	int b = st.top();
	st.pop();
	int a= st.top();
	st.pop();
	if(c =="+")
		return a+b;
	else if(c =="-")
		return a-b;
	else if(c =="*")
		return a*b;
	else if(c=="/")
		return a/b;
}
int main(){
	int num;
	stringstream ss;
	string c;
	while(cin >> c){
		if(c=="+"||c=="-"||c=="*"||c=="/"){
			st.push(solve(c));
		}
		else{
			ss << c;
			ss >> num;
			
			st.push(num);
			ss.clear();
		}
		if (getchar()=='\n'){
			cout << st.top() << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2000*2000;
const char newl = '\n';

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

  ll h, w;
  cin >> h >> w;
  char c[h][w];
  rep(i, h) rep(j, w) cin >> c[i][j];

  vvl o(h, vl(w)), cnum=o, rnum=o, cparent=o, rparent=o;
  rep(i, h) {
    ll p=0;
    rep(j, w) {
      if(c[i][j] == '.') {
        cnum[i][p]++;
        cparent[i][j] = p;
      }else if(c[i][j] == '#') {
        p = j+1;
      }
    }
  }

  rep(j, w) {
    ll p=0;
    rep(i, h) {
      if(c[i][j] == '.') {
        rnum[p][j]++;
        rparent[i][j] = p;
      }else if(c[i][j] == '#') {
        p = i+1;
      }
    }
  }

  ll ans = 0;
  rep(i, h) rep(j, w) chmax(ans, cnum[i][cparent[i][j]] + rnum[rparent[i][j]][j] - 1);
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 163684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
bool stone[100005];

int main() {
  int n,k;
  vi aa;
  cin>>n>>k;
  rep(i,n){
    int a;
    cin>>a;
    aa.push_back(a);
  }
  for(int i=1;i<=k;i++){
    for(int a:aa){
      if(i-a<0) continue;
      if(stone[i-a]==false){
        stone[i]=true;
        break;
      }
    }
  }
  if(stone[k]) puts("First");
  else puts("Second");
  return 0;
}


Measured memory_bytes: 384
nv, ne = map(int, input().split(' '))
in_degs = [0] * nv
q = []
outs = {}
o = []

for _ in range(ne):
    s, t = map(int, input().split(' '))

    if s in outs: outs[s].append(t)
    else: outs[s] = [t]

    in_degs[t] += 1

for i in range(nv):
    if in_degs[i] == 0: q.append(i)

while len(q) > 0:
    v = q.pop(0)
    o.append(v)

    if v in outs:
        for out in outs[v]:
            in_degs[out] -= 1
            if in_degs[out] == 0: q.append(out)

[print(v) for v in o]

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

int main() {
 int N;
  cin >> N;
  int i=0;
  string A="Three";
    while(i<N){
      string S_i;
      cin >> S_i;
      if(S_i=="Y"){
        A="Four";
        break;
      }
      else{
        i++;
      }
    }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    VL a(3); cin >> a;
    each(i, a)if (i % 2 == 0) {
        cout << "0\n";
        return 0;
    }
    SORT(a);
    ll ans = LLINF;
    FOR(i, 0, 3)FOR(j, i + 1, 3)chmin(ans, a[i] * a[j]);
    cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string s = NextString();
        for (int i = 0; i < s.Length - 1; i++)
            if ((s[i].ToString() + s[i + 1].ToString()) == "AC") { Console.WriteLine("Yes");return; }
        Console.WriteLine("No");
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");
	var max = parseInt(tmp[0], 10);
	var sum = parseInt(tmp[1], 10);
	var count = 0;
	if (sum-2*max>=0) {
		for (i=sum-2*max;i<=max;i++) {
			if (sum-max-i>=0) {
				count += 2*max-sum+i+1;
			} else {
				count += sum-i+1;
			}
		}
	} else if (sum >= max){
		for (i=0;i<=max;i++) {
			if (sum-max-i>=0) {
				count += 2*max-sum+i+1;
			} else {
				count += sum-i+1;
			}
		}
	} else {
		for (i=0;i<=sum;i++) {
				count += sum-i+1;
			}
	}
	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 998244353;

signed main(){
  lint N; cin >> N;
  vector<lint> a(N), num(N, 0);
  for(lint i = 0; i < N; i++) {cin >> a[i]; num[a[i]]++;};
  if(a[0] != 0 || num[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  lint ans = 1;
  for(lint i = 1; i < N; i++){
    ans *= num[a[i] - 1];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;

	vector<int> A(N);
	for(auto &x : A) {
		cin >> x;
	}

	sort(A.begin(), A.end(), [](int &a, int &b) {
		return a > b;
	});

	long long result = 0;
	if(N % 2 == 0) {
		const int last = N / 2 - 1;
		for(int i = 0; i <= last; i++) {
			result += A[i] * 2;
		}
		result -= A[0];
	} else {
		const int last = (N - 1) / 2;
		for(int i = 0; i <= last; i++) {
			result += A[i] * 2;
		}
		result -= (A[0] + A[last]);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , t , x , y , k;
    cin >> n;
    int a = 0 , b = 0 , c = 0;
    for( int i = 0 ; i < n ; i++ ) {
        cin >> t >> x >> y;
        k = abs( a - x ) + abs( b - y );
        if( t - c < k || ( k - t + c ) % 2 ) {
            cout << "No";
            return 0;
        }
        a = x;
        b = y;
        c = t;
    }
    cout << "Yes";
}




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

int main(void){
    int x;
    cin >> x;
    
    int a, b, c;
    a = x/100;
    b = a*5;
    c = x%100;

    int flag = 0;
    if(x >= 2000 || c <= b){
        flag = 1;
    }
    cout << flag << endl;
    return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++)
        reverse(divide[i].begin(), divide[i].end());

    bool ans = true;
    for (int i = 0; i < s.size();) {
        bool can = false;
        for (int j = 0; j < 4; j++) {
            string d = divide[j];
            if (s.substr(i, d.size()) == d) {
                can = true;
                i += d.size();
            }
        }
        if (!can) {
            ans = false;
            break;
        }
    }
    if (ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		for (long i=0;i*(i+1)/2<=n;i++) {
			if (i*(i+1)/2==n) {
				System.out.println("Yes");
				System.out.println(i+1);
				List<List<Long>> ans = (solve(i));
				for (List<Long> l : ans) {
					System.out.println(parse(l));
				}
				return;
			}
		}
		System.out.println("No");

	}
	
	static List<List<Long>> solve (long n) {
		if (n==2) {
			List<List<Long>> ans = new ArrayList<>();
			List<Long> l1 = new ArrayList<Long>();
			l1.add(1L);
			l1.add(2L);
			ans.add(l1);
			List<Long> l2 = new ArrayList<Long>();
			l2.add(2L);
			l2.add(3L);
			ans.add(l2);
			List<Long> l3 = new ArrayList<Long>();
			l3.add(3L);
			l3.add(1L);
			ans.add(l3);
			return ans;
		} else if (n==1) {
			List<List<Long>> ans = new ArrayList<>();
			List<Long> l1 = new ArrayList<Long>();
			l1.add(1L);
			ans.add(l1);
			List<Long> l2 = new ArrayList<Long>();
			l2.add(1L);
			ans.add(l2);
			return ans;
		} else if (n==0) {
			List<List<Long>> ans = new ArrayList<>();
			ans.add(new ArrayList<Long>());
			return ans;
		} else {
			List<List<Long>> ans = solve (n-3);
			for (int i=0;i<n-2;i++) {
				ans.get(i).add((n-2)*(n-3)/2+i+1);
				ans.get(i).add((n-2)*(n-3)/2+i+n);
				ans.get(i).add((n-2)*(n-3)/2+i+2*n-1);
			}
			List<Long> tmp1 = new ArrayList<Long>();
			List<Long> tmp2 = new ArrayList<Long>();
			List<Long> tmp3 = new ArrayList<Long>();
			for (int i=0;i<n;i++) {
				tmp1.add((n-2)*(n-3)/2+(i==0 ? 3*n-3 : i));
				tmp2.add((n-2)*(n-3)/2+i+n-1);
				tmp3.add((n-2)*(n-3)/2+i+2*n-2);
			}
			ans.add(tmp1);
			ans.add(tmp2);
			ans.add(tmp3);
			return ans;
		}
	}

	static String parse ( List<Long> l) {
		String ans = ""+l.size();
		for (Long lo : l) {
			ans = ans + " " + lo;
		}
		return ans;
	}



}




Measured memory_bytes: 341488
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


int N;

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


	cin >> N;
	if (N % 10 == 3)cout << "bon" << endl;
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)cout << "pon" << endl;
	else cout << "hon" << endl;

	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0; i<n; i++)
        cin>>v[i];
    int MIN=v[0],cnt=0;
    for(int i=0; i<n; i++)
    {
        MIN=min(MIN,v[i]);
        if(MIN>=v[i])cnt++;
    }
    //cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1024
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
using namespace std;

int main(){
   int n;
   cin >> n;
   vector<int> l(n);
   for(int i=0; i<n; i++) cin >> l[i];
   long long sum=0;
   sort(l.begin(),l.end());
   for(int i=0; i<n-2; i++){
       for(int j=i+1; j<n-1; j++){
           for(int k=j+1; k<n; k++){
               if(l[j]<(l[i]+l[k]) && l[k]<(l[i]+l[j])){
                   sum++;
               }
           }
       }
   }
   cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
dl = []
for i in range(n):
    d = list(map(int,input().split()))
    dl.append(d)
ans = 'No'
for i in range(n-2):
    if dl[i][0] == dl[i][1] and dl[i+1][0] == dl[i+1][1] and dl[i+2][0] == dl[i+2][1]:
        ans = 'Yes'
        break
print(ans)


Measured memory_bytes: 9180
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}

namespace adaptor = boost::adaptors;

void Main()
{
	int N;
	std::cin >> N;
	bool f = false;
	for (int i : boost::irange(0, N))
	{
		int a;
		std::cin >> a;
		if (a % 2 != 0)
		{
			f = true;
		}
	}
	if (f)
	{
		out::write_line("first");
	}
	else
	{
		out::write_line("second");
	}
}

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


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

int main(){
  int n; cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        puts("DENIED");
        return 0;
      }
    }
  }
  puts("APPROVED");
  return 0;
}

Measured memory_bytes: 256
import sys
from fractions import *

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
now = 1
ct = 0
for i in range(n):
    if a[i] == now:
        now += 1
        ct += 1
print(-1) if ct == 0 else print(n-ct)


Measured memory_bytes: 27068
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      char[][] c = new char[h][w];
      for(int i = 0;i < h;i++)c[i]=sc.next().toCharArray();
      for(int i = 0;i < h;i++){
      	for(int j = 0;j < w;j++){
        	if(c[i][j]=='#'){
            	if((i>=1&&c[i-1][j]=='#')||(i<=h-2&&c[i+1][j]=='#')||(j>=1&&c[i][j-1]=='#')||(j<=w-2&&c[i][j+1]=='#')){}
                else {
                	System.out.println("No");
                    return;
                }
            }
        }
      }
      System.out.println("Yes");
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int W, a, b; cin >> W >> a >> b;
	int A = min(a, b), B = max(a, b);
	int ans = (B - A - W >= 0) ? (B - A - W) : 0;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; string s;
  cin >> n >> s;
  if (n%2==0){
    n /=2;
    rep(i,n){
      if(s[i]!=s[i+n]){
        cout << "No" << endl;
        return 0;
      }
    }
  }else {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
A, B, C, X, Y = list(map(int, input().split()))

a = A*X+B*Y
b = max(X,Y)*C*2
c = min(X,Y)*C*2
if max(X,Y) == X:
    c += (X-Y)*A
else:
    c += (Y-X)*B

print(min(min(a,b),c))

Measured memory_bytes: 9104
#include<cstdio>
#include<stdlib.h>

#define B_MAX ( (int) 4 )
#define B_MIN ( (int) 1 )
#define F_MAX ( (int) 3 )
#define F_MIN ( (int) 1 )
#define R_MAX ( (int) 10 )
#define R_MIN ( (int) 1 )
#define V_MAX ( (int) 9 )
#define V_MIN ( (int) 0 )


class HOUSE
{
	public:
		int InputHouse(void);
		int CheckHouse(void);
		void PrintHouse(void);
	private:
		int n = 0, b = 0, f = 0, r = 0, v = 0;
		int house[B_MAX][F_MAX][R_MAX]={ { { 0 } } };
};

int HOUSE::InputHouse(void)
{
	scanf("%d %d %d %d\n", &b, &f, &r, &v);
	
	if(CheckHouse() == -1)
	{
		return -1;
	}
	
	house[b-1][f-1][r-1] += v;
	
	if( (house[b-1][f-1][r-1] < V_MIN) || (house[b-1][f-1][r-1] > V_MAX) )
	{
		return -1;
	}
	
	return 0;
}

int HOUSE::CheckHouse(void)
{
	if( (b < B_MIN) || (b > B_MAX) ||
		(f < F_MIN) || (f > F_MAX) ||
		(r < R_MIN) || (r > R_MAX) )
	{
		return -1;
	}
	
	return 0;
}

void HOUSE::PrintHouse(void)
{
	for(int i = 0; i < B_MAX; i++)
	{
		for(int j = 0; j < F_MAX; j++)
		{
			for(int k = 0; k < R_MAX; k++)
			{
				printf(" %d", house[i][j][k]);
			}
			printf("\n");
		}
		if(i != (B_MAX - 1))
		{
			printf("####################\n");
		}
	}
}

int main(void)
{
	int n = 0;
	HOUSE House;
	
	scanf("%d", &n);
	while(n-- > 0)
	{
		if(House.InputHouse() == -1)
		{
			return -1;
		}
	}
	
	House.PrintHouse();
	
	return 0;
}



Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
vi vec = {1,0,-1,0,1};
int main(){
  unsigned h,w; cin >> h >> w;
  vt<string> vs(h);
  rep(i,h) cin >> vs[i];
  
  for(unsigned i = 0; i < h; i++)for(unsigned j = 0; j < w; j++){
    if(vs[i][j] == '#'){
    [&]{
      rep(k,4){
        //SHOW(i,j);
        unsigned ni = i + vec[k];
        unsigned nj = j + vec[k+1];
        if(ni >= h || nj >= w) continue;
        if(vs[ni][nj] == '#') return;
        if(k == 3){
          cout << "No" << endl;
          exit(0);
        }
    }
    }();
  }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(string::iterator it=(v).begin();it!=(v).end();++it)

#define MOD 1000000007

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

  LL A = 0;
  LL AB = 0;
  LL ABC = 0;
  LL q = 1;

  IFOR(S, it) {
    if (*it == 'C')
      ABC = (ABC + AB) % MOD;
    else if (*it == 'B')
      AB = (AB + A) % MOD;
    else if (*it == 'A')
      A += q;
    else {
      ABC = (3 * ABC % MOD + AB) % MOD;
      AB = (3 * AB % MOD + A) % MOD;
      A = (3 * A % MOD + q) % MOD;
      q = (q * 3) % MOD;
    }
  }
  cout << ABC % MOD << endl;

  return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,x,y,cnt,flag;
bool dp[8009][32009];
vint v1,v2,v3;
string s;

bool solve(vint vec,int g){
    rep(i,0,vec.size()+1)rep(j,0,32000+1)dp[i][j]=false;
    dp[0][16000]=true;
    rep(i,0,vec.size()){
        rep(j,0,32000+1){
            if(!dp[i][j])continue;
            dp[i+1][j+vec[i]]=true;
            dp[i+1][j-vec[i]]=true;
        }
    }
    return dp[vec.size()][16000+g];
}

signed main(){
    cin>>s>>x>>y;
    rep(i,0,s.size()+1){
        if(i!=s.size()&&s[i]=='F')cnt++;
        else{
            if(flag==0)v1.pb(cnt);
            if(flag==1)v2.pb(cnt);
            cnt=0;
            flag?flag=0:flag=1;
        }
    }
    x-=v1[0];
    rep(i,1,v1.size())v3.pb(v1[i]);
    if(solve(v3,x)&&solve(v2,y))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 125312
N = int(input())
A = [int(_) for _ in input().split()]


class SegmentTree():
    def __init__(self, array, m, e, size):
        self.m = m  # monoid
        self.e = e  # identity element
        self.size = size  # limit for array size
        self.n = n = len(array)  # array size
        self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


gcd = lambda x, y: gcd(y, x) if x < y else x if y == 0 else gcd(y, x % y)
e = 0
size = 10**6
ST = SegmentTree(A, m=gcd, e=e, size=size)

ans = 1
for i, a in enumerate(A):
    ST.modify(i, 0)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


Measured memory_bytes: 128792
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define fr first
#define sc second
typedef pair<string,int> Pi;
int main(){
  int n;
  while(cin >> n , n){
    char mas[1000][1000];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        cin >> mas[i][j];
      }
    }
    int cnt[1000][1000] = {{}} , ans = 0;
    for(int i=0;i<n;i++){
      if(mas[i][0] == '.') cnt[i][0] = 1;
      if(mas[0][i] == '.') cnt[0][i] = 1;
    }
    for(int i=1;i<n;i++){
      for(int j=1;j<n;j++){
        if(mas[i][j] == '*') cnt[i][j] = 0;
        else{
          cnt[i][j] = min(cnt[i-1][j-1],min(cnt[i-1][j],cnt[i][j-1])) + 1;
          ans = max(ans,cnt[i][j]);
        }
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

struct Vector2 {
    int x, y;
    Vector2() {}
    Vector2(int x, int y) : x(x), y(y) {}
    void operator=(const Vector2 &other) {
        x = other.x;
        y = other.y;
    }
    Vector2 operator+(const Vector2 &other) {
        return Vector2(x + other.x, y + other.y);
    }
    Vector2 operator-(const Vector2 &other) {
        return Vector2(x - other.x, y - other.y);
    }
    bool operator==(const Vector2 &other) {
        return (x == other.x && y == other.y);
    }
    int dot(Vector2 other) {
        return x * other.x + y * other.y;
    }
    int det(Vector2 other) {
        return x * other.y - y * other.x;
    }
};


bool cmp_x(const Vector2 &p, const Vector2 &q) {
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}

//凸包を求める, psはすでにsort済み
vector<Vector2> convexhull(vector<Vector2> &ps) {
    sort(ps.begin(),ps.end(),cmp_x);
    int size = ps.size();
    int k = 0;
    if (size <= 2) return ps;
    vector<Vector2> qs(size * 2);
    for (int i = 0; i < size; ++i) {
        while (k > 1 && (qs[k - 2] - qs[k - 1]).det(ps[i] - qs[k - 1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for (int i = size - 2, t = k; i >= 0; i--) {
        while(k > t && (qs[k - 2] - qs[k - 1]).det(ps[i] - qs[k - 1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k - 1);
    return qs;
}

int N;
vector<Vector2> P;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        P.push_back(Vector2(x,y));
    }
    auto qs=convexhull(P);
    int ans=0;
    for(int i=0;i<qs.size()-1;++i){
        for(int j=i+1;j<qs.size();++j){
            int d=abs(qs[i].x-qs[j].x)+abs(qs[i].y-qs[j].y);
            chmax(ans,d);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7452
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;

int h, w;
int W, B;
bool a[400][400];//使ったか？
string b[400];
int dx[4] = { -1,0,0,1 }, dy[4] = { 0,-1,1,0 };
void saiki(int x, int y) {
	if (a[x][y])return;
	a[x][y] = true;
	if (b[x][y] == '#')B++;
	else W++;
	for (int i = 0; i < 4; i++) {
		if (x + dx[i] < h&&x + dx[i] >= 0 && y + dy[i] < w&&y + dy[i] >= 0 && b[x + dx[i]][y + dy[i]] != b[x][y]) {
			saiki(x + dx[i], y + dy[i]);
		}
	}
}
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)cin >> b[i];
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			W = B = 0;
			saiki(i, j);
			ans += B*W;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 10624
#include<stdio.h>
#define MAX 10001

int main(){
	int x;
	int a[MAX]={0};
	
	a[1]=2;
	
	while(scanf("%d",&x)!=EOF){
		if(a[x]!=0)printf("%d\n",a[x]);
		else {
			for(int i=2;i<=x;i++){
				if(a[i]==0){
					a[i]=a[i-1]+i;
				}
			}
			printf("%d\n",a[x]);
		}
	}
	
	return 0;
}


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

class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		char[] input = reader.readLine().toCharArray();

		int result = 0;
		for(int i = 1; i < input.length; i++) {
			int me = (i%2==0)?0:1;
			int you = (input[i]=='g')?0:1;
			result += me-you;
		}

		System.out.println(result);
	}
}


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

int main(){
  int i,j,k,l,n,a[9][9],ans[9][9],c=0;
  while(cin >> n){
    for(i=0;i<n;i++){

      if(c) cout << endl;
      c = 1;

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  cin >> a[j][k];
	  ans[j][k] = 0;
	}
      }

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  for(l=k+1;l<9;l++){
	    if(a[j][k] == a[j][l]) ans[j][k] = ans[j][l] = 1;
	    if(a[k][j] == a[l][j]) ans[k][j] = ans[l][j] = 1;
	  }
	}
      }

      for(j=0;j<=6;j+=3){
	for(int m=0;m<=6;m+=3){
	  for(k=0;k<9;k++){
	    for(l=k+1;l<9;l++){
	      if(a[k/3+j][k%3+m] == a[l/3+j][l%3+m]) ans[k/3+j][k%3+m] = ans[l/3+j][l%3+m] = 1;
	    }
	  }
	}
      }

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  if(ans[j][k]) cout << "*" << a[j][k];
	  else cout << " " << a[j][k];
	}
	cout << endl;
      }

    }
  }
  return 0;
}

Measured memory_bytes: 0
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi a(4), b(2);
  rep(i, 4) cin >> a[i];
  rep(i, 2) cin >> b[i];
  sort(rall(a)), sort(rall(b));
  cout << a[0] + a[1] + a[2] + b[0] << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N,0);
    int Ai;
    for (int i=1;i<=N;i++){
        cin >> Ai;
        vec.at(Ai-1) = i;
        
    }
    for(int i=0;i<N;i++){
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S;
  cin >> S;
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  } else if(S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}


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

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

	set<pair<int, int>> HW;
	vector<int> sum_h(H), sum_w(W);
	int max_sum_h = 0, max_sum_w = 0;
	rep(i, M){
		int h, w; cin>>h>>w; h--, w--;
		HW.insert({h, w});
		sum_h[h]++, sum_w[w]++;
		max_sum_h = max(max_sum_h, sum_h[h]);
		max_sum_w = max(max_sum_w, sum_w[w]);
	}

	vector<int> hs, ws;
	rep(i, H) if(sum_h[i] == max_sum_h) hs.push_back(i);
	rep(i, W) if(sum_w[i] == max_sum_w) ws.push_back(i);

	int ans = max_sum_h + max_sum_w - 1;
	for(int h:hs) for(int w:ws){
		if(HW.count({h, w})) continue;
		cout<< ans + 1 <<endl;
		return 0;
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 23784
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {
  
  string S;
  cin >> S;
  if (S[S.length() - 1] == 's') cout << S + "es" << endl;
  else cout << S + "s" << endl;

  return 0;
}

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

class Main{
    public static void main(String[] arg){
	Scanner cin = new Scanner(System.in);
	int[] a = new int[10];
	int[] c = new int[10];
	for(int i=0; i<10; i++){
		a[i] = cin.nextInt();
		c[i] = a[i];
	}

	Arrays.sort(a);

	for(int i=1; i<=3; i++){System.out.println(a[a.length-i]);}
   }
}

Measured memory_bytes: 12000
def f(i,k):
  for j in range(13):
    dp[i+1][(j*10+k)%13]+=dp[i][j]
    dp[i+1][(j*10+k)%13]%=mod
  
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*13 for i in range(10**5+1)]
dp[0][0]=mul=1

for i in range(n):
  if s[i]=='?':
    for k in range(10):
      f(i,k)
  else:
    f(i,int(s[i]))
  
print(dp[n][5]%mod)


Measured memory_bytes: 95780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    combination C(2*N);
    if(N<=K){
        cout << C.hcomb(N,N) << "\n";
        return 0;
    }
    mint ans = 0;
    for(int i=1;i<=K;i++){
        ans += C.comb(N,i)*C.hcomb(N-i,i);
//        cerr << ans << "\n";
    }
    cout << ans+1 << "\n";
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
const int N = 4004;
bool m[3][3][N];
string a[3];
int w[3] = {0, 1, 2};

bool check(string& x, string& y, int p) {
  bool ok = true;
  for (int i = 0; ok && i < y.size() && p + i < x.size(); ++i) {
    if (y[i] == '?' || x[p + i] == '?') continue;
    ok = y[i] == x[p + i];
  }
  return ok;
}

int main() {
  for (int i = 0; i < 3; ++i) cin >> a[i];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i != j) {
        for (int k = 0; k < a[i].size(); ++k) {
          m[i][j][k] = !check(a[i], a[j], k);
        }
      }
    }
  }
  int v = 3 * N;
  do {
    int x = w[0], y = w[1], z = w[2];
    for (int i = 0; i < 2001; ++i) {
      if (!m[x][y][i]) {
        for (int j = 0; j < 2001; ++j) {
          if (!m[x][z][i + j] && !m[y][z][j]) {
            v = min(v, int(max({i + j + a[z].size(), i + a[y].size(), a[x].size()})));
            break;
          }
        }
      }
    }
  } while(next_permutation(w, w + 3));
  cout << v << '\n';
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>

#define PI  2*acos(0.0)
#define pb push_back


using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


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

string s;
ll n;
cin>>n;
vector<ll>v(n);
for(auto& x : v)
{
	cin>>x;
}

sort(v.begin(),v.end(),greater<ll>());

ll ans=0;
for(int i=1;i<n;i++)
{
	ans+=v[floor(i/2)];
}

cout<<ans<<"\n";

	
	
	return 0;
	
	
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
const int Inf = 1e6 + 7;
int n, k;
int a[15];
int ans;
bool vis[12];

int main() {
	cin >> n >> k;
	for(int i = 1; i <= k; i++) cin >> a[i];
	for(int i = 1; i <= k; i++) vis[a[i]] = 1;
	for(int i = n; i <= Inf; i++) {
		int t = i;
		bool flg = 1;
		while(t) {
			int s = t % 10;
			if(vis[s]) {
				flg = 0;
				break;
			}
			t /= 10;
		}
		if(flg) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int64_t A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(A > B){
        A *= -1;
        B *= -1;
    }
    A += V*T;
    B += W*T;
    cout << (A >= B ? "YES" : "NO") << endl;
    return 0;
}


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

int n,k;

vector<int> vec;
vector<int> dp;

bool solve(int stones)
{
	if(dp[stones]!=-1)
		return dp[stones];
	bool ans=false;
	for(int i=0; i<n; i++)
	{
		if((stones-vec[i]>=0&&!solve(stones-vec[i])))
		{
			ans=true;
			break;
		}
	}
	return dp[stones]=ans;
}	

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	vec.resize(n);
	dp.assign(k+1,-1);
	for(int i=0; i<n; i++)
	{
		cin>>vec[i];
	}
	if(solve(k))
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}


Measured memory_bytes: 5376
# ABC073D - joisino's travel
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
    dist = [float("inf")] * size
    queue = [(0, start)]
    heapify(queue)
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for u, next_cost in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (cost + next_cost, u))
    return dist


def main():
    global G, N
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, c in zip(*[iter(ABC)] * 3):
        G[v].append((u, c)), G[u].append((v, c))
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9828
#include<stdio.h>
#include<string.h>
int up(const void *a,const void *b){
  return *(char *)a-*(char*)b;
}
int down(const void *a,const void *b){
  return *(char *)b-*(char*)a;
}
int main(){
  char s[110],t[110];
  scanf("%s%s",s,t);
  qsort(s,strlen(s),sizeof(char),up);
  qsort(t,strlen(t),sizeof(char),down);
  if(strcmp(s,t)<0)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin,c.end()
#define tr(c,i) for(typeof(c).begin() i=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

void solve(){
    int n;
    cin>>n;
    ll ans=0;
    rep1(i,n) if(i%3!=0 && i%5!=0) ans+=i;
    cout<<ans;
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 3644