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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

vector<vector<int>> Combination_dp(int n){
  vector<vector<int>> dp(n+1,vector<int>(n+1)); //dp[n][r] = nCr
  for(int i = 0; i <= n; i++){
    dp[i][0] = 1;
    for(int j = 1; j <= i; j++){
      dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
    }
  }
  return dp;
}

signed main(){

  int n,a,b; cin >> n >> a >> b;
  vector<int> v(n);
  map<int,int> mp;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    mp[v[i]]++;
  }
  sort(v.rbegin(),v.rend());

  int res = 0;
  for(int i = 0; i < a; i++){
    res += v[i];
  }
  printf("%.6f\n",(double)res/a);

  auto dp = Combination_dp(n);
  int ans = 0;
  for(int i = a; i <= b; i++){
    map<int,int> mp2;
    int res2 = 0;
    for(int j = 0; j < i; j++){
      mp2[v[j]]++;
      res2 += v[j];
    }
    if(res * i != res2 * a) continue;
    int res = 1;
    for(auto p : mp2){
      res *= dp[mp[p.first]][p.second];
    }
    ans += res;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    bool f = false;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(v[i][j] == '#'){
                v[i][j] = '?';
                if(v[min(i+1, n-1)][j] == '#'){v[i][j] = '#'; continue;}
                if(v[max(i-1, 0)][j] == '#'){v[i][j] = '#'; continue;}
                if(v[i][min(j+1, n-1)] == '#'){v[i][j] = '#'; continue;}
                if(v[i][max(j-1, 0)] == '#'){v[i][j] = '#'; continue;}
                f = true; break;
            }
        }
        if(f){cout << "No" << endl; break;}
    }
    if(!f){cout << "Yes" << endl;}
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

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

    u64 sum = 0;
    u64 jSum = 0;
    u64 div = pow(10, 9) + 7;
    for(s64 i = n - 2; i >= 0; i--)
    {
        s64 j = i + 1;
        jSum += a[j];
        jSum %= div;
        sum += a[i] * jSum;
        sum %= div;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4836
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
 
if (max(a,b,c,d,e) - min(a,b,c,d,e) <= k):
	print('Yay!')
else:
	print(':(')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int combination(int n, int r) {
	if (n < r)return 0;
	r = min(r, n - r);
	int ret = 1;
	for (int i = 1; i <= r; i++) {
		ret *= n + 1 - i;
		ret /= i;
	}
	return ret;
}
signed main() {
	int n, a, b, v[60];
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> v[i];
	sort(v, v + n);
	int cnt = 0;
	for (int i = 0; i < a; i++)cnt += v[n - 1 - i];
	if (cnt / (a * 10) > 0)cout << cnt / (a * 10);
	cnt %= a * 10;
	printf("%.6f\n", (double)cnt / a);
	cnt = 0; int cnt1 = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] == v[n - a]) {
			cnt++;
			if (i >= n - a)cnt1++;
		}
	}
	int ans = 0; int p = (v[n - 1] == v[n - a] ? b - a + 1 : 1);
	for (int i = 0; i < p; i++)ans += combination(cnt, cnt1 + i);
	cout << ans << endl;
	cin >> n;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define lim5 100002
#define lim9 1000000002

