akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            BSubstring solver = new BSubstring();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class BSubstring {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] a = s.next().toCharArray(), b = s.next().toCharArray();
            int na = a.length, nb = b.length;
            int ans = na;
            for (int i = 0; i <= na - nb; i++) {
                int cur = 0;
                for (int j = 0, k = i; j < nb; j++, k++) {
                    if (a[k] != b[j]) cur++;
                }
                ans = Math.min(ans, cur);
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32748
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    cout << a[i];
    if (i == 0) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 3116
# 入力
N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

# スコア計算
def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            tmp += di
    return tmp

# DFS
def dfs(A):
    if len(A) == N:
        return score(A) # 数列 A のスコアを返す
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A)) # 再帰呼出しながら、スコア最大値も更新
        A.pop()
    return res

# 求める
print(dfs([]))

Measured memory_bytes: 9248
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  int N, M;

  cin >> N ;

  /* vector<int> K(N);
  vector<vector<int>> A(N, vector<int>(30));
  for (int i = 0; i < N; i++)
  {
    cin >> K.at(i);
    for (int j = 0; j < K.at(i); j++)
    {
      cin >> A.at(i).at(j);
    }
  }*/

  cout << 3 * N * N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
constexpr int min(int a, int b){ return a < b ? a : b;}
string x,y;

