akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int d,s;

	scanf("%d",&d);

	for(int i=0; i < d; i++){
		scanf("%d",&s);

		printf("Case %d:\n",i+1);
		for(int k=0; k < 10; k++){
			s = s*s;
			s /= 100;
			s %= 10000;
			printf("%d\n",s);
		}

	}

    return 0;
}

Measured memory_bytes: 2648
pre = input().split()
X = int(pre[0])
Y = int(pre[1])

#2t+4k=Y
#t=X-k
#k=X-t

#2X-2k+4k =Y
#2k = Y-2X
#k = Y/2 - X
#X-t = Y/2 -X
#t = 2X -Y/2

if Y%2==0 and Y/2-X>=0 and 2*X-Y/2>=0:
  print("Yes")
else:
  print("No")
  
  
  



Measured memory_bytes: 9156
n,k = map(int, input().split())

if n >= k:
  ans_a = n % k
  ans_b = abs(n %k - k)
  ans = min(ans_a, ans_b)
else:
  if n >= abs(n-k):
    ans = abs(n-k)
  else:
    ans = n

print(ans)

Measured memory_bytes: 9112
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }else if(s.size() == 26){
        bool f = false;
        for(int i = 24; i >= 0; i--){
            for(int j = 1; j <= 'z' - s[i]; j++){
                if(s[i] != 'z' && s.find(s[i] + j) > i){
                    s[i] += j;
                    s.erase(s.begin() + i + 1, s.end());
                    f = true;
                    break;
                }
            }
            if(f) break;
        }
    }else{
        for(char c = 'a'; c <= 'z'; c++){
            if(s.find(c) == -1){
                s += c;
                break;
            }
        }
    }
    cout << s << endl;
    return 0;
}

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