int main(){
	int n, k, h, cnt=0;
	cin >> n >> k;
	rep(i, n) {
		cin >> h;
		if(h >= k) ++cnt;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

int N, M, x[100005], y[100005], num[100005];
bool red[100005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        x[i] = a;
        y[i] = b;
    }

    REP(i, N) num[i] = 1;
    red[0] = true;

    REP(i, M) {
        num[x[i]]--;
        num[y[i]]++;

        if (red[x[i]]) red[y[i]] = true;
        if (num[x[i]] == 0) red[x[i]] = false;
    }

    int ans = 0;
    REP(i, N) {
        if (red[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mxe max_element
#define mne min_element
#define bg begin()
#define nd end()
#define u unsigned
 
void swap(int &a,int &b)
{
    int t=a;
    a=b;
    b=t;
    return ;
}





int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll t,n,m;
    cin>>n;
    
    u ll sum=0;
    
    vector<u ll> v(n),mp(100069,0);
    // unordered_map<u ll,u ll> mp;
    for(int i=0;i<n;i++){
        cin>>v[i];
        mp[v[i]]++;
        sum+=v[i];
    }
    
    cin>>m;
    
        
    for(int i=0;i<m;i++)
    {
        u ll a,b;
        cin>>a>>b;
        // v[mp[a]]=b;
        // for(auto x:mp[a])
        sum+=b*(mp[a]);
        sum-=a*mp[a];
        mp[b]+=mp[a];
        mp[a]=0;
        
        cout<<sum<<endl;
    }
    
    
    
    
    return 0;
}








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

int main(){
  string s,s_1;
  string t,u,t_1,u_1;
  
  int p=1,q=1,r=1;
  
  cin >> s;
  s_1 = s;
  reverse(s_1.begin(),s_1.end());
  int N = s.size();
  N = (N-1)/2;
  int M = (s.size()+3)/2;
  
  t = s.substr(0,N);
  t_1 = t;  
  reverse(t_1.begin(),t_1.end());
  
  u = s.substr(M-1,N);
  u_1 = u;
  reverse(u_1.begin(),u_1.end());
  
  if(!(s == s_1)){
    p = 0;
  }
  
  if(!(t == t_1)){
    q = 0;
  }
  
  if(!(u == u_1)){
    r = 0;
  }
  
/*  cout << s << " " << s_1 << endl;
  cout << t << " " << t_1 << endl;
  cout << u << " " << u_1 << endl;
  
  cout << p << q << r << endl;  */
  
  if(p + q + r == 3){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> L(N);

    REP(i, N)
    {
        cin >> L.at(i);
    }

    int D = 0;
    int ans = 1;
    FOR(i, 1, N + 1)
    {
        D = D + L.at(i - 1);
        if (D <= X)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main() {
    int N, A;
    cin >> N >> A;
    if (N%500 <= A){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	long long ans = pow(k - 1, n - 1);
	ans *= k;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

template <typename Monoid>
struct SegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    int N;
    vector<Monoid> node;
    F f;
    Monoid e;  // identity element

public:
    SegmentTree(){}
    SegmentTree(F f, Monoid e):f(f), e(e){}
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.assign(2*N-1, e);
    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k, Monoid x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }
    // [a,b)
    Monoid query(int a, int b){return query(a, b, 0, 0, N);}
    Monoid query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return e;
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = query(a, b, 2*k+1, l, (l+r)/2);
        vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

auto f = [&](P a, P b){return max(a,b);};
SegmentTree<P> seg(f,P(0,0));

int main() {
    ll n;
    cin >> n;
    vector<P> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i].first;
        a[i].second = -i;
    }
    sort(a.begin(), a.end());
    seg.init(n);
    ll len = 0, ans = 0;
    for(int i=0;i<n;i++){
        // (len, sum)
        P p = seg.query(0,abs(a[i].second));
        p.first++;
        p.second += a[i].first;
        seg.update(abs(a[i].second), p);
        if(p.first > len){
            len = p.first;
            ans = p.second;
        }
        else if (p.first == len){
            ans = max(ans, p.second);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8392
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint N, M;
llint dp[3005][3005];
llint dp2[3005][3005];
llint sum[3005], sum2[3005];

int main(void)
{
	cin >> N >> M;
	N--, M--;
	
	dp[0][0] = 1;
	for(int i = 0; i < M; i++){
		for(int j = 0; j <= N; j++){
			if(j < N) dp[i+1][j+1] += dp[i][j], dp[i+1][j+1] %= mod;
			if(j >= 2) dp[i+1][j-1] += dp[i][j], dp[i+1][j-1] %= mod;
			if(j > 0) dp[i+1][j] += 2 * dp[i][j], dp[i+1][j] %= mod;
		}
	}
	for(int i = 0; i <= M; i++){
		for(int j = 0; j <= N; j++){
			sum[i] += dp[i][j];
			sum[i] %= mod;
		}
	}
	
	dp2[0][0] = 1;
	for(int i = 0; i < M; i++){
		for(int j = 0; j <= N; j++){
			if(j < N) dp2[i+1][j+1] += dp2[i][j], dp2[i+1][j+1] %= mod;
			if(j > 0) dp2[i+1][j-1] += dp2[i][j], dp2[i+1][j-1] %= mod;
			dp2[i+1][j] += 2 * dp2[i][j], dp2[i+1][j] %= mod;
		}
	}
	for(int i = 0; i <= M; i++){
		for(int j = 0; j <= N; j++){
			sum2[i] += dp2[i][j];
			sum2[i] %= mod;
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= M; i++){
		ans += sum[i] * sum2[M-i] % mod;
		ans %= mod;
	}
	ans *= 4, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 141312
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 101;

int cost[N][N][2];
int d[N][N][2];
int n;
bool used[N];

void dijkstra(int, int);

int main(void){
    for(int m; cin >> m >> n, n;){
        rep(i, n) rep(j, n) rep(k, 2){
            cost[i][j][k] = INF;
            d[i][j][k] = -1;
        }
        while(m--){
            int a, b, c, t; cin >> a >> b >> c >> t;
            a--, b--;
            cost[a][b][0] = c;
            cost[b][a][0] = c;
            cost[a][b][1] = t;
            cost[b][a][1] = t;
        }
        int k; cin >> k;
        while(k--){
            int p, q, r; cin >> p >> q >> r;
            p--, q--;
            if(!~d[p][q][r]) dijkstra(p, r);
            cout << d[p][q][r] << endl;
        }
    }

    return 0;
}

void dijkstra(int s, int t){
    rep(i, n) d[s][i][t] = INF;
    rep(i, n) used[i] = false;
    d[s][s][t] = 0;

    while(1){
        int v = -1;
        rep(u, n) if(!used[u] && (!~v || d[s][u][t] < d[s][v][t])) v = u;

        if(!~v) break;
        used[v] = true;

        rep(u, n) d[s][u][t] = min(d[s][u][t], d[s][v][t] + cost[v][u][t]);
    }
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2010;
int N,X,Y,A[MAXN];
int cal(int a,int b)
{
	return abs(a-X)+1+abs(Y-b);
}
int main()
{
	cin>>N>>X>>Y;
	for (int i=1;i<=N;++i)
		for (int j=i+1;j<=N;++j)
		{
			int v=min(j-i,cal(i,j));
			A[v]++;
		}
	for (int i=1;i<N;++i) printf("%d\n",A[i]);
	return 0;
}

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

int main()
{
    int N, M, count_p=1, count_m=0, sum=0;
    cin >> N;
    vector<string> n(N);

    for (int i = 0; i < N; i++)
    {
        cin >> n.at(i);
    }
    cin >> M;
    vector<string> m(M);
    for (int i = 0; i < M; i++)
    {
        cin >> m.at(i);
    }

    for (int i = 0; i < N-1;i++){
        for (int j = i + 1; j < N;j++){
            if(n.at(i)==n.at(j)){
                count_p++;
            }
        }
        for (int j = 0; j < M;j++){
            if (n.at(i) == m.at(j))
            {
                count_m++;
            }
        }
        if((count_p-count_m)>sum){
            sum = count_p - count_m;
        }
        //cout <<i<<" "<< count_p - count_m << endl;
        count_m = 0;
        count_p = 1;

    }
    cout << sum << endl;
    //cout << n.at(0) << " " << m.at(0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int nn,n,m,cap;
int s,g;
set<string>S;
map<string,int>M;
vector<P>edge[6005];
bool ok[6005];
string from[6005],to[6005];
int d[6005];
int dist[305][6005];
int D[305];
int main(){
	while(1){
		cin>>nn>>m>>cap;
		if(nn==0) return 0;
		string ss,gg; cin>>ss>>gg;
		M.clear(); S.clear();
		rep(i,6005){
			edge[i].clear(); ok[i]=0;
		}
		S.insert(ss); S.insert(gg);
		rep(i,nn){
			cin>>from[i]>>to[i]>>d[i];
			S.insert(from[i]);
			S.insert(to[i]);
		}
		vector<string>hoge;
		rep(i,m){
		    string f; cin>>f; hoge.pb(f);
		}
		int nxt = 1;
		for(auto s:S){
		    M[s] = nxt++;
		}
		rep(i,nn){
		//	cin>>from[i]>>to[i]>>d[i];
			edge[M[from[i]]].pb(mp(M[to[i]],d[i]));
			edge[M[to[i]]].pb(mp(M[from[i]],d[i]));
		}
		vector<int>cand;
		rep(i,m){
			if(M.find(hoge[i]) == M.end()) continue;
		    ok[M[hoge[i]]] = 1;
		    cand.pb(M[hoge[i]]);
		}
		cand.pb(M[ss]); s = M[ss];
		cand.pb(M[gg]); g = M[gg];
		for(int i=0;i<cand.size();i++){
			rep(j,6005) dist[i][j] = INF;
			dist[i][cand[i]] = 0;
			priority_queue<P,vector<P>,greater<P> >que;
			que.push(mp(0,cand[i]));
			while(!que.empty()){
				P p = que.top(); que.pop();
				if(dist[i][p.sc] != p.fi) continue;
				for(int x=0;x<edge[p.sc].size();x++){
					int to = edge[p.sc][x].fi;
					int cs = edge[p.sc][x].sc;
					if(p.fi+cs < dist[i][to]){
						dist[i][to] = p.fi+cs;
						que.push(mp(p.fi+cs,to));
					}
				}
			}
		}
		rep(i,cand.size()) D[i] = INF;
		int sss,ggg;
		rep(i,cand.size()){
			if(cand[i] == s) sss = i;
			if(cand[i] == g) ggg = i;
		}
		D[sss] = 0;
		priority_queue<P,vector<P>,greater<P> >que;
		que.push(mp(0,sss));
		while(!que.empty()){
			P p = que.top(); que.pop();
			if(D[p.sc] != p.fi) continue;
			for(int j=0;j<cand.size();j++){
				if(dist[p.sc][cand[j]] > cap * 10) continue;
				if(D[p.sc] + dist[p.sc][cand[j]] < D[j]){
					D[j] = D[p.sc] + dist[p.sc][cand[j]];
					que.push(mp(D[j],j));
				}
			}
		}
		if(D[ggg] > 1e8) D[ggg] = -1;
		cout << D[ggg] << endl;
	}
}


Measured memory_bytes: 11848
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main()
{
  long long N, K;
  cin >> N >> K;
  long long sum = 0;
  for (long long i = K; i <= N + 1; ++i)
  {
    long long mi = i * (i - 1) / 2;
    long long ma = N * i - i * (i - 1) / 2;
    sum += (ma - mi + 1) % mod;
    sum %= mod;
  }
  sum %= mod;
  cout << sum << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int a, b, c;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		if(a == 5){
			if(b == 5){
				if(c == 7)System.out.print("YES");
				else System.out.print("NO");
			}
			else if(b == 7){
				if(c == 5)System.out.print("YES");
				else System.out.print("NO");
			}
		}
		else if(a == 7){
			if(b == 5){
				if(c == 5)System.out.print("YES");
				else System.out.print("NO");
			}
			else System.out.print("NO");
		}
		else System.out.print("NO");


	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
 
#define FOUND 1
#define NOT_FOUND -1
 
bool compare(string s1, string s2){
  if(s1.size() == s2.size()) return s1 < s2;
  return s1.size() < s2.size();
} 
 
int main(){
  string in, sub;
  string seq;
  bool flag = true;
  while(getline(cin, in)){
    if(!flag && (in.size() == 0 || cin.eof())){
      if(cin.eof()) sub += in;   
      flag = true;
       
      map<char, int > mp;
      set<char> data;
 
      for(int i = 0 ; i < sub.size() ; i++) data.insert(sub[i]);
      for(int i = 0 ; i < sub.size() ; i++) mp[ sub[i] ] = NOT_FOUND;
       
      int ans = 0;
      int len = (1<<29);
      string ans2;
       
      for(int i = 0 ; i < seq.size() ; i++){
    if(data.find(seq[i]) == data.end()) continue;
    mp[ seq[i] ] = i;
     
    int left = (1<<29);
    bool ok = true;
    for(int j = 0 ; j < sub.size() ; j++){
      if(mp[ sub[j] ] == NOT_FOUND){
        ok = false;
        break;
      }
      left = min(left, mp[ sub[j] ]);
    }
     
    if(!ok) continue;
     
    if(i - left == len) ans++;
    if(i - left < len){
      len = i - left;
      ans = 1;
      //cout << "i = " << i << " left = " << left << endl;
      //cout << i << endl;
      ans2 = seq.substr(left, i-left+1);
      //cout << seq.substr(left, i-left+1) << endl;
    }
     
      }
       
      cout << ans << endl << endl;
      if(ans != 0){
    for(int i = 0 ; i < ans2.size() ; i += 72){
      cout << ans2.substr(i, 72) << endl;
    }
    if(!cin.eof()) cout << endl;
      }
 
      //cout << "ans_len = " << len << endl;
      //cout << "ans_cnt = " << ans << endl;
      //cout << "seq = " << seq << endl;
      //cout << "sub = " << sub << endl;
      //cout << endl;
      seq = "", sub = "";
      continue;
    }
    else if(flag && in.size() != 0){
      seq += in;
      continue;
    }
    else if(flag && in.size() == 0){
      flag = false;
      continue;
    }
    else if(!flag && in.size() != 0){
      sub += in;
      continue;
    }
   
     
 
  }
   
  return 0;
}

Measured memory_bytes: 1832
import sys

input = sys.stdin.readline

M = int(input())
dc = [list(map(int,input().split())) for i in range(M)]

digit = 0
numsum = 0
for di, ci in dc:
	digit += ci
	numsum += di*ci

ans = digit-1 + (numsum-1)//9
print(ans)

Measured memory_bytes: 74460
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;


static const int MAX_N = 100010;
int main(void){
  long long int N;
  long long int A[MAX_N], B[MAX_N];
  //入力
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  long long int sum[MAX_N];
  for(int i = 0; i < N; i++){
    sum[i] = A[i] + B[i];
  }
  vector<pair<long long int, long long int> > pairs(N);
  for(int i = 0; i < N; i++){
    pairs[i] = make_pair(sum[i], i);
  }
  sort(pairs.begin(), pairs.end(), greater<pair<long long int, long long int> >());
  long long int ans = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      ans += A[pairs[i].second];
    }
    else{
      ans -= B[pairs[i].second];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	ll n,m;
	cin>>n>>m;
	if(n>=m)
    {

        printf("%lld\n",min(n%m,m-n%m));
    }

	else printf("%lld\n",min(n,m-n));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 55;
ll X[MAX_N],Y[MAX_N];

int main()
{
	int N,K;
	cin >> N >> K;
	rep(i,N)
	{
		cin >> X[i] >> Y[i];
	}
	ll ans = ll(1e19);
	rep(i,N)
	{
		for(int j = i+1; j < N; ++j)
		{
			rep(k,N)
			{
				for(int l = k+1; l < N; ++l)
				{
					ll x1 = X[i], x2 = X[j], y1 = Y[k], y2 = Y[l];
					if (x1 > x2) swap(x1,x2);
					if (y1 > y2) swap(y1,y2);
					int cnt = 0;
					rep(m,N)
					{
						if (x1 <= X[m] && X[m] <= x2 && y1 <= Y[m] && Y[m] <= y2) cnt++;
					}
					if (cnt >= K)
					{
						ans = min(ans,(x2 - x1) * (y2 - y1));
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Pattern;

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

    String s = sc.next();
    String t = sc.next();

    if(s.length() <= 0 || s.length() >= 11) {
      System.out.println("No");
      System.exit(0);
    }

    if((t.length()-s.length()) != 1) {
      System.out.println("No");
      System.exit(0);
    }

    if(isHalfAlphanumeric(s) == false) {
      System.out.println("No");
      System.exit(0);
    }

    if(isHalfAlphanumeric(t) == false) {
      System.out.println("No");
      System.exit(0);
    }

    if(t.substring(0, s.length()).equals(s)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
    sc.close();
  }
  public static boolean isHalfAlphanumeric(String str) {
    return Pattern.matches("^[a-z]+$", str);
  }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;
const ll mod = 1e9 + 7;

const int maxn = 1e6 + 5;


ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

void gen_inv() {
    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);
}

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

void add(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x += y;
    if (x>=mod) x%=mod;
}

void mul(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x *= y;
    if (x>=mod) x%=mod;
}



ll brute(ll n, ll k) {
    assert(k>1);
    vector<ll> v;
    ll res=0;
    function<void(int i)> dfs = [&](int rem) {
	if (rem==0) {
	    bool ok = true;
	    for (int i=0; i+1<k && ok; i++) {
		if (v[i+1]>n/v[i]) ok=false;
	    }
	    res += ok;
	} else {
	    for (ll i=1; i<=n; i++) {
		v.push_back(i);
		dfs(rem-1);
		v.pop_back();
	    }
	}
    };
    dfs(k);
    return res;
}


ll n, k;
vector<ll> terms;

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

    gen_inv();

    cin>>n>>k;
    ll Q = 1;
    while ((Q+1)*(Q+1) <= n) Q++;

 
    vector<ll> over;
    for (ll i=1; i*i<=n; i++) {
	terms.push_back(i);

	if (n/i != i) {
	    over.push_back(n/i);
	}
    }
    
    while (over.size()) {
	terms.push_back(over.back()); over.pop_back();
    }

    // for (ll x: terms) cout<<x<<" ";
    // cout<<endl;

    int N = terms.size();

    vector<vector<ll>> dp(k+1, vector<ll>(N, 0));
    dp[0][0] = 1;

    for (int i=1; i<=k; i++) {

	// prefix sum
	for (int j=1; j<N; j++) {
	    add(dp[i-1][j], dp[i-1][j-1]);
	}

	for (int j=0; j<N; j++) {
	    if (terms[j] <= Q) {
		ll fac = n / terms[j];
		int idx = std::prev(upper_bound(terms.begin(),terms.end(),fac))-terms.begin();
		add(dp[i][j], dp[i-1][idx]);
	    } else {
		ll options = terms[j]-terms[j-1];
		ll fac = n / terms[j];
		int idx = lower_bound(terms.begin(),terms.end(),fac)-terms.begin();
		add(dp[i][j], options*dp[i-1][idx]);
	    }
	}
	
	// watch(i);
	// for (int j=0; j<N; j++) {
	//     cout<<dp[i][j]<<" ";
	// }
	// cout<<endl;
    }


    ll res = 0;
    for (int j=0; j<N; j++) {
	add(res, dp[k][j]);
    }
    
    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;


    // ll bru = brute(n, k);
    // watch(bru);
    // assert(res==bru);
    
    return 0;
}


Measured memory_bytes: 78036
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,m,q,f[100005][12],vq[100005],dq[100005],c[100005];
vector<int> g[100005];
void dfs(int x,int d,int ind){
	if(f[x][d] || d<0)return;
	f[x][d]=ind;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		dfs(u,d-1,ind);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>vq[i]>>dq[i]>>c[i];
	}
	for(int i=q;i>0;i--){
		for(int j=dq[i];j>=0;j--){
			dfs(vq[i],j,c[i]);
		}
	}
	for(int i=1;i<=n;i++){
		cout<<f[i][0]<<'\n';
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    ll dp[15][110000] = {};

    dp[0][0] = 1;
    rep(i, s.size()){
        if(s[i]=='?'){
            rep(j, 13){
                rep(num, 10){
                    dp[(j*10+num)%13][i+1] += dp[j][i];
                    dp[(j*10+num)%13][i+1] %= MOD;
                }
            }
        }else{
            int num = s[i] - '0';
            rep(j, 13){
                dp[(j*10+num)%13][i+1] += dp[j][i];
                dp[(j*10+num)%13][i+1] %= MOD;
            }
        }
    }
    cout << dp[5][s.size()] << endl;
    return 0;
}

Measured memory_bytes: 13312
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int c = 0;
	for (int i = 0; i < n; i++) {
		if (sum % (4 * m) != 0 && a[i] > sum / (4 * m))
			c++;
		else if (sum % (4 * m) == 0 && a[i] >= sum / (4 * m))
			c++;
	}
	if (c >= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s1 = iterator.next().unwrap();
    let s2 = iterator.next().unwrap();
    let s3 = iterator.next().unwrap();

    let ans = format!(
        "{}{}{}",
        s1.chars().next().unwrap(),
        s2.chars().next().unwrap(),
        s3.chars().next().unwrap()
    );

    return ans;
}


Measured memory_bytes: 2088
#include<stdio.h>
using namespace std;
int check(int a) {
	int s = 0;
	int P[10000];
	for (int i = 1; i <= 200; i++) {
		P[i - 1] = i * i;
		if (P[i - 1] == a) {
			s++;
		}
	}
	return s;
}
int main(void)
{
	int N, D;
	int count = 0;
	int X[20][20];
	scanf("%d%d", &N, &D);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			scanf("%d", &X[i][j]);
			//printf("%d\n", X[i][j]);
		}
	}
	int sum = 0;
	int q = 0;
	int r = 1;
	for (int i = 0; i < (N * (N - 1)) / 2; i++) {
		for (int j = 0; j < D; j++) {
			sum += (X[q][j] - X[q + r][j]) * (X[q][j] - X[q + r][j]);
			//printf("%d\n", sum);
		}
		//printf("%d %d %d\n", sum,q,r);
		if (check(sum) == 1) {
			count++;
		}
		
		if (r == N- 1 - q) {
			q++;
			r = 1;
		}
		else
			r++;
		sum = 0;
	}


	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF (1<<21)
#define MAX 101
int n,M[MAX][MAX];

int prim(){
  int u,minv,i,j,v,sum;
  int d[MAX],p[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1){
    minv = INF;
    u = -1;
    for(i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v]  != INF){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  sum = 0;
  for(i=0;i<n;i++){
    if(p[i] != -1)sum += M[i][p[i]];
  }

  return sum;
}

int main(){
  int temp,ans,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
    scanf("%d",&temp);
    if(temp == -1)M[i][j] = INF;
    else M[i][j] = temp;
    }
  }
  ans = prim();
  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n;
        for(int i=0;i<n;i++)cin>>num[i];
        bool NA=0;
        for(int i=0;!NA&&i<10001;i++){
            bool kawa=1;
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                NA=1;
                cout<<i<<endl;
            }
            num[co]=co+1;
            for(int j=0;j<=co;j++){
                if(num[j]==1)for(int k=j+1;k<=co&&num[j]==1;k++)if(num[k]!=1)swap(num[j],num[k]);
                num[j]--;
                if(num[j]==0)co=j-1;
            }
            co++;
        }
        if(!NA)cout<<-1<<endl;
    }
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string s ;
    cin >> s ;
    if(s[0]=='B'&&s[1]=='B'&&s[2]=='B'){
        cout<< "No" << endl;
    }else if(s[0]=='A'&&s[1]=='A'&&s[2]=='A'){
        cout<< "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
x,k,d = map(int,input().split())
ans = 0
x = abs(x)
if x>d*k:
    ans = x-d*k
else:
    ans = x-x//d*d
    k-=x//d
    if k%2:
        ans = ans-d
ans = abs(ans)
print(ans)

Measured memory_bytes: 9140
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, a[N], res;

signed main()
{
    init_ios();
    cin >> n;
    for (int i = 1; i <= n; ++i)
    	cin >> a[i];
    for (int i = 1; i <= n; ++i) {
    	if (a[i] == 0)
    		continue;
    	if (a[i]%2 == 0) {
    		res += a[i]/2;
    		continue;
    	}
    	res += a[i]/2;
    	if (a[i+1] > 0) {
    		++res;
    		a[i+1]--;
    	}
    }
    cout<<res<<"\n";
}

Measured memory_bytes: 1024
/*
*Bismillahir Rahmanir Rahmin
* @Author: {{Syed Yasir Shahriar
{
/*//*\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/
 
//أعوذ بالله من الشيطان الرجيم
//بسم الله الرحمن الرحيم
 
/*//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/
 
/*};/* @Date:   {{create_time}}typedef int MyCustomType;
* @Last Modified by:   mrinm
* @Last Modified time: 2020-06-21 22:04:18
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 
 int arr[10000];
 vector<ll>vv;
 vector<ll>vv2;
 int main(){
 /*    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
     ios::sync_with_stdio(0);
      cin.tie(0),cout.tie(0);
     // ll t,a,b;
     // cin>>t;
        
      /*  int n;
        cin>>n;
        for(int i=1;i<n;i++){
        	int x;
        	cin>>x;
        	vv.pb(x);

        }

        sort(vv.begin(),vv.end());
        
        for(int k=1;k<n;k++){
        	 //cin>>arr[k];
          vv2.pb(k);
        }

       for(int i=1;i<n;i++){
       	  if(vv[i]!=vv2[i]){
       	  	 cout<<vv2[i]<<endl;
       	  	 break;
       	  }
       }*/
       
       int n,k;
       cin>>n>>k;
       for(int i=1;i<=n;i++){
       	  cin>>arr[i];
       }
      sort(arr+1,arr+n+1);
      int ans=0;
     for(int i=1;i<=k;i++){
     	 ans=ans+arr[i];
     }
     cout<<ans<<endl;
      



     
     return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

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

    int res = 0;

    switch (s) {
      case "SUN":
        ++res;
      case "MON":
        ++res;
      case "TUE":
        ++res;
      case "WED":
        ++res;
      case "THU":
        ++res;
      case "FRI":
        ++res;
      case "SAT":
        ++res;
    }

    System.out.println(res);
  }
}

Measured memory_bytes: 21204
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}


int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int ans = 0, mini = n;
  rep(i, n){
    if(i==0) {
      ++ans;
      chmin(mini, p[i]);
    }
    else {
      if(p[i] < mini){
        ++ans;
        chmin(mini, p[i]);
      }
    }
  }

  cout << ans << endl;
}


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

//#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
}

Measured memory_bytes: 256
N,M,C = map(int, input().split(" "))
B = input().split(" ")

A = []

for i in range(N):
  A.append(input().split(" "))

count = 0
for NIndex in range(N):
  cal = 0
  for MIndex in range(M):
    cal += int(A[NIndex][MIndex]) * int(B[MIndex])
  cal += C
  if cal > 0:
    count += 1
    
print(count)
  


Measured memory_bytes: 3060
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sum = 0;
	rep(i,n){
		int l,r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << '\n';
	return 0;	
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a[101], id;
double av, dif = 1000000;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		av += a[i];
	}
	av /= n;
	rep(i,n) {
		double t = abs(a[i]-av);
		if (t<dif) dif = t, id = i;
	}
	cout << id << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N, M;
    map<string,int> p;
    vector<string> key;

    cin >> N;
    rep(i,N) {
        string s;
        cin >> s;

        key.push_back(s);
        p[s] += 1;
    }

    cin >> M;
    rep(i,M){
        string s;
        cin >> s;

        key.push_back(s);
        p[s] -= 1;
    }

    int max = -1;
    rep(i,key.size()){ 
        if(max < p[key[i]]) max = p[key[i]];
    }
    
    if(max > 0){
        cout << max << endl;
    }else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    T = [int(i) for i in input().split()]
    M = int(input())
    t = sum(T)
    for i in range(M):
        P, X = [int(x) for x in input().split()]
        print(t - T[P - 1] + X)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 62908
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string a, b;
int dp[3001][3001];

int solve(int x, int y){
    if(x == a.size() || y == b.size()) return 0;
    int &ret = dp[x][y];
    if(ret != -1) return ret;
    if(a[x] == b[y]) return ret = solve(x + 1, y + 1) + 1;
    return ret = max(solve(x + 1, y), solve(x, y + 1));
}
void rec(int x, int y){
    if(x == a.size() || y == b.size()) return;
    if(a[x] == b[y]){
        cout << a[x];
        rec(x + 1, y + 1);
        return;
    }
    if(solve(x, y + 1) > solve(x + 1, y)) rec(x, y + 1);
    else rec(x + 1, y);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b;
    memset(dp, -1, sizeof dp);
    rec(0, 0);
}


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

using namespace std;
constexpr long long int mod = 1000000007;

int main() {
    int N, M;
    cin >> N>>M;
    vector<int>Height(N);
    vector<bool>low(N,false);
    vector<vector<int>>connected(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> Height.at(i);
    }
    int a, b;
    for (size_t i = 0; i < M; i++)
    {
        cin >> a >> b;
        a--, b--;
        if (Height.at(a) > Height.at(b)) { low.at(b) = true; }
        else if (Height.at(a) < Height.at(b)) { low.at(a) = true; }
        else { low.at(a) = true, low.at(b) = true; }
    }
    int ans=0;
    for (size_t i = 0; i < N; i++)
    {
        if (!low.at(i))ans++;
    }
    cout << ans;
}

Measured memory_bytes: 5900
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n,m;
int fa[100005];
int d[100005];
int getfa(int x)
{
	if(fa[x]==x)	return x;
	int gg=fa[x];
	fa[x]=getfa(fa[x]);
	d[x]+=d[gg];
	return fa[x];
}
int unio(int a,int b,int dd)
{
	int x=getfa(a);
	int y=getfa(b);
	if(x==y)	return d[a]-d[b]==dd;
	fa[x]=y;
	d[x]=dd-d[a]+d[b];
	return 1;
}
int main()
{
	read(n);
	read(m);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	int a,b,c;
	while(m--)
	{
		read(a);
		read(b);
		read(c);
		int gg=unio(a,b,c);
	//	for(int i=1;i<=n;i++)	cout<<"G"<<i<<' '<<fa[i]<<" "<<d[i]<<endl;
		if(gg==0)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int tmp [1001];
int N,M,X ;
int main ()
{
    while (scanf ("%d%d%d",&N,&M,&X)!=EOF)
    {
        for (int i=0;i<M;i++)
           scanf ("%d",&tmp[i]);
        int index= lower_bound (tmp , tmp +M , X) -tmp   ;
        //printf ("%d\n",index );
        int ans = min (M-index , index );
        printf ("%d\n",ans );
    }

    return 0;
}


Measured memory_bytes: 256