akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

NUM = [2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-float('inf') for _ in range(N + 1)]
dp[0] = 0

for i in range(1, N + 1):
    for a in A:
        if i - NUM[a - 1] >= 0:
            dp[i] = max(dp[i], dp[i - NUM[a - 1]] + 1)

dights = dp[N]
ans = ""
matchsticks = N
while(dights > 0):
    for a in A:
        if matchsticks - NUM[a - 1] >= 0 and dp[matchsticks - NUM[a - 1]] == dights - 1:
            ans += str(a)
            dights -= 1
            matchsticks -= NUM[a - 1]
            break

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=200010;

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

    ll n,k;
    cin>>n>>k;
    ll ar[n+1];
    for(ll i=1;i<=n;++i){cin>>ar[i];}

    ll dp[n+1][k+1];
    ll presum[n+1][k+1];

    dp[0][0]=1;
    presum[0][0]=1;
    for(ll i=1;i<=n;++i){dp[i][0]=1;presum[i][0]=1;}
    for(ll j=1;j<=k;++j){dp[0][j]=0;presum[0][j]=1;}

    for(ll i=1;i<=n;++i)
    {
        for(ll j=1;j<=k;++j)
        {
            if(j-ar[i]>0){
                dp[i][j]=(presum[i-1][j]-presum[i-1][j-ar[i]-1]+M)%M;
            }
            else{
                dp[i][j]=presum[i-1][j];
            }
            presum[i][j]=(presum[i][j-1]+dp[i][j])%M;
        }
    }

    cout<<dp[n][k];

    return (0);
}


Measured memory_bytes: 158080
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << a[k - 1] << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
x = []
y = []
for i in range(10):
    n = int(input())
    x.append(n)
    x = sorted(x)
p=x[7:10]
for i in range(10):
    n = int(input())
    y.append(n)
    y = sorted(y)
q=y[7:10]
print(sum(p),sum(q))



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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	string s; cin >> s;
	ll res = 0;
	for (int i = 0; i < s.length() - 1; ++i)
	{
		if (s[i + 1] == s[i])
		{
			res += 1;
			i += 2;
		}
		
	}
	cout << s.length() - res << endl;
}

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


Measured memory_bytes: 3692
#include <iostream>

using namespace std;

int num_elem;

void maxheapfy(int* array, int index)
{
    int l = 2 * index + 1 < num_elem ? 2 * index + 1 : -1;
    int r = 2 * index + 2 < num_elem ? 2 * index + 2 : -1;
    if(l == -1 && r == -1) return;
    int largest = index;
    if(array[largest] < array[l])
    {
        largest = l;
    }
    if(r != -1 && array[largest] < array[r])
    {
        largest = r;
    }
    if(largest != index)
    {   
        swap(array[largest], array[index]);
        maxheapfy(array, largest);
    }
}

void buildmaxheap(int* array)
{
    for(int i=(num_elem) / 2 - 1; i >= 0; --i)
    {
        maxheapfy(array, i);
    }
}

int main()
{
    int array[500001];
    cin >> num_elem;
    for(int i=0;i<num_elem;++i) cin >> array[i];
    buildmaxheap(array);
    for(int i=0;i<num_elem;++i) cout << " " << array[i];
    cout << endl;
}



Measured memory_bytes: 5012
// #define int long long
// #define repeat(i, n) for (int i = 0; i < n; ++i)

#include <cmath> // cmath includes sqrt, abs
#include <iostream> // iostream includes cout, endl
#include <string> // string
#include <algorithm> // algorithm includes sort

#include <set>

using namespace std;

