akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

cntA = [0 for i in range(N+1)]
cntB = [0 for i in range(N+1)]

for i in range(N):
    cntA[A[i]] += 1
for i in range(N):
    cntB[B[i]] += 1

temp = False
for i in range(N):
    if cntA[A[i]] + cntB[A[i]] > N:
        temp = True
        break

if temp:
    print("No")


else:
    print("Yes")
    cA = 0
    cB = 0
    flag = False
    C = [B[N-i-1] for i in range(N)]
    D = [B[N-i-1] for i in range(N)]

    for i in range(1,N+1):
        if cA + cB + cntA[i] + cntB[i] == N:
            break
        elif cA + cB + cntA[i] + cntB[i] < N:
            cA += cntA[i]
            cB += cntB[i]
        elif cA + cB + cntA[i] >= N:
            if cA >= cntB[i]:
                for j in range(cntB[i]):
                    C[j] = i
                for j in range(N-cB-cntB[i]):
                    C[j+cntB[i]] = D[j]
            else:
                for j in range(cA):
                    C[j] = i
                for j in range(N-cB-cntB[i]):
                    C[j+cA] = D[j]
                for j in range(cB):
                    C[j+N-(cB+cntB[i]-cA)] = D[N-1-j]
                for j in range(cntB[i]-cA):
                    C[N-j-1] = i
            break
        else:
            if cntA[i] + cntB[i] <= N-cB:
                for j in range(cntB[i]-(N-cB-(cA+cntA[i]))):
                    C[j] = i
                for j in range(N-(cB+cntB[i])):
                    C[j+cntB[i]-(N-cB-(cA+cntA[i]))] = D[j]
                for j in range(N-cB-(cA+cntA[i])):
                    C[j+cA+cntA[i]] = i
            else:
                for j in range(cA):
                    C[j] = i
                for j in range(N-(cB+cntB[i])):
                    C[j+cA] = D[j]
                for j in range(cB):
                    C[j+N+cA-(cB+cntB[i])] = D[N-j-1]
                for j in range(cntB[i]-cA):
                    C[N-(cntB[i]-cA)+j] = i
            break
    F = [str(x) for x in C]
    print(" ".join(F))