int main(){
  int n,x;
  cin>>n>>x;
  if(x==2*n-1||x==1)cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    if((2*n-1)/2>=x){
      for(int i=x+1;i<=(2*n-1)/2+1;i++)cout<<i<<endl;
      for(int i=1;i<=x;i++)cout<<i<<endl;
      for(int i=(2*n-1)/2+2;i<=2*n-1;i++)cout<<i<<endl;
    }else{
      for(int i=1;i<=(2*n-1)/2;i++)cout<<i<<endl;
      for(int i=x;i<=2*n-1;i++)cout<<i<<endl;
      for(int i=(2*n-1)/2+1;i<x;i++)cout<<i<<endl;
    }
  }
  return 0;
}


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

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

    ll ans = 0;
    ll sum = A.at(0);
    for(ll i=0; i<N; i++){
        if(sum >= B.at(i)){
            if(i==0){
                ans += B.at(i);
                sum = A.at(1);
                continue;
            }
            ans += A.at(i) + B.at(i) - sum;
            sum = A.at(i+1);
        }
        else{
            ans += A.at(i);
            if(A.at(i+1) - (B.at(i) - sum) > 0){
                if(i == N-1){
                    //cout << B.at(i) - sum << " " << sum << endl;
                    ans += B.at(i) - sum;
                }
                sum = A.at(i+1) - (B.at(i) - sum);  
            }
            else if(A.at(i+1) - (B.at(i) - sum) <= 0){
                sum = 0;
                if(i == N-1){
                    ans += A.at(i+1);
                }
            }
        }
    }    

    cout << ans << endl;

}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int sum = 0;
	int ans = 0;
	rep(i, N) {
		ans += sum * A[i] % MOD;
		ans %= MOD;
		sum += A[i];
		sum %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

bool check(string s, int x) {

	int l = 0, r = x, step = 1;

	for (int i = 0; i < s.size(); ++i) {
		if (l == r) step = 1;

		if (s[i] == '0') {
			l--, r--;
			if (l < 0) {
				l += step;
			}
			if (l > r) {
				return false;
			}
		}
		else if (s[i] == '1') {
			l++, r++;
			if (r > x) {
				r -= step;
			}
			if (l > r) {
				return false;
			}
		}
		else {
			if (step == 2 || l != r) {
				l--, r++;
				if (l < 0) {
					l += step;
				}
				if (r > x) {
					r -= step;
				}
				if (l > r) {
					return false;
				}
			}
			else {
				l--, r++;
				step = 2;
				if (l < 0) {
					l += step;
				}
				if (r > x) {
					r -= step;
				}
				if (l > r) {
					return false;
				}
			}
		}
	}

	return true;

}

int main(){
#ifdef LOCAL
	freopen("H_input.txt", "r", stdin);
	//freopen("H_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;

	int L = 0, R = 1e7;
	while (R-L>1) {
		int M = (L+R)/2;
		if (check(s, M)) R = M;
		else L = M;
	}

	cout << R;

}


Measured memory_bytes: 5332
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, K;
  cin >> N >> K;

  if (K == 0) {
    cout << N * N;
    return 0;
  }

  ll ans = 0;

  FOR(i, K + 1, N + 1) {
    ans += (N / i) * (i - K);
    ans += max(N % i - (K - 1), 0LL);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, C, D = mapint()
if A+B>C+D:
    print('Left')
elif A+B<C+D:
    print('Right')
else:
    print('Balanced')

Measured memory_bytes: 61844
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1e17+7;


int main(){

    ll n,m;
    cin >> n >> m;
    vector<ll> x(n),y(m);
    ll mini = INF;
    for(int i = 0;i < n;i++){
        cin >> x[i];
        mini = min(mini,x[i]);
    }
    if(mini < 0){
        for(int i = 0;i < n;i++){
            x[i] -= mini;
        }
    }
    mini = INF;
    for(int i = 0;i < m;i++){
        cin >> y[i];
        mini = min(mini,y[i]);
    }
    if(mini < 0){
        for(int i = 0;i < m;i++){
            y[i] -= mini;
        }
    }
    vector<ll> xs(n+1,0),ys(m+1,0);
    
    //累積和
    for(int i = 1;i <= n;i++){
        xs[i] = xs[i-1] + x[i-1];
    }
    for(int i = 1;i <= m;i++){
        ys[i] = ys[i-1] + y[i-1];
    }

    ll x_cnt = 0,y_cnt = 0;//縦、横の長さの総和

    for(int i = 1;i <= n-1;i++){
        x_cnt += (xs[n]-xs[n-i]) - xs[i];
        x_cnt %= MOD;
    }
    
    for(int i = 1;i <= m-1;i++){
        y_cnt += (ys[m]-ys[m-i]) - ys[i];
        y_cnt %= MOD;
    }

    cout << (x_cnt * y_cnt)%MOD << endl;







    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#define ll int

//next_permutation
void nexp(ll*a,int cnt){
	int l=cnt-1,r=cnt-1;
	ll t;
	while(--l>=0&&a[l]>a[l+1]);
	if(l>=0){
		while(a[l]>a[r])r--;
		t=a[l];a[l]=a[r];a[r]=t;
	}
	for(l++,r=cnt-1;l<r;l++,r--)t=a[l],a[l]=a[r],a[r]=t;
}

int a[10];
int main(){
	int n;
	scanf("%d",&n);
	int s=1;
	for(int i=0;i<n;i++)s*=a[i]=i+1;
	
	for(int i=0;i<s;i++){
		for(int i=0;i<n;i++)printf("%d%c",a[i],i==n-1?10:32);
		nexp(a,n);
	}
}


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

int main(){
    int M , N , X;
    cin >> N >> M >> X;
    vector<int> prices(N);
    vector<int> sum_prices;
    vector<int> understand(M,0);
    vector<vector<int>> A(N,vector<int>(M));
    for(int i = 0; i < N; i++){
        cin >> prices[i];
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    for(int bit = 0; bit < (1<<N); bit++){
        for(int i = 0; i < understand.size(); i++){
            understand[i] = 0;
        }
        vector<int> S;
        int sum_price = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        for(int i = 0; i < (int)S.size(); i++){
            //cout << S[i] << " ";
            for(int j = 0; j < M; j++){
                understand[j] += A[S[i]][j];
            }
            sum_price += prices[S[i]];
        }
        //cout << endl;
        int count = 0;
        for(int i = 0; i < (int)understand.size(); i++){
            //cout << understand[i] << " ";
            if(understand[i] >= X){
                count++;
            }
        }
        if(count == understand.size()) sum_prices.push_back(sum_price);
        //cout << sum_price << endl;
    }
    int ans;
    if(sum_prices.size() > 0){
        ans = *min_element(sum_prices.begin(),sum_prices.end());
    }else ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200100;
int n,a,b,c,d;
char s[N];

int main()
{
	n=rd();a=rd();b=rd();c=rd();d=rd();
	scanf("%s",s+1);
	int l=min(a,b),r=max(c,d);
	fo(i,l,r-1)if(s[i]=='#'&&s[i+1]=='#')return puts("No"),0;
	if(c>d){
		bool f=0;
		fo(i,b,d)if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')f=1;
		if(!f)return puts("No"),0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      int n = sc.nextInt();
      int x = sc.nextInt();
      if (n == 0 && x == 0) {
        break;
      }
      int count = 0;
      for (int i = 1; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
          int k = x - i - j;
          if (j < k && k <= n) {
            count++;
          }
        }
      }
      System.out.println(count);
    }
  }
}



Measured memory_bytes: 26184
s = input()
t = input()

S = sorted([x for x in s])
T = sorted([x for x in t])[::-1]
s = "".join(S)
t = "".join(T)
if s == t:
    print("No")
    exit(0)

A = sorted([s,t])
print("Yes" if A[0]==s else "No")


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
using std::cin;
using std::cout;

int main(){
    int h,n;
    bool result = false;
    cin>>h>>n;
    for(int i = 0;i<n;++i){
        int a;
        cin >> a;
        h = h - a;
        if(h <= 0){
            result = true;
        }
    }
    cout << ((result)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

inline int euclid(int a, int b) {
    if (a > b) swap(a, b);
    int r = a % b;
    while (r > 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    lli X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<lli> A, B, C;
    for (int i = 0; i < X; i++) {
        lli input;
        cin >> input;
        A.push_back(input);
    }
    sort(A.begin(), A.end(), greater<lli>());
    for (int i = 0; i < Y; i++) {
        lli input;
        cin >> input;
        B.push_back(input);
    }
    sort(B.begin(), B.end(), greater<lli>());
    for (int i = 0; i < Z; i++) {
        lli input;
        cin >> input;
        C.push_back(input);
    }
    sort(C.begin(), C.end(), greater<lli>());

    vector<lli> AB;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<lli>());
    if (K + 1 < X * Y) AB.erase(AB.begin() + K + 1, AB.end());
    if (K + 1 < Z) C.erase(C.begin() + K + 1, C.end());

    vector<lli> ans;
    for (int i = 0; i < AB.size(); i++) {
        for (int j = 0; j < C.size(); j++) {
            ans.push_back(AB[i] + C[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<lli>());

    for (int i = 0; i < K; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43344
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i =0 ; i < n; i++){
		cin >> a[i];
	}
	sort (a, a + n);
	int sum = 0;
	for (int i = 0; i < k; i++){
		sum += a[i];
	}
	cout << sum;
}


Measured memory_bytes: 3640
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b)
{
    if (a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main()
{
    int X, Y;
    cin >> X >> Y;

    int ans = X + Y/2;

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int const static N = 10;
  int n;cin>>n;
  double x[N];
  string u[N];

  rep(i,n){
    cin >> x[i];
    cin >> u[i];
  }
  double rate = 380000.0;
  double sum = 0;
  rep(i,n){
    if(u[i] == "JPY"){
      sum += double(x[i]);
    }else if( u[i] == "BTC"){
      sum += double(x[i] * rate );
    }
  }
  cout << fixed;
  cout << setprecision(10) << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  bool flag[26]={0};
  rep(i,s.size() ){
    flag[s[i]-'a']=true;
  }
  rep(i,26){
    if(!flag[i]){
      s+=i+'a';
      break;
    }else if(i==25){
      int num=s[s.size() -1];
      int mn=num;
      int p=0;
      repn(j,s.size()-1){
	if(s[j]<s[j+1]) break;
	p=j;
      }
      if(s=="zyxwvutsrqponmlkjihgfedcba") {cout<<-1<<endl;return 0;}
      next_permutation(s.begin()+p-1,s.end() );
      s=s.substr(0,p);
      
     
    }
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::cmp::max;

fn find_lcs(x: &Vec<char>, y: &Vec<char>) -> u32 {
    let len_x = x.len();
    let len_y = y.len();
    let mut lengths = vec![vec![0; len_y]; len_x];

    for (i, xi) in x.iter().enumerate() {
        for (j, yj) in y.iter().enumerate() {
            if xi == yj {
                lengths[i][j] = 1;
            };
        }
    }

    // for row in &lengths {
    //     println!("{:?}", row);
    // }
    // println!();

    for (i, _) in x.iter().enumerate() {
        for (j, _) in y.iter().enumerate() {
            if i == 0 && j == 0 {
                continue;
            } else if i == 0 {
                lengths[i][j] = max(lengths[0][j - 1], lengths[i][j]);
                continue;
            } else if j == 0 {
                lengths[i][j] = max(lengths[i - 1][0], lengths[i][j]);
                continue;
            }

            lengths[i][j] = max(
                max(lengths[i - 1][j], lengths[i][j - 1]),
                lengths[i - 1][j - 1] + lengths[i][j],
            );
        }
    }

    // for row in &lengths {
    //     println!("{:?}", row);
    // }

    lengths[len_x - 1][len_y - 1]
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n = line.trim().parse::<usize>().unwrap();

    let mut x = Vec::new();
    let mut y = Vec::new();

    for i_line in 0..(2 * n) {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        let inputs: Vec<char> = line.split_whitespace()
            .map(|e| e.parse::<String>().ok().unwrap())
            .collect::<String>()
            .chars()
            .collect();

        if i_line % 2 == 0 {
            x = inputs;
        } else {
            y = inputs;
            println!("{}", find_lcs(&x, &y));
        }
    }
}



Measured memory_bytes: 9088
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class SuffixArray {
	void CEB(vector<int> &v, vector<int> &b) {
		int vs = v.size(), bs = b.size();
		fill(b.begin(), b.end(), 0);
		for (int i = 0; i < vs; i++) b[v[i]]++;
		for (int i = 1; i < bs; i++) b[i] += b[i - 1];
	}
	void ISort(vector<int> &v, vector<int> &SA, int mv, vector<int> &b, vector<int> &isL) {
		int vs = v.size(), bs = b.size();
		fill(b.begin(), b.end(), 0);
		for (int i = 0; i < vs; i++) b[v[i]]++;
		int sum = 0;
		for (int i = 0; i < bs; i++) b[i] += sum, swap(sum, b[i]);
		for (int i = 0; i < vs; i++) {
			if (SA[i] > 0 && isL[SA[i] - 1]) SA[b[v[SA[i] - 1]]++] = SA[i] - 1;
		}
	}
	void IISort(vector<int> &v, vector<int> &SA, int mv, vector<int> &b, vector<int> &isL) {
		CEB(v, b);
		for (int i = v.size() - 1; i >= 0; i--) {
			if (SA[i] > 0 && !isL[SA[i] - 1]) SA[--b[v[SA[i] - 1]]] = SA[i] - 1;
		}
	}
	vector<int>SA_IS(vector<int> v, int mv) {
		int vs = v.size();
		if (vs == 1) return vector<int>(1, 0);
		vector<int> isL(vs), b(mv + 1), SA(vs, -1), ord(vs);
		auto isLMS = [&](int x)->bool { return x > 0 && isL[x - 1] && !isL[x]; };
		for (int i = vs - 2; i >= 0; i--) isL[i] = (v[i] > v[i + 1]) || (v[i] == v[i + 1] && isL[i + 1]);
		CEB(v, b);
		for (int i = 0; i < vs; i++) {
			if (isLMS(i)) SA[--b[v[i]]] = i;
		}
		ISort(v, SA, mv, b, isL);
		IISort(v, SA, mv, b, isL);
		int cur = 0;
		for (int i = 0; i < vs; i++) {
			if (isLMS(i)) ord[i] = cur++;
		}
		vector<int> nxv(cur);
		cur = -1;
		int prev = -1;
		for (int i = 0; i < vs; i++) {
			if (!isLMS(SA[i])) continue;
			bool diff = false;
			for (int d = 0; d < vs; d++) {
				if (prev == -1 || v[SA[i] + d] != v[prev + d] || isL[SA[i] + d] != isL[prev + d]) {
					diff = true;
					break;
				}
				else if (d && isLMS(SA[i] + d))break;
			}
			if (diff) cur++, prev = SA[i];
			nxv[ord[SA[i]]] = cur;
		}
		vector<int> reord(nxv.size());
		for (int i = 0; i < vs; i++) {
			if (isLMS(i)) reord[ord[i]] = i;
		}
		vector<int> nxSA = SA_IS(nxv, cur);
		CEB(v, b);
		for (int i = 0; i < SA.size(); i++) SA[i] = -1;
		for (int i = nxSA.size() - 1; i >= 0; i--) {
			SA[--b[v[reord[nxSA[i]]]]] = reord[nxSA[i]];
		}
		ISort(v, SA, mv, b, isL);
		IISort(v, SA, mv, b, isL);
		return SA;
	}
	vector<int>SA_IS(string s) {
		vector<int> v(s.size() + 1);
		for (int i = 0; i < s.size(); i++) v[i] = s[i] + 1;
		return SA_IS(v, *max_element(v.begin(), v.end()));
	}
public:
	string s;
	vector<int> sa;
	void init(string &T) {
		s = T;
		sa = SA_IS(s);
	}
	SuffixArray(string &t) { init(t); }
	SuffixArray() {}
	bool contain(string &t) {
		int a = 0, b = s.size();
		while (b - a > 1) {
			int c = (a + b) / 2;
			if (s.compare(sa[c], t.size(), t) < 0) a = c;
			else b = c;
		}
		return s.compare(sa[b], t.size(), t) == 0;
	}
};
int q; string s, t;
int main() {
	cin >> s >> q;
	SuffixArray v(s);
	for(int i = 0; i < q; i++) {
		cin >> t;
		cout << (v.contain(t) ? 1 : 0) << endl;
	}
}

Measured memory_bytes: 37128
#include <stdio.h>
int main(){
  int a = 0, i, data[100] = {0};
  while(scanf("%d", &a) != EOF){
    if(a == 0){
      printf("%d\n", data[i]);
      i --;
    }else{
      i ++;
      data[i] = a;
    }
  }
  return 0;
}

Measured memory_bytes: 1028
/* In the name of ALLAH */
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>

// MAXIMUM and MINIMUM elements
#define mx_ari(a)   *max_element(a , a+sizeof(a)/4)
#define mn_ari(a)   *min_element(a , a+sizeof(a)/4)
#define mx_arl(a)   *max_element(a , a+sizeof(a)/8)
#define mn_arl(a)   *min_element(a , a+sizeof(a)/8)
#define mx_vec(v)   *max_element(v.begin() , v.end())
#define mn_vec(v)   *min_element(v.begin() , v.end())
// COUNT the occurence of an element
#define cnt_ari(a,b)   count(a , a+sizeof(a)/4 , b)
#define cnt_arl(a,b)   count(a , a+sizeof(a)/8 , b)
#define cnt_vec(v,b)   count(v.begin() , v.end() , b)
// INPUTs
#define sci(a)        scanf("%d",&a)
#define scii(a,b)     scanf("%d %d",&a,&b)
#define sciii(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scl(a)        scanf("%lld",&a)
#define scll(a,b)     scanf("%lld %lld",&a,&b)
#define sclll(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define scf(a)        scanf("%f",&a)
#define scff(a,b)     scanf("%f %f",&a,&b)
#define scfff(a,b,c)  scanf("%f %f %f",&a,&b,&c)
#define scd(a)        scanf("%ld",&a)
#define scdd(a,b)     scanf("%lf %lf",&a,&b)
#define scddd(a,b,c)  scanf("%lf %lf %lf",&a,&b,&c)
// OUTPUTs
#define pri(a)        printf("%d ",a)
#define prii(a,b)     printf("%d %d ",a,b)
#define priii(a,b,c)  printf("%d %d %d ",a,b,c)
#define prl(a)        printf("%lld ",a)
#define prll(a,b)     printf("%lld %lld ",a,b)
#define prlll(a,b,c)  printf("%lld %lld %lld ",a,b,c)
#define prd(a)        printf("%.4lf ",a)
#define prdd(a,b)     printf("%.4lf %.4lf ",a,b)
#define prddd(a,b,c)  printf("%.4lf %.4lf %.4lf ",a,b,c)
#define prf(a)        printf("%.4f ",a)
#define prff(a,b)     printf("%.4f %.4f ",a,b)
#define prfff(a,b,c)  printf("%.4f %.4f %.4f ",a,b,c)
// LOOPs
#define foi(i,n)      for(int i=0;i<n;i++)
#define fol(i,n)      for(long long int i=0;i<n;i++)
#define fod(i,n)      for(double i=0;i<n;i++)
#define fof(i,n)      for(float i=0;i<n;i++)
// NEWLINEs
#define nwl           << "\n"
#define nl            printf("\n");
// PAIRs and PUSHbacks
#define mp            make_pair
#define pb            emplace_back
// IMPORTANTs
#define ll          long long
#define ull         unsigned long long int
#define mod         1000000007
#define lcm(a,b)     (a*b) / __gcd(a,b)

using namespace std;


int cost[100010];
int chi(int i , int n , int a[]){
   if(i < 0){
      return cost[0];
   }

   cost[i] = min(abs(a[i] - a[i+1])+cost[i+1] , abs(a[i] - a[i+2])+cost[i+2]);
   return chi(i-1 , n , a);
}

int main()
{
   int n;
   cin >> n;
   int a[n];
   foi(i,n){
      cin >> a[i];
   }

   cost[n-1] = 0;
   cost[n-2] = abs(a[n-1] - a[n-2]);

   cout << chi(n-3 , n , a);

   return 0;
}

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

int main(void) {
	string a, b; cin >> a >> b;
	int i;
	if (a.size()!=b.size()) {
		cout << a[0];
		for (i = 0; i < b.size(); i++) {
			cout << b[i];
			cout << a[i + 1];
		}
	}
	else {
		for (i = 0; i < a.size(); i++) {
			cout << a[i];
			cout << b[i];
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <array>
    #include <string>
    #include <stack>
    #include <queue>
    #include <deque>
    #include <map>
    #include <unordered_map>
    #include <set>
    #include <unordered_set>
    #include <tuple>
    #include <bitset>
    #include <memory>
    #include <cmath>
    #include <algorithm>
    #include <functional>
    #include <iomanip>
    #include <numeric>
    #include <climits>
    #include <cfloat>
     
    int main() {
    	std::cin.tie(0); std::cin.sync_with_stdio(false);
    	int n, m, l; std::cin >> n >> m >> l;
    	std::vector<std::vector<long long int>> min_distance(n, std::vector<long long int>(n, LLONG_MAX));
    	for (auto i = 0; i < m; ++i) {
    		int a, b, c; std::cin >> a >> b >> c; --a; --b;
    		min_distance[a][b] = min_distance[b][a] = c;
    	}
    	for (auto k = 0; k < n; ++k) for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (min_distance[i][k] != LLONG_MAX && min_distance[k][j] != LLONG_MAX) {
    		min_distance[i][j] = min_distance[j][i] = std::min(min_distance[i][j], min_distance[i][k] + min_distance[k][j]);
    	}
    	std::vector<std::vector<int>> min_supply(n, std::vector<int>(n, INT_MAX));
    	for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) {
    		if (min_distance[i][j] <= l) {
    			min_supply[i][j] = min_supply[j][i] = 1;
    		}
    	}
    	for (auto k = 0; k < n; ++k) for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (min_supply[i][k] != INT_MAX && min_supply[k][j] != INT_MAX) {
    		min_supply[i][j] = min_supply[j][i] = std::min(min_supply[i][j], min_supply[i][k] + min_supply[k][j]);
    	}
    	int q; std::cin >> q;
    	for (auto i = 0; i < q; ++i) {
    		int s, t; std::cin >> s >> t; --s; --t;
    		if (min_supply[s][t] == INT_MAX) {
    			std::cout << -1 << '\n';
    		}
    		else {
    			std::cout << min_supply[s][t] - 1 << '\n';
    		}
    	}
    }

Measured memory_bytes: 1664
#include <stdio.h>
int main()
{
    char s1[101],s2[101],s[101];
    scanf("%s %s %s",s1,s,s2);
    if(s[0]>='a'&&s[0]<='z')
    {
        s[0]=s[0]-32;
    }
    printf("A%cC",s[0]);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	int max = 0;
      	//配列
        int num[] = new int[n];
        for(int i = 0; i < n; i++){
        	num[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < n-1; i++){
          if(num[i] >= num[i+1]){
              count++;
          if(count>max){
              max = count;
            }
        }else{
            if(max<count){
         	max = count;
          }
            count = 0;
        }
        }
        System.out.println(max);
     }
}

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

int main() {
    int n, k, ans = 1;
    cin >> n >> k;
    rep(i, n) ans = min(ans + k, 2 * ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
m, otoshidama = map(int, input().split(" "))

for yukichi in range(m + 1):
  for higuchi in range(m + 1):
    noguchi = m - yukichi - higuchi
    if noguchi >= 0:
      money = yukichi * 10000 + higuchi * 5000 + noguchi * 1000
      if money == otoshidama and yukichi + higuchi + noguchi == m:
        print(yukichi,higuchi,noguchi)
        exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int c[] = {6000,4000,3000,2000};
    int t,n;
    while(cin>>t>>n){
        cout<<n*c[t-1]<<endl;
    }


    return 0;
}

Measured memory_bytes: 1164
n,k = map(int,input().split())
ans = 0
if k == 0:
    for x in range(1,n+1):
        ans += n//x
    k += 1
for b in range(k,n+1):
    m = int((n+1)/b)
    ans += m*(b-k)
    ans += max(0,n-m*b-k+1)

print(ans)

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

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> prob(n);
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> prob.at(i);
        sum += prob.at(i);
    }
    if(sum % 10 !=0){
        cout << sum << endl;
        return 0;
    }
    sort(prob.begin(), prob.end());
    int i = 0;
    int temp = 0;
    int cnt = 0;
    while (sum % 10 == 0 && i < n){
        sum -= prob.at(i);
        if(prob.at(i)%10==0){
            temp += prob.at(i);
            cnt++;
        }
        i++;
    }
    if(n==cnt)
        cout << sum << endl;
    else
        cout << sum + temp << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
int h[100000];
int dp[100001];
int rec(int i){
  int res;
  if(dp[i]>=0) return dp[i];
  if(i==n-1) res=0;
  else if(i==n-2) res=rec(i+1)+abs(h[i]-h[i+1]);
  else res=min(rec(i+1)+abs(h[i]-h[i+1]),rec(i+2)+abs(h[i]-h[i+2]));
  return dp[i]=res;
}
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> h[i];
  memset(dp,-1,sizeof(dp));
  cout << rec(0) << "\n";
  
  return 0;
}


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

#define INF -1LL<<63

string S;
char U[11] = "0123456789";
int junjo[4] = { 0,0,1,1 };

long long STOI(string V) {
	int LEN = V.size();
	if (LEN == 0) { return 0; }
	return (V[LEN - 1] - '0') + 10 * (STOI(V.substr(0, LEN - 1)));
}
long long calc(int L, int R) {
	int K = 0;
	vector<int>junjo2[4];
	for (int i = 0; i<4; i++) {
		junjo2[junjo[i]].push_back(i);
	}
	for (int i = 0; i<4; i++) {
		if (junjo2[i].size() >= 1) {
			for (int j = R - 1; j >= L; j--) {
				if (S[j] == '(') { K++; }
				if (S[j] == ')') { K--; }
				for (int k = 0; k<junjo2[i].size(); k++) {
					if (junjo2[i][k] == 0) {
						if (S[j] == '+' && K == 0) {
							return calc(L, j) + calc(j + 1, R);
						}
					}
					if (junjo2[i][k] == 1) {
						if (S[j] == '-' && K == 0) {
							return calc(L, j) - calc(j + 1, R);
						}
					}
					if (junjo2[i][k] == 2) {
						if (S[j] == '*' && K == 0) {
							return calc(L, j)*calc(j + 1, R);
						}
					}
					if (junjo2[i][k] == 3) {
						if (S[j] == '/' && K == 0) {
							return calc(L, j) / calc(j + 1, R);
						}
					}
				}
			}
		}
	}
	if (S[L] == '(' && S[R - 1] == ')') { return calc(L + 1, R - 1); }
	return STOI(S.substr(L, R - L));
}


int main() {
	long long maxn = INF;
	int POW[4] = { 1,4,16,64 };
	cin >> S;
	S += '=';
	for (int i = 0; i < 256; i++) {
		for (int j = 0; j < 4; j++) {
			junjo[j] = (i / POW[j]) % 4;
		}
		maxn = max(maxn, calc(0, S.size() - 1));
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n;
  while(cin>>n,n){
    int v[n];
    ll ans = 0;
    int tmp = 0;
    REP(i,n) cin>>v[i];
    sort(v, v+n);
    REP(i,n-1) ans += (tmp += v[i]);
    cout << ans << endl;
  }
  return 0;
}

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


int main() {


    int n,k;
    cin>>n>>k;

    //1.サイコロを1回振り、出た目を現在の得点とする。
    //期待値は1*1/N+2*1/N...N*1/N
    //得点は結局1～Nのどれか。
    //2.得点が1以上K-1以上で有る限りコインを降り続ける。表が出たら2倍になり、裏が出たら0になる。
    //1の時にK以上になる確率、logx2(K/1)回サイコロがあたり続ければよい。
    //3.得点が0またはK以上になるとゲームが終了する。このとき得点がK点以上であると勝ち、0の場合負け。
    //勝つ確率を求める。

    long double probab=0;
    for(int i=1;i<=n;i++){


        long double wk = ceil(log2(ceil((long double)k/(long double)i)));
        probab+=pow(0.5,wk);
    }

    cout << fixed << setprecision(15) << probab/(long double)n << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[]list=new int[n+1];
        boolean[]isVisit=new boolean[n+1];
        for (int i = 1; i <= n; i++) {
           list[i]= in.nextInt();
        }
        int count=0;
        int start=1;
        
        while(true){
           if(isVisit[start]){
            System.out.println(-1);
            return;
        }
            isVisit[start]=true;
        
        if(start==2)
            break;
       
            start=list[start];
        count++;
        }
        
        
        System.out.println(count);
    }
}


Measured memory_bytes: 51248
N = int(input())
xy = [[int(_) for _ in input().split()] for i in range(N)]

xsort_n = sorted(range(N), key=lambda n:xy[n][0])
ysort_n = sorted(range(N), key=lambda n:xy[n][1])

from collections import defaultdict

neighbors = defaultdict(list)

for i in range(N - 1):
    x1 = xsort_n[i]
    x2 = xsort_n[i+1]
    xd = xy[x2][0] - xy[x1][0]
    y1 = ysort_n[i]
    y2 = ysort_n[i+1]
    yd = xy[y2][1] - xy[y1][1]
    neighbors[x1].append((x2, xd))
    neighbors[x2].append((x1, xd))
    neighbors[y1].append((y2, yd))
    neighbors[y2].append((y1, yd))

from heapq import *

isused = [0] * N

h = []

heappush(h, (0, 0))

result = 0

while h:
    d, n = heappop(h)
    if isused[n]:
        continue
    result += d
    isused[n] = 1
    for ni, nd in neighbors[n]:
        if not isused[ni]:
            heappush(h, (nd, ni))
    
print(result)


Measured memory_bytes: 124888
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int n,x[200010],y[200010],a[200010],b[200010];

int main(){
	n=read();
	for(int i=1;i<=n;i++) x[i]=read(),y[i]=read();
	for(int i=1;i<=n;i++) a[i]=x[i]+y[i],b[i]=x[i]-y[i];
	sort(a+1,a+n+1),sort(b+1,b+n+1);
	printf("%lld\n",max(a[n]-a[1],b[n]-b[1]));
	return 0;
}


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

bool is_sorted(ll a[],ll n)
{
	bool flg=true;
	for(ll i=1;i<n;i++)
	{
		if (a[i]<a[i-1])
		{
			flg=false;
			break;
		}
	}
	return flg;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}	

	bool flg=is_sorted(a,n);

	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			swap(a[i],a[j]);
			if (is_sorted(a,n))
			{
				flg=true;
			}
			swap(a[i],a[j]);
		}
	}
	if (flg)
		cout<<"YES";
	else
		cout<<"NO";
}

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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int main(){
  int64_t n,l0,l1;
  cin >> n;
  l0 = 2;
  l1 = 1;
  if (n == 1){
    cout << 1 << endl;
  }else{
    int64_t tmp;
    for (int i=2;i<=n;i++){
      tmp = l0 + l1;
      l0 = l1;
      l1 = tmp;
    }
    cout << tmp << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from typing import *

def solve(n: int) -> int:
    nums = [i for i in range(15) if i % 3 != 0 and i % 5 != 0]
    k = (n + 1) // 15
    ans = k * sum(nums) + k * (k - 1) // 2 * len(nums) * 15
    for i in range((n + 1) // 15 * 15, n + 1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    return ans


# generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
    N = int(input())
    ans = solve(N)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
   

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<string,int> CardGame{};
    
    
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        if(!CardGame.count(s)) CardGame.insert(make_pair(s, 1));
        else CardGame[s]++;
    }
    
    
    
    int m; cin >> m;
    for (int j = 0; j < m; j++) {
        string s; cin >> s;
        if(CardGame.count(s)) CardGame[s]--;
    }
    
    
    
    
    int ans = 0;
    
    for (auto p: CardGame) ans = max(ans, p.second);
    
    cout << ans << endl;
    
    
    
    
}



Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())

def noudo(weight,sugar):
    if sugar is None:return -1000000000
    else:return(sugar*100/weight)
    
def noudosafe(w,s):
    if (noudo(w,s)<=noudo(100+E,E)):return s
    else:return None
    
def eraseNone(i):
    if i is None:return 0
    else: return i
    
dp=[None]*(F+1) #dp[x]はｘｇの砂糖水の中に最大限入っている砂糖の量
dp[0]=0
for i in range(1,F+1):#iグラムの砂糖水
    sug1,sug2,sug3,sug4=[None]*4
    if i>=100*A:
        sug1=dp[i-100*A]
        if sug1 is not None:
            sug1=noudosafe(i,sug1)
    if i>=100*B:
        sug2=dp[i-100*B]
        if sug2 is not None:
            sug2=noudosafe(i,sug2)
    if i>=C:
        sug3base=dp[i-C]
        if sug3base is not None:
            sug3=noudosafe(i,sug3base+C)
    if i>=D:
        sug4base=dp[i-D]
        if sug4base is not None:
            sug4=(noudosafe(i,sug4base+D))
            
    sug=(sug1,sug2,sug3,sug4)
    if all([k is None for k in sug]):
        continue
    else:
        dp[i]=max([eraseNone(k) for k in sug])

ansi=0
anssugar=0
maxnoudo=0
for x,s in enumerate(dp):
    if x==0:continue
    if maxnoudo<noudo(x,s):
        maxnoudo=noudo(x,s)
        ansi=x
        anssugar=s
if anssugar:print(ansi,anssugar)
else: print(100*A,0)

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	int n,a,b; cin >> n >> a >> b;
	vector<int> p(n);
	int cnt=0;
	int cnt1=0;
	for(int i=0;i<n;i++){
		cin >> p[i];
		if(p[i]<=a)cnt++;
		if(p[i]>b)cnt1++;
	}
	cout << min(min(cnt,cnt1),n-cnt-cnt1) << endl;
}

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

using namespace std;

const int maxn = 1e5+500;
int a[maxn];
int b[maxn];
int c[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<=n;i++){
		cin>>a[i];
//		c[i]+=a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	long long cnt = 0;
	for(int i=0;i<n;i++){
		if(b[i]>a[i]){
			cnt += a[i];
		
			b[i] = b[i]-a[i];	a[i] = 0;
		//	cout<<b[i]<<endl;
			if(a[i+1] > (b[i]-a[i])){
				a[i+1] -= (b[i]-a[i]);
				cnt += (b[i]-a[i]);
			}else{
				cnt += a[i+1];
				a[i+1]=0;
			}
		}else{
			cnt+=b[i];
		}
	}
	cout<<cnt<<endl;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(ll i=0;i<n;i++) {
    if(a[i]%2) {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int X = in.nextInt();
        int Y = in.nextInt();
        int Z = in.nextInt();
        
      System.out.print(Z + " " + X + " " + Y);
    }
}

Measured memory_bytes: 21844
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int digits(ll n){
  ll ret = 0;
  while(n){
    ret++;
    n /= 10;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  vll s(m), c(m);
  rep(i, m){
    cin >> s[i] >> c[i];
  }
  if(n == 1){
    bool f = 1;
    rep(i, m){
      if(c[i]){
        f = 0; break;
      }
    }
    if(f){
      print(0);
      return 0;
    }
  }
  repr(i, 1, 1000){
    if(digits(i) == n){
      auto ns = to_string(i);
      bool f = 1;
      rep(j, m){
        if(ns[s[j]-1] != c[j] + '0'){
          f = 0;
        }
      }
      if(f){
        print(i);
        return 0;
      }
    }
  }
  print(-1);
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


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

    int A[2][N];
    int up[N];
    int down[N];

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

    for(int i=0;i<N-1;i++){
        up[i+1] = up[i] + A[0][i];
    }
    for(int i=0;i<N-1;i++){
        down[i+1] = down[i] + A[1][i];
    }
    
    int ans=0;
    for(int i=0;i<N;i++){
        ans = max(ans, up[i]+down[N-1]-down[i] + A[0][i] + A[1][N-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.85 #ループの時間制限
PROB=0.001 #突然変異の確率  
A=26 #アルファベットの数
START=time.time()
C_MIN,C_MAX=1,5
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<=TIME_LIMIT:
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    if (S[d][q]-S[d][p])+Z*C[q]-Y*C[p]>0 or random()<PROB:
        T[d]=q

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 90728