int main() {
  bool can = false;
  int num = 0;
  string S;
  int N;

  int K;
  int l[50];

  cin >> N >> K;
  for (int i = 0; i < N; ++i) cin >> l[i];

  sort(l, l + N, greater<int>());

  for (int i = 0; i < K; ++i) {
    num += l[i];
  }
  
  cout << num << endl;
  
  // if (can) cout << "Yes" << endl;
  // else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N;
  string S;
  cin >> N >> S;
  int pre[N+1],suf[N+1];
  pre[0] = suf[N] = 0;
  int i;REP(i,N){
    int rev = 0;
    if(S[i]=='W') rev = 1;
    pre[i+1] = pre[i] + rev;
    rev = 0;
    if(S[N-i-1]=='E') rev = 1;
    suf[N-i-1] = suf[N-i] + rev;
  }
  int min = MAX_I;
  REP(i,N){
    if(pre[i] + suf[i+1]<min) min = pre[i]+suf[i+1];
  }
  cout << min << endl;
  return 0;
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


const ll MOD = 1000000007;
void solve(ll N, string S){
    vector<pair<char, ll>> P;
    rep(i, sz(S)) {
        vector<char> c;
        rep(j, sz(P)) {
            c.push_back(P[j].first);
        }
        if(is(find(c.begin(), c.end(), S[i]), c.end())) {
            P.push_back(make_pair(S[i], 1));
        } else {
            rep(j, sz(P)) {
                if (is(P[j].first, S[i])) {
                    P[j].second++;
                }
            }
        }
    }
    ll ans = 1;
    rep(i, sz(P)) {
        ans *= (P[i].second + 1);
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}

int main() {
    ll N;
    scanf("%lld",&N);
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    // Your code here!
    // Your code here!
    
    int N;
    char S[101];
    int result = 1;
    
    
    scanf("%d", &N);
    scanf("%s", S);
    
    
    if (N==1 | N % 2 == 1) {
        result = 0;
    }
    
    for(int i=0; i<N/2; i++) {
        if (S[i] != S[i+N/2]) {
            result = 0;
        }
    }
    
    if (result == 1) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main(){
  int n;
  int l, r;
  int sum = 0;
  
  std::cin >> n;
  
  for (int i=0; i<n; i++){
    std::cin >> l >> r;
    sum += (r+1 - l);
  }
  
  std::cout << sum << std::endl;
  return 0;
}

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

namespace ConsoleApp1
{
    static class ABeginner
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var n = int.Parse(s[0]);
            var r = int.Parse(s[1]);

            int rateInner;

            if (10 <= n)
            {
                rateInner = r;
            }
            else
            {
                rateInner = 100 * (10 - n) + r;
            }            

            Console.WriteLine(rateInner);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

w,a,b = map(int,input().split())
l = max(a,b)
s = min(a,b)
print(max(l-s-w,0))

Measured memory_bytes: 3316
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

sum = 0
xor_sum = 0
cnt = 0
r = 0

for l in range(N):
    while r < N and (sum + A[r] == (xor_sum ^ A[r])):
        sum += A[r]
        xor_sum ^= A[r]
        r += 1
    cnt += r - l
    sum -= A[l]
    xor_sum ^= A[l]

print(cnt)


Measured memory_bytes: 23560
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;

const int N=100005;

int n,t,k;
ll mx,ans;
int a[N];
ll dp1[N],dp2[N],s[N],f[N];

int main(){
	int i;
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) s[i]=s[i-1]+1ll*a[i];
	for (i=1;i<=n;i++) dp1[i]=dp1[i-1]+max(a[i],0);
	for (i=n;i>=1;i--) dp2[i]=dp2[i+1]+max(a[i],0);
	for (i=1;i+k<=n;i++){
		ans=max(ans,dp1[i-1]+dp2[i+k]);
		ans=max(ans,dp1[i]+dp2[i+k+1]);
	}
	dp1[0]=dp1[n+1]=dp2[0]=dp2[n+1]=0;
	for (i=1;i<=n;i++) f[i]=max(f[i-1],dp1[i]-s[i]);
	for (i=n+1;i>k;i--){
		ans=max(ans,dp2[i]+f[i-k-1]+s[i-1]);
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 3712
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> S;
    std::vector<int64_t> PS;
    int64_t s = 0;
    int64_t ps = 0;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        s += t;
        S.push_back(s);

        if (t > 0) {
            ps += t;
        }
        PS.push_back(ps);
    }

    int64_t ans = 0;

    for (int64_t i = 0; i <= N - K; ++i) {
        int64_t v = 0;

        if (i == 0) {
            v += S[K-1] > 0 ? S[K-1] : 0;
            v += PS[N-1] - PS[K-1];
        }
        else {
            v += PS[i-1];
            v += S[i+K-1] - S[i-1] > 0 ? S[i+K-1] - S[i-1] : 0;
            v += PS[N-1] - PS[i+K-1];
        }
        ans = std::max(ans, v);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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 Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	REP(i, h) cin >> s[i];

	Array flag(h, false);
	ll min = INF;

	ll num = 1;
	Matrix ans(h, Array(w, 0));

	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == '#') {
				flag[i] = true;
				chmin(min, i);
				break;
			}
		}
		if (flag[i]) {
			bool flag2 = false;
			REP(j, w) {
				if (s[i][j] == '#') {
					if (flag2) {
						num++;
						ans[i][j] = num;
					}
					else {
						flag2 = true;
						ans[i][j] = num;
					}
				}
				else {
					ans[i][j] = num;
				}
			}
			num++;
		}
	}

	REP(i, h) {
		if (!flag[i]) {
			if (i <min) {
				REP(j, w) {
					ans[i][j] = ans[min][j];
				}
			}
			else {
				REP(j, w) {
					ans[i][j] = ans[i-1][j];
				}
			}
		}
	}

	for (auto i : ans) {
		for (auto j : i) {
			cout << j << " ";
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
 int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);}
  vector<int> distances(N);
  for(int i=0;i<N-1;i++){
    distances.at(i)=A.at(i+1)-A.at(i);}

  distances.at(N-1)=K-A.at(N-1)+A.at(0);
      sort(distances.begin(), distances.end()); // {1, 2, 2, 5}
    reverse(distances.begin(), distances.end()); // {5, 2, 2, 1}
cout<<K-distances.at(0)<<endl;
  }



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)

