akhauriyash/Code-Regression huggingface dataset:
n, m = [int(x) for x in input().split(' ')]

cities = list()
for i in range(m):
    pi, pm = [int(x) for x in input().split(' ')]
    cities.append([pi, pm, i])

p = [0] * (n+1)
for c in sorted(cities, key=lambda city: city[1]): # sort by year
    p[c[0]] += 1 # city birth order
    c.append(p[c[0]])

for c in cities:
    print('{:06d}{:06d}'.format(c[0], c[3]))


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

Int n;
vector<Int> read01(Int n){
  char last = '0';
  char c;
  vector<Int> hoge;
  for(Int i = 0;i < 2*n;i++)hoge.push_back(0);
  for(Int i = 0;i < n;i++){
    cin >> c;
    if(c!= last){
      hoge.push_back(i);
      last = c;
    }
  }
  for(Int i = 0;i < 2*n;i++)hoge.push_back(n);
  return hoge;
}

Int solve(vector<Int> &pos1, vector<Int> &pos2, Int offset){
  Int ans = 0;
  for(Int i = 0;i + offset < pos1.size() && i < pos2.size();i++){
    ans += abs(pos1[offset+i] - pos2[i]);
  }
  return ans;
}

int main(){
  cin >> n;
  vector<Int> pos1 = read01(n);
  vector<Int> pos2 = read01(n);
  Int res = 1LL << 60;
  for(Int i = 0;i < 2*n;i+=2){
    res = min(res, solve(pos1, pos2, i));
    res = min(res, solve(pos2, pos1, i));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=5e5+5;
int st[N],pk[N],a[N],nxt[N],las[N],xia[N],n,pos,top;ll k;
int main(){
    scanf("%d%lld",&n,&k);
    fp(i,1,n)scanf("%d",&a[i]),nxt[las[a[i]]]=i,las[a[i]]=i;
    fp(i,1,n)nxt[las[a[i]]]=i,las[a[i]]=i;
    fp(i,1,n-1)xia[i]=i+1;xia[n]=1;
    st[++top]=1,pk[top]=1,pos=1;
    do{
        ++top,pk[top]=pk[top-1]+(nxt[pos]<=pos)+(nxt[pos]==n);
        st[top]=pos=xia[nxt[pos]];
    }while(st[top]!=st[1]);
    k-=(k-1)/(pk[top]-1)*(pk[top]-1);
    R int j=1;
//  fp(i,1,top)printf("%d %d %d\n",i,st[i],pk[i]);
//  printf("%lld\n",k);
    while(j<=top-1&&pk[j+1]<=k)++j;
//  if(j==top-1)return 0;
//  fp(i,st[j],n)printf("%d ",a[i]);
    for(R int i=st[j];i<=n;++i){
        if(nxt[i]>i)i=nxt[i];
        else printf("%d ",a[i]);
    }
    return 0;
}


Measured memory_bytes: 10880
from math import ceil
from fractions import Fraction

n = int(input())
sa, st = 1, 1

for a, t in (map(int, input().split()) for _ in range(n)):
    r = ceil(max(Fraction(sa, a), Fraction(st, t)))
    sa, st = a * r, t * r

print(sa + st)


Measured memory_bytes: 5688
#include<iostream>
#include<string>
using namespace std;
string mcxi="ixcm";

int mcxi_to_int(string sa){
	int a,b;
	b=0;
	for(int i=0;i<sa.size();i++){
		if('1'<=sa[i] && sa[i]<='9')a=(int)sa[i]-(int)'0',i++;
		else a=1;
		for(int j=0;j<4;j++){
			if(sa[i]==mcxi[j])break;
			a*=10;
		}
		b+=a;
	}
	return b;
}

string int_to_mcxi(int t){
	int a,b;
	int i,j,k;
	string sa="";
	for(i=0;t>0;i++,t/=10){
		a=t%10;
		if(a>0)sa=mcxi[i]+sa;
		if(a>1)sa=(char)(a+'0')+sa;
	}
	return sa;
}

int main(){
	int n;
	int a,b,c;
	string sa,sb;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>sa>>sb;
		cout<<int_to_mcxi(mcxi_to_int(sa)+mcxi_to_int(sb))<<endl;
	}
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
  	fastio;
    int n, m;
    cin >> n >> m;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    int min = accumulate(a, a+n, 0);
	int count = 0;
	for(int i = 0; i < n; ++i) {
		if(a[i] * 4 * m >= min) count++;
	}

	cout << (count >= m ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <functional>
#include <numeric>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <stdio.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a%2 == 0 || b%2 == 0 || c%2 == 0){
		puts("0");
		return 0;
	}
	printf("%lld\n", min({1ll * a * b, 1ll * b * c, 1ll * c * a}));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

map<ll, int> factorize(ll n) {
    map<ll, int> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res[i] = 0;
        while (n % i == 0) {
            n /= i;
            res[i]++;
        }
    }

    if (n != 1) res[n] = 1;
    return res;
}

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

    map<ll, int> fs;

    for (int i = 2; i <= n; i++) {
        auto f = factorize(i);
        for (auto e : f) {
            fs[e.first] += e.second;
        }
    }

    vector<int> counts;
    for (auto e : fs) counts.push_back(e.second);

    int m = counts.size();

    int ans = 0;

    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            for (int k = j + 1; k < m; k++) {
                if (counts[i] >= 2 && counts[j] >= 4 && counts[k] >= 4)ans++;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            for (int k = j + 1; k < m; k++) {
                if (counts[i] >= 4 && counts[j] >= 2 && counts[k] >= 4)ans++;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            for (int k = j + 1; k < m; k++) {
                if (counts[i] >= 4 && counts[j] >= 4 && counts[k] >= 2) ans++;
            }
        }
    }


    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            if (counts[i] >= 14 && counts[j] >= 4)ans++;
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            if (counts[i] >= 4 && counts[j] >= 14) ans++;
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            if (counts[i] >= 2 && counts[j] >= 24) ans++;
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            if (counts[i] >= 24 && counts[j] >= 2)ans++;
        }
    }

    for (int i = 0; i < m; i++) {
        if (counts[i] >= 74) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
using namespace std;
const ll M = 1e9 + 7;
ll n,ans;
void solve()
{
    char c;
    cin>>c;
    if(isupper(c))
    cout<<"A";
    else
    {
        cout<<"a";
    }
    
}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int H, W, tmp;
    cin >> H >> W >> tmp;

    vector<string> S(H);
    vector<int> row(H, 0);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') row[i]++;
        }
    }

    vector<vector<int>> output(H, vector<int>(W, -1));
    int K = 1;
    for (int i = 0; i < H; i++) {
        int w = 0;
        if (row[i] == 0 && i != 0) {
            for (int j = 0; j < W; j++) {
                output[i][j] = output[i - 1][j];
            }
            continue;
        }
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                if (row[i] > 1) {
                    for (int l = w; l < j + 1; l++) {
                        output[i][l] = K;
                    }
                } else if (row[i] == 1) {
                    for (int l = w; l < W; l++) {
                        output[i][l] = K;
                    }
                }
                row[i]--;
                K++;
                w = j + 1;
            }
        }
        // cout << "i=" << i << endl;
        // for (int i = 0; i < H; i++) {
        // for (int j = 0; j < W; j++) {
        // cout << output[i][j] << " ";
        // }
        // cout << endl;
        // }
    }

    for (int i = H - 2; i >= 0; i--) {
        if (output[i][0] == -1) {
            for (int j = 0; j < W; j++) {
                output[i][j] = output[i + 1][j];
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << output[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 4140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n,m;
	static int a[100010],b[100010];
	scanf("%d%d",&n,&m);
	rep1(i,m)scanf("%d%d",&a[i],&b[i]);
	
	static int cnt[100010] = {};
	rep1(i,m){
		cnt[a[i]] ++;
		cnt[b[i]] ++;
	}
	rep1(i,n){
		if(cnt[i]&1){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


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

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

        long sumall = 0;
        for (int i = 0; i < Math.pow(2, S.length()-1); i++) {
            String ans = S.substring(0, 1);
            long sum = 0;
            for (int j = 0; j < S.length()-1; j++) {
                if ((1 & (i >> j)) == 1) {
                    sum += Long.parseLong(ans);
                    ans = "";
                }
                ans += S.substring(j+1, j+2);
            }
            sum += Long.parseLong(ans);
            sumall += sum;
        }
        out.printf("%d\n", sumall);
        out.flush();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <functional>
#include <algorithm>
using namespace std;

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int team, game, i, j;
	int point[100] = {0};
	int a, b, c, d;

	cin >> team;

	game = team * ( team - 1 ) / 2;

	for(i = 0; i < game; i++) {
		cin >> a >> b >> c >> d;
		if(c < d) {
			point[b-1] += 3;
		} else if(c > d) {
			point[a-1] += 3;
		} else if(c == d) {
			point[a-1] += 1;
			point[b-1] += 1;
		}
	}

	int rank[100] = {0};
	for(i = 0; i < team; i++) {
		rank[i] = point[i];
	}

	sort(rank, rank+100, greater<int>());

	for(i = 0; i < team; i++) {
		for(j = 0; j < team; j++) {
			if(point[i] == rank[j]) {
				cout << j + 1 << endl;
				break;
			}
		}
	}

	return 0;

}

Measured memory_bytes: 1180
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int64 MOD = 1e9 + 7;

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

  int n; cin >> n;
  string s; cin >> s;

  int64 cnt[26] = {};

  for (auto c : s){
    ++cnt[c - 'a'];
  }

  int64 ans = 1;

  for (int i = 0; i < 26; ++i){
    ans *= (int64) cnt[i] + 1;
    ans %= MOD;
  }

  print(ans - 1);

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
  RSQ:Range Add Query
  segment tree を利用
  https://www.youtube.com/watch?v=ReGvflPU81c&list=PL3Hpv03CoZ24p5a6qT0LsFKEhiDWxf_B_&index=4
*/

#define SEG_LEN (1 << 18) //10^5 より大きい２進数, index = 1から利用する．
int seg[SEG_LEN * 2];

//one point 取得
long long int get(int ind){
  ind += SEG_LEN;
  long long int sum = 0;
  sum += seg[ind];
  while(true){
    ind /= 2;
    if(ind == 0) break;
    sum += seg[ind];
  }
  return sum;
}

void add(int l, int r, int x){
  l += SEG_LEN;
  r += SEG_LEN;
    while(l < r){
    if(l%2 == 1){
      seg[l] += x;
      l++;
    }
    l /= 2;

    if(r%2 == 1){
      seg[r - 1] += x;
      r--;
    }
    r /= 2;
  }
}

int main(){
  int n, q;
  cin >> n >> q;

  REP(i,q){
    int com;
    cin >> com;
    if(com == 0){//add
      int l, r, x;
      cin >> l >> r >> x;
      add(l, r+1, x);
    }

    if(com == 1){//get
      int ind;
      cin >> ind;
      cout << get(ind) << endl;

    }
  }


  return 0;
}



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


int main() {
  int N,M;
  cin >> N >> M;
  vector<int>vec(N);
  long int sum = 0;
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }

  int count = 0;
  for(int i=0;i<N;i++){
    if(4*M*vec.at(i)>=sum){
      count++;
    }
  }
  if(count>=M) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define max_v(v) *max_element(all(v));
#define min_v(v) *min_element(all(v));
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl
template <typename T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    for(int i = 0; i < vec.size(); i++) {
        os << vec.at(i) << (i + 1 == vec.size() ? "" : " ");
    }
    return os;
}

int main() {
    int X, Y, Z;
    cin >> X >> Y;
    bool flg = false;

    rep(i, X + 1) {
        int Z = X - i;
        int F = i * 2 + Z * 4;
        if(F == Y) {
            flg = true;
            break;
        }
    }

    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
const int MAX=1e6+9;
const int mod=1e9+7;
using namespace std;
int cnt[MAX];

int main(){
	string s;
	cin>>s;
	int cntzo=0, cntoo=0;
	int cntze=0, cntoe=0;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='0')
				cntze++;
		}
		else {
			if(s[i]=='1')
				cntoe++;
		}
	}
	int mn=cntze+cntoe;
	cntze=0;
	cntoe=0;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='1')
				cntze++;
		}
		else {
			if(s[i]=='0')
				cntoe++;
		}
	}
	cout<<min(mn , cntze+cntoe);
	
	
}

