akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
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>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    ll sum = accumulate(ALL(A), 0LL) / 2LL;
    for (int i = 1; i < N; i += 2) {
        sum -= A[i];
    }
    vector<ll> ans(N);
    ans[0] = sum;
    for (int i = 0; i < N - 1; i++) {
        ans[i + 1] = A[i] - ans[i];
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] * 2LL;
        if (i != N - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
//Connected Component
#include <iostream>
#include <vector>

using namespace std;

static const int N = 100000;
int n, colors[N] = {};
vector<int> G[N];

void dfs_visit(int u, int c) {
    if(colors[u] == c) return;
    colors[u] = c;
    for(int i = 0; i < G[u].size(); i++) {
        dfs_visit(G[u][i], c);
    }
}

void dfs() {
    for(int i = 0; i < N; i++) colors[i] = -1;
    for(int i = 0; i < n; i++) {
        if(colors[i] == -1) {
            dfs_visit(i, i);
        }
    }
}

int main() {
    int m, s, t, q;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    dfs();
    
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> s >> t;
        if(colors[s] == colors[t]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



Measured memory_bytes: 12060
function Main(input) {
	input = input.split("\n");
	var n = input[1].split(" ").map(Number);
	var arr = [];
  	var m = [100000000000001]
	for(var i=0;i<n.length;i++){
		m[i+1] = m[i]+n[i];
	}
	for(i=0;i<m.length;i++){
		if(arr[m[i]]){
			arr[m[i]]++;
		}else{
			arr[m[i]] = 1;
		}
	}
	var sum = 0;
 /* console.log(arr)
  console.log(m)*/
	Object.keys(arr).forEach(function(key){
		sum += arr[key]*(arr[key]-1)/2;
	});
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

int a[105];

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		ans = ans + (d-1)/a[i] + 1;
	}
	cout << ans + x << endl;
	return 0;
}

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

using namespace std;

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

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

	if (accumulate(a.begin(), a.end(), 0) == 0) { cout << 1 << endl; return 0; }

	int counter = 0;
	int maxcount = 0;
	for (int i = 2; i <= n+1; i++) {
		if (a[i] == 1 && a[i - 1] == 1) { counter++; }
		else { counter = 0; }
		maxcount = max(counter, maxcount);
	}
	cout << maxcount + 2 << endl;

}


Measured memory_bytes: 3096
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    writefln("%.09f", ((N/2).to!double + (N%2 == 0 ? 0.0 : 1.0)) / N.to!double);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  	int N, M;
  	cin >> N >> M;
  
  	int *A = (int *)malloc(sizeof(int)*M);
    if (A == NULL) {
        printf("Memory cannot be allocated.");
    }
  
  	int MaxDay;
  	MaxDay = N;
	for(int i; i<M; i++){
    	cin >> A[i]; 
      	MaxDay -= A[i];
      
    }
  
  	if(MaxDay < 0){
      MaxDay=-1;
    }
    cout << MaxDay << endl;
    
}

Measured memory_bytes: 3652
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
c=collections.Counter(a)
counter=0
for i in range(a[0],a[n-1]+1):
    sum=c[i-1]+c[i]+c[i+1]
    if sum>counter:
        counter=sum

print(counter)


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

int n, ans[200];

bool Query(const std::vector<int> &A) {
	std::cout << "? ";
	for (int v : A) {
		std::cout << v + 1 << " ";
	}
	std::cout << std::endl;
	std::string res;
	std::cin >> res;
	return res == "Red" ? 1 : 0;
}

int getInterval(int l, int r, bool st) {
	if (l + 1 == r) {
		return r;
	}
	int md = (l + r + 1) >> 1;
	std::vector<int> id;
	for (int i = 0; i < n; ++i) {
		id.push_back(md + i);
	}
	if (Query(id) == st) {
		return getInterval(md, r, st);
	} else {
		return getInterval(l, md, st);
	}
}

int main() {
	std::cin >> n;
	std::vector<int> id;
	for (int i = 0; i < n; ++i) {
		id.push_back(i);
	}
	int st = Query(id);
	int p = getInterval(0, n, st);
	id.clear();
	for (int i = 0; i < n - 1; ++i) {
		id.push_back(p + i);
	}
	ans[p - 1] = st, ans[p + n - 1] = !st;
	std::vector<int> nid;
	for (int i = 0; i < 2 * n; ++i) {
		if (i < p - 1 || i >= p + n) {
			id.push_back(i);
			ans[i] = Query(id);
			id.pop_back();
			nid.push_back(i);
		}
	}
	for (int i = p; i < p + n - 1; ++i) {
		nid.push_back(i);
		ans[i] = Query(nid);
		nid.pop_back();
	}
	std::cout << "! ";
	for (int i = 0; i < 2 * n; ++i) {
		std::cout << (ans[i] ? 'R' : 'B');
	}
	std::cout << std::endl;
}