int main() {

    int h,w;
    int a[10010];
    int n;

    int cnt = 0;


    scanf("%d %d", &h, &w);
    scanf("%d", &n);

    Repe(i,n+1,1){
            scanf("%d", a+i);
    }
    int col = 1;

    int ans[101][101];

    Rep(i, h){
        if( i % 2 == 1 ){
            for (int j = 0; j < w; j++){
                if( cnt == a[col]){
                    col++;
                    cnt = 0;
                }
                cnt++;
                ans[i][j] = col;
            }
        }else{
            for (int j = w-1; j >= 0; j--){
                if( cnt == a[col]){
                    col++;
                    cnt = 0;
                }
                cnt++;
                ans[i][j] = col;
            }
        }
    }

    Rep(i,h){
        Rep(j,w){
            printf ("%d", ans[i][j]);
            if( j != w-1 ) printf (" ");
        }
        printf ("\n");
    }

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <functional>
    #include <queue>
    #include <deque>
    #include <string>
    #include <stack>
    #include <unordered_set>
    #include <cmath>
    #include <climits>
    #include <cstdlib>
    #define endl '\n'
    #define ll long long
    #define mod 1000000007
    #define NCONS 201
    #define PLUS 0
    #define MINUS 1
     
    using namespace std;
     
    int main(void)
    {
    	cin.tie(NULL); ios_base::sync_with_stdio(false);
     
    	string str; cin >> str;
     
    	if ((str[0] == str[1] && str[1] == str[2]) || (str[1] == str[2] && str[2] == str[3]))
    		cout << "Yes";
    	else
    		cout << "No";
     
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int d[90005];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W,D,Q;
  cin >> H >> W >> D;
  vector<pair<int, int>> p(H*W);
  REP(h,H){
    REP(w,W){
      int v;
      cin >> v;
      p[v-1] = make_pair(h,w);
    }
  }
  
  FOR(i,D+1,H*W+1){
    d[i] = d[i-D] + abs(p[i-1].first - p[i-D-1].first) + abs(p[i-1].second - p[i-D-1].second);
  }
  cin >> Q;
  REP(i,Q){
    int L,R;
    cin >> L >> R;
    cout << d[R] - d[L] << '\n';
  }
  return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    string s;
    cin >> s;

    if (s.size() % 2 == 0 && s[0] == s[s.size() -1]) {
        put("First");
    }
    else if (s.size() % 2 == 1 && s[0] != s[s.size() - 1]) {
        put("First");
    }
    else {
        put("Second");
    }
    
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);

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

	return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    char S[N];
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    int flag = 0;

    for(int i = 0; i < N; i++) {
        if(S[i] == 'Y') {
            flag =1;
            break;
        }
    }

    if(flag == 0) {
        cout << "Three";
    }
    else {
        cout << "Four";
    }
    
    cout << endl;
    return 0;
}

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