Measured memory_bytes: 156104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
char a[6][6];
void solve()
{
	int h, w, k;
	int totalCnt = 0;
	cin>>h>>w>>k;
	REP(i,h)
		REP(j, w)
			cin>>a[i][j];
	for(int i = 0; i<(1<<(h+w)); i++)
	{
		int cnt = 0;
		REP(j, h)
			REP(k, w)
			{
				// k is column number (0 indexing)
				// j is row nunmber (0 indexing)
				// if jth bit is 1 or (h+k)th bit is 1 then, we don't consider that cell
				if((i>>j)&1 || ((i>>(h+k)))&1)
					continue;
				if(a[j][k]=='#')
					cnt++;
			}
		if(cnt==k)
			totalCnt++;
	}
	cout<<totalCnt<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;
import java.math.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		int count=0;
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		
		
		boolean x=true;
		
		if(A>8 || B>8)x=false;
		
		if(x){
			System.out.println("Yay!");
		}else{
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 22924
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

string str;
int main(){
	while(cin>>str){
		if(str=="0")break;
		int a,b;
		a=b = 0;
		for(int i =1;i <str.length();i++){
			if(str[i]=='A'){
				a++;
			}else{
				b++;
			}
			if(i==str.length()-1){
				if(a>b){
					a++;
				}else{
					b++;
				}
			}
		}
		cout <<a<<" "<<b<<endl;
		for(int i = 0;i <2;i++){
			cin>>str;
			a = b = 0;
			for(int j = 1;j <str.length();j++){
				if(str[j]=='A'){
					a++;
				}else{
					b++;
				}
				if(j==str.length()-1){
					if(a>b){
						a++;
					}else{
						b++;
					}
				}
			}
			cout <<a<<" "<<b<<endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1184
import java.util.BitSet;
import java.util.HashMap;
import java.util.Scanner;

import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main{
	
	// teight_meight ??????????????????????????????
	// ??????????????¨
	
	
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){

            int n = in.nextInt();
            int m = in.nextInt();
            if (n + m == 0) break;
 
            int[] c = new int[m];
            for (int i=0; i<m; i++) {
                c[i] = in.nextInt();
            }
 
            int[] dp = new int[256];
            fill(dp,Integer.MAX_VALUE);
            dp[128] = 0;
 
            for (int k=0; k<n; k++) {
                int x = in.nextInt();
                int[] temp = new int[256];
                fill(temp,Integer.MAX_VALUE);
                for (int i=0; i<256; i++) {
                    if (dp[i] == Integer.MAX_VALUE) continue;
                    for (int j=0; j<m; j++) {
                        int cur = i + c[j];
                        if (cur < 0) cur = 0;
                        else if (255 < cur) cur = 255;
                        temp[cur] = min(temp[cur],dp[i] + (cur-x)*(cur-x));
                    }
                }
                dp = temp;
            }
 
            int min = Integer.MAX_VALUE;
            for (int i=0; i<256; i++) {
                min = min(min, dp[i]);
            }
 
            System.out.println(min);
		}
	}
	
}

Measured memory_bytes: 63112
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007

#define INF 100000000


int main() {
    int a, b; cin >> a >> b;
    if(a <= 9 and b <= 9) cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
     
    using namespace std;
     
    typedef long long ll;
    const ll INF=1e12;
    const int maxn=100+5;
     
    ll a[maxn],b[maxn];
    ll c[maxn],d[maxn];
     
    int main() {
    	int n,m;
    	scanf("%d%d",&n,&m);
    	for(int i=1;i<=n;i++)
    		scanf("%lld%lld",&a[i],&b[i]);
    	for(int j=1;j<=m;j++)
    		scanf("%lld%lld",&c[j],&d[j]);
    	for(int i=1;i<=n;i++) {
    		int to;
    		ll now,mn=INF;
    		for(int j=1;j<=m;j++) {
    			now=abs(a[i]-c[j])+abs(b[i]-d[j]);
    			if(now<mn) mn=now,to=j;
    		}
    		printf("%d\n",to);
    	}
    	return 0;
    }

Measured memory_bytes: 256
import sys
import math
import itertools

a=[]
min=10
ans=0

for i in range(5):	
	a.append(float(input()))
	if (min>a[i]%10)and(a[i]%10>0):
		min=int(a[i])%10
	a[i]=a[i]/10
	a[i]=math.ceil(a[i])
	a[i]=int(a[i])*10
	ans+=a[i]

ans=ans-10+min
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long 
#define ld long double
#define mod7 1000000007
#define mod9 1000000009
#define mod 1000003
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second

//   ll flag[100005]={0};
	// ll a[100005]={0};
	// ll b[100005]={0}; 
	// vector<ll>v(100005);     	
bool isPrime(ll n) 
{ 
	// Corner case 
	if (n <= 1) 
		return false; 
	
	// Check from 2 to n-1 
	for (ll i = 2; i*i <= n; i++) 
		if (n % i == 0) 
			return false; 
	
	return true; 
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod) * (a%mod);
        a = (a%mod) * (a%mod);
        b >>= 1;
    }
    return res%mod;
}

bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.se<b.se);
}
ll lcm(ll a,ll b)
{
	return(a*b)/__gcd(a,b);
}
void SieveOfEratosthenes() 
{  
	ll n=100005;
    bool prime[100005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
	for(ll i=2;i<100005;i++)
	{
		if(prime[i])
		{
			// v.pb(i);
		}
	}
	
} 
ll fact[1000007]={0};
ll expo(ll x, ll y) {ll res=1;x=x%mod7;while(y>0){if(y&1)res=(1ll*res*x)%mod7;
y=y>>1;x=(1ll*x*x)%mod7;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod7;}
ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod7-2)))%mod7; return res; }
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
 int main()
{
    fast
	ll n;
	cin>>n;
	vector<ll>v(n+1);
	ll a[n+1]={0};
	for(ll i=1;i<=n;i++)
	{
		cin>>v[i];
		a[v[i]]++;
	}
	map<ll,ll>m;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if(a[i]!=0&&a[i]!=1)
		{
			ll k=ncr(a[i],2);
			m[i]=k;
			ans+=k;
		}
	}
	ll s=ans;
	for(ll i=1;i<=n;i++)
	{
		s=ans;
		ll k=a[v[i]]-1;
		s-=m[v[i]];
		if(k!=0&&k!=1)
		{
			s+=ncr(k,2);
		}
		cout<<s<<"\n";
	}
	
}




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

