akhauriyash/Code-Regression huggingface dataset:
N = gets.chomp.to_i
b = gets.chomp.split.map(&:to_i)

ans = []

N.times do |i|
  tmp = 1000
  b.length.times do |j|
    if b[j] == j + 1
      tmp = j + 1
    end
  end

  if tmp == 1000
    puts -1
    exit
  end

  b.delete_at(tmp-1)
  ans << tmp
end

ans.reverse.each do |num|
  p num
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    string T;
    cin >> S >> T;
    if(S.size() < T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string>ans;
    bool flag = false;
    for(int i = 0; i <= S.size()-T.size(); i++) {
        bool ok = true;
        int X = i;
        for(int j = 0; j < T.size(); j++) {
            if(S[X+j] != '?' && T[j] != S[X+j]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            flag = true;
            string cnt = "";
            for(int k = 0; k < S.size(); k++) {
                if(k == X) {
                    cnt+=T;
                    k+=T.size()-1;
                }
                else {
                    if(S[k] == '?') {
                        cnt+='a';
                    }
                    else {
                        cnt+=S[k];
                    }
                }
            }
            ans.push_back(cnt);
        }
    }
    if(flag) {
        sort(ans.begin(),ans.end());
        cout << ans[0] << endl;
    }
    else {
        cout << "UNRESTORABLE" << endl;
    }
}

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

int findSum(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    int min=1000000;
    for (int i=1; i<N; i++){
        int A = i;
        int B = N - A;
        int S = findSum(A) + findSum(B);
        if (min > S){
            min = S;
        }
    }
    cout << min << endl;
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  if (N[0] != '7' && N[1] != '7' && N[2] != '7'){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3628
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if((B-A)%2==0){
        cout << (B-A)/2 << el;return;
    }
    ll to0 = A;
    ll Bp = B - to0;
    ll mn1 = to0 + Bp/2;

    ll toN = N - B + 1;
    ll Ap = A + toN;
    ll mn2 = toN + (N-Ap)/2;
    cout << min(mn1, mn2) << el;
}



Measured memory_bytes: 256
PROGRAM Marks
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: n,k, i
      integer(p),allocatable :: a(:),score(:)
      
      read*,n,k
      allocate( a(n),score(n) )
      read*,a
      
      do i = k+1,n
        if( a(i-k)<a(i) )then
          print*,'Yes'
        else
          print*,'No'
        end if
      end do
      
      
 !     score = 0
 !     score(k) = 1
 !     do i = 1,k
 !       score(k) = score(k)*a(i)
 !     end do
 !     do i = k+1,n
 !       score(i) = score(i-1)/a(i-k)*a(i)
 !     end do
      
 !     do i = k+1,n
 !       if( score(i)>score(i-1) )then
 !         print*,'Yes'
 !       else
 !         print*,'No'
 !       end if
 !     end do
      
      
      stop
      !debugg
      
      do i = k,n
        print*,score(i)
      end do
      
      END PROGRAM

Measured memory_bytes: 6108
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,h[1001000],tag[1001000],d[1001000];
char s[1001000],c[1001000];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>c+1>>s+1;
	int k=n,flag=1;
	for(int i=1;i<=n;i++) flag&=c[i]==s[i];
	if(flag){cout<<0<<'\n';return 0;}
	for(int i=n;i;i--){
		if(k>i) k=i;
		while(k>0&&c[k]!=s[i]) k--;
		if(!k){cout<<-1<<'\n';return 0;}
		tag[k]=1;h[i]=k;
	}
	int now=0,ans=0;k=0;
	for(int i=n;i;i--){
		now+=d[i+k];
		if(i==n||h[i]!=h[i+1]){
			now++;k++;
			d[i+k-1]=0;
			d[h[i]-1+k]--;
		}
		ans=max(ans,now);
	}
	cout<<ans<<'\n';
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

constexpr int INF = 1 << 30;

struct Edge {
    int from;	//出発点
    int to;		//到達点
    int cost;	//移動コスト
};

vector<int> to[2505];
vector<int> reverse_to[2505];
bool ok[2505];
bool reachableFrom1[2505];
bool reachableFromN[2505];

void dfs(int v)
{
	if (reachableFrom1[v])
	{
		return;
	}
	reachableFrom1[v] = true;

	for(const auto& u : to[v])
	{
		dfs(u);
	}
}

void dfs_reverse(int v)
{
	if (reachableFromN[v])
	{
		return;
	}
	reachableFromN[v] = true;

	for(const auto& u : reverse_to[v])
	{
		dfs_reverse(u);
	}
}


void solve()
{
	fill(ok, ok + 2505, false);
	fill(reachableFrom1, reachableFrom1 + 2505, false);
	fill(reachableFromN, reachableFromN + 2505, false);

	int n, m, p;
	cin >> n >> m >> p;

	vector<Edge> edges;
	vector<int> dist(n, INF);
	dist[0] = 0;

	for(int i = 0; i < m; ++i)
	{
		Edge edge;
		cin >> edge.from >> edge.to >> edge.cost;
		edge.from--;
		edge.to--;
		edge.cost -= p;
		edge.cost *= -1; // コストを反転させて最短経路問題を解けば、最長経路になる

		edges.emplace_back(edge);

		to[edge.from].emplace_back(edge.to);
		reverse_to[edge.to].emplace_back(edge.from);
	}

	dfs(0);
	dfs_reverse(n - 1);
	for(int i = 0; i < n; ++i)
	{
		ok[i] = reachableFrom1[i] & reachableFromN[i];
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			Edge e = edges[j];
			if(!ok[e.to]) continue;
			if(!ok[e.from]) continue;

			if (dist[e.to] > dist[e.from] + e.cost)
			{
				dist[e.to] = dist[e.from] + e.cost;
				if (i == n - 1)
				{
					cout << -1;
					return;
				}
			}
		}
	}
	cout << max(dist[n - 1] * -1, 0);
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

using namespace std;

using ll = long long;

const int N = 2e5 + 5;

int arr[N], dp[N];

int main(){
	int n;	cin >> n;
	for(int i = 0; i < n; i++)	cin >> arr[i];
	for(int i = 1; i < n; i++)
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[max(0, i - 2)] + abs(arr[i] - arr[max(0, i - 2)]));
	cout << dp[n - 1] << "\n";
		
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 3e3+5;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn],d[maxn],c[maxn],ans;
int32_t main()
{
    IOS;
    cin>>n>>m;
    if(n<m)cout<<0;
    else cout<<10;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,k,s,d=1e9;
    cin >> n >> k >> s;
    if(s==int(1e9)) d = 1;
    for(int i=0;i<k;i++){
        cout << s << ' ';
    }
    for(int i=k;i<n;i++){
        cout << d << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3672
use std::io;


fn main() {
    let n = read_one::<usize>();
    let mut an = Vec::new();
    for _ in 0..n {
        an.push(read_one::<usize>());
    }

    if an.iter().all(|a| a % 2 == 0) {
        println!("second");
    } else {
        println!("first");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    prev_a = A[0]
    max_a = A[0]
    for a in A[1:]:
        if a + 1 < prev_a or a + 1 < max_a:
            print("No")
            break
        elif prev_a == a:
            prev_a = a
            max_a = max(max_a, a)
        else:
            prev_a = a - 1
            max_a = max(max_a, a)
    else:
        print("Yes")
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    string s[N];
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }
    string prev;
    string current;
    map<string, int> mp;
    prev = s[0];
    mp[prev] = 1;
    for(int i = 1; i < N; i++){
        current = s[i];
        auto itr = mp.find(current);
        // different word
        if(prev[prev.length()-1] != current[0]){
            cout << "No" << endl;
            return 0;
        }
        // find
        if(itr != mp.end()){
            cout << "No" << endl;
            return 0;
        }
        mp[current] = 1;
        prev = current;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define N 100010
int par[N], Rank[N], SIZE[N];

void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        Rank[i] = 0;
        SIZE[i] = 1;
    }
}
int find(int x)
{
    if (par[x] == x)
        return x;
    else
        return par[x] = find(par[x]);
}
void unit(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        SIZE[y] += SIZE[x];
    }
    else
    {
        par[y] = x;
        SIZE[x] += SIZE[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}
bool same(int x, int y)
{
    return find(x) == find(y);
}

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    rep(i, m) a[i]--, b[i]--;
    reverse(all(a));
    reverse(all(b));
    init(n);
    vector<int> ans(m);
    int num = n * (n - 1) / 2;
    rep(i, m)
    {
        ans.push_back(num);
        int x = SIZE[find(a[i])], y = SIZE[find(b[i])];
        if (!same(a[i], b[i]))
        {
            num -= x * y;
            unit(a[i], b[i]);
        }
    }
    reverse(all(ans));
    rep(i, m) cout << ans[i] << endl;
}

Measured memory_bytes: 6768
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 
#define MO 
int mi,n,ss,a[10999];
inline void _Sol_()
{
	read(n);F(i,1,n)read(a[i]); 
	sort(a+1,a+n+1); mi=INF;
	F(k,1,100){
		ss=0;
		F(i,1,n)ss+=(a[i]-k)*(a[i]-k);
		chmin(mi,ss);
	}
	priE(mi);
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

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

int main() {
	int e, m, a, x;
	double c, d;
	while (true) {
		cin >> e;
		if (e == 0) break;
		m = 90000000;

		c = pow(e, 1.0 / 3.0);
		d = sqrt(e);
		for (int z = 0; z <= c + 10; z++) {
			for (int y = 0; y <= d; y++) {	
				x = e - y*y - z*z*z;
				if (x < 0) break;
				else {
					a = x + y + z;
					if (a < m) m = a;
				}
			}
		}

		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
N = int(input())
A = sorted(list(map(int,input().split())))
ans = 1
flag = 0
if(A[0] == 0):
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if ans >10**18:
            flag = 1
            break
    if(flag == 0):
        print(ans)
    else:
        print(-1)


Measured memory_bytes: 89532
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	bool ok = false;
	rep(i,n){
		cin >> a[i];
		if(a[i]%2 == 1) ok = true;
	}
	cout << (ok ? "first" : "second") << endl;
	return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll a,b,c;
	cin >> a >> b >> c;
	if(a==b && b==c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

int n;
double p[3005], dp[3005][3005];
bitset<3005> visited[3005];

double solve(int id, int head) {
	if (id == n) {
		if (head > n / 2) return 1;
		else return 0;
	}
	if (visited[id][head]) return dp[id][head];

	visited[id][head] = 1;
	return dp[id][head] = solve(id + 1, head + 1) * p[id] + solve(id + 1, head) * (1.0 - p[id]);
}

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

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

	double ans = solve(0, 0);
	cout << setprecision(10) << fixed << ans << '\n';

	return 0;
}

Measured memory_bytes: 71296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e6+5;
double a[9],b[9];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lf%lf",&a[i],&b[i]);
    }
    double t,s;
    if(n==2)t=2,s=2;
    else if(n==3)t=4,s=6;
    else if(n==4)t=12,s=24;
    else if(n==5)t=48,s=120;
    else if(n==6)t=240,s=720;
    else if(n==7)t=1440,s=5040;
    else if(n==8)t=10080,s=40320;
    double ans=0;
    for(int i=0; i<n-1; i++)
    {
        for(int j=i+1; j<n; j++)
            ans+=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
    }
    printf("%.10lf",ans*t/s);
    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const int MAXV = 100001;
const ll INF = numeric_limits<long long>::max();
struct edge { ll to, cost; };
int V, m, s, t;

void dijkstra(int s, vector<vector<edge>>& G, vector<ll>& d) {
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
    d[s] = 0;
    que.push(make_pair(0, s));

    while (!que.empty()) {
        pair<ll, ll> p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

ll ans[MAXV];

int main() {
    cin >> V >> m >> s >> t;
    s--;
    t--;
    vector<vector<edge>> g1(MAXV), g2(MAXV);
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        g1[u].push_back(edge{v, a});
        g1[v].push_back(edge{u, a});
        g2[u].push_back(edge{v, b});
        g2[v].push_back(edge{u, b});
    }
    vector<ll> d1(MAXV, INF);
    vector<ll> d2(MAXV, INF);
    dijkstra(s, g1, d1);
    dijkstra(t, g2, d2);

    rep(i, V) {
        if (i == s) {
            ans[i] = d2[i];
        }
        else if (i == t) {
            ans[i] = d1[i];
        }
        else {
            ans[i] = d1[i] + d2[i];
        }
    }

    ll mi = ans[V-1];
    for (int i=V-1; i>=0; --i) {
        mi = min(mi, ans[i]);
        ans[i] = min(ans[i], mi);
    }

    ll tmp = 1e15;

    rep(i, V) {
        cout << tmp-ans[i] << endl;
    }
}


Measured memory_bytes: 19844
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t;
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC"<<endl;
	else 
	cout<<"ABC"<<endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define Flash ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define rev(v) reverse(all(v))
#define sot(v) sort(all(v))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,end,c) for(int i=0;i<end;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define mem(a,x) memset(a,x,sizeof(a))

const int N = (int) 1e5 + 7;
const int MOD = (int) 1e9 + 7;
const ll INF = (ll) 1e18;

using namespace std;
using cd = complex<double>;
const double PI = acos(-1);

void fft(vector<cd> & a, bool invert) {
    int n = a.size();
    for (int i = 1, j = 0; i < n; i++) {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1)
            j ^= bit;
        j ^= bit;
        if (i < j)
            swap(a[i], a[j]);
    }
    for (int len = 2; len <= n; len <<= 1) {
        double ang = 2 * PI / len * (invert ? -1 : 1);
        cd wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) {
            cd w(1);
            for (int j = 0; j < len / 2; j++) {
                cd u = a[i+j], v = a[i+j+len/2] * w;
                a[i+j] = u + v;
                a[i+j+len/2] = u - v;
                w *= wlen;
            }
        }
    }
    if (invert) {
        for (cd & x : a)
            x /= n;
    }
}

vector<ll> multiply(vector<ll> const& a, vector<ll> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);
    vector<ll> result(n);
    for (int i = 0; i < n; i++)
        result[i] = round(fa[i].real());
    return result;
}

int main() {
    Flash;
    ll n, m, x, maxi = -1;
    cin >> n >> m;
    map <int,int> M;
    for(int i = 0; i < n; i++) {
        cin >> x;
        M[x]++;
        maxi = max(x, maxi);
    }
    vector <ll> A(maxi+1);
    for(auto g: M) A[g.ff] = g.ss;
    vector <ll> B = multiply(A, A);
    ll res = 0;
    for(int i = B.size()-1; i >= 0 && m > 0; i--) {
        res += min(B[i], m) * i;
        m -= min(B[i], m);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 15944
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
//1秒間で処理できる for 文ループの回数は、10^8=100,000,000回程度
int main(){
    //A
    /*
    int N;
    cin>>N;
    if(N/100==7||N/10%10==7||N%10==7){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    */
   //B
   int n;cin>>n;
   ll c=0;
   rep(i,1,n+1) {
       if(i%3!=0&&i%5!=0) c+=i;
   }
   cout<<c<<endl;
   
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    string ans;
    while(1){
        c -= b;
        if(c <= 0){
            ans = "Yes";
            break;
        }
        a -= d;
        if(a <= 0){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

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

  int FUCK = 0;
  int tmp;

  for (int i=1; i<=1000; i++) {
    for (int j=2; j<=1000; j++) {
      tmp = pow(i, j);
      if (FUCK < tmp && tmp <= a) FUCK = tmp;
      else if (tmp > a) break;
    }
  }

  cout << FUCK << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second


int main()
{
    int n,r;
    std::cin >> n >> r;
    if(n >= 10){
        std::cout << r << std::endl;
    }else{
        std::cout << r + (100 * (10 - n)) << std::endl;
    }

}


Measured memory_bytes: 764
import numpy as np
N, train_max = map(int, input().split())
members = np.sort(list(map(int, input().split())))
members_sum = members.sum()
foods = np.sort(list(map(int, input().split())))[::-1]

inferenced_time_max = int(1e+6 * 1e+6)
inferenced_time_min = -1

while inferenced_time_max > inferenced_time_min+1:
  inferenced_time = (inferenced_time_max + inferenced_time_min) // 2
  inferenced_members = np.minimum(members, inferenced_time // foods)
  if members_sum - inferenced_members.sum() <= train_max:
    inferenced_time_max = inferenced_time
  else:
    inferenced_time_min = inferenced_time

print(inferenced_time_max)

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

#define int long long

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const char dc[4] = {'E', 'S', 'W', 'N'};

signed main() {
  int H, W, L;
  while ( cin >> H >> W >> L, H ) {
    char grid[H][W];
    int used[H][W][4];
    fill_n(**used, H*W*4, -1);    
    int y, x, d;    
    for ( int i = 0; i < H; i++ ) {
      for ( int j = 0; j < W; j++ ) {
	cin >> grid[i][j];
	if ( grid[i][j] != '#' && grid[i][j] != '.' ) {
	  y = i; x = j;
	  if ( grid[i][j] == 'E' ) d = 0;
	  if ( grid[i][j] == 'S' ) d = 1;
	  if ( grid[i][j] == 'W' ) d = 2;
	  if ( grid[i][j] == 'N' ) d = 3;
	}
      }
    }

    int cnt = 0;
    bool flag = false;
    while ( 1 ) {
      if ( used[y][x][d] >= 0 && !flag ) {
	if ( L-cnt-used[y][x][d]-10 > 0 ) {
	  cnt += (L-cnt-used[y][x][d]-1)/(cnt-used[y][x][d])*(cnt-used[y][x][d]);
	}
	flag = true;
      }
      if ( cnt >= L ) break;
      if ( cnt ) used[y][x][d] = cnt;      
      int nx = x+dx[d], ny = y+dy[d];
      if ( nx < 0 || ny < 0 || nx >= W || ny >= H || grid[ny][nx] == '#' ) {
	d = (d+1)%4LL;	
      } else {
	cnt++;
	x = nx;
	y = ny;
	if ( cnt >= L ) break;
      }
    }

    cout << y+1 << " " << x+1 << " " << dc[d] << endl;
  }

  return 0;
}


Measured memory_bytes: 3408
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 405;
const ll inf = 1e18;
int a[maxn];
ll b[maxn], dp[maxn][maxn];

int main() {
    int n;
    cin >> n;
    REP(i, n) cin >> a[i];
    REP(i, n) b[i + 1] = b[i] + a[i];
    REPP(i, 2, n + 1) REP(j, n + 1 - i) {
        ll x = inf;
        REPP(k, 1, i) x = min(x, dp[j][j + k] + dp[j + k][j + i]);
        dp[j][j + i] = x + b[j + i] - b[j];
    }
    cout << dp[0][n] << endl;
    return 0;
}


Measured memory_bytes: 1536
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(Q)]

answer = 0
for sq in combinations_with_replacement(range(1, M+1), N):
    score = 0
    for a, b, c, d in A:
        if sq[b - 1] - sq[a - 1] == c:
            score += d
    answer = max(answer, score)
print(answer)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n,a,b;
  cin >> n >> a >> b;
  if(abs(n-a) < abs(n-b))cout << 'A' << endl;
  else cout << 'B' << endl;


  

  return 0;
}


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

public class Main {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        int[] res = new int[n];
        Arrays.setAll(A, i -> Integer.parseInt(sc.next()));
        int idx1 = n / 2 + (n % 2 == 0 ? -1 : 0);
        int idx2 = n / 2 + (n % 2 == 0 ? 0 : 1);
        for(int i = 0; i < n; i++) {
            if(n % 2 == 0) {
                if(i % 2 == 0) res[idx2++] = A[i];
                else res[idx1--] = A[i];
            } else {
                if(i % 2 == 0) res[idx1--] = A[i];
                else res[idx2++] = A[i];
            }
        }
        for(int i = 0; i < n; i++) sb.append(res[i] + (i < n-1 ? " " : "\n"));
        System.out.print(sb);
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


int main(){
  ll n;
  cin >> n;
  vector<ll> b(n+1, 1e6);
  rep(i, n-1) cin >> b[i+1];


  vector<ll> a(n);
  rep(i, n) a[i] = min(b[i], b[i+1]);


  ll sum = 0;
  rep(i, n) sum += a[i];
  

  cout << sum << endl;



  return 0;
}


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

#define M 1000001/* your task*/
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % M-1); }

int find(char str[]){
  int x = h1(getKey(str));
  int y = h2(getKey(str));

  while(1){
    if(strcmp(H[x],str) == 0) return 1;
    if(strcmp(H[x],"\0") == 0) break;
     x = (x+y) % M;
  }
  return 0;
}

int insert(char str[]){
  int x = h1(getKey(str));
  int y = h2(getKey(str));

  while(1){
    if(strcmp(H[x],"\0") == 0){
      strcpy(H[x],str);
      return 1;
    }
     x = (x+y) % M;
  }
  return NIL;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

ll n,m;
ll x[1200],y[1200];
ll dp[3000];
ll i,j;
ll sumx,sumy;
ll ans = 0;

bool solve(){
	cin >> n;
	if(n == 0){
		return false;
	}
	sumx = 0;
	sumy = 0;
	ll v = -1;
	ll sumv = -1;
	for(i=0;i<n;i++){

		cin >> x[i] >> y[i];
		if(x[i] > sumv){
			sumv = x[i];
			v = i;
		}
		sumx += x[i];
		sumy += y[i];
	}
	sort(x,x+n);
	reverse(x,x+n);
	if(x[0] * 2 > sumx){
		//cout << "!" << endl;
		ll w = x[0] - (sumx - x[0]);
		dp[0] = 1;
		for(i=1;i<=w;i++)dp[i] = 0;
		for(i=0;i<n;i++){
			if(i == v)continue;
			for(j=w;j>=1;j--){
				if(j - y[i] >= 0){
					dp[j] |= dp[j - y[i]];
				}
			}
		}
		ll ma = 0;
		for(i=1;i<=w;i++){
			//cout << dp[i] << " ";
			if(dp[i])ma = i;
		}
		//cout << endl;
		ll ans1,ans2;
		ans1 = sumx + sumy + w - ma;
		ans2 = 0;
		//cout << "ma = " << ma << endl;
		cout << max(ans1,ans2) << endl;
	}else{
		cout << sumx + sumy << endl;
	}
	return true;
}

int main(){
	while(solve()){}
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

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

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll used[114514] = {};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	vector<P> s(n), use, hoka;
	for (int i = 0; i < n; ++i) {
		int t, d;
		cin >> t >> d;
		s[i] = P(d, t);
	}
	sort(s.begin(), s.end(), greater<P>());
	ll cnt = 0;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		int t = s[i].second;
		if (used[t] == 0 && cnt < k) {
			used[t]++;
			sum += s[i].first;
			use.push_back(s[i]);
			cnt++;
		} else {
			hoka.push_back(s[i]);
		}
	}
	for (int i = cnt; i < k; ++i) {
		use.push_back(hoka[i - cnt]);
		sum += hoka[i - cnt].first;
		used[hoka[i - cnt].second]++;
	}
	priority_queue<P, vector<P>, greater<P>> que;
	for (int i = 0; i < k; ++i) {
		int t = use[i].second;
		if (used[t] == 1) { que.push(use[i]); }
	}
	ll m = hoka.size();
	for (int i = k - cnt; i < m && !que.empty(); ++i) {
		P unko = que.top();
		ll dif = hoka[i].first - unko.first;
		// cout << unko.first << endl;
		if (dif > 2 * cnt - 1) {
			sum += dif;
			cnt--;
			que.pop();
		}
	}
	// cout << cnt << endl;
	cout << sum + cnt * cnt << endl;

	return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli data[20][2000];
lli s[20][2000];

lli bitNum(lli num){
	lli cnt=0;
	for(;num!=0;num>>=1)cnt+=num&1;
	return cnt;
}

signed main(){

	lli h,w,k;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>h>>w>>k;

	REP(i,0,h)REP(j,0,w){
		char tmp;
		cin>>tmp;
		data[i][j]=tmp-'0';
	}

	REP(i,0,h+1){
		REP(j,0,w+1){
			s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j]+data[i][j];
		}
	}

	lli ans = INF;
	//縦方向にはビット全探索で破壊する。
	for(lli b=0;b<(1LL<<h);b++){
		lli cnt=bitNum(b);
		b |= (1LL<<h);
		lli beforeW=0;
		lli beforeI=0;
		bool ok=true;
		lli beforeJ=INF;
		for(lli j=1;j<=w;j++){
			beforeI = 0;
			//次の場所まですすめるとkを越えてしまうならbeforeWを更新する必要がある。
			bool twoRtry=false;
			for(lli i=0;i<=h;i++){
				if(!(b&(1LL<<(i))))continue;
				lli num = s[i+1][j] - s[beforeI][j]-s[i+1][beforeW]+s[beforeI][beforeW];
				if(num>k){
					if(beforeJ==j){
						twoRtry=true;
						break;
					}
					if(DEBUG)cout<<"break!!!"<<endl;
					ok=false;
					beforeW=j-1;
					cnt++;
					beforeJ=j;
					j--;
					break;
				}
				beforeI = i+1;
			}
			if(twoRtry){
				cnt=INF;
				break;
			}
		}
		b ^= (1LL<<h);
		ans = min(ans,cnt);
	}
	cout<<ans<<endl;

	
	return 0;
}

Measured memory_bytes: 512
<?php
list($k) = ints();
$a = [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];
echo $a[$k - 1];
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16072
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int n,k,dp[2010];
int qpow(int x,int n){
	int ret=1;
	while(n){
		if(n&1)
			ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;
		n>>=1;
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&k);
	dp[0]=1;
	for(int i=1;i<n;i++){
		for(int j=i;j;j--){
			dp[j]=dp[j-1]+dp[j+1];
			if(dp[j]>=mod)
				dp[j]-=mod;
		}
		dp[0]=dp[1];
	}
	printf("%d",1ll*dp[n-k]*qpow(2,max(n-k-1,0))%mod);
	return 0;
}

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

int N;
vector<int> A;
int ButtonCheck(int x,int y);

int main(){
  
  cin >> N;
  
  A = vector<int>(N);
  
  for(int i = 0;i<N;i++){ 
    cin >> A.at(i);
  }
  
  int ans = ButtonCheck(0,0);
  
  cout << ans <<endl;
}

int ButtonCheck(int x,int y){
  int R;
  
  if(A.at(x) == 2){R= 0;}
  else if(y>=N){return -y-1;}
  else {R=ButtonCheck(A.at(x)-1,y+1);}

  return R+1;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<stack>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define prt(x) printf("%d\n",x)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-1;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,string> pcc;
typedef pair<double,double> pbb;
vector<int> v[3003];
int main()
{
	int x;
	cin>>x;
	if(x>=30)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 3656
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = do
	[ x, k, d ] <- readIntegers
	print $ if k * d <= abs x
		then abs x - k * d
		else let k' = k - abs x `div` d in abs ( abs x - ( k - k' ) * d - ( if k' `mod` 2 == 0 then 0 else d ) )

Measured memory_bytes: 3844
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int c[105][105];
int main(){
	std::ios::sync_with_stdio(false);
	int h,w,n,x,i=1,j=1,fl=0,k;
	cin>>h>>w>>n;
	rep(k,n)
	{
		cin>>x;
		while(x--)
		{
			//cout<<i<<" "<<j<<endl;
			c[i][j]=k+1;
			if(fl==0)
			{
				j++;
				if(j==w+1)
				{
					fl=1;
					i++;
					j=w;
				}
			}
			else
			{
				j--;
				if(j==0)
				{
					fl=0;
					i++;
					j=1;
				}
			}
		}
	}	
	f(i,1,h+1)
	{
		f(j,1,w+1)
		{
			cout<<c[i][j]<<" ";
		}
		cout<<"\n";
	}
} 


Measured memory_bytes: 384
import sys
Sin = input()
#print(Sin)
S = [int(x) for x in list(str(Sin))]
#print(S)
test = 0
for i in range(0,3):
#    print(i)
    if S[i+1] == S[i]:
        print("Bad")
        test = 1
        sys.exit()
        
if test !=1:
    print("Good")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,a,b,ans;
    cin>>n>>a>>b;
    if((b-a)%2==0) ans=(b-a)/2;
    else if((b-a)%2==1) ans=min(a-1,n-b)+1+(b-a)/2;
    cout<<ans;
}

Measured memory_bytes: 3628
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>

using namespace std;

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

int main() {
    string s,t;
    cin >> s;
    cin >> t;

    ll dp[s.length()+1][t.length()+1];

    REP(i,s.length()+1){
        REP(j,t.length()+1){
            dp[i][j]=0;
        }
    }

    REP(i,s.length()){
        REP(j,t.length()){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }else{
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }

    string ans="";
	int ss=s.size(), ts=t.size();
	while(ss>0 && ts>0){
	    if(dp[ss][ts-1]==dp[ss][ts]){
            --ts;
	    }else if(dp[ss-1][ts]==dp[ss][ts]){
            --ss;
        }else{
            ans += s[ss-1];
	        --ss;
	        --ts;
        }
	}

	for(int i=dp[s.size()][t.size()]; i>0; --i){
        cout << ans[i-1];
    }
    cout << endl;

}

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

/*#ifndef ONLINE_JUDGE
    #include <lol.h>
#endif*/
#define mp make_pair
#define pb push_back
#define pf push_front
#define sz(a) (int)((a).size())
#define fr(i,n) for(ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define frk(i,k,n) for(ll i=k;i<n;i++)
#define rfr(i,n) for(ll i=n-1;i>=0;i--)
#define foa(i,a,n) for(ll i=0;i<n;i+=a)
#define f first
#define s second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vsort(x) sort(all(x))
#define debug cout<<"Hey Sweetie, Stop Right Here......"<<endl;

typedef long long int ll;
typedef stack<ll> stll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef set<ll> sll;
typedef multiset<ll> msll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef long double ld;
ll modmulti(ll a, ll b, ll m) {
  return ((a % m) * (b % m)) % m;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll m)
{
  if (y == 0)
    return 1;
  ll p = power(x, y / 2, m) % m;
  p = (p * p) % m;

  return (y % 2 == 0) ? p : (x * p) % m;
}
ll power2(ll x, ll y)
{
  if (y == 0)
    return 1;
  ll p = power2(x, y / 2);
  p = (p * p);

  return (y % 2 == 0) ? p : (x * p);
}
bool cmp(pair<ll, ll>&a, pair<ll, ll>&b) {
  if (a.first == b.first) return (a.second < b.second);
  else return (a.first > b.first);
}

ll bin(vll a, ll left, ll right, ll x) {
  ll mid = left + (right - left) / 2;
  if (a[mid] == x) return mid;
  if (left <= right) {
    if (a[mid] < x) return bin(a, mid + 1, right, x);
    else if (a[mid] > x) return bin(a, left, mid - 1, x);
  }
  return -1;
}
ll findclosest(ll n) {
  ll i;
  for (i = 0; i <= 64; i++) {
    if (power2(2, i) <= n) continue;
    else break;
  }
  return power2(2, i - 1);
}
ll get_signi(ll n) {
  while (n >= 10) {
    n = n / 10;
  }
  return n;
}
ll get_digits(ll n) {
  ll i = 0;
  while (n >= 10) {
    n = n / 10;
    i++;
  }
  return i;
}
bool is_palindrome(string t) {
  for (int i = 0; i < t.size() / 2; i++) {
    if (t[i] != t[t.size() - i - 1]) return false;
  }
  return true;
}
int main() {
  fastio;
  ll n, m;
  cin >> n >> m;
  vll a(n);
  ll sum = 0;
  fr(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll cnt = 0;
  ll need = (sum / (m * 4));
  if(sum%(4*m)==0) need--;
  fr(i, n) {
    if (a[i] > need)cnt++;
  }
  if (cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
plus_max = 10**20 * -1
plus_min = 10**20
minus_max = 10**20 * -1
minus_min = 10**20
for _ in range(n):
    x, y = map(int, input().split())
    plus_max = max(plus_max, x + y)
    plus_min = min(plus_min, x + y)
    minus_max = max(minus_max, x - y)
    minus_min = min(minus_min, x - y)
print(max(plus_max - plus_min, minus_max - minus_min))


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

using namespace std ;

const int MAX = 2e5 + 10 ;

long long arr[MAX] ;
int cost[MAX] ;
int n ;

string s ;

int cnt[10][50][25] ;
long long cnt2[10] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>s ;
		bool flag = false ;
		for(int j = 0 ; j < s.size() ; ++j)
		{
			if(s[j] == '.')
			{
				flag = true ;
				cost[i] = s.size() - j - 1 ;
				continue ;
			}
			arr[i] = arr[i] * 10ll + (s[j] - '0') ;
		}
		for(int j = s.size()-1 ; j >= 0 && flag ; --j)
		{
			if(s[j] != '0')
				break ;
			cost[i]-- ;
			arr[i] /= 10ll ;
		}
		assert(cost[i] >= 0 && cost[i] <= 9) ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		int x = 0 , y = 0 ;
		while(arr[i] % 2 == 0)
			x++ , arr[i] /= 2 ;
		while(arr[i] % 5 == 0)
			y++ , arr[i] /= 5 ;
		cnt[cost[i]][x][y]++ ;
	}
	long long ans = 0 ;
	for(int i = 0 ; i <= 9 ; ++i)
	{
		for(int j = 0 ; j <= 45 ; ++j)
		{
			for(int k = 0 ; k <= 20 ; ++k)
			{
				for(int i2 = i ; i2 <= 9 ; ++i2)
				{
					long long x = 0 ;
					for(int j2 = 0 ; j2 <= 45 ; ++j2)
					{
						for(int k2 = 0 ; k2 <= 20 ; ++k2)
						{
							if(i == i2 && j == j2 && k == k2)
							{
								if(j + j2 >= i + i2 && k + k2 >= i + i2)
									x += cnt[i][j][k] * 1ll * (cnt[i2][j2][k2] - 1ll) ;	
							}
							else if(j + j2 >= i + i2 && k + k2 >= i + i2)
								x += cnt[i][j][k] * 1ll * cnt[i2][j2][k2] ;
						}
					}
					if(i == i2)
						cnt2[i] += x ;
					else
						ans += x ;
				}
			}
		}
	}
	for(int i = 0 ; i <= 9 ; ++i)
		ans += cnt2[i] / 2ll ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 6004
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     int n;
     cin>>n;
     int a[n];
     rep(i,0,n)
     { cin>>a[i];
        a[i]*=2;}
        int sum=0;
        rep(i,0,n)
        {
            if(i%2==0)
                sum+=a[i];
            else
                sum-=a[i];

        }
        int x=sum/2;
        rep(i,0,n)
        {
            if(i==0)
            {
                cout<<x<<" ";
                x=a[i]-x;
                continue;
            }
            cout<<x<<" ";
            x=a[i]-x;
        }


}

signed main()
{
        FIO
       
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 4600