akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = 200005;
int n, a[N];

bool check(int mid) {
	map<int, int> b;
	for (int i = 2; i <= n; ++i) {
		while (!b.empty() && b.rbegin()->first >= a[i])
			b.erase(--b.end());
		if (a[i] <= a[i - 1]) {
			++b[a[i] - 1];
			for (int j = a[i] - 1; b.count(j) && b[j] == mid; --j) {
				b.erase(j);
				if (j == 0) return false;
				++b[j - 1];
			}
		}
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	bool flag = true;
	for (int i = 2; i <= n; ++i)
		flag &= a[i] > a[i - 1];
	if (flag) return puts("1"), 0;
	int l = 2, r = n;
	while (l < r) {
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", r);
	return 0;
}


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

int n;
const long long mod=1e9+7;
long long inv[1000010];

int main(){
	scanf("%d",&n);
	inv[1]=1;for(int i=2;i<=n;i++) inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	long long ans=0,data=1,x=333333336;
	for(int i=1;i<=n;i++) (data*=x)%=mod,ans+=data*inv[n]%mod*inv[n-i+1]%mod;
	printf("%lld\n",ans%mod);
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<si> vsi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vsi> vvsi;


// bool sieve[100005];

// void sieveoferat()
// {
// 	for(ll p = 2; p*p<100005 ; p++)
// 	{
// 		if(sieve[p])
// 		{
// 			for(int j = p*p; j<100005; j+=p)
// 				sieve[j] = false;
// 		}
// 	}
// }

// void dp(sp_1, sp_2.....)
// {
// 	if()//exit statement
// 	if()//using the memoization 
// 	ll ans = //default/dummy answer
// 	//recursions
// 			//max/min
// 	return memo[][].. = ans;

// }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	//memset(memo, -1, sizeof memo);
 	// memset(sieve, true, sizeof sieve);
 	// sieveoferat();
 	int n, x,j;
 	cin>>n>>x;
 	ll a[n+1];
 	a[0] = 0;
 	int c = 1;
 	for(int i = 1 ; i <=n; i++)
 	{
 		cin>>j;
 		a[i] = j+a[i-1];
 		if(a[i]<=x)
 			c++;
 	}
 	cout<<c<<endl;
	return 0;
}

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

using namespace std;
#define int long long
bool comp(pair <int,int> a,pair <int,int> b)
{
  a.first++;
  b.first++;
    return (a.second*b.first+b.first+b.second)<(b.second*a.first+a.first+a.second);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,t;
    cin>>n>>t;
    vector <int> v;
    vector <pair <int,int> > a;
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        if(x==0)
        {
            v.push_back(y);
        }
        else
        {
            a.push_back({x,y});
        }
    }
    sort(a.begin(),a.end(),comp);
    vector <int> res(40);
    res[0]=0;
    for(int i=1;i<40;++i)
    {
        res[i]=(t+1);
    }
    int sz=a.size();
    for(int i=0;i<sz;++i)
    {
        //cout<<" upd "<<a[i].first<<" "<<a[i].second<<endl;
        for(int j=38;j>=0;j--)
        {
            res[j+1]=min(res[j+1],a[i].first*(res[j]+1)+a[i].second+res[j]+1);
        }
    }
    int sz2=v.size();
    sort(v.begin(),v.end());
    vector <int> pr1(sz2+1);
    pr1[0]=0;
    for(int i=0;i<sz2;++i)
    {
        pr1[i+1]=pr1[i]+v[i]+1;
    }
    int ans=0;
    for(int j=0;j<39;++j)
    {
        if(res[j]<=t)
        {
            //cout<<j<<" res[j] "<<res[j]<<endl;
            ans=max(ans,j);
            ans=max(ans,(int) (j+(upper_bound(pr1.begin(),pr1.end(),t-res[j])-pr1.begin()))-1);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <stdio.h>
using namespace std;
double sumofs(double);

int main(){
    double x,y;
    while (cin >>x){
        if (cin.eof()){break;}
        y = sumofs(x);
        printf("%.7f\n",y);
    }
}

double sumofs(double x){
    double a[10];
    double sum=0;
    a[0] = x;

    for (int i=0;i<9;i++){
        if(i%2==0)
            a[i+1]=a[i]*2;
        else
            a[i+1]=a[i]/3;
    }
    for (int j=0;j<10;j++)
        sum +=a[j];
    return sum;
}

Measured memory_bytes: 1236
n = gets.chomp
exit 1 unless n
a = gets
exit 1 unless a
n = n.to_i
a = a.to_i

if n >= 500
  mod = n % 500
  if a >= mod
    puts 'Yes'
  else
    puts 'No'
  end
else
  if a >= n
    puts 'Yes'
  else
    puts 'No'
  end
end

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

using namespace std;

int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if (N >= K)
    cout << (N - K) * Y + K * X << endl;
    else 
        cout << N * X << endl;
    return 0; 
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val X = readLine()!!.toInt()
    val isPrime = BooleanArray(100004) { true }
    isPrime[0] = false; isPrime[1] = false
    for (i in 2..100003) {
        if (isPrime[i]) {
            for (j in (i * 2)..100003 step i) isPrime[j] = false
        }
    }

    for (k in X..100003) {
        if (isPrime[k]) {
            println(k)
            break
        }
    }
}

Measured memory_bytes: 33984
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


int main() {
    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int prev, start;
    vector<int> v;
    prev = s[0];
    if (s[0] == '0') {
        v.push_back(0);
    }
    int i = 0;
    while (true) {
        int count = 0;
        while (i < s.length() && s[i] == prev) {
            count++;
            i++;
        }
        v.push_back(count);

        if (i >= s.length()) {
            break;
        }

        prev = s[i];
    }

    if (s[n - 1] == '0') {
        v.push_back(0);
    }

    // for (int kk = 0; kk < v.size(); kk++) {
    //     cout << v[kk] << ' ';
    // }
    // cout << endl;

    int total = 0;
    int l = 0, r = 2 * k;
    if (r >= v.size()) {
        r = v.size() - 1;
    }

    for (int jj = l; jj <= r; jj++) {
        total += v[jj];
    }

    int max = total;
    l += 2; r += 2;
    while (r < v.size()) {
        total += - v[l - 2] - v[l - 1] + v[r - 1] + v[r];
        if (total > max) {
            max = total;
        }
        l += 2; r += 2;
    }

    cout << max << endl;    

    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans="AC";
  if(s.at(0)!='A'){ans="WA";}
  int Ccount=0;
  for(int i=1;i<s.size();i++){
    if(s.at(i)=='C'){Ccount++;}
    else if((int)(s.at(i))-96<0){ans="WA"; break;}
  }
  if(Ccount!=1){ans="WA";}
  if(s.at(1)=='C'||s.at(s.size()-1)=='C'){ans="WA";}
  cout<<ans;
}

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

namespace OJcsharp
{
    class Program
    {
        static void Main(string[] args)
        {

            //31.29.31.30.31.30.31.31.30.31.30.31
            int[] sei = new int[101];
            int saidai = 0;
            for (int n = 0; n < 101; n++)
                sei[n] = 0;
            string str=Console.ReadLine();
            do
            {
                if (saidai < int.Parse(str))
                    saidai = int.Parse(str);
                sei[int.Parse(str)]++;
                str = Console.ReadLine();
            } while (string.IsNullOrEmpty(str) == false);
            int saihin = 0;
            for (int n = 1; n < saidai + 1; n++)
            {
                if (saihin < sei[n])
                    saihin = sei[n];
            }
            for (int n = 1; n < saidai + 1; n++)
            {
                if (saihin == sei[n])
                    Console.WriteLine(n);
            }
        }
    }
}

Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;


vector <int> v;
void compute(int len)
{
	int k = pow(3,len);
	int i;
	fr(i,0,k)
	{
		int mask = i;
		int p = 1, res = 0;
		for(int j = 0; j<len; j++)
		{
			if(mask%3 == 0) res += p*3;
			if(mask%3 == 1) res += p*5;
			if(mask%3 == 2) res += p*7;
			mask /= 3;
			p*=10;
		}

		int temp = res;
		bool b3 = 0, b5 = 0, b7 = 0;
		while(temp)
		{
			if(temp%10 == 3) b3 = 1;
			if(temp%10 == 5) b5 = 1;
			if(temp%10 == 7) b7 = 1;
			temp /= 10;
		}

		if(b3 && b5 && b7) {v.pb(res);}
	}
}
signed main()
{
	//FILEIO
 	//start_routine
	
	int tests = 1;
	int i;
	//cin>>tests;
	fr(i,3,10)compute(i);
	sort(v.begin(), v.end());

	while(tests--)
	{
		int n;
		cin>>n;
		int l = 0, r = v.size() - 1;
		int ans = -1;

		while(l <= r)
		{
			int mid = (l + r)>>1;
			if(v[mid] <= n)
				ans = mid, l = mid + 1;
			else r = mid - 1;
		}

		cout<<ans + 1<<'\n';
	}

 	//end_routine
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int m,n1,n2;
main()
{
	while(cin>>m>>n1>>n2,m)
	{
		int p[222],ansg=0,ansi;
		for(int i=0;i<m;i++)cin>>p[i];
		for(int i=n2;i>=n1;i--)
		{
			if(ansg<p[i-1]-p[i])
			{
				ansg=p[i-1]-p[i];
				ansi=i;
			}
		}
		cout<<ansi<<endl;
	}
}



Measured memory_bytes: 3052
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll fa[100009];
ll fam[100009];

ll modpow(ll a,ll n,ll mod){ // a^n の mod を計算
    ll res = 1;
    while(n>0){
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}


ll nck(ll n,ll k){
    ll ans=0;
    ans = (fa[n]*fam[n-k]%mod)*fam[k];
    ans %= mod;
    return ans;
}

signed main(){
    rep(i,100009){
        if(i==0) fa[i]=1, fam[i] = 1;
        else {
            fa[i]= i* fa[i-1];
            fa[i] %= mod;
            fam[i] = fam[i-1] * modinv(i,mod);
            fam[i] %= mod;
        }
    }
    ll n,k,s=0;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll n_k = nck(n,k);
    ll ts = 0;
    rep(i,n){
        ts = 0;
        if(n-1-i >= k-1) ts -= (a[i]%mod) * (nck(n-1-i,k-1));
        if(i >= k-1) ts += (a[i]%mod) * (nck(i,k-1));
        ts %= mod;
        s += ts;
        s %= mod;
        if(s<0) s+= mod;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	int n;

	cin >> n;

	int a[n],dp[n];

	dp[0] = 0;

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

	dp[1] = abs(a[0]-a[1]);
	
	for (int i = 2; i < n; ++i){
		dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
	}

	cout << dp[n-1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a[26];

int main()
{
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>n;
    map<string,long long>mp;
    for(i=1;i<=n;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    map<string,long long>:: iterator it;
    for(it=mp.begin();it!=mp.end();it++){
        long long xx=it->second;
        long long yy=(xx*(xx-1))/2;
        x=x+yy;
    }
    cout<<x<<endl;


}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

char S[1];

int main()
{
  cin>>S;
  
  
  if(S[0]=='Q' || S[0]=='W'|| S[0]=='E'|| S[0]=='R'|| S[0]=='T'|| S[0]=='Y'|| S[0]=='U'|| S[0]=='I'|| S[0]=='O'|| S[0]=='P'|| S[0]=='A'|| S[0]=='S'|| S[0]=='D'|| S[0]=='F'|| S[0]=='G'|| S[0]=='H'|| S[0]=='J'|| S[0]=='K'|| S[0]=='L'|| S[0]=='Z'|| S[0]=='X'|| S[0]=='C'|| S[0]=='V'||S[0]=='B'|| S[0]=='N'|| S[0]=='M')
  {
    cout<<"A";
  }
  else cout <<"a";
    
}

Measured memory_bytes: 3628
low = int(input())
arrow = list(map(int, input().split()))

arrow1 = sorted(arrow)
arrow2 = sorted(arrow, reverse=True)
res = "YES"

for i in range(int(low/2)):
  if arrow1[i] == arrow1[i+1]:
    res = "NO"
    break

if res == "NO":
  print(res)
else:
  for i in range(int(low/2)):
    if arrow2[i] == arrow2[i+1]:
      res = "NO"
      break
    
  print(res)
  

Measured memory_bytes: 26808
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, m, s;
    cin >> n >> m;
    vector<vector<int>> matrix(n, vector<int>(m));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> matrix[i] [j];
        }
    }
    vector<int>vec(m);
    for (int i = 0; i < m; i++){
        cin >> vec[i];
    }

    for (int i = 0; i < n; i++){
        int k = 0;
        for (int j = 0; j < m; j++){
            k += (matrix[i][j]) * (vec[j]);
        }
        cout << k << endl;
    }
}


Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=1e16;
int dx[]={0,1,0,-1,0,2,0,-2};
int dy[]={1,0,-1,0,2,0,-2,0};
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ma=0;
	int t=0;
	rep(i,n){
		if(s[i]=='I')t++;
		else t--;
		ma=max(ma,t);
	}
	cout<<ma<<endl;
}







Measured memory_bytes: 256
# 整数の入力
a, b, c = map(int, input().split())
# 合計17でないときNOを出力
if not (a+b+c == 17):
    print("NO")
    exit()
# 7を含まないときNOを出力
if not 7 in (a, b, c):
    print("NO")
    exit()
# 5を含まないときNOを出力、それ以外はYESを出力
if not 5 in (a, b, c):
    print("NO")
    exit()
else:
    print("YES")

Measured memory_bytes: 9164
# https://atcoder.jp/contests/abc152/tasks/abc152_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, m = map(int, input().split())
    print('Yes' if n == m else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int dp[3050][3050];
char a[maxn];
char b[maxn];
int n,m;
int c[maxn];
int pre[maxn];
int lis[maxn];
int main()
{
    scanf("%s",a);
    scanf("%s",b);
    n=strlen(a);
    m=strlen(b);
    memset(c,-1,sizeof(c));
    for(int i=0;i<m;i++)
    {
        if(a[0]==b[i])
        {
            dp[0][i]=1;
        }else
        {
            if(i>=1)
                dp[0][i]=dp[0][i-1];
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[0])
        {
            dp[i][0]=1;
        }else if(i>=1)
        {
            dp[i][0]=dp[i-1][0];
        }
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(a[i]==b[j])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
//    cout<<dp[n-1][m-1]<<endl;
//    int i=0;
//    int j=0;
//    while(i<n&&j<m)
//    {
//        if(a[i]==b[j])
//        {
//            putchar(a[i]);
//            i++;
//            j++;
//        }else if(dp[i][j]==dp[i+1][j])
//        {
//            i++;
//        }else
//        {
//            j++;
//        }
//    }
    int i=n-1;
    int j=m-1;
    int cnt=dp[n-1][m-1];
    char ans[cnt+50];
    while(i>=0&&j>=0)
    {
        if(a[i]==b[j])
        {
//            putchar(a[i]);
            ans[cnt--]=a[i];
            j--;
            i--;
 
        }else if(dp[i][j]==dp[i-1][j])
        {
            i--;
 
        }else
        {
            j--;
        }
 
    }
    cnt=dp[n-1][m-1];
    repd(i,1,cnt)
    {
        putchar(ans[i]);
    }
    return 0;
}
 
inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Measured memory_bytes: 43520
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

dic = {}
for d in D:
    if d in dic.keys():
        dic[d] += 1
    else:
        dic[d] = 1

for t in T:
    if t in dic.keys():
        if dic[t] == 0:
            print('NO')
            exit()
        dic[t] -= 1
    else:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 41316
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String input = sc.next();
			Integer num = map.get(input);
			if (num != null) {
				map.put(input, num + 1);
			} else {
				map.put(input, 1);
			}
		}
		int max = 0;
		for (Map.Entry<String, Integer> entry : map.entrySet()) {
			if (entry.getValue() > max) {
				max = entry.getValue();
			}
		}
		List<String> list = new ArrayList<>();
		for (Map.Entry<String, Integer> entry : map.entrySet()) {
			if (entry.getValue() == max) {
				list.add(entry.getKey());
			}
		}
		list.stream().sorted((str1, str2) -> str1.compareTo(str2)).forEach(System.out::println);
	}
}


Measured memory_bytes: 88092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
ll n;
ll solve(vector<ll> p){
    ll ans = 0;
    rep(i,1,n-1){
        if (i == n-2){
            if (p[i]){
                if (p[i-1] <= p[i]){
                    ans += p[i-1]*2;
                    p[i] -= p[i-1];
                    p[i-1] = 0;
                }
                else{
                    ans += p[i]*2;
                    p[i-1] -= p[i];
                    p[i] = 0;
                }
            }
            if (p[i]){
                ans += p[i]*2;
                if (p[i+1] <= p[i]){
                    p[i+1] = p[i] = 0;
                }
                else{
                    p[i+1] -= p[i];
                    p[i] = 0;
                }
            }
            continue;
        }
        if (p[i]){
            if (p[i+1] <= p[i]){
                ans += p[i+1]*2;
                p[i] -= p[i+1];
                p[i+1] = 0;
            }
            else{
                ans += p[i]*2;
                p[i+1] -= p[i];
                p[i] = 0;
            }
        }
        if (p[i]){
            ans += p[i]*2;
            if (p[i-1] <= p[i]){
                p[i-1] = p[i] = 0;
            }
            else{
                p[i-1] -= p[i];
                p[i] = 0;
            }
        } 
    }
    return ans+p[0]+p[n-1];
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<ll> p(n),q;
    rep(i,n) cin >> p[i];
    q = p;
    reverse(all(q));
    PRINT(min(solve(p),solve(q)));
}



Measured memory_bytes: 3364
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int a[] = new int[m];
        for (int ct = 0; ct < a.length; ct++) {
            a[ct] = sc.nextInt();
        }
        int lo = 0, hi = 0;
        for (int oki : a) {
            if (oki < x) {
                lo++;
            } else {
                hi++;
            }
        }
        if (lo < hi) {
            System.out.println(lo);
        } else {
            System.out.println(hi);
        }
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
set<string> subs;
int main(){ _;
  string s;cin>>s;
  int sz=s.size();
  int k;cin>>k;
  REP(i,sz){
    for(int len=1;len<=5;len++){
      if(i+len>sz)break;
      subs.insert(s.substr(i,len));
    }
  }
  auto it=subs.begin();
  int i=0;
  while(it!=subs.end()){
    if(++i==k){
      cout<<*it<<endl;
      break;
    }
    it++;
  }
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<iomanip>
#include<cmath>
#include<unordered_set>
using namespace std;

int main()
{
    unordered_set<int> data;
    int N, K, i, j, d, b;
    cin>>N>>K;
    for(i=0;i<K;i+=1)
    {
        cin>>d;
        for(j=0;j<d;j=j+1)
        {
            cin>>b;
            data.insert(b);
        }
    }
    cout<<N-data.size()<<endl;
}


Measured memory_bytes: 3600
s = input()
t = input()
n = len(s)
m = len(t)
ans = 2000
for i in range(n):
  if i+m > n:
    break
  u = s[i:i+m]
  cnt = 0
  for j in range(m):
    if t[j] != u[j]:
      cnt += 1
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,sum=0;
  cin>>n;
  vector<int>b(n-1);
  rep(i,n-1) cin>>b[i];
  vector<int>a(n);
  a[0]=b[0];
  sum+=a[0];
  for(int i=1;i<n-1;i++){
    a[i]=min(b[i-1],b[i]);
    sum+=a[i];
  }
  a[n-1]=b[n-2];
  sum+=a[n-1];
  cout<<sum<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input;

    public IO(TextReader reader)
    {
        input = reader.ReadToEnd().Split(new[] { " ", "\n", "\r" },
            StringSplitOptions.RemoveEmptyEntries);
    }

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

static class Extentions
{
}

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO(In));
        Out.Flush();
    }

    public static void Solve(IO io)
    {
        var k = io.L;
        var n = 50L;

        var t = k;
        while ((t - 1) % n != 0) t--;

        var a = new long[n];
        var u = a[0] = n + (t - 1) / n;
        a[1] = a[0] - n;
        for (var i = 2; i < n; i++) a[i] = a[i - 1] + 1;

        for (var i = 0; i < k - t; i++)
        {
            for (var j = 0; j < n; j++)
            {
                if (a[j] == u - n) a[j] = u;
                else a[j]--;
            }
        }

        io.Write(n);
        io.Write(a);
    }
}

Measured memory_bytes: 13268
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    sc.nextLine()
    val tmp = sc.nextLine()
    val s = tmp.split(" ")(0)
    val t = tmp.split(" ")(1)

    val str = new Array[Char](2 * n)
    for (i <- 0 until str.size) {
      if (i % 2 == 0) str(i) = s(i / 2)
      else str(i) = t(i / 2)
    }
    println(str.mkString(""))
  }
}