Measured memory_bytes: 3840
use std::io::stdin;

fn read_line() -> Vec<String> {
    let mut line = String::new();
    stdin().read_line(&mut line).expect("Failed to read line");
    return line.trim().split_whitespace().map(|s| s.to_string()).collect();
}

struct Reader {
    v: Vec<String>,
    n: usize,
}

impl Reader {
    fn new() -> Reader {
        let v = read_line();
        return Reader { v: v, n: 0 };
    }
    fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
        if self.n == self.v.len() {
            self.v = read_line();
            self.n = 0;
        }
        let x = self.v[self.n].parse().expect(&self.v[self.n]);
        self.n += 1;
        return x;
    }
    fn nexts<T>(&mut self, n: usize) -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            v.push(self.next());
        }
        return v;
    }
}

fn gcd(x: u64, y: u64) -> u64 {
    if y==0 {
        return x;
    } else {
        return gcd(y, x%y);
    }
}

fn main() {
    let mut r = Reader::new();
    let t: usize = r.next();
    for _ in 0..t {
        let a: u64 = r.next();
        let b: u64 = r.next();
        let c: u64 = r.next();
        let d: u64 = r.next();
        if a < b {
            println!("No");
            continue;
        }
        if d < b {
            println!("No");
            continue;
        }
        if c >= b {
            println!("Yes");
            continue;
        }

        let a = a % b;
        let d = d % b;
        
        let g = gcd(d, b);
        let k = (b - a - 1) / g;
        if a + k * g <= c {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

pair<vector<ll>, vector<ll>> prime_factor_decomp(ll n) {
    vector<ll> p, e;
    ll m = n;
    for (ll i = 2; i * i <= n; i++) {
        if (m % i != 0){
            continue;
        }
        int c = 0;
        while (m % i == 0){
            c++;
            m /= i;
        }
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return make_pair(p, e);
}

int main(){
    ll n;
    cin >> n;
    set<ll> prime_factor;
    map<ll, ll> count_prime_factor;
    for (ll i=1; i<=n; ++i){
        pair<vector<ll>, vector<ll>> p = prime_factor_decomp(i);
        for (int j=0; j<(int)p.first.size(); ++j){
            if(prime_factor.find(p.first[j]) == prime_factor.end()){
                prime_factor.insert(p.first[j]);
                count_prime_factor.insert(make_pair(p.first[j], p.second[j]));
            }
            else {
                ll tmp = count_prime_factor.at(p.first[j]);
                count_prime_factor.erase(p.first[j]);
                count_prime_factor.insert(make_pair(p.first[j], tmp + p.second[j]));
            }
        }
    }
    ll ans = 1;
    const ll div = 1000000000 + 7;
    for (auto itr = prime_factor.begin(); itr != prime_factor.end(); ++itr){
        ll num = count_prime_factor.at(*itr);
        ans *= (num + 1);
        ans = ans % div;
    }
    cout << ans << endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Edge{
  int to, cost;

  Edge(int t, int c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph =  vector< vector<Edge> >;

// ????????°???????????¨???
void add_edge(Graph& graph, int u, int v, int cost = 0){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}

/** calc diameter
 * O(E)
 * require: G is tree
 * return: farthest vertex (u, v), r <- diameter
 */
PII diameter(const Graph& G, int& r){
  function<PII(int,int)> diameter_ = [&](int prv, int now){
	PII res(0, now);
	for(auto& e: G[now]){
	  if(prv == e.to) continue;
	  PII tmp = diameter_(now, e.to);
	  tmp.first += e.cost;
	  if(res.first < tmp.first)
		res = tmp;
	}
	return res;
  };

  PII u = diameter_(-1, 0);
  PII v = diameter_(-1, u.second);
  r = v.first;
  return PII(u.second, v.second);
}

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

  int N;
  cin >> N;
  Graph G(N);
  REP(i,N-1){
	int s, t, w;
	cin >> s >> t >> w;
	add_edge(G, s, t, w);
  }
  int r;
  diameter(G, r);
  cout << r << endl;

  return 0;
}

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

int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	int ans=0;
	if(x==1&&y==1)ans+=400000;
	if(x==1)ans+=300000;
	if(x==2)ans+=200000;
	if(x==3)ans+=100000;
	if(y==1)ans+=300000;
	if(y==2)ans+=200000;
	if(y==3)ans+=100000;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
from itertools import accumulate 

n = int(input())
song= []
time = [0]

for i in range(n):
    s, t = input().split()
    song.append(s)
    time.append(int(t) + time[i])

#time_acc = list(accumulate(time))
x = input()
print(time[n] - time[song.index(x) + 1])

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

int main() {
	int in[3];
	rep (i, 3) cin >> in[i];
	sort(in, in + 3);
	int a = in[0], b = in[1], c = in[2];

	if (a % 2 && b % 2 && c % 2) {
		cout << (c - a) / 2 + (c - b) / 2 << endl;
	} else if (!(a % 2) && !(b % 2) && !(c % 2)) {
		cout << (c - a) / 2 + (c - b) / 2 << endl;
	} else if (!(a % 2) && !(b % 2) && (c % 2)) {
		cout << (c - 1 - a) / 2 + (c - 1 - b) / 2 + 1 << endl;
	} else if ((a % 2) && (b % 2) && !(c % 2)) {
		cout << (c - 1 - a) / 2 + (c - 1 - b) / 2 + 1 << endl;
	} else if (!(a % 2) && (b % 2) && !(c % 2)) {
		cout << (c - a) / 2 + (c - b) / 2 + 1 + 1 << endl;
	} else if ((a % 2) && !(b % 2) && (c % 2)) {
		cout << (c - a) / 2 + (c - b) / 2 + 1 + 1 << endl;
	} else if ((a % 2) && !(b % 2) && !(c % 2)) {
		cout << (c - a) / 2 + (c - b) / 2 + 1 + 1 << endl;
	} else if (!(a % 2) && (b % 2) && (c % 2)) {
		cout << (c - a) / 2 + (c - b) / 2 + 1 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
num = int(input())
stn = list(input())
num_W = stn.count('W')
num_R = stn.count('R')
cnt = 0

if num_W >= num_R:
    for i in range(num_R):
        if stn[i] == "W":
            cnt += 1

else:
    for i in range(num_W):
        if stn[-i-1] == "R":
            cnt += 1

print(cnt)

Measured memory_bytes: 10752
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
    d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=n=0);Z[n];a=H[P[n++]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 37988
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string s;
  cin>>s;
  int c = 0;
  for (char c1 : s) if (c1 == 'R') c++;
  if (c != 2) cout << c << '\n';
  else if (s[1] == 'S') cout << 1 << '\n';
  else cout << '2' << '\n';
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



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

	string ans = "Yes";
	rep(i, S.size()) {
		if (T[i] != S[i]) { ans = "No"; }
	}
	cout << ans << endl;

	system("PAUSE");

}

Measured memory_bytes: 3692
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

string S, T;

//0 ぴったし,1 そうじゃない
LL dp[234567][10][2], ep[234567][10][2];

const LL MOD = 1000000007;

int main() {
	cin >> S >> T;
	int N = S.size();
	dp[0][0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 10; ++j) {
			for (int k = 0; k < 2; ++k) {
				bool no[10] = {};
				if (T[i] != '?') {
					for (int jj = 0; jj < 10; ++jj) {
						if (T[i] - '0' != jj)no[jj] = true;
					}
				}
				if (k == 0) {
					for (int jj = 0; jj < 10; ++jj) {
						if (S[i] - '0' < jj) {
							no[jj] = true;
						}
					}
				}
				for (int jj = 0; jj < 10; ++jj) {
					if (no[jj])continue;
					auto &dxt = dp[i + 1][jj][k | (S[i] - '0' != jj)];
					dxt += dp[i][j][k];
					dxt %= MOD;
					auto& ext = ep[i + 1][jj][k | (S[i] - '0' != jj)];
					ext += ((ep[i][j][k] * 10) % MOD + (jj * dp[i][j][k]) % MOD) % MOD;
					ext %= MOD;
				}
			}
		}
	}
	LL ans = 0;
	LL deb = 0;
	for (int j = 0; j < 10; ++j) {
		for (int k = 0; k < 2; ++k) {
			deb += dp[N][j][k];
			ans += ep[N][j][k];
			ans %= MOD;
		}
	}
	cout << ans << endl;
	//cout << deb << endl;
	return 0;
}


Measured memory_bytes: 66000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <set>
#include <memory.h>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    if(a <= 8 && b <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" <<endl;
    }
}


Measured memory_bytes: 256
a, b = list(map(int, input().split()))
result = 0

for i in range(a, b+1):
  ok = True
  c = str(i)
  for j in range(int(len(c) / 2)):
    if c[j] != c[-j-1]:                                                                                                    
      ok = False
      break
  if ok:
    result += 1

print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define int LL

const int N = 3e3 + 5;
const int mod = 998244353;

int n, s, a[N];
LL ans, f1[N][N], f2[N][N];

signed main() {
	scanf("%lld %lld", &n, &s);
	for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= s; ++j) {
			f2[i][j] = f2[i - 1][j];
			if (j >= a[i]) {
				int t = j - a[i];
				f1[i][j] = f2[i - 1][t];
				if (!t) (f1[i][j] += i) %= mod;
			}
			(f2[i][j] += f1[i][j]) %= mod;
		}
		(ans += f1[i][s] * (n - i + 1)) %= mod;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 141184
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()
    A = sorted(A)

    a = A[-1]
    mid = a / 2
    diff = INF
    b = -1
    for j in A[:-1]:
        d = abs(j - mid)
        if d < diff:
            b = j
            diff = d
    print(a, b)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 20116
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int a, b;
    bool input() {
        if (stdin.eof) return false;
        scanf("%d %d\n", &a, &b);
        return true;
    }
    void solve() {
        writeln((a + b).to!string.length);
    }
    while (input) solve;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans = 0;
  int W, a, b;
  cin >> W >> a >> b;

  if (a + W < b) {
    ans = b - (a + W);
  } else if (b + W < a) {
    ans = a - (b + W);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    s += '0';
    int n = s.size();
    auto dp = make_v(n+1, 2, INF<int>);
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 2; ++j) {
            int x = s[i]-'0'+j;
            int k = 0;
            if(x >= 10) k++, x -= 10;
            chmin(dp[i+1][k], dp[i][j]+x);
            chmin(dp[i+1][1], dp[i][j]+10-x);
        }
    }
    cout << dp.back()[0] << "\n";
    return 0;
}

Measured memory_bytes: 55940
#include <stdio.h>


int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    int h[n];
    for (int i=0; i < n; i++){
        scanf("%d", &h[i]);
    }
    
    int cnt = 0;
    for (int i=0; i < n; i++){
        if (k <= h[i])
            cnt++;
    }


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



    return 0;
} 


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, T, t[200001];

int main() {
	cin >> n >> T;
	inc(i, n) { cin >> t[i]; }
	
	t[n] = 1000000000000LL;
	
	LL ans = 0;
	inc(i, n) {
		ans += min(t[i + 1] - t[i], T);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
n=int(input())
arr=list(map(int,input().split()))
acum=[0]*(n+1)
cnt=0
for i in range(1,n+1):
  acum[i]=acum[i-1]+arr[i-1]
acum=sorted(acum)
acum.append(10**10)
tmp=1
for i in range(1,len(acum)):
  if  acum[i]==acum[i-1]:
    tmp+=1
  else:
    cnt+=tmp*(tmp-1)//2
    tmp=1
print(cnt)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k, q; cin >> n >> k >> q;
	vector<int> a(n);
	for(auto &i:a) cin >> i;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
	for(int i=0; i<n; ++i) pq.push(make_pair(a[i], i));
	vector<int> b(n);
	int ans = n == 1 ? 0 : 1e9;
	for(int i=0; i<n-q; ++i){
		priority_queue<int, vector<int>, greater<>> p;
		for(int j=0; j<n; ++j){
			priority_queue<int, vector<int>, greater<>> r;
			for(int l=0; l<k-1; ++l) r.push(a[j+l]);
			for(int l=j; l<n; ++l){
				if(b[l] == 1){
					j = l;
					break;
				}
				if(l-j+1 >= k) r.push(a[l]);
				if(l == n-1) j = n-1;
			}
			int m = max(0, (int)r.size()-k+1);
			for(int l=0; l<m; ++l){
				p.push(r.top());
				r.pop();
			}
		}
		if(p.size() < q) break;
		int mi = p.top();
		for(int j=0; j<q-1; ++j) p.pop();
		int ma = p.top();
		ans = min(ans, ma - mi);
		pair<int, int> x = pq.top(); pq.pop();
		b[x.second] = 1;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N*A, B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug(x) cout << #x << " = " << x << endl
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define reset(x) memset(x,0,sizeof(x))
#define up(i,l,r) for(int i=l;i<=r;i++)
#define down(i,r,l) for(int i=r;i>=l;i--)
using namespace std;
typedef long long int ll;
int n,a,Ti;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>a;
	Ti=n*n-a;
	cout<<Ti<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    int a;
    cin >> a;
    cout << a*a*a + a*a + a << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb push_back
#define trav(a, x) for (auto &a : x)
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define pii pair<int, int>

using namespace std;

const int mod = 1e9 + 7;
const int N = 1e6 + 5;

void solve() {

    int k; cin >> k;
    string str = "ACL";
    string ans = "";
    rep(i, 0, k) {
      ans += str;
    }
    cout << ans << endl;
}

int main() {

    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
int main ()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a+b==c||a+c==b||b+c==a)
	{
		printf ("Yes\n");
	}
	else
		printf ("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;
	
	string str[n];
	for(int i = 0; i < n; i++){
		cin >> str[i];
	}
	sort(str, str + n);
	for(auto item : str){
		cout << item;
	}
	cout << endl;
	return 0;
}


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

using namespace std;

int a, b, k;
int ans[105];
int cou;

int main()
{
    scanf("%d%d%d",&a,&b,&k);
    for(int i = 1,j = 1;i <= min(a,b);i++)
    {
        if(a%i==0 && b%i==0)
        {
            ans[j] = i;
            cou = j;
            j++;
        }
    }
    printf("%d\n",ans[cou - k + 1]);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k = I()
a = k // 2
b = (k-1) // 2 + 1
ans = a*b
print(ans)



Measured memory_bytes: 38256
import sys
import math
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
mod = 10 ** 9 + 7


A.sort()

# check
check = 0
if N % 2 == 1:
    for i in range(1,N + 1):
        if A[i-1] != math.floor(i/2) * 2:
            check = 1
            break
if N %2 == 0:
    for i in range(N):
        if A[i] != math.floor(i/2) * 2 + 1:
            check = 1
            break

if check == 1:
    ans = 0
    print(ans)
    sys.exit()

if N % 2 == 1:
    jou = (N-1)/2
else:
    jou = N/2

ans = 1
for i in range(int(jou)):
    ans = (ans * 2) % mod

print(ans)

Measured memory_bytes: 13876
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  int N,M,ans;
  string S;
  cin >> S;
  
  ans=S.size();
 
  cout << S[0] << ans-2 << S[S.size()-1] << endl;
 
 
 
  return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
double ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll l,r;
 rep(i,0,n){
  sc(l);sc(r);
  ans+=r-l+1;
 }
 pr(ans);
return 0;}

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

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll aq = a/x;
    ll bq = b/x;
    if(a % x == 0)bq++;
    cout << bq - aq << endl;
}


Measured memory_bytes: 384
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  double W, H, x, y; cin >> W >> H >> x >> y;
  coutdb << W*H / 2.0 << ' ';
  if(x == W/2 and y == H/2) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

struct card{
  int num;
  char mark;
};

struct card card_i[40], card_j[40];

void BubbleSort(int n);
void SelectionSort(int n);
void write(int n);
void stable(int n);

int main(void){
  int n, i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    while(1){
      scanf("%c", &card_i[i].mark);
      if((card_i[i].mark == ' ') || (card_i[i].mark == '\n')) continue;
      scanf("%d", &card_i[i].num);
      card_j[i] = card_i[i];
      break;
    }
  }
  BubbleSort(n);
  stable(n);
  SelectionSort(n);
  stable(n);

  return 0;
}

void BubbleSort(int n){
  int i, j;
  struct card k;
  for(i = 0; i < n-1; i++){
    for(j = n-1; j > i; j--){
      if(card_j[j].num < card_j[j-1].num){
	k = card_j[j];
	card_j[j] = card_j[j-1];
	card_j[j-1] = k;
      }
    }
  }
  write(n);
  return;
}

void SelectionSort(int n){
  int i, j, minj;
  struct card k;

  for(i = 0; i < n-1; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(card_j[j].num < card_j[minj].num) minj = j;
    }
    k = card_j[minj];
    card_j[minj] = card_j[i];
    card_j[i] = k;
  }
  write(n);
  return;
}

void write(int n){
  int i, j;
  for(i = 0; i < n; i++){
    printf("%c%d", card_j[i].mark, card_j[i].num);
    if(i+1 != n) printf(" ");
  }
  printf("\n");
  return;
}

void stable(int n){
  int i, j, k[4], kk[4], co1 = 0, co2 = 0, co = 0, l;
  for(i = 1; i < 10; i++){
      for(j = 0; j < n; j++){
	if(card_j[j].num == i){
	  k[co1] = card_j[j].mark;
	  co1++;
	  co++;
	}
      }
      for(j = 0; j < n; j++){
	if(card_i[j].num == i){
	  kk[co2] = card_i[j].mark;
	  co2++;
	}
      }
      for(j = 0; j < co; j++){
	if(co == 0) break;
	if(k[j] != kk[j]){
	  for(l = 0; l < n; l++){
	    card_j[l] = card_i[l];
	  }
	  printf("Not stable\n");
	  return;
	}
      }
      co1 = 0;
      co2 = 0;
      co = 0;
  }
  for(l = 0; l < n; l++){
    card_j[l] = card_i[l];
  }
  printf("Stable\n");
  return;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,x,ans=0;
  long long a[100009];
  cin>>n>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]>x){
      long long temp=a[i]+a[i+1]-x;
      ans+=temp;
      a[i+1]-=temp;
      if(a[i+1]<0)a[i+1]=0;
    }
  }
  cout<<ans<<endl;
  return(0);
}
  


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