int dp[200100]={};

int main(){
    int N; cin >> N;
    int p[N];
    int ind[N+1];
    for(int i=0;i<N;i++){
        cin >> p[i];
        ind[p[i]]=i;
    }
    bool used[N+1]={};
    used[p[0]]=true;
    dp[0]=1;
    for(int i=1;i<N;i++){
        if(used[p[i]-1]){
            dp[i]=dp[ind[p[i]-1]]+1;
            used[p[i]]=true;
        }else{
            used[p[i]]=true;
            dp[i]=1;
        }
    }
    int ans=0;
    /*
    for(int i=0;i<N;i++){
        cout << dp[i] << " ";
    }
    */
    cout << endl;
    for(int i=0;i<N;i++){
        ans=max(dp[i],ans);
    }
    cout << N-ans << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int MAX_V = 10000;

struct edge{
  int to,cap,cost,rev;
};

vector<edge> G[MAX_V];
int dist[MAX_V];
int h[MAX_V]; // ポテンシャル

// 直前の頂点と辺
int prevv[MAX_V];
int preve[MAX_V];

const int INF = 1000000000;
// firstは最短距離、secondは頂点の番号
typedef pair<int,int> P;
// fromからtoへむかう容量cap,コストcostの辺をグラフに追加する。
void add_edge(int from,int to,int cap,int cost){	
  edge e;
  e.to = to,e.cap = cap,e.cost = cost,e.rev = G[to].size();
  G[from].push_back(e);

  e.to = from,e.cap = 0,e.cost = -cost,e.rev = G[from].size()-1;
  G[to].push_back(e);
}

// sからtへの流量fの最小費用流を求める
// ながせない場合は-1を返す
int min_cost_flow(int s,int t,int f,int V){
  int res = 0;
  fill(h,h+V,0);
  // 流量が限界に達するまで流す
  while(f > 0){
    // ダイクストラ法で、最短距離を検索
    priority_queue<P,vector<P>,greater<P> > que;
    fill(dist,dist+V,INF);
    dist[s] = 0;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top();
      que.pop();
      int v = p.second;
      if(dist[v] < p.first)
	continue;
      for(int i = 0; i < G[v].size(); i++){
	edge &e = G[v][i];
	if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
	  dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  que.push(P(dist[e.to],e.to));
	}
      }
    }
    if(dist[t] == INF)
      return -1;
    for(int i = 0; i < V; i++)
      h[i] += dist[i];
    int d = f;
    for(int v = t; v != s; v = prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d*h[t];
    for(int v = t; v != s; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int n;
int W[101][101];
int E[101][101];
bool field[101][101];
bool fin[101][101];

int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>W[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>E[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      char ch;
      cin>>ch;
      if(ch=='o')field[i][j]=true;
      else field[i][j]=false;
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int cost=0;
      for(int k=0;k<n;k++){
	if(k!=j){
	  if(field[i][k])
	    cost+=E[i][k];
	}
      }
      for(int k=0;k<n;k++){
	if(k!=i){
	  if(field[k][j])
	    cost+=E[k][j];
	}
      }
      if(!field[i][j])cost+=2*W[i][j];
      add_edge(i,j+n,1,cost);
    }
  }
  const int s=2*n;
  const int t=2*n+1;
  for(int i=0;i<n;i++)add_edge(s,i,1,0);
  for(int i=0;i<n;i++)add_edge(i+n,t,1,0);
  int a=min_cost_flow(s,t,n,2*n+2);
  cout<<a/2<<endl;
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)G[i].size();j++){
      edge &e=G[i][j];
      if(e.to>=n&&e.to<2*n){
	if(e.cap==0)fin[i][e.to-n]=true;
	else fin[i][e.to-n]=false;
      }
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(field[i][j]^fin[i][j])cnt++;
  cout<<cnt<<endl;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(field[i][j]&&!fin[i][j])
	cout<<i+1<<" "<<j+1<<" erase"<<endl;
      else if(!field[i][j]&&fin[i][j])
	cout<<i+1<<" "<<j+1<<" write"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1984
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 520
using namespace std;
struct node{
	int x,id,sum;
}b[N];
int ans[N*N],p[N];
int n,a[N],head,tot;
bool cmp(node x,node y){
	return x.x<y.x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i].x=a[i];
		b[i].id=i;
		b[i].sum=n-i;
	}
	sort(b+1,b+1+n,cmp);
	head=1;
	int sum=0;
	for(int i=1;i<=n;i++){
		int k=b[i].x;
		int o=b[i].id;
		int tot=0;
		for(int i=1;i<=k-1;i++){
			if(tot==o-1)break;
			if(ans[i]==0)ans[i]=o,tot++;
		}
		ans[k]=o;
	}
	for(int i=1;i<=n*n;i++){
		if(ans[i])continue;
		if(head==n&&b[head].sum==0)break;
		while(b[head].sum==0&&head<n)head++;
		b[head].sum--;
		ans[i]=b[head].id;
	}
	for(int i=1;i<=n*n;i++){
		p[ans[i]]++;
		if(ans[i]==p[ans[i]]){
			if(a[ans[i]]!=i){
				printf("No\n");
				exit(0);
			}
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n*n;i++)printf("%d ",ans[i]);
}

Measured memory_bytes: 2176
#include <stdio.h>
 
int main(){
    int n, x;
    int a, b, c, ans;
    while(1){
        scanf("%d%d", &n, &x);
        if(n == 0 && x == 0){break;}
         
        ans = 0;
for(a = 1; a <= n; a++){
for(b = a; b <= n; b++){
for(c = b; c <= n; c++){
if(a == b || b == c || c == a){
continue;
                    }
                    if(x == a + b + c){
                 //       printf("%d,%d,%d\n",a,b,c);
                        ans++;
                    }
                }
            }    
        }
         
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	int a[3];
	REP(i, 3)cin >> a[i];
	sort(a, a + 3);
	int ans = 0;
	ans += a[2] - a[1];
	if ((a[1] - a[0]) % 2 == 0) {
		ans += (a[1] - a[0]) / 2;
	}
	else {
		ans += (a[1] - a[0] + 1) / 2;
		ans++;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int min = Integer.MAX_VALUE;
    for (int i = -100; i <= 100; i++) {
      int cost = 0;
      for (int j = 0; j < n; j++) {
        cost += (a[j] - i) * (a[j] - i);
      }
      if (cost < min) {
        min = cost;
      }
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
 
int main() {      
    int K;
    std::cin >> K;

    std::string S;
    std::cin >> S;

    std::string ret;
    if (static_cast<int>(S.size()) <= K) {
        ret = S;
    } else {
        ret = S.substr(0, K) + "...";
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

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

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

string s, t;
int n, m;
string a;
vector<int>v[26];
int ans = 0;
signed main() {
	cin >> s >> t;
	int n = s.size(), m = t.size();
	a = s;
	sort(all(a));
	rep(i, m) {
		if (!binary_search(all(a), t[i])) {
			cout << -1 << endl;
			return 0;
		}
	}
	rep(i, n) {
		int a = s[i] - 'a';
		v[a].push_back(i);
	}
	int b;
	rep(i, m) {
		int a = t[i] - 'a';
		if (i == 0) {
			ans += v[a][0];
			b = v[a][0];
		}
		else {
			int c = upp(all(v[a]), b) - v[a].begin();
			//cout << c << " ";
			if (c < v[a].size()) {
				ans += (v[a][c] - b);
				b = v[a][c];
			}
			else {
				ans += n - b + v[a][0];
				b = v[a][0];
			}
		}
		//cout << b << endl;
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int r, d, x;
    cin >> r >> d >> x;
    
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

int main(void)
{
	fast;
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	ll k, a, b; cin >> k >> a >> b;
	if (b <= a+2)
	{
		cout << k+1 << endl;
		return 0;
	}
	if (k <= a-1)
	{
		cout << k+1 << endl;
		return 0;
	}
	ll have = a;
	ll rem = k - (a-1);
	ll extra = b-a;
	have += extra*(rem/2);
	have += rem%2;
	cout << have << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


 int main(){int i,l,u,S[13],H[13],C[13],D[13];
 	char t;
 	for(i=0;i<=12;i++){
 	S[i]=0;H[i]=0;C[i]=0;D[i]=0;
 	};
 	scanf("%d",&l);
 	for(i=0;i<l;i++){
 		scanf(" %c %d",&t,&u);
 		if(t=='S'){S[u-1]=1;};
 		if(t=='H'){H[u-1]=1;};
 		if(t=='D'){D[u-1]=1;};
 		if (t=='C'){C[u-1]=1;};
 	};
 	for(i=0;i<13;i++){if(S[i]==0){printf("S %d\n",(i+1));};};
 	for(i=0;i<13;i++){if(H[i]==0){printf("H %d\n",(i+1));};};
 	for(i=0;i<13;i++){if(C[i]==0){printf("C %d\n",(i+1));};};
 	for(i=0;i<13;i++){if(D[i]==0){printf("D %d\n",(i+1));};};
 
 return 0;}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

int main() {
	int N;
	scanf("%d", &N);
	int a[50];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	bool trade[50];
	bool pos = true;
	SET_ZERO(trade);
	
	int *maxp = max_element(a, a+N);
	int *minp = min_element(a, a+N);
	int basei = (abs(*maxp) < abs(*minp))?minp-a:maxp-a;
	int base = a[basei];
	
	for (int i = 0; i < N; i++) {
		a[i] += base;
	}
	if (a[0] < 0 || a[1] < 0) pos = false;
	if (pos) {
		for (int i = 1; i < N; i++) {
			if (a[i-1] > a[i]) {
				cnt++;
				a[i] += a[i-1];
				trade[i] = true;
			}
		}
	} else {
		for (int i = N-2; i >= 0; i--) {
			if (a[i] > a[i+1]) {
				cnt++;
				a[i] += a[i+1];
				trade[i] = true;
			}
		}
	}

	printf("%d \n", cnt + N);	
	for (int i = 0; i < N; i++) {
		if (i != basei) printf("%d %d\n", basei+1, i+1);
	}
	printf("%d %d\n", basei+1, basei+1);
	if (pos) {
		for (int i = 0; i < N; i++) {
			if (trade[i]) printf("%d %d\n", i-1+1, i+1);
		}
	} else {
		for (int i = N-1; i >= 0; i--) {
			if (trade[i]) printf("%d %d\n", i+1+1, i+1);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<lint> A_list(N);
    range(i, 0, N) cin >> A_list.at(i);
    vec<lint> pref_sum(N);
    pref_sum.at(0) = A_list.at(0);
    range(i, 1, N) pref_sum.at(i) = pref_sum.at(i - 1) + A_list.at(i);
    lint len = pref_sum.at(N - 1);
    lint ans = 1LL << 58;
    range(i, 0, N - 1) {
        lint left = pref_sum.at(i);
        lint right = len - left;
        ans = min(ans, abs(left - right));
        // cout << left << " " << right << "\n";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3328
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int r , g , b , n;

int main() {
    mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> r >> g >> b >> n;
    int answ = 0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(r * i + j * g > n)continue;
            int x = n - r * i - j * g;
            if(x % b == 0){
                ++answ;
            }
        }
    }
    cout << answ << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

   using namespace std;

  int main(void)
  {
	  int n, t, a[1000],b[1000],i,mini;
	  cin >> n>>t;
	  for (i = 0; i < n; i++)
		  cin >> a[i] >> b[i];
	  mini = 1001;
	  for (i = 0; i < n; i++)
	  {
		  if (b[i] <= t)
		  {
			  if (a[i] <= mini)
				  mini = a[i];
		  }
	  }
	  if (mini == 1001)
		  cout << "TLE";
	  else
		  cout << mini;
	  return 0;
  }



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        a: f64, b: f64, h: f64, m: f64
    }

    let mut thita = ((h * 30. + m / 2.) - (m * 6.)).abs().to_radians();
    if thita > 180. {
        thita = 360. - thita;
    }
    dbg!(thita);
    dbg!(thita.cos());
    let ans = (a.powi(2) + b.powi(2) - 2. * a * b * thita.cos()).sqrt();
    println!("{}", ans);
}


Measured memory_bytes: 3004
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    L = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            L[j] += 1

    res = 0
    for i in range(1, n + 1):
        res += i * L[i]
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 151488
H, W = map(int, input().split())
A = ""
inf = 1e5
cnt = {}
ans = "Yes"
for i in range(H):
    a = input()
    A += a

for a in A:
    if a not in cnt.keys():
        cnt[a] = 1
    else:
        cnt[a] += 1
jud = [inf, 0, 0, 0]
if H % 2 == 1 and W % 2 == 1:
    jud[2] = H//2+W//2
    jud[1] = 1
elif H % 2 == 1:
    jud[2] = W//2
elif W % 2 == 1:
    jud[2] = H//2
for i in cnt.values():
    b = i % 4
    jud[b] -= 1
    if jud[b] < 0:
        ans = "No"
print(ans)


Measured memory_bytes: 9228
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	/** 最大数 */
	static final int MAX = 55555;

	/** 合計を計算する数字の数 */
	static final int N = 5;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			// MAXまでのすべての素数を計算
			boolean[] isPrime = new boolean[MAX + 1];
			Arrays.fill(isPrime, true);
			isPrime[0] = isPrime[1] = false;
			IntStream.range(2, MAX).forEach(i -> {
				if (isPrime[i]) {
					for (int j = i * 2; j <= MAX; j += i) {
						isPrime[j] = false;
					}
				}
			});
			@SuppressWarnings("unchecked")
			List<Integer>[] lists = new List[N];
			IntStream.range(0, N).forEach(i -> lists[i] = new ArrayList<>());
			IntStream.range(2, MAX).filter(i -> isPrime[i]).forEach(i -> lists[i % N].add(i));
			int index = IntStream.range(1, N).filter(i -> lists[i].size() >= n).findFirst().getAsInt();
			IntStream.range(0, n).forEach(i -> System.out.println(lists[index].get(i)));
		}
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  //sort(A.begin(), A.end());
  int Q;
  cin >> Q;
  vector<int> B(Q), C(Q);
  for(int i = 0; i < Q; ++i){
    cin >> B.at(i) >> C.at(i);
  }
  /*
  for (int i = 0; i < Q; ++i){
    vector<int>::iterator it_s = lower_bound(A.begin(),A.end(),B.at(i));
    vector<int>::iterator it_e = upper_bound(A.begin(),A.end(),B.at(i));
    for(vector<int>::iterator itr = it_s; itr < it_e; ++itr){
      *itr = C.at(i);
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
  }
  */
  vector <long long> count(10*10*10*10*10 + 1, 0);
  for(int i = 0; i < N; ++i){
    ++count.at(A.at(i));
  }
  long long sum = accumulate(A.begin(), A.end(), 0LL);
  for(int i = 0; i < Q; ++i){
    sum += (long long)C.at(i) * count.at(B.at(i)) - (long long)B.at(i) * count.at(B.at(i));
    count.at(C.at(i)) += count.at(B.at(i));
    count.at(B.at(i)) = 0;
    cout << sum << endl;
  }
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double w,h,x,y;
  cin >>w>> h>> x >> y;
auto ans = w*h/2;
  
  if(x==w/2 && y==h/2)
    cout << ans << " "<< 1  <<endl;
  else
    cout << ans << " "<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v vector<long long>
#define f first
#define s second
#define pb push_back

using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin>>n;
    ll x=0,a;
    for(ll i=0;i<n;i++)
    {
        cin>>a;
        x=x^a;
    }
    if(x==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=2e5+5;
int n,k;
ll sum[N];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+i;
    ll ans=0;
    while(k<=n+1)
    {
        ll l=sum[k-1];
        ll r=sum[n]-sum[n-k];
        ans=(ans+r-l+1)%mod;
        k++;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 5320
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    int N,rs = 0;
    cin >>N >> s;

    for(int i = 0;i < s.size() - 2;i++){
        if(s.at(i) == 'A' and s.at(i+1) == 'B' and s.at(i+2) == 'C')
            rs++;
    }

    cout << rs << endl;
    

}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> a[i][j];
        }
        
    }
    vector<vector<char>>b(H+2,vector<char>(W+2));
    for (int i = 0; i < H+2; i++)
    {
        for (int j = 0; j < W+2; j++)
        {
            if (i==0||i==H+1)
            {
                b[i][j]='#';
            }
            else
            {
                if (j==0||j==W+1)
                {
                    b[i][j]='#';
                }
                else
                {
                    b[i][j]=a[i-1][j-1];
                }
                
            }
            
        }
        
    }
    for (int i = 0; i < H+2; i++)
    {
        for (int j = 0; j < W+2; j++)
        {

            
            cout<<b[i][j];
            if (j==W+1)
            {
                cout<<endl;
            }
            

        }
        
    }
    
    


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//



     signed main(){
  int d;
  clock_t st=clock();
  cin>>d;
    clock_t ed=clock();
random_device seed_gen;
default_random_engine engine(seed_gen());
  int c[26];
  for(int i=0;i<26;i++)cin>>c[i];
  int t[d],s[d][26],x[26]={};
    vector<int>v[26];
    for(int i=0;i<26;i++)v[i].push_back(-1);

  for(int i=0;i<d;i++)for(int j=0;j<26;j++)cin>>s[i][j];
   // cerr<<'i';
  for(int i=0;i<d;i++){
      for(int j=0;j<26;j++)x[j]+=c[j];
      int k=0;
      for(int j=1;j<26;j++)if(x[k]+s[i][k]<x[j]+s[i][j])k=j;
      t[i]=k;
      x[k]=0;
      v[k].push_back(i);
  }
  for(int i=0;i<26;i++)v[i].push_back(d);
//for(int i=0;i<d;i++)cout<<t[i]+1<<endl;
  // cerr<<double(clock()-st)/CLOCKS_PER_SEC<<endl;
while(double(clock()-st)/CLOCKS_PER_SEC<1.90){
    int p=rand()%d;
    auto q=find(v[t[p]].begin(),v[t[p]].end(),p);
    q++;
  // int m=(p+(*q))/2;
 //  int m=p+rand()%((*q)-p);
   if((*q)-p==1)continue;
   binomial_distribution<> dist((*q)-p-1,0.5);
   int m=p+dist(engine);
//cerr<<m<<' '<<p<<endl;
   if(m==p)continue;
   auto r1=find(v[t[m]].begin(),v[t[m]].end(),m);
   auto r0=r1-1,r2=r1+1;
   if((m-p)*((*q)-m)*c[t[p]]+s[m][t[p]]>(m-(*r0))*((*r2)-m)*c[t[m]]+s[m][t[m]]){
 
    v[t[p]].insert(q,m);
    v[t[m]].erase(r1);
    t[m]=t[p];
   }




}
     for(int i=0;i<d;i++)cout<<t[i]+1<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 4256