Measured memory_bytes: 27328
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int len = line.length();
		if (len == 1) {
			System.out.println(line);
			return;
		}
		long sum = 0;
		int max = 1 << (len-1);
		for (int i=0; i<max; i++) {
			int mask = max;
			StringBuilder sb = new StringBuilder();
			sb.append(line.charAt(0));
			for (int j=1; j<len; j++) {
				mask >>= 1;
				if ((i & mask) == mask) {
					sum += Long.parseLong(sb.toString());
					sb = new StringBuilder();
				}
				sb.append(line.charAt(j));
			}
			sum += Long.parseLong(sb.toString());
		}
		System.out.println(sum);
		long end = System.currentTimeMillis();
//		System.out.println((end-start) + "ms");
	}

}


Measured memory_bytes: 8912
n = int(input())

a = list(map(int,input().split()))

a.sort()

dp = [True] * (a[-1] + 1)

ans = 0

m = a[-1]

for i, x in enumerate(a[:-1]):
    if not a[i+1] == x and dp[x]:
        ans += 1
    for b in range(x, m + 1, x):
        dp[b] = False

if dp[a[-1]]:
    ans += 1

print(ans)

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int k = int.Parse(Console.ReadLine());
            for (int i = 0; i < k; i++)
            {
                inp = inp.OrderByDescending(x => x).ToArray();
                inp[0] *= 2;
            }
            Console.WriteLine(inp.Sum());
        }
    }
}