int main(){
    cin >> x >> y;
    int ans = y.size();
    for(int i = 0 ;i < x.size()-y.size()+1 ; ++i){
        int diff = 0;
        for(int j = 0; j < y.size() ; ++j){
            if(x[i+j] != y[j]) diff++;
        }
        ans = min(ans, diff);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
N=int(input())
zorome=[]
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        zorome.append(1)
    else:
        zorome.append(0)

flag=0
for i in range(N-2):
    if zorome[i]==1 and zorome[i+1]==1 and zorome[i+2]==1:
        flag=1
        break
if flag==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 62316
#include <stdio.h>
int main(int argc, const char * argv[]) {
	int a = 0;
	int b = 0;
	int c = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a < b) {
		if (b < c) {
			printf("Yes\n");
		}else {
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("a") || s.equals("e") || s.equals("i") || s.equals("u") || s.equals("e") || s.equals("o")) {
            System.out.println("vowel");
        }
        else {
            System.out.println("consonant");
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int main(void)
{
  int N,T,i;
  int a = 1e6;
  int c[100],t[100];
    
     scanf("%d %d",&N,&T);
  
  for(i=0;i<N;i++)
  {
    scanf("%d %d",&c[i],&t[i]);
  }
  for(i=0;i<N;i++)
  {
    if(t[i]<=T && c[i]<a )
    {
        a=c[i];
    }
      }
  if(a >= 1e6)
  {
    printf("TLE");
  }
  else  
  {
    printf("%d",a);
  }
  
  return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * len(A)
C = [0] * len(A)
mod = 10 ** 9 + 7
counter = 0
for i in range(N):
    B[i] = sum([A[i] > A[j] for j in range(0, N)])  # Aの中でAi>Ajとなる個数
    C[i] = sum([A[i] > A[j] for j in range(i, N)])  # Aの中でAi 以降で　Ai>Ajとなる個数

for i in range(N):
    c = (C[i] * K)%mod + ((K - 1) * K * B[i] // 2)%mod
    
    counter = (counter + c) % mod
print(int(counter))


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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for (int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowerCnt(const vector<int>& cnrvnSeq)
{
  int nMaxSeqCnt = 0;
  int nBgn = 0;

  while (nBgn < cnrvnSeq.size() - 1)
  {
    int nSeqCnt = 0;
    int nFoward;

    for (nFoward = nBgn; nFoward < cnrvnSeq.size() - 1; nFoward++)
      if (cnrvnSeq[nFoward] >= cnrvnSeq[nFoward + 1])
        nSeqCnt++;
      else
        break;

    nMaxSeqCnt = max(nMaxSeqCnt, nSeqCnt);
    nBgn = nFoward + 1;
  }
  return nMaxSeqCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowerCnt(vnSeq) << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()

{
    long long int a,b;
    scanf("%lld%lld",&a,&b);
    if((a+b)%2==0)
    {
        printf("%lld",(a+b)/2);
    }
    else
    {
        printf("IMPOSSIBLE\n");

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int NIL=-1;
const int MAXt=10000;

class node
{
public:
	int p;
	int l;
	int r;
};

node T[MAXt];

int treein(int n)
{
	int id,r,l,root;
	for(int i=0;i<n;i++)T[i].p=NIL;
	for(int i=0;i<n;i++)
	{
		cin>>id>>l>>r;
		T[id].l=l;
		if(l!=NIL)T[l].p=id;
		T[id].r=r;
		if(r!=NIL)T[r].p=id;
	}
	for(int i=0;i<n;i++)if(T[i].p==NIL){root=i;break;}
	return root;
}

void preo(int u)//preorder
{
	if(u==NIL)return;
	cout<<" "<<u;
	preo(T[u].l);
	preo(T[u].r);
	return;
}

void ino(int u)//inorder
{
	if(u==NIL)return;
	ino(T[u].l);
	cout<<" "<<u;
	ino(T[u].r);
	return;
}

void posto(int u)//postorder
{
	if(u==NIL)return;
	posto(T[u].l);
	posto(T[u].r);
	cout<<" "<<u;
	return;
}
int main() {
	int n,root;cin>>n;
	root=treein(n);
	cout<<"Preorder"<<endl;
	preo(root);
	cout<<endl;
	cout<<"Inorder"<<endl;
	ino(root);
	cout<<endl;
	cout<<"Postorder"<<endl;
	posto(root);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3068
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int r,D,x_2000;cin>>r>>D>>x_2000;
  int x_t = x_2000;
  int x_r;
  REP(i,10) {
    x_r = r*x_t - D;
    p(x_r);
    x_t = x_r;
  }
  return 0;
}



Measured memory_bytes: 256
N = int(input())
K = int(input())
x= list(map(int,input().split(" ")))
ans = 0
for i in range(N):
    temp_x = x[i]
    if temp_x < abs(K-temp_x):
       ans += 2*temp_x 
    else:
        ans+=2*abs(K-temp_x)

print(ans)

Measured memory_bytes: 3060
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define memo(a,val) memset(a,val,sizeof(a))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 3010;
int a[mxn];
int dp[mxn][mxn][2];

int32_t main(){
	NINJA;

	int n; cin >> n;
	int sum = 0;

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

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

	for(int RminusL=1;RminusL<n;RminusL++)
	{
		for (int L = 0; L+RminusL < n; ++L)
		{
			int R = L+RminusL;
			dp[L][R][0] = max(a[L]+dp[L+1][R][1],a[R]+dp[L][R-1][1]);
			dp[L][R][1] = min(dp[L+1][R][0],dp[L][R-1][0]);
		}
	}

	cout << 2*dp[0][n-1][0] - sum << endl;
	
	return 0;
}

Measured memory_bytes: 85396
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define SIZE 20
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf[1 << 15];
double cst[1 << 15];
double x[15], y[15], a[15];
double dp[1 << 15];
typedef pair<int, int>pii;
typedef pair<double, pii>pdi;
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%lf%lf%lf", &x[i], &y[i], &a[i]);
	vector<pdi>v;
	for (int i = 0; i < num; i++)for (int j = i + 1; j < num; j++)v.push_back(make_pair(sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])), make_pair(i, j)));
	sort(v.begin(), v.end());
	for (int i = 0; i < (1 << num); i++)uf[i].init();
	for (int i = 0; i < v.size(); i++)
	{
		int s = v[i].second.first, t = v[i].second.second;
		double d = v[i].first;
		for (int p = 0; p < (1 << num); p++)
		{
			if ((p&(1 << s)) != 0 && (p&(1 << t)) != 0)
			{
				if (uf[p].find(s) != uf[p].find(t))
				{
					cst[p] -= d;
					uf[p].unite(s, t);
				}
			}
		}
	}
	for (int p = 1; p < (1 << num); p++)
	{
		int cnt = 0;
		for (int i = 0; i < num; i++)if (p&(1 << i))cst[p] += a[i], cnt++;
		cst[p] /= cnt;
	}
	dp[0] = 1000000000000000000.0;
	for (int p = 0; p < (1 << num); p++)
	{
		int mask = (1 << num) - 1 - p;
		int now = mask;
		for (;;)
		{
			if (now == 0)break;
			dp[p + now] = max(dp[p + now], min(dp[p], cst[now]));
			now--;
			now &= mask;
		}
	}
	printf("%.20lf\n", dp[(1 << num) - 1]);
}

Measured memory_bytes: 8448
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


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

	string S;
	cin >> S;
	cout << S.substr(0, 3) << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  if(n&1) drop(0);
  n/=10;
  Int ans=n;
  while(n){
    n/=5;
    ans+=n;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin>>n;
    map<string,ll>m;
  while(n--){
  
    string s;
    cin>>s;
    m[s]++;
  }
  ll ma=0;
  for(auto it:m){
    if(it.second>ma)
      ma=it.second;
  }
  for(auto it:m){
    if(it.second==ma)
      cout<<it.first<<endl;
  }
}
    

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,M;
  cin>>N>>M;
  vector<int>A(M);
  for(int i=0;i<M;i++)cin>>A[i];
  ll sum=0;
  for(int i=0;i<M;i++)sum+=A[i];
  ll ans=N-sum;
  if(ans<0)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define LEN 100005
using namespace std;
 
typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a, int b){ return a<b ? a:b;}

int main(){
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    
    for (int i=1; i<=n; i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head =1; tail=n+1;
    
    while(head!=tail){
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0) enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    
    return 0;
}


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

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

    int a = 0;
    int b = 0;
    int c = 0;

    for(int i = 0; i < 3; i++){
        if(S.at(i) == 'a'){
            a++;
        }
        if(S.at(i) == 'b'){
            b++;
        }
        if(S.at(i) == 'c'){
            c++;
        }
    }

    if(a == 1 && b == 1 && c == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

string s;

int main()
{
	IOS;
	cin >> s;
	int ans = 1000;
	for (int i = 0; i <= s.size()-3; i++) {
		int num = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		ans = min(ans, abs(num - 753));
	}
	cout << ans << endl;
 	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 100005;
ll pre[101][100001];
void go() {
	int n, k;
	cin >> n >> k;
	int x;
	cin >> x;
	f(x + 1) {
		pre[1][i] = i + 1;
	}
	fr(i,x+1,k+1) {
		pre[1][i] = x + 1;
	}
	for (int i = 2 ; i <= n ; i++) {
		int x;
		cin >> x;
		for (int j = 0 ; j <= k ; j++) {
			ll way;
			if (j <= x) {
				way = pre[i - 1][j];
			}
			else {
				way = (pre[i - 1][j] - pre[i - 1][j - x - 1] + mod) % mod;
			}
			if (j == 0) {
				pre[i][j] = way;
			}
			else {
				pre[i][j] = (pre[i][j - 1] + way) % mod;
			}
		}
	}
	if (!k) {
		cout << 1 << '\n';
	}
	else {
		cout << (pre[n][k] - pre[n][k - 1] + mod) % mod << '\n';
	}
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    set<int> st;
    map<int, int> mp;

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

    rep(i, n) {
        int a;
        cin >> a;
        st.insert(a);
        mp[a]++;
    }

    vector<int> v;
    auto itr = st.begin();

    rep(i, st.size()) {
        v.push_back(mp[*itr]);
        itr++;
    }

    sort(v.begin(), v.end());

    int sum = 0;

    rep(i, st.size() - k) {
        sum += v[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 20092
#include<stdio.h>

int a[101][101];
int t[101][2];
int num, n, count = 1;

void dfs(int);

int main ()
{
  int k, v;
  int i, j;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++)
    {
      t[i][0] = 0;
      t[i][1] = 0;
    }
  
  for(i = 0; i < n; i++)
    {      
      scanf("%d%d", &num, &k);
      
      for(j = 0; j <= n; j++)
	{
	  a[num][j] = 0;
	  t[num][j] = 0;
	}
      
      
      for(j = 0; j < k; j++)
	{
	  scanf("%d", &v);
	  a[num][v] = 1;
	}
    }

  dfs(1);

 if(n*2 != count)
    {
      for(i = 1; i <= n; i++)
	{
	  if(t[i][0] == 0)
	    {
	    dfs(i);
	    }
	}
    }
  
  for(i = 1; i <= n; i++)
    {
      printf("%d %d %d\n", i, t[i][0], t[i][1]);
    }
      
  return 0;
}

void dfs(int start)
{
  int i;

  if(t[start][0] == 0)t[start][0] = count++;
  
  for(i = 1; i <= n; i++)
    {
  
      if(a[start][i] == 1 && t[i][0] == 0)
	{
	  dfs(i);
	}
    }
  if(t[start][1] == 0)t[start][1] = count++;

 
  return;
}



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




int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	while (true)
	{
		if (C>0)
		{
			C -= B;
		}
		if (C<=0)
		{
			cout << "Yes" << endl;
			break;
		}
		if (A>0)
		{
			A -= D;
		}
		if (A<=0)
		{
			cout << "No" << endl;
			break;
		}
		
		
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string s;
  cin >> s;
  int N = len(s);

  string t;
  rep(i, N) {
    if (s[i] != 'x')
      t.pb(s[i]);
  }

  bool ok = true;
  int M = len(t);
  rep(i, M / 2) {
    if (t[i] != t[M - 1 - i])
      ok = false;
  }

  if (!ok) {
    cout << -1 << '\n';
    return 0;
  }

  int ans = 0;
  int l = 0, r = N - 1;
  while (l < r) {
    int xl = 0;
    while (s[l] == 'x') {
      xl++;
      l++;
    }

    int xr = 0;
    while (s[r] == 'x') {
      xr++;
      r--;
    }

    ans += abs(xr - xl);
    l++, r--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 592
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N;
int slime[110];
int ans = 0;

int main(){
    cin >> N;

    rep(i, 0, 110){
        slime[i] = 6000;
    }

    rep(i, 0, N){
        int tmp;
        cin >> tmp;
        slime[i+1] = tmp;
    }

    while(true){
        int a = 0;
        rep(i, 0, N+1){
            if(slime[i] == slime[i+1] && slime[i+1] == slime[i+2]){
                slime[i+1] = 10000-ans;
                a = 1;
                ++ans;
            }
            if(slime[i] == slime[i+1]){
                    slime[i+1] = 10000-ans;
                a = 1;
                ++ans;
            }
        }
        if(a == 0) break;
    }

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


/*
GRID構造の0と1からなるデータがあり、
このGRIDを端から端まで分割することで、1が含まれるものをKマス以下にしたい。
分割の操作の最小数をもとめたい。
ただし、このGRIDは横1~1000マス、縦1~10マスとなる。

GRIDの縦が10マスであることがポイント。
縦方向の分割は全パターンを試しても、2^9で抑えられる。

縦方向の分割が確定した状態で、
横方向の分割の最小数を求めたい。

貪欲法でよさそう。




*/

const int COL_MAX = 1010;
int choko[10][COL_MAX] = {0};
int choko_rowsum[11][COL_MAX] = {0};

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    rep(i,h){
        string s; cin >> s;
        rep(j,w){
            choko[i][j] = s[j]-'0';
        }
    }
    rep(i,h)rep(j,w){
        choko_rowsum[i+1][j] = choko_rowsum[i][j] + choko[i][j];
    }


    int ans = MOD;
    rep(i, 1<<(h-1)){
        int tans = 0;
        bool isok = true;
        vector<int> div; 
        div.push_back(0);
        for (int j = 0; j < h-1; j++)
        {
            if ((i>>j)&1==1){
                div.push_back(j+1);
                tans++;
            }
        }
        div.push_back(h);
        vector<int> block(div.size()-1, 0);
        vector<int> blockOneRow(div.size()-1, 0);
        //show(div);
        for(int row = 0; row < w; row++){
            bool isbreak = false;
            for (int d = 0; d < div.size()-1; d++)
            {
                blockOneRow[d] = choko_rowsum[div[d+1]][row] - choko_rowsum[div[d]][row];
                //cout << block[d] << ":" << d << ":"<<row <<"::";
                if (blockOneRow[d] > k){
                    isok = false; break;
                }
                if (block[d]+blockOneRow[d] > k){
                    isbreak = true;
                } else {
                    block[d] += blockOneRow[d];
                }
            }
            if (isbreak){
                copy(blockOneRow.begin(), blockOneRow.end(), block.begin());
                //cout << row << endl;
                tans++;
            }     
        }
        //cout  << i << " " << tans << endl;
        if (isok) ans = min(tans, ans);
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(new InputStreamReader(System.in))){
			int N = scan.nextInt();
			int K = scan.nextInt();
			
			StringBuffer sb = new StringBuffer();
			sb.append("^.*[");
			
			for(int i = 0; i<K; i++){
				sb.append(scan.nextInt());
				sb.append("|");
			}

			sb.deleteCharAt(sb.length()-1);
			sb.append("].*$");
			
			String regex = sb.toString();
			
			while(true){
				if(Integer.toString(N).matches(regex) == false){
					System.out.println(N);
					return;
				}
				
				N++;
			}
		}
	}
}


Measured memory_bytes: 20088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto MAX = 100000;
constexpr auto INF = 2147483647;
typedef long long ll;

int A[MAX];


int Partition(int p, int r){
	int x = A[r];
	int i = p - 1;
	int t, j;
	for (j = p; j < r; j++) {
		if (A[j] <= x){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[j]);

	return i + 1;
}


int main() {

	int n, idx;
	cin >> n;
	rep(i, n) cin >> A[i];
	idx = Partition(0, n - 1);
	rep(i, n) {
		if (i) cout << " ";
		if (i == idx) cout << "[";
		cout << A[i];
		if (i == idx) cout << "]";
	}
	cout << endl;


	return 0;
}


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

int main() {
	int n; cin>>n;
	bool band=false;
	
	for(int i=1; i<=n; i++){
		if (n%i==0){
			int aux=n/i;
			int aux2=n/aux;
			
			if(aux >= 1 && aux <=9  && aux2 >= 1 && aux2 <= 9){
				band=true;
				break;
			}
		}
	}
	string res=band ? "Yes" : "No";
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String  u = "ai1333";
			int x = sc.nextInt();
			int y = x / 100;
			
			if(y > 0) {
				for(int i=1; i<=y; i++) {
					u += 3;
				}
			}
			System.out.println(u);
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	string s,t;
	cin>>t>>s;
	ll mi = INF;
	for(int i=0;i+s.size()-1<t.size();i++)
	{
		string h = t.substr(i,s.size());
		ll cnt = 0;
		FOR(j,0,s.size())
			cnt+=(s[j]!=h[j]);
		mi = min(mi,cnt);
	}
	cout<<mi<<Endl;
	return 0;
}


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

  int n,a;
  cin>>n;
  vector <pair< pair<string,int> ,int >> res(n);  
  rep(i,n){
    cin>>res[i].first.first>>a;
    res[i].first.second=(-1)*a;
    res[i].second=i+1;  
  }
  
  sort(res.begin(),res.end());
  
  rep(i,n) cout<<res[i].second<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
//#define N 100010
//#define M 61
//#define MOD 100003
//vector <pair<int,int> > edge[M];
//int d[N][N];
//priority_queue <pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >q;
//queue <int> q;
//ll cnte[N];
//int ans=0;
//vector <int> edge[N];
//int arr[N];
void solve()
{
	int n;
	cin>>n;
	if (n%1000==0)
		cout<<"0"<<endl;
	else
		cout<<((n/1000+1)*1000-n)<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	int t;
//	cin>>t;
//	while (t--)
		solve();
	return 0;
} 

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

long long int n;

int F(long long int A){
	int cnt = 0;
	while (A){
		cnt++;
		A /= 10;
	}
	return cnt;
}

int main(){
	scanf("%lld", &n);
	int AC = INT_MAX;
	for (long long int i = 1; i*i <= n; i++){
		if (n%i == 0LL){
			AC = min(AC, max(F(i), F(n / i)));
		}
	}
	cout << AC << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    string s;
    in(s);
    if (s[0] == s[1] && s[1] == s[2])
    {
        out("No");
    }
    else
    {
        out("Yes");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<long long> sum(N + 1, 0), sumxor(N + 1, 0);
    for(int i = 0; i < N; i++){
        sum[i + 1] = sum[i] + A[i];
        sumxor[i + 1] = sumxor[i] ^ A[i];
    }
    int l = 0, r = 1;
    long long ans = 0;
    for(l; l < N; l++){
        if(l == r) r++;
        while(r < N && sum[r + 1] - sum[l]== (sumxor[r + 1] ^ sumxor[l])){
            r++;
        }
        ans += r - l;
    }
    cout << ans << endl;
}

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

int main(){
  int n,a[101],c,minv;
  cin >> n;
  
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  
  for(int i = 0;i < n-1;i++){
    minv = i;
    for(int j = i;j < n;j++){
      if(a[j] < a[minv])
        minv = j;
    }
    swap(a[i],a[minv]);
    if(minv != i )
      c++;
  }
  
  for(int i = 0;i < n;i++){
    cout << a[i];
    if(i != n-1)
      cout << " ";
  }cout << endl << c << endl;
  
  return 0;
}

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

	int n, t[100], m;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		int p, x,sum = 0;
		cin >> p >> x;
		for (int i = 0; i < n; i++) {
			if (i == p - 1) {
				sum += x;
			}
			else {
				sum += t[i];
			}
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int h , w , i , j;

  while(1){
    scanf("%d%d" , &h , &w);
    if(h == 0 && w == 0) break;

    for(i = 0 ; i < h ; i++){
      for(j = 0 ; j < w ; j++){

	if(i == 0 || i == h - 1) printf("#");

	else if(j == 0 || j == w - 1) printf("#");
	else printf(".");
	
      }
      printf("\n");

    }
    printf("\n");

  }

  return 0;

}

Measured memory_bytes: 572
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

ll calculateF (ll x, ll y, ll z) {
	ll ret = (x * x) + (y * y) + (z * z);
	ret += (x * y) + (y * z) + (z * x);
	return ret;
}

void Flash(){
	ll n;
	cin>>n;
	ll f[n + 1];
	memset(f, 0, sizeof(f));
	ll temp;
	for (ll x = 1; x <= 100; x++) {
		for (ll y = 1; y <= 100; y++) {
			for (ll z = 1; z <= 100; z++) {
				temp = calculateF(x, y, z);
				if (temp <= n) {
					++f[temp];
				}
			}
		}
	}
	for (ll i = 1; i <= n; i++) {
		cout<<f[i]<<"\n";
	}
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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

template <class T> struct dinic {
  struct edge {
    int to;
    T cap;
  };
  static constexpr T inf = numeric_limits<T>::max();
  vector<edge> es;
  vector<vector<int>> g;
  vector<int> dist, i;
  dinic(int n) : g(n), dist(n), i(n) {}
  void add_edge(int from, int to, T cap) {
    assert(from != to);
    assert(cap >= 0);
    if (cap == 0) return;
    g[from].push_back(es.size()), es.push_back({to, cap});
    g[to].push_back(es.size()), es.push_back({from, 0});
  }
  void bfs(int s) {
    fill(begin(dist), end(dist), -1);
    queue<int> que;
    dist[s] = 0;
    que.push(s);
    while (not que.empty()) {
      int v = que.front();
      que.pop();
      for (int id : g[v]) {
        auto e = es[id];
        if (e.cap == 0 or dist[e.to] != -1) continue;
        dist[e.to] = dist[v] + 1;
        que.push(e.to);
      }
    }
  }
  T dfs(int v, int s, T f) {
    if (v == s) return f;
    for (; i[v] < (int)g[v].size(); ++i[v]) {
      edge &e = es[g[v][i[v]]], &re = es[g[v][i[v]] ^ 1];
      if (dist[e.to] >= dist[v] or re.cap == 0) continue;
      T d = dfs(e.to, s, min(f, re.cap));
      if (d > 0) {
        re.cap -= d;
        e.cap += d;
        return d;
      }
    }
    return 0;
  }
  T max_flow(int s, int t) {
    assert(s != t);
    T res = 0;
    while (true) {
      bfs(s);
      if (dist[t] == -1) return res;
      fill(begin(i), end(i), 0);
      while (true) {
        T f = dfs(t, s, inf);
        if (f == 0) break;
        res += f;
      }
    }
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (auto&& v : a) {
    for (auto&& e : v) {
      cin >> e;
      --e;
    }
  }
  for (int c = 0; c < m; ++c) {
    int s = 2 * n, t = s + 1;
    dinic<int> d(t + 1);
    for (int i = 0; i < n; ++i) {
      d.add_edge(s, i, 1);
      d.add_edge(n + i, t, 1);
    }
    for (int i = 0; i < n; ++i) {
      vector<bool> be(n);
      for (int j = c; j < m; ++j) {
        be[a[i][j] / m] = true;
      }
      for (int x = 0; x < n; ++x) {
        if (be[x]) {
          d.add_edge(i, n + x, 1);
        }
      }
    }
    int f = d.max_flow(s, t);
    assert(f == n);
    for (int i = 0; i < n; ++i) {
      for (int id : d.g[i]) {
        if (id % 2 == 0 and d.es[id].cap == 0) {
          int j = find_if(begin(a[i]) + c, end(a[i]), [&](int e) {
            return e / m == d.es[id].to - n;
          }) - begin(a[i]);
          swap(a[i][c], a[i][j]);
          break;
        }
      }
    }
  }
  for (auto e : a) {
    for (int j = 0; j < m; ++j) {
      cout << e[j] + 1 << " \n"[j == m - 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    vector<int> v;
    for (int i = 0; i < n; ++i) {
      v.push_back(a[i][j]);
    }
    sort(begin(v), end(v));
    for (int i = 0; i < n; ++i) {
      a[i][j] = v[i];
    }
  }
  for (auto e : a) {
    for (int j = 0; j < m; ++j) {
      cout << e[j] + 1 << " \n"[j == m - 1];
    }
  }
}


Measured memory_bytes: 800
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int main() {
	int n,m;
	cin>>n>>m;
	int a[200001]={};
	int b[200001]={};
	bool d[200001]={};
	for(int i=1;i<m+1;++i){
		cin>>a[i]>>b[i];
		if(a[i]==1)d[b[i]]=true;
	}
	for(int i=1;i<m+1;++i){
		if(b[i]==n&&d[a[i]]){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


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

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

int main() {
	int n; cin >> n;
	bool ng[200100] = {};
	rep(i, n) {
		int p; cin >> p; p--;
		if(i == p) ng[i] = true;
	}

	int res = 0;
	rep(i, n) {
		if(ng[i]){
			if(ng[i+1]) i++;
			res++;
		}
	}

	cout << res << endl;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	ll n;
	cin >> n;
	ll res = LINF;
	FOR(i, 1, sqrt(n)) {
		if (n%i == 0) {
			ll j = n / i;
			res = min(res, i + j-2);
		}
	}
	pv(res);
	return(0);
}

Measured memory_bytes: 256
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x:x[0])
ans = 0
nokori = M
for j in range(N):
	ans += a[j][0]*min(a[j][1],nokori)
	nokori -= a[j][1]
	if nokori <= 0:
		print(ans)
		exit()



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

int n,a,b,c,d;
string s;

int main(){
	cin>>n>>a>>b>>c>>d;
	cin>>s;
	s='#'+s;
	bool ok=true;
	if(d>c){
		for(int i=b;i<d;++i)
			if(s[i]=='#'&&s[i+1]=='#') ok=false;
		for(int i=a;i<c;++i)
			if(s[i]=='#'&&s[i+1]=='#') ok=false;
		if(ok) cout<<"Yes";
		else cout<<"No";
	}
	else{
		bool mid=false;
		for(int i=b;i<=d;++i)
			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') mid=true;
		bool ok=mid;
		for(int i=b;i<d;++i)
			if(s[i]=='#'&&s[i+1]=='#') ok=false;
		for(int i=a;i<c;++i)
			if(s[i]=='#'&&s[i+1]=='#') ok=false;
		if(ok) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
} 

Measured memory_bytes: 772
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  rep(snip_i, n) cin >> v.at(snip_i);
  v.push_back(x);
  sort(v.begin(), v.end());
  int ans;
  rep(i, n){
    int d = v.at(i+1) - v.at(i);
    if(i == 0) ans = d;
    else ans = __gcd(ans, d);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
  
int main(){
  vector<char> c(9);
  for(int i=0;i<9;i++){
    cin >> c.at(i);
  }
  cout << c.at(0) << c.at(4) << c.at(8) << endl;
  
  return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        r: usize,
    }

    match r {
        0...1199 => println!("ABC"),
        1200...2799 => println!("ARC"),
        2800...4209 => println!("AGC"),
        _ => return,
    }

}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

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; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

ll n;
ll ans = 0;

int nums[] = {3, 5, 7};

bool is_ok(ll x) {
  if (x > n) return false;
  int num_3 = 0, num_5 = 0, num_7 = 0;
  while (x > 0) {
    if (x % 10 == 3) num_3++;
    else if (x % 10 == 5) num_5++;
    else if (x % 10 == 7) num_7++;
    else return false;
    x /= 10;
  }
  if (num_3 > 0 && num_5 > 0 && num_7 > 0) return true;
  else return false;
}

void dfs(ll x) {
  for (int a : nums) {
    ll y = x * 10 + a;
    if (y > n) continue;
    if (is_ok(y)) ans++;
    dfs(y);
  }
}

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

  cin >> n;

  dfs(0);

  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;


int main(){
	ll n;
	cin >> n;
	vector<ll> v(n);
	for(int i = 0;i < n;i++){
		int kk;
		cin >> kk;
		v[i] = kk;
	}
	ll sum = 0;
	for(auto& i : v){
		sum += i;
		i = sum;
	}
	// for(auto i : v){
	// 	cout << i << " ";
	// }
	ll ans = INT_MAX;
	for(int i = 0;i<n-1;i++){
		ans = min(ans,abs(sum - 2 * v[i]));
	}
	cout << ans << "\n";
	return 0;

}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        long N = stdIn.nextLong();
        long A = stdIn.nextLong();
        long B = stdIn.nextLong();
        stdIn.close();
 
        long Count = 0;
 
        if (N % (A + B) > A) {
            Count = A * (N / (A + B)) + A;
        } else {
            Count = A * (N / (A + B)) + (N % (A + B));
        }
 
        System.out.println(Count);
    }
}

Measured memory_bytes: 22612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 200005, M = N << 1, inf = 1e9 + 7 ;
using namespace std ;

int e, n, ter[M], nxt[M], lnk[N], v[N], f[N][3], g[N][3] ;
char s[N] ;
ll ans = 0 ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

void dfs1(int p, int las) {
	f[p][0] = 0, f[p][1] = inf, g[p][0] = g[p][1] = inf ;
	if (v[p]) g[p][0] = 0 ;
	for (int i = lnk[p]; i; i = nxt[i]) if (ter[i] != las) {
		int v = ter[i] ;
		dfs1(v, p) ;
		if (f[v][0] + 1 > f[p][0]) f[p][1] = f[p][0], f[p][0] = f[v][0] + 1 ; else f[p][1] = max(f[p][1], f[v][0] + 1) ;
		if (g[v][0] + 1 < g[p][0]) g[p][1] = g[p][0], g[p][0] = g[v][0] + 1 ; else g[p][1] = min(g[p][1], g[v][0] + 1) ;
	}
}

void dfs2(int p, int u) {
	f[p][2] = 0, g[p][2] = inf ;
	if (u) {
		f[p][2] = max(f[p][2], f[u][2] + 1) ;
		if (f[p][0] + 1 == f[u][0]) f[p][2] = max(f[p][2], f[u][1] + 1) ; else
		  f[p][2] = max(f[p][2], f[u][0] + 1) ;
		g[p][2] = min(g[p][2], g[u][2] + 1) ;
		if (g[p][0] + 1 == g[u][0]) g[p][2] = min(g[p][2], g[u][1] + 1) ; else
		  g[p][2] = min(g[p][2], g[u][0] + 1) ;
	} 
	for (int i = lnk[p]; i; i = nxt[i]) if (ter[i] != u) dfs2(ter[i], p) ;
}

void dfs3(int p, int las) {
	int low = inf, high = f[p][0] + 1, mx = max(f[p][2], f[p][0]), cnt = (las > 0) ;
	if (las && g[p][2] < inf) low = min(low, min(f[p][2], f[p][0] + 2 * g[p][2])) ; 
	for (int i = lnk[p]; i; i = nxt[i]) if (ter[i] != las) {
		dfs3(ter[i], p) ;
		high = min(high, f[ter[i]][2]) ;
		++ cnt ;
		if (g[ter[i]][0] < inf) low = min(low, min(f[ter[i]][0] + 1, f[ter[i]][2] - 1 + (g[ter[i]][0] + 1) * 2)) ;
	}
	high = min(high, mx - 1) ;
	if (cnt == 1) {
		low = min(low, 2 * g[p][0]) ;
		low = min(low, 2 * g[p][2]) ;
		high = min(high, 1) ;
	}
	if (v[p]) low = 0 ;
//	cout << p << " " << low << " " << high <<endl ;
	ans += max(high - low + 1, 0) ;
}

int main() {
	scanf("%d", &n) ;
	int x, y ;
	rep(i, 1, n - 1) {
		scanf("%d%d", &x, &y) ;
		add(x, y), add(y, x) ;
	}
	scanf("%s", s + 1) ;
	rep(i, 1, n) v[i] = s[i] - '0' ;
	dfs1(1, 0), dfs2(1, 0), dfs3(1, 0) ;
	printf("%lld\n", ans + 1) ;
	return 0 ; 
}

Measured memory_bytes: 21760