int main()
{
	int i,j ;
	while( cin >> i >> j )
	{
		i += j ;
		int count = 0 ;

		while( i > 0 )
		{
			i = i / 10 ;
			count ++ ;
		}

		cout << count << endl ;
	}

	return 0 ;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define inf 1e12+7
typedef long long ll;

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

    for(int i = 0; i < s.size(); i++){
        if(s[i]+n > 'A'+25){
            s[i] = 'A' + n - ('Z' - s[i]) - 1;
        }
        else{
            s[i] += n;
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
    string s;
    int k;
    cin >> k >> s;
    int size = s.length();

    if(size <= k){
        cout << s << endl;
    }else{
        string ss = s.substr(0, k);
        cout << ss << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
from collections import defaultdict
h, w, m = map(int, input().split())

row = [[0, 0] for _ in range(h + 1)]
col = [[0, 0] for _ in range(w + 1)]
ex = defaultdict(bool)
for i in range(m):
    r, c = map(int, input().split())
    row[r][0] += 1
    col[c][0] += 1
    row[r][1] = r
    col[c][1] = c
    ex[(r, c)] = True
row = sorted(row)[::-1]
col = sorted(col)[::-1]
ans = 0
for i in range(0, h + 1):
    for j in range(0, w + 1):
        ans = max(ans, row[i][0] + col[j][0] - ex[(row[i][1], col[j][1])])
        if not ex[(row[i][1], col[j][1])]:
            # iが同一だったら、jの値降順に見てるので木って良い
            break

print(ans)


Measured memory_bytes: 217632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
int n;
vector<int>edge[1000005];
int dfs(int v,int u){
	vector<int>vec; int X = 0;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		int Y = dfs(edge[v][i],v);
		vec.pb(Y); X^=(Y+1); 
	}
	return X;
}
int main(){
	cin >> n ;
	for(int i=1;i<n;i++){
		int a,b; cin >> a >> b;
		edge[a].pb(b); edge[b].pb(a);
	}
	if(dfs(1,-1)) puts("Alice"); else puts("Bob");
}

Measured memory_bytes: 37760
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n, m;
	cin >> n >> m;
	string a[n];
	string b[m];

	REP(i, n) cin >> a[i];
	REP(i, m) cin >> b[i];

	for (int i = 0; i < n - m + 1; i++){
		for (int j = 0; j < n - m + 1; j++){
			bool match = true;
			for (int y = 0; y < m; y++){
				if (b[y] != a[i + y].substr(j, m)) match = false;
			}
			if (match){
				cout << "Yes" << endl;
				return 0;
			}

		}
	}

	cout << "No" << endl;


}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	ll cnt=0,ans=0;
	rep(i,n-1){
		if(a[i]>=a[i+1]) cnt++;
		else{
			chmax(ans,cnt);
			cnt=0;
		}
	}
	chmax(ans,cnt);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n; cin >> n;
    set<ll> st;
    n--;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            st.insert(i);
            st.insert(n/i);
        }
    }
    n++;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            st.insert(i);
            st.insert(n/i);
        }
    }
    int ans=0;
    for(auto u:st){
        if(u==1) continue;
        ll res=n;
        while(res%u==0){
            res/=u;
        }
        ll a=res/u;
        res-=a*u;
        if(res==1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512