Measured memory_bytes: 512
# coding=utf-8

N = int(input())
S = input()

R = {i for i, c in enumerate(S) if c == 'R'}
G = {i for i, c in enumerate(S) if c == 'G'}
B = {i for i, c in enumerate(S) if c == 'B'}

r = len(R)
g = len(G)
b = len(B)

all_ = r * g * b

# i - j = j - k (i.e. k = 2*j -i) の場合を引く
sub = 0

for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            continue
        else:
            k = 2 * j - i
            if k < N and S[i] != S[k] and S[j] != S[k]:
                sub += 1

print(all_ - sub)

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

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

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ll a, b, c;
	scanf("%lld %lld.%lld", &a, &b, &c);

	ll A = a, B = 100 * b + c;
	ll num = A * B;

	printf("%lld\n", num / 100ll);
	
	return 0;
}

Measured memory_bytes: 3864
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => {
  const a = parseInt(input.split(" ")[0]);
  const b = parseInt(input.split(" ")[1]);
  if (a > b) {
    console.log("a " + ">" + " b");
  } else if (a == b) {
    console.log("a " + "==" + " b");
  } else {
    console.log("a " + "<" + " b");
  }
});


Measured memory_bytes: 15252
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
int main(void)
{
    int n;
    cin >> n;
    long double ans = ((n + 1) / 2) / double(n);
    cout << fixed << setprecision(15);
    cout << ans << endl;
}