int main()
{
   ll n,a,b;
   cin>>n>>a>>b;
   ll ans =0;
   if( n>= 2) {
       ll temp1 = (n - 2) * b + b + a;
       ll temp2 = (n - 2) * a + a + b;
       ans = temp1 - temp2 + 1;
       if( a> b)
           ans =0;
   } else
   {
       if( n==1 && a!= b)
       {
           ans =0;
       }
       else ans =1;
   }
   cout<<ans;

}

Measured memory_bytes: 3504
#include "bits/stdc++.h"
using namespace std;

#define print(n) cout  << n << "\n"

int main() {
	int n;
	cin >> n;
	int colorMin = 0;
	int colorMax = 0;
	int rateArray[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

	for (int i = 0; i < n; i++) {
		int rate;
		cin >> rate;
		if (rate >= 3200) {
			rateArray[8]++;
		}
		else {
			rateArray[rate / 400]++;
		}
	}
	int count = 0;
	for (int i = 0; i < 8; i++) {
		if (rateArray[i] != 0) {
			count++;
		}
	}

	colorMin = count;
	if (colorMin == 0){
		colorMin = 1;
	}

	colorMax = count + rateArray[8];

	print(colorMin << " " << colorMax);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (double)(w * h) / 2.0 << " ";
    if(x * 2 == w && y * 2 == h) cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

ans = 0
for i in range(n):
  ans += b[a[i] - 1]
  if i < n-1 and a[i+1] - a[i] == 1:
    ans += c[a[i] - 1]
print(ans)

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

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

  int a[N];
  rep(i,0,N-1) cin >> a[i];

  int ans = 0;
  rep(i,0,N-1) {
    int r = a[i]-1, l = a[r]-1;
    if (l == i) ans++;
  }

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


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct AB{
    long long a;
    long long  b;
    
    AB(long long sub_a,long long  sub_b){
        a=sub_a;
        b=sub_b;
    }
    
    bool operator<(const AB &another)const{
        return a < another.a;
    };
};

int main(){
    long long N,M;
    long long ans=0;
    cin >> N >> M;
    
	vector<AB> vec(N,AB(0,0));
	
	for(int i=0;i<N;i++)cin >> vec[i].a >>vec[i].b;
	sort(vec.begin(),vec.end());
	for(int i=0;M>0;i++){
	    if(M-vec[i].b>0){
	        ans+=vec[i].b*vec[i].a;
	        M-=vec[i].b;
	    }else{
	        ans+=vec[i].a*M;
	        break;
	    }
	}
	
	cout << ans<<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
using namespace std;
typedef long long ll;
void print(vector<int> vec) {
    for (int i=0; i<(int)vec.size(); ++i) {
        cout << (i == 0 ? "" : " ") << vec[i];
    }
    cout << endl;
}
int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i=0; i<n; ++i) {
        cin >> A[i];
    }

    print(A);
    for (int j=1; j<n; ++j) {
        int key = A[j];
        int i = j-1;
        while (i >= 0 && A[i] > key) {
            A[i+1] = A[i];
            -- i;
        }
        A[i+1] = key;
        print(A);
    }

    return 0;
}

Measured memory_bytes: 1216
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9,maxn=2e5+5,mod=1e9+7;

int n,m,lim,fa[maxn];
struct ee{int x,y,z;}e[maxn];
int cmp(ee a,ee b){return a.z<b.z;}
int find(int x){return fa[x] == x?fa[x]:fa[x]=find(fa[x]);}
void un(int x,int y){int fx=find(x),fy=find(y);if(fx!=fy)fa[fy]=fx;} 
int pw(int x,int y){
	if(y==0)return 1;if(y==1)return x;int mid=pw(x,y>>1);
	if(y&1)return 1ll*mid*mid%mod*x%mod;return 1ll*mid*mid%mod;
}
int kruskal(){
	for(int i=1;i<=n;i++)fa[i]=i;
	int mst=0;
	for(int i=1;i<=m;i++){
		int x=e[i].x,y=e[i].y;
		int fx=find(x),fy=find(y);
		if(fx!=fy){
			mst+=e[i].z;
			fa[fy]=fx;
		}
	}
	return mst;
}

int kruskal(int fo){
	for(int i=1;i<=n;i++)fa[i]=i;
	int ffx=find(e[fo].x),ffy=find(e[fo].y);
	fa[ffy] = ffx;
	int mst=e[fo].z;
	for(int i=1;i<=m;i++){
		if(i==fo)continue;
		int x=e[i].x,y=e[i].y;
		int fx=find(x),fy=find(y);
		if(fx!=fy){
			mst+=e[i].z;
			fa[fy]=fx;
		}
	}
	return mst;
}

signed main(){
	scanf("%lld%lld%lld",&n,&m,&lim);
	for(int i=1;i<=m;i++){
		scanf("%lld%lld%lld",&e[i].x,&e[i].y,&e[i].z);
	}
	sort(e+1,e+m+1,cmp);
	int orig = kruskal();
	if(lim<orig)return puts("0"), 0;
	if(lim==orig){
		int fce=0;
		for(int i=1;i<=m;i++){
			int nw = kruskal(i);
			if(nw == orig)++ fce;
		}
		printf("%lld\n",1ll*(pw(2,fce)-2+mod)%mod*pw(2,m-fce)%mod);
		return 0;
	}
	int fce=0,fcd=0;
	for(int i=1;i<=m;i++){
		int nw = kruskal(i);
		if(nw == lim)++ fce;
		else if(nw>lim) ++ fcd;
	}
	printf("%lld\n",2ll*((pw(2,fce)-1))%mod*pw(2,fcd)%mod);

	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main (){
	double n,t,a;
	vector<double> h;
	cin >> n;
	cin >> t >> a;
	for(int i=0;i<n;i++){
		double temp;
		cin >> temp;
		h.push_back(temp);
	}
	int ans;
	double mini = 10000000000000;
	for(int i=0;i<n;i++){
		double ave;
		ave = t-h[i]*0.006;
		if(mini>abs(ave-a)){
			ans = i;
			mini = abs(ave-a);
		}
	}
	cout<<ans+1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,c,d,n;
	while(1){
		c=0;d=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>a;
			if(a>1)c++;
			else if(a==0)d++;
		}
		if(c>0)cout<<n+1-d<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
	ll d[26];
	rep(i,0,26)d[i] = 1000;
	ll n;
	cin>>n;
	rep(i,0,n){
		ll dd[26];
		clr(dd,0);
		string s;
		cin>>s;
		rep(j,0,s.sz){
			dd[s[j]-'a']++;
		}
		rep(j,0,26){
			d[j] = min(d[j],dd[j]);
		}
	}
	string ans;
	rep(i,0,26){
		rep(j,0,d[i]){
			ans += 'a'+i;
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
    ｜ ――― ｜　　  ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<numeric>
using namespace std;
 
//#define int ll

typedef int64_t ll;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")


signed main(){
    vector< string > s,t;
    s.resize(114,"f__k");
    t.resize(114,"f__k");

    int n,m;
    cin >> n;
    REP(i,n) cin >> s[i];
    cin >> m;
    REP(i,m) cin >> t[i];

    int ans = -114514;

    REP(i,n){
        int tmp = 1;
        REP(j,n){
            if(i==j) continue;
            if(s[i]==s[j]) tmp++;
        }
        REP(j,m) if(s[i]==t[j]) tmp--;

        ans = max(ans,tmp);
    }

    printf("%d\n",max(ans,0));

    return 0;
}


Measured memory_bytes: 256
# import numpy as np
# import math
import sys
input = sys.stdin.readline

W,H,N = map(int,input().split())

L = 0
B = 0
R,T = W,H

for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        L = max(L,x)
    elif a == 2:
        R = min(R,x)
    elif a == 3:
        B = max(B,y)
    elif a == 4:
        T = min(T,y)

res = (R-L) * (T-B)

# res = max(res,0)

if (R-L <= 0) or (T-B <= 0):
    print(0)
else:
    print(res)


Measured memory_bytes: 3064
def inpl(): return [int(i) for i in input().split()]
N, K = inpl()
A = inpl()
H = [[0, 0] for _ in range(41)]
Kb = list(map(int, bin(K)[2:].zfill(41)))
for a in A:
    for i, v in enumerate(map(int, bin(a)[2:].zfill(41))):
        H[i][v] += 1 
ans = 0
ctr = 0
Hm = [max(j, k)*2**(40 - i) for i, [j, k] in enumerate(H)]
for i, v in enumerate(Kb):
    if not v:
        ctr += H[i][1]*2**(40-i)
    else:
        ans = max(ans, ctr + H[i][1]*2**(40-i) + sum(Hm[i+1:]))
        ctr += H[i][0]*2**(40-i)
print(max(ans, ctr))
    

Measured memory_bytes: 14708
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    int n;
    double s[1000];
    while (1)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        double sum = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> s[i];
            sum += s[i];
        }
        double average = sum / n;
        sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += (s[i] - average) * (s[i] - average);
        }
        sum /= n;

        cout << fixed << setprecision(5) << pow(sum, 1. / 2) << endl;
    }
    return 0;
}



Measured memory_bytes: 3452
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

inline void Solve () {
	//easy
	int a, b;
	cin >> a >> b;
	if (a > 0) {
		cout << "Positive";
		exit(0);
	}		
	if (a <= 0 && b >= 0) {
		cout << "Zero";
		exit(0);
	}

	int len = b - a + 1;
	if (abs(len) & 1) {
		cout << "Negative";
		exit(0);
	}

	cout << "Positive";
		
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 256
#define FORI(x) for(int i=0;i<x;++i)
#define FORJ(x) for(int j=0;j<x;++j)

#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {
	int n, l;
	cin >> n >> l;
	int ans = 0;
	FORI(n) {
		ans += i+l;
	}
	if (l > 0) {
		ans -= l;
	}else if (n + l -1< 0) {
		ans -= n + l-1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
s = gets.to_i
ary = [s]
i = 0
ans = 0
until ary.count(ans) == 2 do
  if ary[i].odd?
    ans = 3*ary[i]+1
  else
    ans = ary[i]/2
  end
  ary << ans
  i+=1
end
puts i+1

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int N,K;
	cin >> N >> K;
	if(ceil((double)N/2)>=K) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ull mod = 1e9 + 7;

vector<int> contain(string a, string b) {
    int al = a.size(), bl = b.size();
    vector<int> ret;
    if (al > bl) return ret;

    ull t = 1;
    for (int i = 0; i < al; i++) t *= mod;
    ull ah = 0, bh = 0;
    for (int i = 0; i < al; i++) ah = ah * mod + a[i];
    for (int i = 0; i < al; i++) bh = bh * mod + b[i];

    for (int i = 0; i + al <= bl; i++) {
        if (ah == bh) ret.push_back(i);
        if (i + al < bl) bh = bh * mod + b[i + al] - b[i] * t;
    }
    return ret;
}

bool check(string s, int k) {
    bool checked[s.size()] = {};
    for (int i = 0; i <= s.size() - k; i++) {
        if (!checked[i]) {
            vector<int> ret = contain(s.substr(i, k), s);
            if (ret.size() >= 2) {
                if (ret[ret.size() - 1] - ret[0] >= k) return 1;
                for (auto &i : ret) checked[i] = 0;
            }
        }
    }
    return 0;
}

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

    int ok = 0, ng = n;
    while (ng - ok > 1) {
        int md = (ok + ng) / 2;
        if (check(s, md)) ok = md;
        else ng = md;
    }
    cout << ok << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int cost(int x,int y){
	if(x>=y){
		return (x-y);
	}else{
		return (y-x);
	}
}

int main(void){
	int n,a[100001],i,sum=0,ans;
	scanf("%d",&n);
	a[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1]=0;
	for(i=1;i<=n+1;i++){
		if(a[i]>=a[i-1]){
			sum=sum+(a[i]-a[i-1]);
		}else{
			sum=sum+(a[i-1]-a[i]);
		}
	}
	for(i=1;i<=n;i++){
		ans=sum+cost(a[i+1],a[i-1])-cost(a[i+1],a[i])-cost(a[i],a[i-1]);
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  REP(i,h)cin>>t[i];
  vector<vecint> psum(h+1, vecint(w+1, 0));
  REP(i,h) {
    REP(j,w) {
      int c = t[i][j] == '#';
      psum[i+1][j+1] = c + psum[i][j+1] + psum[i+1][j] - psum[i][j];
    }
  }
  constexpr int total = 185*185*185;
  vector<int16_t> max_v(total,-1), max_h(total,-1);
  REP(i,h)REP(j,i+1) {
    REP(k,w)REP(l,k+1) {
      int cnt = psum[i+1][k+1] - psum[j][k+1] - psum[i+1][l] + psum[j][l];
      if (cnt == 0 || cnt == (i-j+1)*(k-l+1)) {
        int idx_v = j*w*w + k*w + l;
        max_v[idx_v] = max(max_v[idx_v], static_cast<int16_t>(i));
        int idx_h = l*h*h + i*h + j;
        max_h[idx_h] = max(max_h[idx_h], static_cast<int16_t>(k));
      }
    }
  }
  int whole_idx = (w-1)*w;
  if (max_v[whole_idx] == h-1) {
    cout << 0 << endl;
    return 0;
  }
  FOR(mx,1,17) {
    auto next_v = max_v;
    auto next_h = max_h;
    REP(i,h)REP(j,i+1) {
      int idx_h = i*h + j;
      REP(k,w) {
        int16_t current_index = max_h[idx_h + k*h*h];
        if (current_index < k) continue;
        int16_t next_index = max_h[idx_h + min(w-1, current_index+1)*h*h];
        if (next_index < k) continue;
        next_h[idx_h + k*h*h] = max(
            next_h[idx_h + k*h*h],
            next_index
        );
        next_v[next_index*w + k + j*w*w] = max(
            next_v[next_index*w + k + j*w*w],
            static_cast<int16_t>(i)
        );
      }
    }
    REP(i,w)REP(j,i+1) {
      int idx_w = i*w + j;
      REP(k,h) {
        int16_t current_index = max_v[idx_w + k*w*w];
        if (current_index < k) continue;
        int16_t next_index = max_v[idx_w + min(h-1, current_index+1)*w*w];
        if (next_index < k) continue;
        next_v[idx_w + k*w*w] = max(
            next_v[idx_w + k*w*w],
            next_index
        );
        next_h[next_index*h + k + j*h*h] = max(
            next_h[next_index*h + k + j*h*h],
            static_cast<int16_t>(i)
        );
      }
    }
    for (int i = h-1; i>0; --i) {
      REP(j,i) {
        int idx_h = i*h + j;
        int small_idx_h = (i-1)*h+j;
        REP(k,w) {
          next_h[small_idx_h + k*h*h] = max(next_h[small_idx_h + k*h*h], next_h[idx_h + k*h*h]);
        }
      }
    }
    for (int i = w-1; i>0; --i) {
      REP(j,i) {
        int idx_w = i*w + j;
        int small_idx_w = (i-1)*w+j;
        REP(k,h) {
          next_v[small_idx_w + k*w*w] = max(next_v[small_idx_w + k*w*w], next_v[idx_w + k*w*w]);
        }
      }
    }
    if (next_v[whole_idx] == h-1) {
      cout << mx << endl;
      return 0;
    }
    swap(max_v, next_v);
    swap(max_h, next_h);
  }
  return 0;
}


Measured memory_bytes: 53256
#include<stdio.h>
int main(void)
{
    int n,m,i,j,w,a[50],x;
	scanf("%d %d",&n,&m);
	x=0;
	for(i=0;i<n;i++){
	    scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++){
	    for(j=i+1;j<n;j++){
		    if(a[i]<a[j]){
			    w=a[i];
				a[i]=a[j];
				a[j]=w;
			}
		}
	}
	for(i=0;i<m;i++){
	    x=x+a[i];
	}
	printf("%d\n",x);
	return 0;
}

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

namespace from_ecnerwala {

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;
}
using namespace from_ecnerwala;

const int MAXN = 5010;
int N;
vector<int> adj[MAXN];

num dp[MAXN][MAXN];
num tmp[MAXN];
int sz[MAXN];

void dfs(int cur = 1, int prv = 0) {
	if (prv) {
		adj[cur].erase(find(adj[cur].begin(), adj[cur].end(), prv));
	}

	sz[cur] = 1;
	dp[cur][1] = 1;
	for (int nxt : adj[cur]) {
		dfs(nxt, cur);

		fill_n(tmp, sz[cur] + sz[nxt] + 1, 0);
		for (int i = 0; i <= sz[cur]; i++) {
			for (int j = 0; j <= sz[nxt]; j++) {
				tmp[i+j] += dp[cur][i] * dp[nxt][j];
			}
		}
		sz[cur] += sz[nxt];
		copy_n(tmp, sz[cur] + 1, dp[cur]);
	}

	num coef = -1;
	for (int i = 2; i <= sz[cur]; i += 2) {
		coef *= (i-1);
		dp[cur][0] += coef * dp[cur][i];
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs();
	cout << -dp[1][0] << endl;

	return 0;
}

Measured memory_bytes: 99072
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

cost_l = 0
cost_r = 0
left = True

for ai in A:
    if left:
        if ai > X:
            left = False
            cost_r += 1
            continue
        cost_l += 1
    else:
        cost_r += 1

print(min(cost_l, cost_r))


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

bool compare(pair< pair< string ,int>,int> a,pair< pair< string ,int>,int> b)
{
    if( a.first.first!=b.first.first) return a.first.first<b.first.first;
    return a.first.second>b.first.second;
  
}
int main()
{
   int n;
   cin>>n;
   vector < pair< pair< string ,int>,int> > res;
    
  for(int i=0;i<n;i++)
  {   
      string s;
      int c;
      cin>>s>>c;
      res.push_back({{s,c},i+1});
  } 
  
   sort(res.begin(),res.end(),compare);

   for(auto i:res)
   {
     cout<<i.second<<endl;
   }
    
  return 0;
  
}

Measured memory_bytes: 256
N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = [input().split() for l in range(N)]

count = 0
for i in range(N):
    hantei = C
    for j in range(M):
        hantei += int(A[i][j]) * B[j]
    if hantei > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define LIM 2500
#define MAX 5001

using namespace std;

int main(void) {
	int num, ave, i = 0, j;
	cin >> num >> ave;
	vector<vector<long long>> dp(num, vector<long long>(MAX));
	vector<int> d(num);
	for (; i < num; i++) {
		cin >> d[i];
		d[i] -= ave;
	}
	dp[0][d[0] + LIM]++;
	dp[0][LIM]++;
	for (i = 1; i < num; i++) {
		for (j = 0; j < d[i]; j++)
			dp[i][j] = dp[i - 1][j];
		for (; j < MAX + d[i]; j++) {
			if (j == MAX)
				break;
			dp[i][j] = dp[i - 1][j] + dp[i - 1][j - d[i]];
		}
		for (; j < MAX; j++)
			dp[i][j] = dp[i - 1][j];
	}
	cout << dp[num - 1][LIM] - 1 << "\n";
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int H, W;
int A[80][80];

bitset<160*161> B[80][80];

void solve() {
    cin >> H >> W;
    rep(y, H) rep(x, W) cin>>A[y][x];
    rep(y, H) rep(x, W) {
        int r;
        cin >> r;
        A[y][x] = abs(A[y][x] - r);
    }
    B[0][0][80*160+A[0][0]] = 1;
    rep(y, H) rep(x, W) {
        // 下移動
        if (y + 1 < H) {
            B[y+1][x] |= B[y][x] << A[y+1][x];
            B[y+1][x] |= B[y][x] >> A[y+1][x];
        }
        // 右移動
        if (x + 1 < W) {
            B[y][x+1] |= B[y][x] << A[y][x+1];
            B[y][x+1] |= B[y][x] >> A[y][x+1];
        }
    }

    int mi=101010;
    rep(i, 160*161) if(B[H-1][W-1][i]) mi=min(mi, abs(i-80*160));
    cout << mi << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();



}

Measured memory_bytes: 20480
/*
 * abc153a.cpp
 * Copyright (C) 2020 itachi <itachi@itachi-Z510>
 *
 * Distributed under terms of the MIT license.
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int h,a;
    cin >> h >> a;
    int count = 0;
    while (h>0) {
        h -= a;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define mod %
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , l ;
    cin >> n >> l ;
    vector<string > v ;
    forn(i , 1 , n ) {
       string s ;
       cin >> s ;
       v.pb(s);
    }
    sort(all(v)) ;
    string ans = "";
    for(auto &x : v) {
        ans = ans + x ;
    }
    cout << ans << el ;
    ro ;
}































Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int n, m, num, max1, max2, ans, a[100010];

int main()
{
	max1 = max2 = ans = num = 0;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = n; i; i--) {
		max1 = max(a[i], max1);
		num = max(max1 - a[i], num);
	}
	for (int i = n; i; i--) {
		max2 = max(a[i], max2);
		if (max2 - a[i] == num)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q, sum, cnt, m, k;
int arr[N+2], brr;


void solve()
{

      cin >> n;
      int r = n/500;
      n -= 500*r;
      int y = n/5;
      cout << 1000*r + y*5 << endl;
}

int32_t main()
{
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
     // INP(); 

      int test = 1;
      // cin >> test;

      // cout << setprecision(9) << fixed;
      // clock_t z = clock();
      while(test--)solve();
      // cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var (
		w string
	)
	result := make(map[string]int, 110)
	fmt.Scan(&w)
	for _, ww := range w {
		result[string(ww)]++
	}

	for _, v := range result {
		if v % 2 != 0 {
			fmt.Println("No")
			os.Exit(0)
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1852
#include <stdio.h>
#include <stdlib.h>
#define ll long long int
#define NUM 1000000007 //10^9+7
int main(void){
	ll n,i,ans=1,num;
	scanf("%lld",&n);
	ll a[100000]={0};
	for(i=0;i<n;i++){
		scanf("%lld",&num);
		a[num]++;
	}
	if(n%2==0){
		for(i=1;i<=n-1;i+=2){
			if(a[i]!=2){
				printf("0");
				return 0;
			}
		}
	}else{
		if(a[0]!=1){
			printf("0");
			return 0;
		}
		for(i=2;i<=n-1;i+=2){
			if(a[i]!=2){
				printf("0");
				return 0;
			}
		}
	}
	for(i=0;i<n/2;i++)	ans=ans*2%NUM;
	printf("%lld",ans);
	return 0;
}

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

string M[8];

void dfs(int x, int y) {
  M[y][x]='0';
  for(int i=-3; i<=3; i++) {
    if(i && 0<=x+i&&x+i<8 && M[y][x+i]-'0') dfs(x+i,y);
  }
  for(int i=-3; i<=3; i++) {
    if(i && 0<=y+i&&y+i<8 && M[y+i][x]-'0') dfs(x,y+i);
  }
}

int main() {
  int n;
  
  cin>>n;
  for(int k=0; k<n; k++) {
    cin.ignore();cin.ignore();
    for(int i=0; i<8; i++) getline(cin,M[i]);
    int x, y;
    cin>>x>>y; x--,y--;
    dfs(x,y);
    cout<<"Data "<<k+1<<":"<<endl;
    for(int i=0; i<8; i++) cout<<M[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>

int main()
{
  char s[201];
  int m, h, l, i, j;

  scanf("%s", s);
  while (strcmp(s, "-") != 0) {
    l = strlen(s);
    i = 0;
    scanf("%d", &m);
    while (m--) {
      scanf("%d", &h);
      i = (i + h) % l;
    }
    printf("%s", s+i);
    s[i] = '\0';
    printf("%s\n", s);
    scanf("%s", s);
  }

  return 0;
}



Measured memory_bytes: 2064
#include<iostream>
using namespace std;
int main(){

	int a,b;
	cin >> a >> b;

	if (a < b){
		cout << "a < b" << endl;
	}

	if (a > b){
		cout << "a > b" << endl;
	}
	  
	if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define LL long long
#define REP(i, n) for(int i=0;i<(n);++i)
#define REPA(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) for(int i=-;i<(n);++i)
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define DEKAI ((int)1e9+7)
#define ALL(x) (x).begin(), (x).end()
#define BIT(x) (1<<(x))
#define foreach(i, n) for(auto &i:(n))
using namespace std;

int main(){
    string str;
    while(cin>>str&&str!="#"){
        int y, m, d;
        cin>>y>>m>>d;
        if(y<31||y==31&&m<=4){
            cout << str << " " << y << " "<< m <<" " << d << endl;
        }else{
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	ll h;
	int n;
	cin >> h >> n;
	vector<int> a(n);
	ll cnt = 0;
	rep(i, n) {
		cin >> a[i];
		cnt += a[i];
	}
	if (cnt >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,a[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	int gs=0;
	while(n>0)
	{
		n=n/m;
		gs++;
	}
	cout<<gs;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, mi = 1000000000;
    scanf("%d", &n);
    for (int i = 1, total = 0; i < n; ++i, total = 0)
    {
        for (int j = i; j != 0; )
        {
            total += j % 10;
            j /= 10;
        }
        for (int j = n - i; j != 0; )
        {
            total += j % 10;
            j /= 10;
        }
        mi = min(mi, total);
    }
    printf("%d\n", mi);
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i,j;
  int n,q;
  int m,d,a[100];
  int max,ans;
  
  while(1){
    scanf("%d %d ",&n,&q);
    if(!n && !q)break;

    for(i=0;i<100;i++)a[i] = 0;
    
    for(i=0;i<n;i++){
      scanf("%d ",&m);
      
      for(j=0;j<m;j++){
	scanf("%d ",&d);
	a[d]++;
      }
    }
      
    ans = 0;
    max = q-1;
    for(i=0;i<100;i++){
      if(max < a[i]){
	max = a[i];
	ans = i;
      }
    }

    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main() {
    int a, b;

    scanf("%d %d", &a, &b);

    if(a >= -1000 && b <= 1000){
        if(a < b){
            printf("a < b\n");
        } else if(a > b){
            printf("a > b\n");
        } else if(a == b){
            printf("a == b\n");
        }
    }
return 0;
}

Measured memory_bytes: 580