akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

struct Edge {
  long long time;
  int dst;
  int money;
};

struct State {
  long long time;
  int v;
  int money;
  bool operator<(const State& a) const {
    return a.time > time;
  }
  bool operator>(const State& a) const {
    return a.time < time;
  }
};
  

int main(){
  
  int N, M, S;
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &S);
  S=std::min(S, 50*50);
  std::vector<int > A(M), B(M), U(M), V(M), C(N), D(N);
  std::vector<Edge > edge[54];
  for (int i=0; i<M; i++){
    scanf("%d", &U[i]);
    scanf("%d", &V[i]);
    scanf("%d", &A[i]);
    scanf("%d", &B[i]);
    U[i]--;
    V[i]--;
    edge[U[i]].push_back((Edge){B[i], V[i], A[i]});
    edge[V[i]].push_back((Edge){B[i], U[i], A[i]});
  }
  for (int i=0; i<N; i++){
    scanf("%d", &C[i]);
    scanf("%d", &D[i]);
  }
  std::priority_queue<State, std::vector<State >, std::greater<State> > queue;
  queue.push((State){0, 0, S});
  std::vector<std::vector<long long > > dp(54, std::vector<long long > (50*50+4, 10000000000000000));
  dp[0][S]=0;
  while(queue.size()>0){
    State head = queue.top();
    queue.pop();
    // train
    for (int i=0; i<edge[head.v].size(); i++){
      Edge thisedge = edge[head.v][i];
      //printf("head node=%d\n", head.v);
      if (head.money<thisedge.money) continue;
      if (dp[thisedge.dst][head.money-thisedge.money]>dp[head.v][head.money]+thisedge.time){
	dp[thisedge.dst][head.money-thisedge.money]=dp[head.v][head.money]+thisedge.time;
	queue.push((State){dp[thisedge.dst][head.money-thisedge.money], thisedge.dst, head.money-thisedge.money});
	//printf("dp[%d][%d]=%d\n", thisedge.dst, head.money-thisedge.money, dp[thisedge.dst][head.money-thisedge.money]);
      }
    }
    // money exchange
    if (dp[head.v][std::min(2500, head.money+C[head.v])] > dp[head.v][head.money]+D[head.v]){
      dp[head.v][std::min(2500, head.money+C[head.v])] = dp[head.v][head.money]+D[head.v];
      queue.push((State){dp[head.v][std::min(2500, head.money+C[head.v])], head.v, std::min(2500, head.money+C[head.v])});
      //printf("dp[%d][%d]=%d\n", head.v, head.money+C[head.v], dp[head.v][std::min(2500, head.money+C[head.v])]);
    }
  }
  for (int i=1; i<N; i++){
    long long ans = 10000000000000000;
    for (int j=0; j<2504; j++){
      ans = std::min(ans, dp[i][j]);
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 5928
#include<iostream>
using namespace std;
main()
{
	string s;
	cin>>s;
	if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2])
	{
		cout<<"Yes"<<endl;
	}
	else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1])
	{
		cout<<"Yes"<<endl;
	}
	else if(s[0]==s[3] && s[2]==s[1] && s[0]!=s[2])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int[] h = new int[n];
        int[] dif = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }
        int[] ten = new int[n];
        for(int i = 0; i < n; i++){
            ten[i] = t*1000 - h[i]*6;
        }
        for(int i = 0; i < n; i++){
            dif[i] = Math.abs(a*1000 - ten[i]);
        }
        int min = dif[0];
        for(int i = 1; i < n; i++){
            min = Math.min(min, dif[i]);
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(min == dif[i]){
                ans = i+1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	//昇順ソートして
	int n;
	vector<int> d(101);
	std::fill(d.begin(), d.end(), 0);
	cin >> n;
	d.resize(n+1);
	FOR(i, 1, n+1) {
		cin >> d[i];
	}
	std::sort(d.begin(),d.end());
	FOR(i, 1, n+1) {
		if (d[i - 1] == d[i]) {
			continue; 
		} else d[0]++;
	}
	cout << d[0] << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
b = []
g = []
for i in range(1,n):
    if a[i-1] == a[i]:
        b.append(a[i])
if 4 <= n:
    for i in range(3,n):
        if a[i-3] == a[i]:
            g.append(a[i])
c = sorted(list(set(b)),reverse=True)
f = sorted(list(set(g)),reverse=True)
ans = 0
if len(f):
    ans = max(ans,f[0]*f[0])
if 2 <= len(c):
    ans = max(ans,c[0]*c[1])
print(ans)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// #define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
// #define esort(s) sort((s).begin(),(s).end()) 
// #define INF 999999999

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

    rep(i,s.size()){
        if (s[i] + n > 90)
            s[i] = s[i] + n - 26;
        else
            s[i] = s[i] + n;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 09.07.2020 15:01:11
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  ll n,m;
  cin>>n>>m;

  ll ans=0;

  if(n==2 || m==2)ans=0;
  else if(n==1 && m==1)ans=1;
  else if(n==1 || m==1)ans=m*n-2;
  else ans=(m-2)*(n-2);

  cout<<ans<<endl;

  return 0;
}

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

int main()
{
    long long K;
    cin >> K;

    long long N = 50;
    long long A = K / N;
    long long remain = K - A * N;
    vector<long long> a(N, A + N + (N - remain));
    for (int i = 0; i < N; i++)
    {
        if (i < (N - remain))
        {
            a[i] -= N + 1;
        }
    }

    cout << N << endl;
    for (long long x : a)
    {
        cout << x << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int N;
	int A[100000];
	cin >> N;
	int goukei = 0;
	int mae = 0;
	rep(i, N) {
		cin >> A[i];
		goukei += abs(A[i] - mae);
		mae = A[i];
	}
	goukei += abs(A[N - 1]);

	co(goukei - abs(A[0]) - abs(A[0] - A[1]) + abs(A[1]));

	for (int i = 1; i < N - 1; i++) {
		co(goukei - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i - 1]));
	}
	co(goukei - abs(A[N - 1] - A[N - 2]) - abs(A[N - 1]) + abs(A[N - 2]));

	Would you please return 0;
}

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if (a%2 ==0 || b%2 == 0 || c%2 == 0) cout << 0 << endl;
    else cout << min(min(a * b, b * c), c * a) << endl;
}

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