Measured memory_bytes: 3764
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

template <class T>
class cumulativeSum
{
    int ny, nx;
    vector<vector<T> > sum;
public:
    cumulativeSum(const vector<vector<T> >& a)
    {
        ny = a.size();
        nx = a[0].size();
        sum.assign(ny+1, vector<T>(nx+1, 0));
        for(int i=0; i<ny; ++i){
            for(int j=0; j<nx; ++j){
                sum[i+1][j+1] = a[i][j] + sum[i][j+1] + sum[i+1][j] - sum[i][j];
            }
        }
    }
    T getSum(int y1, int x1, int y2, int x2)
    {
        if(y1 > y2 || x1 > x2)
            return 0;
        y1 = max(y1, 0);
        x1 = max(x1, 0);
        y2 = min(y2, ny-1);
        x2 = min(x2, nx-1);
        return sum[y2+1][x2+1] - sum[y1][x2+1] - sum[y2+1][x1] + sum[y1][x1];
    }
};

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > a(n, vector<int>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> a[i][j];
        }
    }
    
    int ret = INT_MIN;
    cumulativeSum<int> cs(a);
    for(int y1=0; y1<n; ++y1){
        for(int y2=y1; y2<n; ++y2){
            for(int x1=0; x1<n; ++x1){
                for(int x2=x1; x2<n; ++x2){
                    ret = max(ret, cs.getSum(y1, x1, y2, x2));
                }
            }
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1300
using System;
using System.Linq;
using static System.Console;

class Program {
	static void Main() {
		var N = int.Parse(ReadLine());
		var S = ReadLine();
		var ans = 0;

		for (var i = 1; i < N; i++) {
			var a = S.Substring(0, i);
			var b = S.Substring(i);
			ans = Math.Max(ans, Calc(a, b));
		}
		WriteLine(ans);
	}

	static int Calc(string x, string y) {
		var result = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			if (x.Contains(c) && y.Contains(c)) {
				result++;
			}
		}
		return result;
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n; cin>>n;
    int a, b, c; cin>>a>>b>>c;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin>>l[i];

    int ans=1e9;
    for(int bita=1; bita<(1<<n); bita++){
        for(int bitb=1; bitb<(1<<n); bitb++){
            for(int bitc=1; bitc<(1<<n); bitc++){
                int cost=0;

                if(bita & bitb) continue;
                if(bitb & bitc) continue;
                if(bitc & bita) continue;

                int suma=0, sumb=0, sumc=0;
                for(int i=0; i<n; i++){
                    if(bita & (1<<i)){
                        if(suma!=0) cost+=10;
                        suma+=l[i];
                    }
                    if(bitb & (1<<i)){
                        if(sumb!=0) cost+=10;
                        sumb+=l[i];
                    }
                    if(bitc & (1<<i)){
                        if(sumc!=0) cost+=10;
                        sumc+=l[i];
                    }
                }
            
                cost+=abs(suma-a);
                cost+=abs(sumb-b);
                cost+=abs(sumc-c);

                chmin(ans, cost);
                
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, t = LI()
ab = sorted(LIR(n))
dp = [0] * t
ans = 0
for a, b in ab:
    ans = max(ans, dp[-1] + b)
    for i in range(a, t)[::-1]:
        dp[i] = max(dp[i], dp[i - a] + b)


print(ans)




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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string S;
    cin >> S;
    if(S=="Sunny"){
        P("Cloudy");
    }else if(S=="Cloudy"){
        P("Rainy");
    }else{
        P("Sunny");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repd(i,a,b) for(ll i=a;i>=b;i--)
#define ford(i,n)  for(ll i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
// const ll mod=998244353;	
const ll mod = 1e9 + 7;
const ll inf = std::numeric_limits<ll>::max();
const ll infi = std::numeric_limits<int>::max();
const double pi = acos(-1.0);
ll gcd(ll a, ll b){if(b == 0) return a; return gcd(b%a, a);}
ll fastexp(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%mod; y=y>>1; x=(x*x)%mod;} return res; }
ll inv_mod(ll n){return fastexp(n,mod-2);}
bool isPrime(ll n){ll srt = sqrt(n);rep(i,3,srt)if(n%i == 0)return false;return true;}
char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

void solve() {
  int n;cin>>n;
  vi a(n), b(n), c(n);
  fori(i,n)cin>>a[i]>>b[i]>>c[i];
  vector<array<int,3>> maxh(n);
  maxh[0][0] = a[0],maxh[0][1] = b[0],maxh[0][2] = c[0];
  rep(i,1,n-1){
    maxh[i][0] = a[i] + max(maxh[i-1][1], maxh[i-1][2]);
    maxh[i][1] = b[i] + max(maxh[i-1][2], maxh[i-1][0]);
    maxh[i][2] = c[i] + max(maxh[i-1][0], maxh[i-1][1]);
  }
  cout<<max({maxh[n-1][0],maxh[n-1][1],maxh[n-1][2]});
}

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


Measured memory_bytes: 5576
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static boolean isInt(String str){
        for (int i = 0; i < str.length(); i++){
            if ( !(str.charAt(i)>= '0' && str.charAt(i) <='9')){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        String [] arr = in.next().split("-");
        if (arr.length == 2 && arr[0].length() == a && arr[1].length() == b){
            if (isInt(arr[0]) && isInt(arr[1]) ) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
string c[1000000];
int main(){
    int n,m,p,cnt=0,cnt2=0;
    string s;
    cin >>n>> m;
    for(int i=0;i<m;i++){
        cin >> p >> s;
        if(s=="WA"){
            if(a[p]!=1){
                b[p]++;
            }
        }else{
            c[p]="AC";
            a[p]=1;

        }
    }
    for(int i=1;i<=100000;i++){
        if(c[i]=="AC"){
                cnt2++;
                cnt+=b[i];
        }
    }

    cout << cnt2 << " " << cnt << endl;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair
signed main(){
  string s;
  cin>>s;
  int n=s.size(),k=n;
  for(int i=0;i<n-1;++i)if(s[i]!=s[i+1])k=min(k,max(i+1,n-i-1));
  cout<<k;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    map<int, int> ans;
    REP(i, n + 1)
        ans.insert(make_pair(i, 0));
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        ans[a]++;
        ans[b]++;
    }

    REP(i, n + 1) {
        if (i == 0) continue ;
        cout << ans[i] << '\n';
    }
    return 0;
}

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

#define MAXN 100000
int N,Root;
vector<int> G[MAXN+5];

int dfs(int u,int fa){//0黑 1百 -1必胜
	if(u!=Root&&G[u].size()==1)
		return 0;
	int cnt=0;
	for(int i=0;i<int(G[u].size());i++){
		int v=G[u][i];
		if(v!=fa){
			int tmp=dfs(v,u);
			if(tmp==-1)
				return -1;
			cnt+=tmp==0;
		}
	}
	if(cnt>=2)
		return -1;
	if(u==Root)
		return cnt!=1;
	return cnt==1;
}

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N-1;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=N;i++){
		if(G[i].size()==1){
			Root=i;
			break;
		}
	}
	puts(dfs(Root,-1)?"First":"Second");
    return 0;
}


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

using namespace std;

using ll = long long;

ll calc(ll n, ll tar) {
    ll res = 0;
    __int128_t hoge = tar;
    while (n >= hoge) {
        res += n / hoge;
        hoge *= tar;
    }
    return res;
}

ll solve2(ll n) {
    return (n % 2 == 0 ? calc(n / 2, 2) + n / 2 : 0);
}

ll solve5(ll n) {
    return (n % 2 == 0 ? calc(n / 2, 5) : calc(n, 5) - calc(n / 2, 5));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << min(solve2(n), solve5(n)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define LL long long
using namespace std;
int n,m;LL t;char s1[N+5],s2[N+5];map<LL,char> p;
I int gcd(CI x,CI y) {return y?gcd(y,x%y):x;}
int main()
{
	RI i;scanf("%d%d%s%s",&n,&m,s1+1,s2+1),t=1LL*n*m/gcd(n,m);
	for(i=1;i<=n;++i) p[(i-1)*(t/n)+1]=s1[i];
	for(i=1;i<=m;++i) if(p.count((i-1)*(t/m)+1)&&p[(i-1)*(t/m)+1]^s2[i]) return puts("-1"),0;
	return printf("%lld\n",t),0;
}

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int mn = a[0];
    int mxd = 0;
    int ans = 0;

    FOR(i,1,n) {
        if (mn > a[i]) {
            mn = a[i];
        }
        if (a[i] - mn > mxd) {
            ans = 1;
            mxd = a[i] -mn;
        } else if (a[i]- mn == mxd) {
            ans++;
        }
    }

    cout << ans << '\n';

    return 0;
}

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

int main(){
    int n, a[200000], b[200000];
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+n, greater<int>());
    
    for ( int i = 0; i < n; i++ ) {
        cout << (a[i] == b[0] ? b[1] : b[0] ) << endl;
    }
    
    return (0);
}

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

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 long long INF = 1LL << 60;


int main(void){
	cout.precision(17);
	double r;cin >> r;
	cout << 2*3.14159265358979323846*r << endl;
	return 0; 
}


Measured memory_bytes: 3748
function Main(input) {
  const data = input.split("");
  var ans = [];
  for (var i = 0; i < data.length; i++) {
    if (data[i] === "1") {
      ans.push("1");
    } else if (data[i] === "0") {
      ans.push("0");
    } else if (data[i] === "B") {
      if (ans.length > 0) {
        ans.pop();
      } else {
        continue;
      }
    }
  }
  console.log(ans.join(""));
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, t;
  cin >> n >> t;

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

  int mn = 1 << 30;
  vector<int> d;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    d.push_back(a[i] - mn);
  }
  sort(d.begin(), d.end());

  cout << upper_bound(d.begin(), d.end(), d.back()) - lower_bound(d.begin(), d.end(), d.back()) << endl;

  return 0;
}

Measured memory_bytes: 1276
#include<cstdio>
const int MaxN=5010;
int N,K,L[MaxN*2];
char S[MaxN*2],mc='z';
bool cmp(int i,int j){
	for(;S[i]==S[j];i++,j++);
	return S[i]<S[j];
}
int main(){
	scanf("%d%d%s",&N,&K,S);
	for(int i=0;i<N;i++)(S[N*2-i-1]=S[i])<mc?mc=S[i]:1;
	if(K>15)K=15;
	int ml=0;
	for(int i=0;i<N*2;i++){
		L[i+1]=S[i]==mc?L[i]+1:0;
		L[i+1]>ml?ml=L[i+1]:1;
	}
	int r=N-(ml<<K-1);
	if(r<0)r=0;
	int p=-1;
	for(int i=N;i<=N*2;i++)if(L[i]==ml&&(p<0||cmp(N*2-i+ml,p)))p=N*2-i+ml;
	for(int i=N-r;i--;)putchar(mc);
	for(int i=0;i<r;i++)putchar(S[p+i]);
	puts("");
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;


bool sub_comb_search(int value,vector<int> &vec,int depth){
  if(value==0) return true;
  if(depth>=vec.size()) return false;
  return sub_comb_search(value,vec,depth+1)||sub_comb_search(value-vec.at(depth),vec,depth+1);
}
bool comb_search(int value,vector<int> &vec){
  return sub_comb_search(value,vec,0);
}

int main(void){

  int size,searchsize;
  cin>>size;
  vector<int> vec(size);
  for(int i=0;i<size;i++) cin>>vec.at(i);
  cin>>searchsize;
  vector<int> search(searchsize);
  for(int i=0;i<searchsize;i++) cin>>search.at(i);
  for(int i=0;i<searchsize;i++){
    if(comb_search(search.at(i),vec)) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define enter "\n"

typedef long long ll;


int abc100_c(){
    //入力
    int n;
    cin >> n;
    vector<ll> a;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    ll ans=0;
    
    //処理
    REP(i,n){
        while(a[i]%2 == 0){
            ans++;
            a[i] /= 2;
        }
    }
    
    
    //出力
    cout << ans << enter;
    return 0;
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == '1'){
      S.at(i) = '9';
    }
    else if (S.at(i) == '9'){
      S.at(i) = '1';
    }
  }
  cout << S << endl;
}
    

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

#define SWAP(a,b) ((a != b)? (a += b,b = a - b,a -= b) : 0 ) //数値のみ
#define SWAPs(type,a,b) { type temp = a; a = b; b = temp; } //型指定する ポインタ, 構造体等
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  ll n, m, ans = 0, sum = 0;
  //map<string, int> m;
  //string s, t;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  rep(i, n - 1) {
    sum += a.at(i);
    sum %= MOD;
    ans += (a.at(i + 1) * sum % MOD);
    ans %= MOD;
  } 
  cout << ans << endl;
}


Measured memory_bytes: 4832
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){

 int n;
 cin>>n;

 cout<<n*n*n<<endl;


    

return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll A,B;
    cin >> A >> B;
    if((A+B)%2 != 0) cout << "IMPOSSIBLE" << endl;
    else cout << (A+B)/2 << endl;
}


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

int main(){
    char s[101],t[101];
    char temp;
    cin >> s >> t;
    int ls,lt;
    ls=strlen(s);
    lt=strlen(t);
    for(int i=0;i<ls-1;i++){
        for(int j=i+1;j<ls;j++){
            if(s[i]>s[j]){
                temp=s[i];
                s[i]=s[j];
                s[j]=temp;
            }
        }
    }
    for(int i=0;i<lt-1;i++){
        for(int j=i+1;j<lt;j++){
            if(t[i]<t[j]){
                temp=t[i];
                t[i]=t[j];
                t[j]=temp;
            }
        }
    }
    int min;
    if(ls>lt){
        min = lt;
    }
    else{
        min =ls;
    }

    for(int i=0;i<min;i++){
        if(s[i]==t[i]){
        }
        else if(s[i]<t[i]){
            cout << "Yes\n";
            return 0;
        }
        else{
            cout << "No\n";
            return 0;
        }
    }
    if(ls<lt){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

class Solve
{
    static void Main(string[] args) {
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int A = arr[0], B = arr[1];
        var S = Console.ReadLine();
        var split = S.Split('-');
        var answer = "No";
        if (split.Length == 2) {
            var a = split[0].Length == A && split[1].Length == B;
            var b = split[0].All(char.IsDigit) && split[1].All(char.IsDigit);
            if (a && b) answer = "Yes";
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27924
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    auto max_index = distance(A.begin(), max_element(A.begin(), A.end()));
    sort(A.begin(), A.end());
    int max = A.at(N-1);
    for(int i=0; i<N; i++) {
        if(i != max_index) {
            cout << max << endl;
        } else {
            cout << A.at(N-2) << endl;
        }
    }
    return 0;
}

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

using namespace std;

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

const int N = 200010;

int n,first,last;
string s;

int dp[N][2][2];

int calc(int idx , int prev,int cur){
	if(idx == n)
		return (cur == first);
	if(idx == n - 1 && cur != last)
		return 0;
	int &ret = dp[idx][prev][cur];
	if(ret != -1)
		return ret;
	ret = 0;
	// sheep
	if(cur == 0){
		if(s[idx] == 'o'){
			ret = ret || calc(idx + 1 , cur,prev);
		}else{
			ret = ret || calc(idx + 1 , cur,!prev);
		}
	}else{
		// wolf
		if(s[idx] == 'o'){
			ret = ret || calc(idx + 1 , cur,!prev);
		}else{
			ret = ret || calc(idx + 1 , cur,prev);
		}
	}
	return ret;
}

string ans = "";

void build(int idx , int prev , int cur){
	if(idx == n)
		return;
	ans += (cur == 0 ? "S" : "W");
	if(cur == 0){
		if(s[idx] == 'o'){
			build(idx + 1 , cur,prev);
		}else{
			build(idx + 1 , cur,!prev);
		}
	}else{
		// wolf
		if(s[idx] == 'o'){
			build(idx + 1 , cur,!prev);
		}else{
			build(idx + 1 , cur,prev);
		}
	}
}
int main(){
  // freopen("input.txt", "r", stdin);
    cin >> n;
    cin >> s;
    for(first = 0 ; first < 2 ; first++){
    	for(last = 0 ; last < 2 ; last++){
    		memset(dp,-1,sizeof dp);
    		if(calc(0,last,first)){
    			build(0,last,first);
    			cout << ans << endl;
    			return 0;
    		}
    	}
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 11648
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int main()
{
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)
        cout<<i<<' ';
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long a, long b) {
    if (a == b) return a;

    if (a % 2 == 0) {
        if (b % 2 == 0) {
            if ((b - a) / 2 % 2 == 0) return b;
            return b ^ 1;
        }

        if ((b - a + 1) / 2 % 2 == 0) return 0;
        return 1;
    }
    else {
        return a ^ calc(a + 1, b);
    }
}

void main() {
    auto ab = reads!long;
    long a = ab[0], b = ab[1];
    writeln(calc(a, b));
}


Measured memory_bytes: 256
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

!function () {
  function splitNum(line) {
    return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
      return parseInt(n);
    });
  }

  function makeArr(size, defaultValue) {
    if (!Array.isArray(size)) size = [size];
    if (1 === size.length) return new Array(size[0]).fill(defaultValue);

    var _size = size,
        _size2 = _toArray(_size),
        here = _size2[0],
        rest = _size2.slice(1);

    return new Array(here).fill(null).map(function () {
      return makeArr(rest, defaultValue);
    });
  }

  !function (input) {
    var lines = input.split("\n");

    var _splitNum = splitNum(lines[0]),
        _splitNum2 = _slicedToArray(_splitNum, 2),
        H = _splitNum2[0],
        W = _splitNum2[1];

    var S = lines.slice(1, H + 1);
    var ws = makeArr([H, W], 0);
    var hs = makeArr([H, W], 0);

    for (var h = 0; h < H; h++) {
      var cur = 0;

      for (var w = 0; w < W; w++) {
        if ("#" === S[h][w]) {
          ws[h][w] = -1;
          cur = 0;
        } else {
          cur++;
          ws[h][w] = cur;
        }
      }

      cur = -1;

      for (var _w = W - 1; _w >= 0; _w--) {
        if (-1 !== ws[h][_w]) {
          if (-1 === cur) cur = ws[h][_w];else ws[h][_w] = cur;
        } else cur = -1;
      }
    }

    for (var _w2 = 0; _w2 < W; _w2++) {
      var _cur = 0;

      for (var _h = 0; _h < H; _h++) {
        if ("#" === S[_h][_w2]) {
          hs[_h][_w2] = -1;
          _cur = 0;
        } else {
          _cur++;
          hs[_h][_w2] = _cur;
        }
      }

      _cur = -1;

      for (var _h2 = H - 1; _h2 >= 0; _h2--) {
        if (-1 !== hs[_h2][_w2]) {
          if (-1 === _cur) _cur = hs[_h2][_w2];else hs[_h2][_w2] = _cur;
        } else _cur = -1;
      }
    }

    var max = 0;

    for (var _h3 = 0; _h3 < H; _h3++) {
      for (var _w3 = 0; _w3 < W; _w3++) {
        var val = ws[_h3][_w3] + hs[_h3][_w3] - 1;
        if (val > max) max = val;
      }
    }

    console.log(max);
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();


Measured memory_bytes: 105900
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
int n;
ll a[100005],b[100005],f,g,h;
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]%2!=0&&a[i]%4!=0)
        {
            b[i]=1;f++;
        }
        else if(a[i]%2==0&&a[i]%4!=0)
        {
            b[i]=2;g++;
        }
        else {b[i]=4;h++;}
    }
    //cout<<f<<" "<<g<<" "<<h<<endl;
    if(h>=f||(g==0&&f==(h+1)))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}


Measured memory_bytes: 1792
def main():
    l = [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]
    K = int(input())
    print(l[K-1])
main()

Measured memory_bytes: 2940
let N = stdin.ReadLine()

stdin.ReadLine().Split(' ') |> Array.map int
|> Array.sortDescending
|> Array.indexed
|> Array.partition (fun (id,x) -> id%2=0)
|> fun (arrAlice, arrBob) -> (Array.sumBy snd arrAlice) - (Array.sumBy snd arrBob)
|> printfn "%d"

Measured memory_bytes: 14172