Measured memory_bytes: 13396
using System;
class Solution
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int A = int.Parse(input[1]);
    int B = int.Parse(input[2]);
    
    int max = Math.Min(A,B);
    int min = Math.Max(0, A+B-N);
    
    Console.WriteLine("{0} {1}", max, min);
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int ht[n];
	for(int i=0;i<n;i++)
		 cin>>ht[i];
	int dp[n];
	dp[0]=0;	
	for(int i=1;i<n;i++)
	{  dp[i]=INT_MAX;
		for(int j=1;j<=k&&i-j>=0;j++)
			 dp[i]=min(dp[i],dp[i-j]+abs(ht[i]-ht[i-j]));
	}
	printf("%d\n",dp[n-1]);	
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int A[N];

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

    int sum = 0;
    bool f = true;

    while (f) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2) {
                f = false;
                break;
            }
        }
        if (!f)
            break;
        for (int i = 0; i < N; i++) {
            A[i] /= 2;
        }
        sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var f = 0;
  var tmpInput = input.toString().split("");
  for(var i = 0; i < tmpInput.length; i++){
    f += parseInt(tmpInput[i]);
  }
  if(input % f == 0){
     myout("Yes");
     }else{
     myout("No");
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll dp[51][51][2501];
ll a[51];
ll n, m;
ll func(ll here, ll how, ll gap)
{
	//prllf("%d %d %d\n", here, how, gap);
	if (here == n) {
		if (how == 0)return 0;
		else if (gap%how == 0 && gap / how == m)return 1;
		else return 0;
	}
	ll &ret = dp[here][how][gap];
	if (ret != -1)return ret;
	ret = 0;
	ret += func(here + 1, how + 1, gap + a[here]);
	ret += func(here + 1, how, gap);
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%lld %lld", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	printf("%lld", func(0, 0, 0));
}

Measured memory_bytes: 50944
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

max_x = max(x)
min_y = min(y)

if max_x < Y and max_x < min_y and min_y > X:
    print("No War")
else:
    print("War")

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

const int MOD = 1e9 + 7;

unsigned int n, last, shold;
unsigned int ans;
int a[100000], val[100000] = {};

int main(void){
    // Here your code !
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
    }
    sort(a, a + n);

    if (n % 2 == 0) {
      for (int i = 0; i < n; ++i) {
        shold = (i / 2);
        val[i] = 2 * shold + 1;
      }

      for (int i = 0; i < n; ++i) {
        if (a[i] != val[i]) {printf("0\n"); return 0;}
      }
    }
    else {
      val[0] = 0;
      for (int i = 1; i < n; ++i) {
        shold = (i + 1) / 2;
        val[i] = 2 * shold;
      }

      for (int i = 0; i < n; ++i) {
        if (a[i] != val[i]) {printf("0\n"); return 0;}
      }
    }

    ans = 1;
    rep(i, n / 2) {ans = (ans * 2) % MOD;}
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ok (no +)

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_"); // ok -5


// included '_'

//string HOGE("_.!\"#&%&'()*+,-/:;<=>?"); // ok more -5
//string HOGE("_.!\"#&%&'()*+,-/:"); // ok more -5 
//string HOGE("_.!\"#&%"); // ok more -5 
//string HOGE("_.!"); // bad 
//string HOGE("_.!\"#&%"); // bad 
//string HOGE("_.!\"#&%&'()"); // ok
//string HOGE("_.!\"#&%&'("); // ok
//string HOGE("_.!\"#&%&'"); // ok
string HOGE("_'"); // ?


int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

Measured memory_bytes: 1224
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 200;

int h, w;
int ft[10][10];
int d[10];
int c[10] = { 0 };
ll ans = 0;

void shortest_path(int s = 1) {
	rep(i, 10) {
		d[i] = INF;
	}

	d[s] = 0;

	while (true) {
		bool update = false;
		rep(i, 10) {
			rep(j, 10) {
				if (d[i] != INF && d[j] > d[i] + ft[i][j]) {
					d[j] = d[i] + ft[i][j];
					update = true;
				}
			}
		}
		if (!update)break;
	}

	return;
}

int main() {

	cin >> h >> w;

	rep(i, 10) {
		rep(j, 10) {
			cin >> ft[j][i];
		}
	}
	
	rep(i, h) {
		rep(j, w) {
			int a;
			cin >> a;
			if (a != -1)c[a]++;
		}
	}

	shortest_path();
	
	rep(i, 10) {
		ans += d[i] * c[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    int main(void){  
        
    int x,y;
    
    while(1){
        scanf("%d %d", &x, &y);
        if ( x == 0 && y == 0 ) break;  
    
         if (x<=y)    printf("%d %d\n",x,y);
         else if (y<x)   printf("%d %d\n",y,x);
    }
  
    
    
    return 0;
    
}



Measured memory_bytes: 2040
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
	map<char,int> cnt;
	string str;
	while(cin>>str){
		for(int i=0;i<str.size();i++){
			if(isupper(str[i])){
				str[i]=tolower(str[i]);
			}
		}
		for(int i=0;i<str.size();i++){
			cnt[str[i]]++;
		}
	}
		for(char c='a';c<='z';c++){
			cout<<c<<" : "<<cnt[c]<<endl;
		}
		
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>

 using namespace std;
 typedef long long ll;

 int main(void){
 ll H,W;
 cin >> H >> W;

 if(H == 1 || W == 1){
 cout << 1 << endl;
 } else {
 cout << (H * W + 1) / 2 << endl;
 }

 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;
constexpr int64_t MOD=1e9+7;
int64_t dp[110][4][4][4];
bool check(int w,int x,int y,int z){
    if(w==0&&x==1&&y==2)return false;
    vector<int> v({w,x,y,z});
    for(int i=0;i<3;++i){
        swap(v[i],v[i+1]);
        for(int k=0;k<2;++k){
            if(v[k]==0&&v[k+1]==1&&v[k+2]==2)return false;
        }
        swap(v[i],v[i+1]);
    }
    return true;
}
bool valid(int x,int y,int z){
    return !(x==0&&y==1&&z==2||x==1&&y==0&&z==2||x==0&&y==2&&z==1);
}

int main() {
    int n;
    cin>>n;
    for(int x=0;x<4;++x)for(int y=0;y<4;++y)for(int z=0;z<4;++z){
        if(!valid(x,y,z))continue;
        dp[2][x][y][z]=1;
    }
    int64_t ans=0;
    for(int i=2;i<n;++i){
        for(int j=0;j<64;++j){
            int x=j%4;
            int y=(j/4)%4;
            int z=(j/16)%4;
            if(!valid(x,y,z))continue;
            for(int w=0;i>2&&w<4;++w){
                if(check(w,x,y,z))dp[i][x][y][z]+=dp[i-1][w][x][y],dp[i][x][y][z]%=MOD;
            }
            if(i==n-1)ans+=dp[i][x][y][z],ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int n = ni();
    int k = ni();

    int[] cnt = new int[n];
    for (int i = 0; i < k; i++) {
      int d = ni();
      for (int j = 0; j < d; j++) {
        int a = ni() - 1;
        cnt[a]++;
      }
    }

    int ret = 0;
    for (int v : cnt) {
      if (v == 0)
        ret++;
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

inline int read() {
    char c; int x; for (c = getchar(); !isdigit(c); c = getchar());
    for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } return x;
}

const int N = 1e5 + 5;

int n, ans, a[N];

int main() {
    n = read();
    for (int i = 0; i < n; i++) { a[i] = read(); }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) { ans += a[i] * a[j]; }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int f(int n) {
    if (n % 2 == 0)
        return n / 2;
    else
        return 3 * n + 1;
}

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

    const int max_m = 100000;
    vector<bool> v(max_m + 1, false);
    int prev = s;  // prev stores v[i-1]
    v[s] = true;
    for (int i = 2;; ++i) {
        int t = f(prev);
        if (v[t]) {
            cout << i << '\n';
            break;
        }
        prev = t;
        v[t] = true;
    }
}


Measured memory_bytes: 256
import sys


if(__name__ == "__main__"):

    N = int( input().strip() )


    list_a = list( map(int, input().strip().split()) )
    list_a.sort(reverse=True)
    comfortables = list_a[0]
    N_twos = (N-2)//2
    if(N%2 !=0):
        comfortables+= list_a[N_twos+1]
    for i in range(1, N_twos+1):
        comfortables += list_a[i] * 2
    print(comfortables)


Measured memory_bytes: 31448
h, w = map(int, input().split())

ll = [list(input()) for _ in range(h)]
ll = [s for s in ll if '#' in s]

lr = []
for i in range(w):
  if any(l[i] == '#' for l in ll):
    lr.append(i)

for l in ll:
  ans = ''
  for i in lr:
    ans += l[i]
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1LL<<62

map<ll,ll>a;

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		a[z]++;
	}
	ll max2,max22;
	max2=max22=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        ll key = itr->first;
        ll val =itr->second ;
        if(val>=4){
        	if(key>=max2){
        		max2=max22=key;
        		continue;
        	}
        	if(key>=max22){
        		max22=key;
        		continue;
        	}
        }
        if(val>=2){
        	if(key>=max2){
        		max22=max2;
        		max2=key;
        		continue;
        	}
        	if(key>=max22){
        		max22=key;
        		continue;
        	}
        }
    }
    cout << max2*max22;
	return 0;
}

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

namespace C___Five_Transportations
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var ABCDE = new int[5].Select(x => long.Parse(Console.ReadLine())).ToArray();

            Console.WriteLine(4 + Math.Ceiling((decimal)N / ABCDE.Min()));
        }
    }
}


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

using namespace std;

long long dp[200000];
long long m = 1e9+7;

int main(){

  int n,t;
  cin >> n >> t;
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  dp[0] = 1;
  
  for (int i=1; i<n; i++) {
    int l=0;
    int r=i;
    while (l<r) {
      if (a[(l+r)/2] < a[i]-t) {
        l = (l+r)/2;
        if (l==r-1) {
          if (a[l]<a[i]-t){
            l = r;
          } else {
            r = l;
          }
        }
      } else {
        r = (l+r)/2;
      }
    }
    dp[i] = (dp[i-1]*(i-r+1)) % m;
  }
  cout << dp[n-1] << endl;
  

  return 0;
}

Measured memory_bytes: 3940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[105];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}

	ll max = 0;
	REP(i, N)
	{
		REP(j, N)
		{
			max = std::max(max, abs(A[i] - A[j]));
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
a = [0 for i in range(q)]
t = [0 for i in range(n)]
for i in range(q):
    a[i] = int(input())
    t[a[i]-1] += 1
for i in range(n):
    if t[i] + k > q:
        print("Yes")
    else:
        print("No")

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

int main(){
    int m, f, r;
    string grade;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1) grade = "F";
        else if(m + f >= 80) grade = "A";
        else if(m + f < 80 && 65 <= m + f) grade = "B";
        else if(m + f < 65 && 50 <= m + f) grade = "C";
        else if(m + f < 50 && 30 <= m + f && 50 <= r) grade = "C";
        else if(m + f < 50 && 30 <= m + f && r < 50) grade = "D";
        else if(m + f < 30) grade = "F";
        cout << grade << endl;   
    }
    return 0;
}


Measured memory_bytes: 3152
use std::collections::BTreeSet;
use std::fmt::Debug;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

fn sub() -> bool {
    let datas: Vec<usize> = read_line();
    let n = datas[0];
    if n == 0 {
        return false;
    }
    let mut cards0 = BTreeSet::new();
    for _i in 0..n {
        let datas: Vec<u32> = read_line();
        cards0.insert(datas[0]);
    }
    let mut cards1 = BTreeSet::new();
    for i in 1..2 * n + 1 {
        let i_u32 = i as u32;
        if !cards0.contains(&i_u32) {
            cards1.insert(i_u32);
        }
    }
    let mut cardss = vec![&mut cards0, &mut cards1];
    let mut ba = 0u32;
    'fin: loop {
        for cards in &mut cardss {
            ba = {
                let val = cards.iter().find(|&card| card > &ba);
                if val == None {
                    ba = 0u32;
                    continue;
                }
                *val.unwrap()
            };
            cards.remove(&ba);
            if cards.is_empty() {
                break 'fin;
            }
        }
    }
    println!("{}", cardss[1].len());
    println!("{}", cardss[0].len());
    return true;
}

fn main() {
    loop {
        if !sub() {
            break;
        }
    }
}


Measured memory_bytes: 5052