akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




string S;
int main() {
    while (cin >> S) {
        if (S == "Sunny") cout << "Cloudy" << endl;
        else if (S == "Cloudy") cout << "Rainy" << endl;
        else cout << "Sunny" << endl;
    }
}


















Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const ll INF = 1000010000;
static const ll MOD = 1000000007;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
	int n;
	cin >> n;
	vector<int> t(n), x(n), y(n);
	REP(i, n){
		cin >> t[i] >> x[i] >> y[i];
	}
	int prex = 0, prey = 0, pret = 0;
	bool flag = true;
	REP(i, n){
		int dist = abs(x[i] - prex) + abs(y[i] - prey);
		if(dist <= t[i] - pret && (t[i] - pret - dist) % 2 == 0){
			
		}else{
			flag = false;
		}
		prex = x[i];
		prey = y[i];
		pret = t[i];		
	}
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define E 2.718
using namespace std;
typedef long long ll;
const ll INF=0x7f7f7f7f;
const int maxn=1e6+8;
const double eps=1e-10;
const ll mod=1000000007;
ll n,m,b;
struct node{
    double w;
}num[150];
bool operator<(node a,node b)
{
    return a.w>b.w;
}
int main()
{
    priority_queue<node>q;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
     scanf("%lf",&num[i].w);
        q.push(num[i]);
    }
    while(q.size()!=1)
    {
        node u=q.top();q.pop();
        node u1=q.top();q.pop();
        node now;now.w=(u.w+u1.w)*0.5;
        q.push(now);
    }
    printf("%.7lf\n",q.top().w);
    return 0;
}


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

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] data = new int[N];
        for (int i = 0; i < N; i++) {
            data[i] = sc.nextInt();
        }
        Arrays.sort(data);
        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += data[i];
        }
        pw.println(sum);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 38812
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b;
	cin>>a>>b;
	if(a%2==1&&b%2==1){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

const int MAX = 4040404;

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	REP(i, n) cin >> a[i], sum += a[i];
	bitset<MAX> dp;
	dp[0] = 1;
	REP(i, n) dp |= (dp << a[i]);
	int ret = 0;
	for (ret = (sum + 1) / 2; ret < MAX; ret++) if (dp[ret]) break;
	cout << ret << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin>>n,n){
		string msg; cin>>msg;
		int a[100],b[100];
		for(int i = 0; i < n; ++i)
		{
			cin>>a[i]>>b[i];
			a[i]--;b[i]--;
		}
		for(int i=n-1;i>=0;i--)
		{
			int x=msg[a[i]], y=msg[b[i]];
			x+=b[i]-a[i]; while(x>'z')x-=26;
			y+=b[i]-a[i]; while(y>'z')y-=26;
			msg[b[i]]=x; msg[a[i]]=y;
		}
		cout<<msg<<endl;
	}

}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#include <stack>

typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,a,b;
  cin >> k >> a >> b;
  ll ret = 1;
  while(k){
    if(a<b && k>=2 && ret>=a && b-a>1){
      ret+=b-a;
      k-=2;
    }else{
      ret++;
      k--;
    }
  }
  cout << ret << endl;
  return 0;
}


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