int main() {
  int N,K;
  map<int, int> A;
  int d,a;
  cin >> N >> K;
  rep(i, K) {
    cin >> d;
    rep(j, d) {
      cin >> a;
      A[--a]++;
    }
  }
  int sum=0;
  rep(i, N) {
    if(A[i] == 0) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}




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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        long[] c = new long[n];
        for(int i = 0;i < n;i++) a[i] = sc.nextLong();
        for(int i = 0;i < n;i++) b[i] = sc.nextLong();
        for(int i = 0;i < n;i++) c[i] = sc.nextLong();
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        
        long ans = 0;
        for(int i = 0;i < n;i++) {
            long bi = b[i];
            int left = -1;
            int right = n;
            while(right - left > 1) {
                int mid = (left + right) / 2;
                if(a[mid] < bi) left = mid;
                else if(a[mid] >= bi) right = mid;
            }
            long aCount = left + 1;

            left = -1;
            right = n;
            while(right - left > 1) {
                int mid = (left + right) / 2;
                if(c[mid] <= bi) left = mid;
                else if(c[mid] > bi) right = mid;
            }
            long bCount = n - left - 1;
            
            ans += aCount * bCount;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 65276
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	lli n,x,t;
	cin>>n>>x>>t;
	lli p=(n+x-1)/x;
	cout<<p*t<<endl;
	
	
	
	
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;

string s;
string t;
int p[100005],q[100005];
void query(int a,int b,int c,int d){
    int k = b-a+1+(p[b]-p[a-1]);
    int t = d-c+1+(q[d]-q[c-1]);
    if(k%3==t%3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}
int main(){
    int qq;
    cin >> s >> t >> qq;
    int ss = (int)s.size();
    int tt = (int)t.size();
    rep(i,ss){
        p[i+1]=p[i];
        if(s[i]=='A')p[i+1]++;
    }
    rep(i,tt){
        q[i+1]=q[i];
        if(t[i]=='A')q[i+1]++;
    }
    int a,b,c,d;
    rep(i,qq){
        cin >> a  >> b >> c >> d;
        if((b-a+1+p[b]-p[a-1])%3==(d-c+1+q[d]-q[c-1])%3){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	ll N, W; cin >> N >> W;
	V<ll> w(N + 1), v(N + 1);
	FOR(i, 1, N + 1) cin >> w[i] >> v[i];
	V<V<ll>> dp(N + 1, V<ll>(100001, (ll)1e15));
	REP(i, N + 1) dp[i][0] = 0;

	FOR(i,1,N+1){
		REP(j,100001){
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			if (j + v[i] > 100000 || dp[i - 1][j] + w[i] > W) continue;
			dp[i][j + v[i]] = min(dp[i][j + v[i]], dp[i - 1][j] + w[i]);
		}
	}
	ll ans;
	for(int i = 100000; 0 <= i; --i){
		if(dp[N][i]<=W) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

int main(){
	int n;
	while(cin>>n&&n){
		vector<P> bridge(n);
		for(int i=0; i<n; ++i){
			cin >> bridge[i].first; //weight
			cin >> bridge[i].second; //limit
		}
		for(int i=0; i<n; ++i){
			for(int j=n-1; j-1>=i; --j){
				if(bridge[j].second<bridge[j-1].second){
					swap(bridge[j],bridge[j-1]);
				} else if(bridge[j].second==bridge[j-1].second&&bridge[j].first<bridge[j-1].first){
					swap(bridge[j],bridge[j-1]);
				}
			}
		}
		bool f=true;
		int w=0;
		for(int i=0; i<n; ++i){
			if(w+bridge[i].first<=bridge[i].second){
				w+=bridge[i].first;
			} else {
				f=false;
			}
		}
		if(f){
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
//largest sum
//probably second question
int32_t main() {
    int a, b;
    cin>>a>>b;
    a += 48;
    b += 48;
    char aa = a;
    char bb = b;
    a-=48;
    b-=48;
    string aaa = "", bbb = "";
    for(int i= 0; i<b; i++){
        aaa += aa;
    }
    for(int i = 0 ; i<a; i++){
        bbb += bb;
    }
    cout<<min(aaa, bbb)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<string> res(100000);
int cnt;
string s;

void dfs(int n) {
	if(n == 0) {
		res[cnt] = s;
		++cnt;
		return;
	}
	bool ex = false;
	REP(i, s.size()) {
		if(s[i] == 'a' + n) {
			ex = true;
			break;
		}
		if(s[i] == 'a' + (n - 1)) {
			s[i] = 'a' + n;
			dfs(n - 1);
			s[i] = 'a' + (n - 1);
		}
	}
	if(!ex) {
		dfs(n - 1);
	}
}

int main(void) {
	while(true) {
		cin>>s;
		if(s == "#") break;
		cnt = 0;
		dfs(25);
		sort(res.begin(), res.begin() + cnt);
		cout<<cnt<<endl;
		if(cnt <= 10) {
			REP(i, cnt) {
				cout<<res[i]<<endl;
			}
		} else {
			REP(i, 5) {
				cout<<res[i]<<endl;
			}
			REP(i, 5) {
				cout<<res[cnt - 5 + i]<<endl;
			}
		}
	}
}

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

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

    int out_num = x;
    bool end_flg = false;
    while(1) {
        int loop_num = 0;
        for ( int i = 2; i <= out_num; i++ ) {
            loop_num = i;
            if ( out_num % i == 0 | loop_num == out_num ) break;
        }
        if ( out_num == loop_num ) break;
        out_num++;
    }

    cout << out_num << endl;

    return 0;
}

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

int main() {
  int K;
  string S;
  
  cin >> K;
  cin >> S;
  
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    string sbuff = S.substr(0, K);
    cout << sbuff << "..." << endl;
  }
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main()
{
	int n, m;
	int z[101];
	int i, j, tmp;
	scanf("%d%d", &n, &m);
	for (i = 1;i <= n;i++)scanf("%d", &z[i]);
	for (i = 1;i <= m;i++) {
		j = 1;
		while (j != n) {
			if (z[j] % i > z[j + 1] % i) {
				tmp = z[j];z[j] = z[j + 1];z[j + 1] = tmp;j++;
			}
			else if (z[j] % i <= z[j + 1] % i) j++;
		}
	}
	for (i = 1;i <= n;i++)printf("%d\n", z[i]);
	return 0;
}

Measured memory_bytes: 596
N,x,y = map(int, input().split())
long_list=[0 for _ in range(N-1)]

for i in range(1,N):
    for j in range(i+1,N+1):
        a=min(j-i,abs(x-i)+abs(j-y)+1)
        long_list[a-1]=long_list[a-1]+1
for i in long_list:
    print(i)

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s; reverse(s.begin(), s.end());
	int n = s.size();
	string tmp[4] = { "maerd","remaerd","esare","resare" };
	rep(i, n) {
		bool ok = false;
		if (i + 6 < n) {
			if (s.substr(i, 7) == tmp[1]) {
				ok = true; i += 6;
			}
		}
		if (i + 5 < n) {
			if (s.substr(i, 6) == tmp[3]) {
				ok = true; i += 5;
			}
		}
		if (i + 4 < n) {
			if (s.substr(i, 5) == tmp[0]) {
				ok = true; i += 4;
			}
			if (s.substr(i, 5) == tmp[2]) {
				ok = true; i += 4;
			}
		}
		if (!ok) {
			cout << "NO" << endl; return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

int n, k, x, y;
vector<int> a, b;
ll ans;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  scanf("%d %d" , &n, &k);
  for(int i = 0 ; i < n ; i++){
  	scanf("%d %d" , &x, &y);
  	a.pb(x);
  	b.pb(y);
  }
  k++;
  int mask = 0;
  for(int i = 30 ; i >= 0 ; i--){
  	if(k & (1 << i)){
  		mask ^= (1 << i);
  		ll temp = 0;
  		for(int j = 0 ; j < n ; j++){
  			if((a[j] & mask) == 0)
  				temp += b[j];
  		}
  		ans = max(ans, temp);
  		mask ^= (1 << i);
  	}
  	else
  		mask ^= (1 << i);
  }

  printf("%lld" , ans);
  return 0;
}  


Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
    int a,b,c;
     cin>>a>>b>>c;
     if(a<b){
         if(b<c)
             cout<<"Yes"<<endl;
         else
              cout<<"No"<<endl;
     }
     else
          cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 200005;

int n,A,B,C,D;

char s[MAXN];

bool reach(int x,int y)
{
	for (int i = x;i < y;i++)
		if (s[i] == '#' && s[i + 1] == '#')
			return 0;
	return 1;
}

int main()
{
	scanf("%d%d%d%d%d%s",&n,&A,&B,&C,&D,s + 1);
	if (C < D)
	{
		puts(reach(A,C) && reach(B,D) ? "Yes" : "No");
		return 0;
	}
	if (!reach(B,D))
	{
		puts("No");
		return 0;
	}
	if (!reach(A,C))
	{
		puts("No");
		return 0;
	}
	for (int i = B;i <= D;i++)
		if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.')
		{
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

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

using namespace std;

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

  int64_t h;
  cin >> h;

  int cnt = 0;
  int64_t ans = 1;
  while (h != 1) {
    h /= 2;
    ++cnt;
    ans += pow(2, cnt);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);


int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  vector<int> y(m);
  rep(i,m) cin >> y[i];
  bool ok;
  for(int i = X+1; i < Y; ++i){
    ok = true;
    rep(j,n){
      if(x[j]>=i){
        ok=false;
        break;
      }
    }
    rep(k,m){
      if(y[k]<i){
        ok=false;
        break;
      }
    }
    if(ok) break;
  }
  if(ok) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=0;i<ty-sy;i++){
        cout<<"U";
    }
    for(int i=0;i<tx-sx;i++){
        cout<<"R";
    }
    for(int i=0;i<ty-sy;i++) cout<<"D";
    REP(i,tx-sx) cout<<"L";
    cout<<"L";
    REP(i,ty-sy+1) cout<<"U";
    REP(i,tx-sx+1) cout<<"R";
    cout<<"D";
    cout<<"R";
    REP(i,ty-sy+1) cout<<"D";
    REP(i,tx-sx+1) cout<<"L";
    cout<<"U"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
ll n, m;
map<int,int> x, y;
struct node{
    int x,y;
};
node a[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n >> m;
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++){
        cin >> a[i].x >> a[i].y;
        x[a[i].x]++;
        y[a[i].y]++;
    }
    int maxx = 0, maxy = 0;
    for(int i = 1; i <= t; i++) maxx = max(maxx, x[a[i].x]), maxy = max(maxy, y[a[i].y]);
    if(x.size() == 1 || y.size() == 1){
        cout << t << endl;
    }
    else{
        if(maxx == 1 && maxy == 1){
            cout << 2 << endl;
        }
        else{
            ll x1 = 0, x2 = 0, y1 = 0, y2 = 0;
            map<int,int>::iterator it;
            for(it = x.begin(); it != x.end(); it++){
                if(it->second == maxx) x1++;
                else if(it->second == maxx - 1) x2++;
            }
            for(it = y.begin(); it != y.end(); it++){
                if(it->second == maxy) y1++;
                else if(it->second == maxy - 1) y2++;
            }
            ll ans1 = 0, ans2 = 0;
            ans1 = x1 * y1;
            ans2 = x2 * y1 + x1 * y2;
            for(int i = 1; i <= t; i++){
                if(maxx + maxy == x[a[i].x] + y[a[i].y]){
                    ans1--;
                    ans2++;
                }
                else if(maxx + maxy - 1 == x[a[i].x] + y[a[i].y]){
                    ans2--;
                }
            }
            if(ans1){
                cout << maxx + maxy  << endl;
            }
            else{
                cout << maxx + maxy - 1  << endl;
            }
        }
    }
}


Measured memory_bytes: 33960
import Text.Printf

main = getLine >>= solve 1 . input

-- 入力
input :: String -> Int
input = read

include3 i x n
  | x `mod` 10 == 3 = do
    p i
    solve (i + 1) n
  | otherwise = do
    let x' = div x 10
    if x' > 0 then include3 i x' n
    else solve (i + 1) n

-- 解答
solve i n | i > n = putStrLn ""
  | otherwise= do
    if i `mod` 3 == 0 then do
      p i
      solve (i+1) n
    else do
      include3 i i n

p i = putStr $ printf " %d" i



Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

ll dp[2][100009];

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

    int N, W, w[100], v[100];
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    rep(i, 2) rep(j, 100009) dp[i][j] = 1e18;
    dp[0][0] = 0;

    rep(j, N) rep(i, 100009) {
        chmin(dp[j + 1 & 1][i], dp[j & 1][i]);
        if(i + v[j] < 100009)
            chmin(dp[j + 1 & 1][i + v[j]], dp[j & 1][i] + w[j]);
    }

    for(int i = 100008;; i--)
        if(dp[N & 1][i] <= W) {
            cout << i << endl;
            return 0;
        }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);

int n, k;
int p[MAX_N];

int counter_mono_part() {
  p[n] = -1;

  int ret = 0;

  int cnt = 1;

  for (int i = 1; i <= n; ++i) {
    if (p[i - 1] < p[i])
      cnt += 1;
    else {
      if (cnt >= k) ret += 1;
      cnt = 1;
    }
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(p[i]));
  }

  set<int> st;

  for (int i = 0; i < k; ++i) {
    st.insert(p[i]);
  }

  int cnt = 1;

  int mono_part = counter_mono_part();

  for (int i = 1; (i + k - 1) < n; ++i) {
    int last_begin_ind = i - 1;
    int last_begin = p[last_begin_ind];

    int cur_end = p[i + k - 1];

    int last_max = *(--st.end());

    st.erase(st.find(last_begin));

    int cur_min = *(st.begin());

    if (!(last_begin < cur_min && last_max < cur_end)) {
      cnt += 1;
    }

    st.insert(cur_end);
  }

  int ans = cnt;

  if (mono_part >= 1) {
    ans -= mono_part;
    ans += 1;
  }

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

  return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t; cin>>s>>t;
  int ans=0;
  rep(i,3) if(s.at(i)==t.at(i)) ans++;
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,ans,arr[200001];
int whack[1000001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
        whack[arr[i]]++;
    }
    for (int i=1;i<=1000000;i++){
        if (whack[i]==0) continue;
        for (int j=i*2;j<=1000000;j+=i){
            whack[j]++;
        }
    }
    for (int i=1;i<=n;i++){
        if (whack[arr[i]]==1) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 8268
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h)cin >> s[i];
	int ans = 0;
	rep(is, 1 << h)rep(js, 1 << w) {
		int cnt = 0;
		rep(i, h)rep(j, w){
			if (is >> i & 1)continue;
			if (js >> j & 1)continue;
			if (s[i][j] == '#')cnt++;
		}
		if (cnt == k)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
const DIV:usize = 1000000007;
const MOVES: [(i32, i32); 4] = [(1, 0), (0, 1), (-1, 0), (0, -1)];
use std::collections::BTreeSet;
fn main(){
    input!{
       s:String,
       k:usize,
    }
    let mut set = BTreeSet::new();
    for j in 0..s.len() {
        for k in 0..k{
            if j+k >= s.len() {break;}
            set.insert(&s[j..j+k+1]);
        }
    }
    let mut v:Vec<_> = set.into_iter().map(|s| s).collect();
    v.sort();
    println!("{}",v[k-1]);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int dp[1010][1010];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s1,s2;
  cin>>s1>>s2;
  int n1=s1.length(),n2=s2.length();
  
  CLR(dp);
  FOR(i,1,1010)dp[i][0]=dp[0][i]=i;
  FOR(i,1,n1+1){
    FOR(j,1,n2+1){
      dp[i][j]=min(dp[i][j-1],min(dp[i-1][j],dp[i-1][j-1]))+1;
      if(s1[i-1]==s2[j-1])dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
      //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    }
  }
  cout<<dp[n1][n2]<<endl;
}


Measured memory_bytes: 7184
#include<iostream>
#include<stack>
#include<cstdio>
using namespace std;

int main(){
  stack<int> s;
  int n;
  while(scanf("%d",&n) != EOF){
    if(n != 0) s.push(n);
    else{
      cout << s.top()<<endl;
      s.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 0;
ll s , c;

bool can(ll x)
{
	ll ss = s , cc = c;
	ll need = x - ss;
	if(need > 0) cc = cc - (need * 2);
	if(cc >= x * 2) return true;
	return false;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> s >> c;
	ll low = 0 , high = c / 2 , mid , ans;
	while(high >= low)
	{
		mid = (high + low) / 2;
		if(can(mid))
		{
			low = mid + 1;
			ans = mid;
		}	
		else high = mid - 1;
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int x = scan.nextInt();
	    int l[]=new int[n];
		for (int i = 0; i < n; i++) {
			l[i]=scan.nextInt();
		}
		scan.close();
		int d=0;
		int cnt=1;
		for (int i = 0; i < n; i++) {
			d=d+l[i];
			if(d<=x)cnt++;
		}
		System.out.println(cnt);
	}
}

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

int main() {
  int n;

  cin >> n;

  int ans = 0, value = 1;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp != value)
      ans++;
    else
      value++;
  }

  if (value > 1)
    cout << ans;
  else
    cout << -1;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int n;
LL f[10010];
int main()
{
	for(int i=1;i<=100;i++)
		for(int j=1;j<=100;j++)
			for(int k=1;k<=100;k++)
			{
				int ass=i*i+j*j+k*k+i*j+j*k+i*k;
				if(ass<=10000)f[ass]++;
			}
	n=read();
	for(int i=1;i<=n;i++)printf("%lld\n",f[i]);
	return 0;
}
/*

*/


Measured memory_bytes: 3112
from bisect import bisect_right
from collections import defaultdict
import sys
read = sys.stdin.readline

s = read()[:-1]
t = read()[:-1]
# 即時終了
if set(t) - set(s):
    print(-1)
    exit()

# 前処理
# 0文字目から見たときにその文字が何文字目にあるかを記録しておく
mojiidx = defaultdict(lambda: [])
for i, ss in enumerate(s + s):
    mojiidx[ss].append(i)

# 本処理
# 最初にうまく飛べる点を探索
for i, ss in enumerate(s):
    if ss == t[0]:
        now = i
        break

for tt in t[1:]:
    idx = now % len(s)
    # 前処理の列から文字ttが何文字あとに出現するかを探索する
    ls = mojiidx[tt]
    tmp = ls[bisect_right(ls, idx)] - idx
    now += tmp
print(now + 1)

Measured memory_bytes: 12268
H = int(input())

#Hは２のjo乗より小さい
i=1
while True:
    A=2**i
    if H==A:
        jo=i
        break
        
    elif H<A:
        jo=i-1
        break
    i+=1

result=0
for j in range(0,jo+1):
    result=result+2**j
print(result)

Measured memory_bytes: 38256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int[string] a, b;
    {
        int n = readint();
        foreach (i; 0..n) {
            a[readln.strip]++;
        }
    }
    {
        int m = readint();
        foreach (i; 0..m) {
            b[readln.strip]++;
        }
    }

    int x;
    foreach (k, v; a) {
        x = max(x, v - b.get(k, 0));
    }
    x.writeln;
    auto _ = readln(); // dbg
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        System.out.print(z + " ");
        System.out.print(x + " ");
        System.out.print(y);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    static class Rect implements Comparable<Rect> {
        int h;
        int w;
        int d2;

        public Rect(int h, int w) {
            this.h = h;
            this.w = w;
            this.d2 = h * h + w * w;
        }

        @Override
        public int compareTo(Rect other) {
            if (d2 != other.d2) {
                return d2 - other.d2;
            }
            return h - other.h;
        }

        @Override
        public boolean equals(Object other) {
            return compareTo((Rect) other) == 0;
        }
    }

    public static void main(String[] args) {
        List<Rect> candidates = new ArrayList<Rect>();
        for (int h = 1; h <= 150; h++) {
            for (int w = h + 1; w <= 150; w++) {
                candidates.add(new Rect(h, w));
            }
        }
        Collections.sort(candidates);

        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }
            Rect rect = new Rect(h, w);
            Rect ansRect = candidates.get(candidates.indexOf(rect) + 1);
            System.out.println(ansRect.h + " " + ansRect.w);
        }
        sc.close();
    }
}

Measured memory_bytes: 32820
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>a[i];
    int l=0,r=n-1;
    int cur=n-1;
    while(l<r)
    {
        b[l]=a[cur];
        cur--;
        b[r]=a[cur];
        cur--;
        l++;
        r--;
    }
    if (l==r)
        b[l]=a[cur];
    for (int i=0;i<n;i++)
    {
        cout<<b[i];
        if (i+1<n)
            cout<<' ';
    }
    cout<<endl;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int i=1,c=0,j=0;
    while(i!=2)
    {
        c++;
        j++;
        i=a[i-1];
        if(j>=n)
            break;
    }
    if(j<=n-1)
        cout<<c;
    else
        cout<<"-1";
    return 0;
}


Measured memory_bytes: 640
n = int(input())
alst = [int(input()) for _ in range(n)]
ans = alst[0] - 1
price = 2
max_p = 2
for a in alst[1:]:
    if a > price:
        ans += (a - 1) // price
    elif max_p == a:
        max_p += 1
        price += 1
print(ans)

Measured memory_bytes: 13836
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn s(n: u32) -> u32 {
    let mut x: u32 = 0;
    for b in format!("{}", n).chars() { x += b as u32 - 48; }
    x
}

fn main() {
    let n: u32 = read();
    println!("{}", if n % s(n) == 0 { "Yes" } else { "No" });
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        ll a; cin>>a;
        mp[a]++;
        mp[a-1]++;
        mp[a+1]++;
    }
    ll ans=0;
    for(auto x:mp){
        ans=max(ans,x.second);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9476
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;
  int A[100010];
int main() {
  int N; cin >> N;
  int cnt = 0;
  int minA = 1e9;
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    if ( A[i] < 0 ) cnt++;
    minA = min(minA,abs(A[i]));
  }

  ll ans = 0;
  if ( cnt % 2 == 0 ) {
    for ( int i = 0; i < N; i++ ) ans += abs(A[i]);
  } else {
    bool f = true;
    for ( int i = 0; i < N; i++ ) {
      if (f && abs(A[i]) == minA) {
	ans -= abs(A[i]);
	f = false;
      } else {
	ans += abs(A[i]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  std::sort(S.begin(), S.end());
  if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int a, b, dp[100005], ans;
vector<vector<int>>g;

int f(int n) {
	if (dp[n] != -1) { return dp[n]; }

	int res = 0;
	for (auto i : g[n]) { chmax(res, f(i) + 1); }
	return dp[n] = res;
}

int main() {
	cin >> a >> b;
	g.assign(a, vector<int>());

	for (int i = 0; i < b; ++i) {
		int n, m;
		cin >> n >> m;
		g[n - 1].push_back(m - 1);
	}

	memset(dp, -1, sizeof(dp));

	for (int i = 0; i < a; ++i) { chmax(ans, f(i)); }

	cout << ans << endl;
}

Measured memory_bytes: 8192
#include <cstdio>
using namespace std;

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

int main() {
	int n = read(), k = read();
	if (k > (n - 1) * (n - 2) / 2) { puts("-1"); return 0; }
	printf("%d\n", n * (n - 1) / 2 - k);
	for (int i = 1; i < n; i++) printf("%d %d\n", i, n);
	int cnt = (n - 1) * (n - 2) / 2 - k;
	for (int i = 1; i < n && cnt; i++) {
		for (int j = i + 1; j < n && cnt; j++) {
			printf("%d %d\n", i, j);
			cnt--;
		}
	}
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

N=list(input())
if len(set(N))==1:
    print(''.join(N))
else:
    if int(N[0])<int(N[1]) or int(N[0])<int(N[2]):
        N=[int(N[0])+1]*len(N)
    else:
        N=[int(N[0])]*len(N)
    print(''.join(map(str,N)))

Measured memory_bytes: 3064