int flag[10][10];
int dx[] = {1,0};
int dy[] = {0,1};
int main()
{
    vector<string> vec;
    int H,W;cin >> H >> W;
    for(int a =0;a < H;a++){
        string str;cin >> str;
        vec.push_back(str);
    }
    std::queue<pair<int,int>> que;
    que.push(make_pair(0,0));
    for(int x = 0;x < W-1;x++){
        for(int y = 0;y < H-1;y++){
            if(vec.at(y).at(x) == '#' && vec.at(y+1).at(x) == '#' && vec.at(y).at(x+1) == '#'){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    for(int x = 1;x < W;x++){
        for(int y = 1;y < H;y++){
            if(vec.at(y).at(x) == '#' && vec.at(y-1).at(x) == '#' && vec.at(y).at(x-1) == '#'){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    while(!que.empty()){
        pair<int,int> p = que.front();
        que.pop();
        if(p.first == W-1&&p.second == H-1){
            cout<<"Possible"<<endl;
            return 0;
        }
        flag[p.first][p.second]=1;
        for(int index = 0;index < 2;index++){
            if(0<=p.first + dx[index] && p.first + dx[index]<=W-1 && 0<=p.second + dy[index] && p.second + dy[index]<= H-1){
                if(flag[p.first+dx[index]][p.second+dy[index]] == 0&& vec.at(p.second+dy[index]).at(p.first+dx[index]) == '#'){
                    que.push(make_pair(p.first+dx[index],p.second+dy[index]));
                }
            }
        }
    }
    cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;

int main(){
  int e[12];
  for(int i=0;i<12;++i)
    cin >> e[i];
  sort(e,e+12);
  if(e[0]==e[3] && e[4]==e[7] && e[8]==e[11])
    cout << "yes" <<endl;
  else
    cout << "no" << endl;
  
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	VI p;
	int a, sj;
	REP(i, n) {
		cin >> a;
		if (i == 0)
			p.push_back(a);
		else {
			sj = distance(p.begin(), lower_bound(p.begin(), p.end(), a));
			if(sj == 0)
				p.insert(p.begin(), a);
			else {
				p[sj - 1] = a;
			}
		}
	}
	cout << p.size();
}

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

int main() {
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if(i == 0) {
            dp[0] = a;
            dp[1] = b;
            dp[2] = c;  
        }
        else { 
            vector<int> new_dp(3);
            new_dp[0] = a + max(dp[2], dp[1]);
            new_dp[1] = b + max(dp[0], dp[2]);
            new_dp[2] = c + max(dp[1], dp[0]);
            dp = new_dp;
        }
    }
    cout << max({dp[0], dp[1], dp[2]});
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int x;

int main(){

	cin >> x;
	if(x >= 400 && x <= 599) puts("8");
	if(x >= 600 && x <= 799) puts("7");
	if(x >= 800 && x <= 999) puts("6");
	if(x >= 1000 && x <= 1199) puts("5");
	if(x >= 1200 && x <= 1399) puts("4");
	if(x >= 1400 && x <= 1599) puts("3");
	if(x >= 1600 && x <= 1799) puts("2");
	if(x >= 1800 && x <= 1999) puts("1");

	return 0;
}


Measured memory_bytes: 3632
l=[]
m=[]
while a = gets
  a = a.split(/ /)
  a[0] = a[0].to_s
  a[1] = a[1].to_i
  p = m.index(a[0])
  if p == NIL
    l.push([a[0],[a[1]]])
    m.push(a[0])
  else
    l[p][1].push(a[1])
  end
end
l.sort!
for i in 0..l.length-1
  puts l[i][0],l[i][1].sort!*" "
end

Measured memory_bytes: 2408
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
#define pq dp
using namespace std;
const ll mx = 4444444444;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t=1, n, k, m, a, b, c, d;
    //cin >> t;

    while(t--){
              cin >> n >> k >> d;
              n = abs(n);
              a = n/d;
              if(k<=a){
                      cout << n-(k*d) << endl;
              }
              else{
                      n-=(a*d);
                      if((k-a)%2){
                             n-=d;
                      }
                      cout << abs(n) << endl;
              }

    }
    return 0;
}




Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> height = new ArrayList<>();
		List<Integer> width = new ArrayList<>();
		int h = 0;
		int w = 0;


		int count = 0;
		boolean judge = false;
		while(!judge){
			h = sc.nextInt();
			w = (sc.nextInt());

			if(h == 0 && w == 0){
				judge = true;
			}else{
				height.add(h);
				width.add(w);
				count++;
			}
		}

		for(int i = 0; i < count; i++){
			for(int j = 0; j < height.get(i); j++){
				for(int k = 0; k < width.get(i); k++){
					if(j == 0 || j == (height.get(i) - 1)){
						System.out.print("#");
					}else{
						System.out.print("#");
						for(int l = 0; l < width.get(i) - 2; l++){
							System.out.print(".");
						}
						System.out.print("#");
						break;
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}

}



Measured memory_bytes: 34784
from itertools import product
import numpy as np

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

INF = 10 ** 9

dp = np.ones(shape=(10, 10), dtype=int) * INF

for i in range(10):
    costs = tuple(map(int, input().split(' ')))
    for j in range(10):
        dp[i][j] = costs[j]

for k, i in product(range(10), repeat=2):
    dp[i] = np.minimum(dp[i], dp[i][k] + dp[k])

cost = 0
for _ in range(H):
    numbers = tuple(map(int, input().split(' ')))
    for n in numbers:
        if n < 0:
            continue
        cost += dp[n][1]

print(cost)


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

/*
  <expr>   ::= <term> [ ('+'|'-') <term> ]*
  <term>   ::= <factor> [ ('*'|'/') <factor> ]*
  <factor> ::= <number> | '(' <expr> ')'
  <number> :== 1?????\????????°???
*/

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s, int& i) {
  int val = term(s, i);
  while (s[i] == '+' || s[i] == '-') {
    char op = s[i];
    i++;
    int val2 = term(s, i);
    if (op == '+')
      val += val2;
    else
      val -= val2;
  }
  return val;
}

int term(string& s, int& i) {
  int val = factor(s, i);
  while (s[i] == '*' || s[i] == '/') {
    char op = s[i];
    i++;
    int val2 = factor(s, i);
    if (op == '*')
      val *= val2;
    else
      val /= val2;
  }
  return val;
}

int factor(string& s, int& i) {
  int val;
  if (s[i] != '(') {
    val = number(s, i);
  } else {
    i++;
    val = expr(s, i);
    i++;
  }
  return val;
}

int number(string& s, int& i) {
  int val = 0;
  while(isdigit(s[i])) {
    val = val*10 + (s[i] - '0');
    i++;
  }
  return val;
}

int main() {
  int n;
  cin >> n;
  for (int j=0; j<n; j++) {
    int i = 0;
    string str;
    cin >> str;
    cout << expr(str, i) << endl;
  }
}

Measured memory_bytes: 2988
#include <iostream>
#include <vector>

using namespace std;

#define W 5

int main(){
    while(true){
        int h;
        cin >> h;
        if(h==0)break;
    vector<vector<int> > map(h,vector<int>(W,0));
    for(int i=0;i<h;i++)
    for(int j=0;j<W;j++){
        cin >> map[i][j];
    }
    bool flag=true;
    int ans=0;
    do{
        flag=false;
        for(int i=0;i<h;i++)
        for(int j=0;j<W;j++){
            if(map[i][j]==-1)continue;

            int seg;
            for(seg=1;j+seg<W;seg++){
                if(map[i][j]!=map[i][j+seg])break;
            }
            if(seg>=3){
                for(int k=0;k<seg;k++){
                    flag=true;
                    ans += map[i][j+k];
                    map[i][j+k] = -1;
                }
            }
        }
        for(int k=0;k<h;k++){
            for(int i=1;i<h;i++){
                for(int j=0;j<W;j++){
                    if(map[i][j]==-1){
                        int tmp = map[i][j];
                        map[i][j]=map[i-1][j];
                        map[i-1][j]=tmp;
                    }
                    
                }
            }
        }

    }while(flag);
    cout << ans << endl;
    }
  return 0;
}

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

class Solve {
private:
	int N, M;
	std::vector<std::list<int>> edge;
	std::vector<int> parities;
	std::vector<int> ans;

	void calcNum()
	{
		if (!is_bipartite(0, 0)) return;
		int count{};
		for (int i{}; i < N; i++)
			if (parities[i])
				count++;
		if (count % 2 == 0) ans.push_back(count / 2);
		if ((N - count) % 2 == 0 && 2 * count != N) ans.push_back((N - count) / 2);
		std::sort(ans.begin(), ans.end());
		return;
	}

	bool is_bipartite(int index, int parity)
	{
		if (parities[index] >= 0)
			return parities[index] == parity;
		parities[index] = parity;
		for (auto& e: edge[index])
			if (!is_bipartite(e, 1 - parity))
				return false;
		return true;
	}

public:
	bool is_last_query{};
	Solve()
	{
		scanf("%d%d", &N, &M);
		if (N == 0 && M == 0)
		{
			is_last_query = true;
			return;
		}
		
		edge.resize(N);
		for (int i{}; i < M; i++)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			u--; v--;
			edge[u].push_back(v);
			edge[v].push_back(u);
		}

		parities.resize(N, -1);
		calcNum();
		printf("%d\n", ans.size());
		for (auto& e: ans) printf("%d\n", e);

		return;
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3320
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int n;
  cin>>n;
  map<int,int> m1;
  map<int,int> m2;
  REP(i,n){
    int v;
    cin>>v;
    if(i%2==0)m1[v]+=1;
    else m2[v]+=1;
  }
  vector<pair<int,int> > p1;
  vector<pair<int,int> > p2;
  for(auto itr = m1.begin();itr!=m1.end();++itr)p1.push_back(*itr);
  sort(p1.begin(), p1.end(), [=](std::pair<int, int>& a, std::pair<int, int>& b)
  {
    return a.second > b.second;
  }
  );
  for(auto itr = m2.begin();itr!=m2.end();++itr)p2.push_back(*itr);
  sort(p2.begin(), p2.end(), [=](std::pair<int, int>& a, std::pair<int, int>& b)
  {
    return a.second > b.second;
  }
  );
  if(p1[0].first==p2[0].first){
    int k1;
    if(p1.size()==0)k1=0;
    else k1=p1[1].second;
    int k2;
    if(p2.size()==0)k2=0;
    else k2=p2[1].second;
    cout<<min(n-p1[0].second-k2,n-p2[0].second-k1)<<endl;
  }else{
    cout<<n-p1[0].second-p2[0].second<<endl; 
  }
  return 0;
}


Measured memory_bytes: 6136
#include<iostream>

int main()
{
	int t, n;
	while( std::cin >> t, t )
	{
		std::cin >> n;
		for( int i = 0; i != n; ++i )
		{
			int s, f;
			std::cin >> s >> f;
			t -= f - s;
		}

		if( t <= 0 )
			std::cout << "OK" << std::endl;
		else
			std::cout << t << std::endl;
	}

	return 0;
}

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

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

#define fori(i,n) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}

int main(){

	fastio
	int n,maxi=0,index=0;
	cin>>n;
	int a[n];
	fori(i,n){
		cin>>a[i];
		if(a[i]>maxi){
			maxi = a[i];
			index = i;
		}
	}
	int max2=0;
	fori(i,n){
		if(i==index)
			continue;
		if(a[i]>max2)
			max2 = a[i];
	}

	fori(i,n){
		if(i==index)
			cout<<max2<<endl;
		else
			cout<<maxi<<endl;
	}





	
}



Measured memory_bytes: 2432
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
#include <iostream>

struct Person {
  int32_t hp{0};
  int32_t attack{0};
};

enum class Turn : int32_t { kTakahashi = 0, kAoki };

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  Person takahashi, aoki;
  std::cin >> takahashi.hp >> takahashi.attack >> aoki.hp >> aoki.attack;
  constexpr int32_t kMaxLoop = 1000000;
  for (int32_t i = 0; i < kMaxLoop; ++i) {
    const Turn turn = ((i % 2) == 0 ? Turn::kTakahashi : Turn::kAoki);
    if (turn == Turn::kTakahashi) {
      aoki.hp -= takahashi.attack;
      if (aoki.hp <= 0) {
        std::cout << "Yes" << std::endl;
        break;
      }
    } else {
      takahashi.hp -= aoki.attack;
      if (takahashi.hp <= 0) {
        std::cout << "No" << std::endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1000000007
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

vector<ll> fact(500005);
vector<ll> invfact(500005);

ll power(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b&1)res=(a*res)%mod;
		a=(a*a)%mod;
		b=b>>1;
	}
	return res%mod;
}

void pre(){
	fact[0]=1;
	fact[1]=1;
	rep(i,2,500005){
		fact[i]=fact[i-1]*i;
		fact[i]%=mod;
	}
	invfact[500004]=power(fact[500004],mod-2);
	repd(i,500003,0){
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=mod;
	}
	return;
}
ll npr(ll a,ll b){
	return (fact[a]*invfact[a-b])%mod;
}
ll ncr(ll a,ll b){
	return (((fact[a]*invfact[b])%mod)*invfact[a-b])%mod;
}
int solve(){
	ll n,m;
	cin>>n>>m;
	ll res=0;
	rep(i,0,n+1){
		ll val=npr(m-i,n-i)%mod*npr(m-i,n-i)%mod*npr(m,i)%mod*ncr(n,i)%mod;
		if(i%2==0)res=res+val;
		else res=res-val+mod;
		res%=mod;
	}
	cout<<res<<endl;
	return 0;
}
int main(){
    waste;
    pre();
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 10972
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define f(i,x,y) for(int i=(x);i<=(y);i++)
#define r(i,x,y) for(int i=(x);i>=(y);i--)
#define ll long long
using namespace std;//head
int a[5][5];
int vis[105];
int main(){
	int n=3,m,x;
	f(i,1,3)
	f(j,1,3)cin>>a[i][j];
	cin>>m;
	while(m--){
		cin>>x;
		vis[x]=true;
	} 
	for(int i=1;i<=n;i++){
		int t=0;
		for(int j=1;j<=n;j++){
			if(vis[a[i][j]])t++;
		}
		if(t==3){
			cout<<"Yes";
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		int t=0;
		for(int j=1;j<=n;j++){
			if(vis[a[j][i]])t++;
		}
		if(t==3){
			cout<<"Yes";
			return 0;
		}
	}
	int t=0;
	for(int i=1;i<=n;i++){
		if(vis[a[i][i]])t++;
	}
	if(t==3){
			cout<<"Yes";
			return 0;
		}
	t=0;
		for(int i=1;i<=n;i++){
		if(vis[a[i][n-i+1]])t++;
	}
	if(t==3){
			cout<<"Yes";
			return 0;
		}
		
		printf("No");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

/*
   AtCoder contests
   coder : yoichion
 */

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];
        for(int n=0;n<N;n++){
            h[n] = sc.nextInt();
        }
        Arrays.sort(h);
        int best = 1_000_000_000;
        for(int n=0;n<=N-K;n++){
            best = Math.min(best, h[n+K-1]-h[n]);
        }
        System.out.println(best);
    }
}

Measured memory_bytes: 48164
import scala.io.StdIn

object Main extends App {
  
  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ")
  val q = StdIn.readLine().toInt

  (0 until q).foreach { i =>
    val qa = StdIn.readLine().split(" ").map(_.toInt)
    val buff = a.slice(qa(0), qa(1)).reverse
    buff.zipWithIndex.foreach{ case (s, index) =>
      a(qa(0) + index) = s
    }
  }
  println(a.mkString(" "))
  
}


Measured memory_bytes: 56360
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   var tdl = arr.shift();
   if (tdl == "0 0 0") break;
   var [t,d,l]=tdl.split(" ").map(Number);
   var cnt=0;
   var time=0;
   for(var i=0;i<t;i++){
      if(time!=0)cnt++;
      if(time>0)time--;
      var x=arr[i]-0;
      if(x>=l)time=d;
   }
   console.log(cnt);
   arr=arr.slice(t);
}


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

const int maxN = 100005;
const int maxD = 15;
using namespace std;

int N, M, Q, ans[maxN], V[maxN], d[maxN], c[maxN];
bool memo[maxN][maxD];
vector<int> g[maxN];

void DFS(int u, int d, int c) {
    if (d < 0 || memo[u][d]) return;
    memo[u][d] = true;
    if (ans[u] == 0)
        ans[u] = c;
    for(int v: g[u])
        DFS(v, d-1, c);
}

int main() {
    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 = 0; i < Q; ++i)
        cin >> V[i] >> d[i] >> c[i];

    for(int i = Q-1; i >= 0; --i)
        DFS(V[i], d[i], c[i]);

    for(int u = 1; u <= N; ++u)
        cout << ans[u] << endl;
}


Measured memory_bytes: 9464
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
ans = [1] * (n + 1)
for i in a:
    ans[i] = 0
for i in range(2, n + 1):
    if ans[i]:
        ans[i] = ans[i - 1] + ans[i - 2]
    if ans[i] >= 1000000007:
        ans[i] = ans[i] % 1000000007
print(ans[-1])

Measured memory_bytes: 7824
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,r[10005],l[10005],ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
		int k=r[i]-l[i]+1;
		ans+=k;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
from itertools import product
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))

schejule_list = set(product([0, 1], repeat=10))
ans = - float("inf")
for schedule in schejule_list:
    if schedule == (0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
        continue
    res = 0
    for i in range(n):
        kaburi = 0
        for j in range(10):
            kaburi += f[i][j] * schedule[j]
        res += p[i][kaburi]
    ans = max(ans, res)
print(ans)




Measured memory_bytes: 9340
import sys
 
if __name__ == '__main__':
    str = input()
    str = input().strip()
 
    arr = [int(e) for e in str.split()]
    if 0 in arr:
        print(0)
        sys.exit()
 
    total = 1
    for e in arr:
        total *= e

        if total > 10 ** 18:
            total = -1
            break

    print(total)

Measured memory_bytes: 84940
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
void print() {}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){ cout << head << " \n"[sizeof...(tail) == 0]; print(forward<Tail>(tail)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll cnt = 0;
    rep(i,1,N+1){
        if(i % 2 == 1) cnt++;
    }
    double ans = (double) cnt / (double) N;
    cout << setprecision(10) << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
}

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

int N, M, P[12];
vector<int> X[12];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int v, a; cin >> v;
		for (int j = 0; j < v; j++) { cin >> a; a--; X[i].push_back(a); }
	}
	for (int i = 0; i < M; i++) cin >> P[i];

	int cnt = 0;
	for (int i = 0; i < (1 << N); i++) {
		int bit[12]; for (int j = 0; j < N; j++) bit[j] = (i / (1 << j)) % 2;

		int ans = 0;
		for (int j = 0; j < M; j++) {
			int ret = 0;
			for (int k : X[j]) ret ^= bit[k];
			if (ret != P[j]) ans++;
		}
		if (ans == 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N,K,sum=0;
	cin >> N >> K;
	int a[N];
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	sort(a,a+N,greater<int>());
	for(int j=0;j<K;j++){
		sum = sum + a[j];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 1010;

int en, head[N];
struct Edge {
    int to, nxt;
} e[N << 1];

inline void add(int x, int y)
{
    e[++en].to = y;
    e[en].nxt = head[x];
    head[x] = en;
}

int d[N], t[N];
bool vis[N];
queue<int> q;
int pre, ret = 0x3f3f3f3f, ans;
vector<int> v;

inline void bfs(int st)
{
    pre = ret;
    memset(vis, 0, sizeof(vis));
    q.push(st);
    vis[st] = 1;
    d[st] = 0;
    while (q.size()) {
        register int now = q.front(); q.pop();
        for (register int i = head[now]; i; i = e[i].nxt) {
            if (vis[e[i].to] == 1) {
                if (e[i].to == st) {
                    if (ret > d[now] - d[e[i].to] + 1) {
                        ret = d[now] - d[e[i].to] + 1, ans = now;
                    }
                }
                continue;
            }
            t[e[i].to] = now;
            d[e[i].to] = d[now] + 1;
            q.push(e[i].to);
            vis[e[i].to] = 1;
        }
    }
    if (pre != ret) {
        v.clear();
        register int now = ans;
        while (now != st) {
            v.push_back(now);
            now = t[now];
        }
        v.push_back(st);
    }
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for (register int i = 1, x, y; i <= m; ++i) {
        scanf("%d %d", &x, &y);
        add(x, y);
    }
    for (register int i = 1; i <= n; ++i) {
        bfs(i);
    }
    int sz = v.size();
    if (sz == 0) sz = -1;
    printf("%d\n", sz);
    sort(v.begin(), v.end());
    for (register int i = 0; i < sz; ++i) {
        printf("%d ", v[i]);
    }
    return 0;
}

Measured memory_bytes: 384
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> H;

void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    H = fetch_vec<int>(N);
}

void solve(){
    input();
    vector<int> A(N,0);
    for(int i=0;i<N-1;i++){
        A[i] = (H[i]>=H[i+1]);
    }
    int count=0;
    int ans;
    for(int i=0;i<N-1;i++){
        if(A[i]) count++;
        else count=0;
        ans = max(ans,count);
    }
    cout << ans << endl;
    
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1024
def main():
    K, X = (int(x) for x in input().split())
    mini = X - K + 1
    maxi = X + K
    ans = [x for x in range(mini, maxi, 1)]
    ans = " ".join(map(str, ans))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

const int N=60;
vector<int> adj[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fastio;
    ll n;cin>>n;
    ll a[n],b[n],c[n-1];
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)cin>>b[i];
    rep(i,0,n-1)cin>>c[i];

    ll ans=0,last=-INF;
    rep(i,0,n)
    {
        ans+=(b[a[i]-1]);
        if(last+1==a[i])
            ans+=(c[last-1]);
        last=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate

# functions used
r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split())
R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)]
Rmap = lambda: map(int, r().split())
# set inputs
N, C = R()
STC = [R() for _ in range(N)]
#  0.5sec as one unit
tbl = [[0]*(2*(10**5)+5) for _ in range(C)]

for s, t, c in STC:
    c -= 1
    # if we can record the programms continuously (ver1)
    if tbl[c][2*s] != 0:
        tbl[c][2*s] += 1
        tbl[c][2*t] -= 1
    # if we can record the programms continuously (ver2)
    elif tbl[c][2*t-1] != 0:
        tbl[c][2*t-1] -= 1
        tbl[c][2*s-1] += 1
    # else:
    else:
        tbl[c][2*s-1] = 1
        tbl[c][2*t] = -1

tbl2 = [list(accumulate(a)) for a in tbl]

# ans = max([sum(x) for x in zip(*tbl2)])
# print(ans)

res = 0
for i in range(200002):
    cc = 0
    for j in range(C):
        if tbl2[j][i] == 1:
            cc += 1
    res = max(res, cc)
print(res)


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli h, w;
    cin2(h, w);

    lli ans1 = LLONG_MAX;
    lli ans2 = LLONG_MAX;
    lli ans3 = LLONG_MAX;
    lli ans4 = LLONG_MAX;
    // 横斬り

    if (h > 2) {
        if (h % 3 == 2) {
            lli x = (h + 1) / 3;
            lli y = (h - x) / 2;
            ans1 = (x - y) * w;
        }
        else {
            lli x = h / 3;
            lli y = h - x*2;
            ans1 = (y - x) * w;

        }
    }

    // 縦斬り
    if (w > 2) {
        if (w % 3 == 2) {
            lli x = (w + 1) / 3;
            lli y = (w - x) / 2;
            ans2 = (x - y) * h;
        }
        else {
            lli x = w / 3;
            lli y = w - x*2;
            ans2 = (y - x) * h;

        }
    }

    // 縦横斬り、横先
    lli xh = h / 3;
    lli yw = w / 2;
    REPE(i, xh, xh+1) {
        lli a = i * w;
        REPE(j, yw, yw+1) {
            if (i == 0 || j == 0)
                continue;
            lli b = j * (h-i);
            lli c = (w-j) * (h-i);
            lli min_men = min({a, b, c});
            lli max_men = max({a, b, c});
            ans3 = min(ans3, max_men - min_men);
            //cout1(a);
            //cout1(b);
            //cout1(c);
            //cout1(max_men);
            //cout1(min_men);
            //cout1(ans3);
        }
    }


    // 縦横斬り、縦先
    lli xw = w / 3;
    lli yh = h / 2;
    REPE(i, xw, xw+1) {
        lli a = i * h;
        REPE(j, yh, yh+1) {
            if (i == 0 || j == 0)
                continue;
            lli b = j * (w-i);
            lli c = (h-j) * (w-i);
            lli min_men = min({a, b, c});
            lli max_men = max({a, b, c});
            ans4 = min(ans4, max_men - min_men);
            //cout1(a);
            //cout1(b);
            //cout1(c);
            //cout1(max_men);
            //cout1(min_men);
            //cout1(ans3);
        }
    }
    //cout1(ans1);
    //cout1(ans2);
    //cout1(ans3);
    //cout1(ans4);
    cout << min({ans1, ans2, ans3, ans4}) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    ll arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << arr[k-1];

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000000000
int main()
{
    long n,k,s;
    long i;
    long j;
    
    scanf("%ld%ld%ld",&n,&k,&s);
    if(s==N){
        for(i=0;i<k;i++){
            printf("%ld ",s);
        }if(k<n){
            for(j=i;i<n;i++)
                printf("%ld ",s-1);
        }
        
    }else{
        for(i=0;i<k;i++){
            printf("%ld ",s);
        }if(k<n){
            for(j=i;i<n;i++)
                printf("%ld ",s+1);
        }
    }


    printf("\n");
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define sc scanf
#define pr printf
#define B break
#define R return
#define C continue
#define pb push_back
using namespace std;
int n,a,m,b,c;
ll ans=1e9,w[2000000];
vector <ll> v;
ll d1=0;
int main()
{
    cin >>a>>b>>c;
    if (a+b>=c) cout <<"Yes\n";
    else cout <<"No\n";
    return 0;
}
// 999999999 1000000000


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;

int main() {
    ll n,a;
    cin>>n>>a;
    ll x[60];
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    ll dp[51][51][2501]={};
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=2500;k++){
                if((i==0)&&(j==0)&&(k==0)){
                    dp[i][j][k]=1;
                    continue;
                }
                if((i>=1)&&(k<x[i])){
                    dp[i][j][k]=dp[i-1][j][k];
                    continue;
                }
                if((i>=1)&&(j>=1)&&(k>=x[i])){
                    dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
                    continue;
                }
                dp[i][j][k]=0;
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 51072
//   1 2 3 4 5 6 7 8
// 1 0 1 1 1 1 1 1 1
// 2 0 0 2 2 2 2 2 2
// 3 0 1 0 3 3 3 3 3
// 4 0 0 1 0 4 4 4 4
// 5 0 1 2 1 0 5 5 5
// 6 0 0 0 2 1 0 6 6
// 7 0 1 1 3 2 1 0 7
// 8 0 0 2 0 3 2 1 0

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    long ans = 0;
    for (int i = K+1; i <= N; i++) {
      ans += (long)(i-K)*(N/i);
      if (N%i != 0 && N%i >= K) {
        ans += K == 0 ? N%i : N%i-K+1;
      }
    }
    System.out.println(ans);
  }
}

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

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, a;
  cin >> h >> a;
  cout << (h - 1) / a + 1;
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int main(){
    char c[105];
    scanf("%s",c);
    char target[10]="keyence";
    int l=0,r=6;
    for(int i=0;c[i]!=0;i++){
        if(c[i]==target[i]){
            l++;
        }
        else{
            break;
        }
    }
    for(int i=strlen(c)-1;i>=0;i--){
        if(c[i]==target[r])r--;
        else break;
    }
    if(l<=r)printf("NO\n");
    else printf("YES\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
 
int main() {
  int n;
  cin >> n;
  int m = 1000;
  int ans;
  rep(i, n){
      if(m < n) m += 1000;
      else ans = m - n;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		int b = 0;
		int c = 1;
		//
		for ( int j = 0; j < n ; j++ ) {
			if ( a[j] == c ) {
				c++ ;
			} else {
				b++ ;
			}
		}
		if ( b == n ) {
			b = -1;
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 84128
#include <bits/stdc++.h>
#define mov(x) (1<<(x))

using namespace std;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, m, sum;
int grp[mov(15)];
int w[15][15];
int f[mov(15)][15], g[mov(15)][15];

int main()
{
	read(n), read(m);
	memset(w, 0x9f, sizeof(w));
	for(int i=1; i<=m; i++)
	{
		int a, b, c;
		read(a), read(b), read(c);
		w[a-1][b-1] = c;
		w[b-1][a-1] = c;
		sum += c;
	}
	memset(f, 0x9f, sizeof(f));
	memset(g, 0x9f, sizeof(g));
	for(int s=1; s<mov(n); s++)
		for(int i=0; i<n; i++)
			if(s & mov(i))
				for(int j=i+1; j<n; j++)
					if(s & mov(j))
						if(w[i][j] > 0)
							grp[s] += w[i][j];
	for(int s=1; s<mov(n); s++)
	{
		if(s & 1)
			f[s][0] = grp[s];
		for(int i=0; i<n; i++)
			if(s & mov(i))
				for(int j=0; j<n; j++)
					if(!(s & mov(j)))
						if(w[i][j] > 0)
							cmax(g[s][j], f[s][i]+w[i][j]);
	}
	for(int s=1; s<mov(n); s++)
	{
		for(int t=s; t; t=((t-1)&s))
			if(t != s)
				for(int i=0; i<n; i++)
					if(t & mov(i))
						cmax(f[s][i], g[s^t][i]+grp[t]);
		for(int i=0; i<n; i++)
			if(s & mov(i))
				for(int j=0; j<n; j++)
					if(!(s & mov(j)))
						if(w[i][j] > 0)
							cmax(g[s][j], f[s][i]+w[i][j]);
	}
	printf("%d\n", sum-f[mov(n)-1][n-1]);
	return 0;
}


Measured memory_bytes: 4352
# include <bits/stdc++.h>
# define rep(i,n) for (int i = 0; i < (n); ++i)
# define FI first
# define SE second
using namespace std;
using P = pair<string, int>;

int main() {
  int n; cin >> n;
  vector<P> towns(n);
  map<int, int> mp;
  rep (i, n) {
    string s; int p; cin >> s; cin >> p;
    towns[i].FI = s;
    towns[i].SE = p;
    mp[p] = i + 1;
  }
  
  sort(towns.begin(), towns.end(), [](P a, P b) {
    if(a.FI != b.FI){
        return a.FI < b.FI;
    } else {
        return a.SE > b.SE;
    }
  });
  
  rep (i, n) {
  	cout << mp[towns[i].SE] << endl;
  }
  
  return 0;
}


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

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  
  	int s = 0;
  	rep(i, n) s ^= a[i];
  	rep(i, n) a[i] ^= s;
  	rep(i, n) cout << a[i] << endl;
}

Measured memory_bytes: 3904