akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define f first
#define s second

#define all(s) s.begin(),s.end()
#define spresent(s,v) ((s).find(v)!=s.end())
#define present(s,v) (find(all(s),v)!=s.end())

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

#define dout(i,s) cout<<"Case "<<i<<": "<<s<<"\n"

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

typedef struct node{
	ll val,more=0,less=0;
	bool operator <(const node& a){
		return val<a.val;
	}
}node;

// typedef struct{
// 	int ind;
// 	bool cl=true;
// }guest;


const int M = 1e9+7;

int main(){

	int n,arr[2005];
	ll k;
	cin>>n>>k;
	for(int i=0;i<n;++i)
		cin>>arr[i];

	int a=0,b=0;

	for(int i=0;i<n;++i){
		for(int j=0;j<i;++j)
			if(arr[j]<arr[i])
				++b;
		for(int j=i+1;j<n;++j)
			if(arr[j]<arr[i])
				++a;
	}

	cout<<((k*(k-1)/2%M)*(a+b)%M + a*k%M)%M;





	return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
       public static void main(String[] args){
       int i;
    	int[] height = new int[10];
        Scanner scan = new Scanner(System.in);
        for(i = 0;i < 10;i++){
        height[i] = scan.nextInt();
        }
        
        int st = 0,nd = 0 ,rd = 0;
        
        
        	for(i = 0;i < 10;i++){
        		if(height[i]>=st){
        		rd = nd;
        		nd = st;
        		st = height[i];
        		}else if(height[i]>=nd){
        		rd = nd ;
        		nd = height[i];
        		}else if(height[i]>=rd){
        		rd = height[i];
        		
        		}
        	}
        	System.out.println(st);
        	System.out.println(nd);
        	System.out.println(rd);
       		}
}

Measured memory_bytes: 26076
#include <iostream>

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

    int nums[1000];
    int index = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            nums[index++] = i * j;
        }
    }
    int n;
    std::cin >> n;
    for (int i = 0; i < index; ++i) {
        if (nums[i] == n) {
            std::cout << "Yes\n";
            return 0;
        }
    }
    std::cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  ll n,k;
  cin >> n >> k;
  set<ll> bound;
  bound.insert(0);
  for(ll i = 1;i * i <= n;++i){
    bound.insert(i);
    bound.insert(n/i);
  }
  auto elem = vector< ll >(bound.begin(),bound.end());
  int sz = bound.size() - 1;
  auto calc = vector< ll >(sz);
  for(int i = 0;i < sz;++i){
    calc[i] = (elem[i+1] - elem[i]) % mod;
  }
  for(int i = 0;i < k-1;++i){
    auto next = vector< ll >(sz,0);
    ll acc = 0LL;
    for(int j = sz-1;j >= 0;--j){
      acc += calc[sz-1-j];
      next[j] = acc * (elem[j+1] - elem[j]);
      next[j] %= mod;
    }
    calc = next;
  }
  ll res = 0LL;
  for(int i = 0;i < sz;++i){
    res += calc[i];
    res %= mod;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4752
n=int(input())
a=list(map(int,input().split()))
a.sort()
min=a[0]
max=a[-1]
ans=[]
for a in a[1:-1]:
    if a>0:
        ans.append([min,a])
        min-=a
    else:
        ans.append([max,a])
        max-=a
ans.append([max,min])
print(max-min)
for x,y in ans:
    print(x,y)

Measured memory_bytes: 22308
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair

vector<pi> W;

ll dis(ll f,ll t){
    return abs(W[f].F-W[t].F)+abs(W[f].S-W[t].S);
}

vector<ll> c(1500000);


int main(){
#define int ll
    ll h,w,d;
    cin>>h>>w>>d;
    W.resize(h*w+1000);
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            int a;
            cin>>a;
            a--;
            W[a]={i,t};
        }
    }
    for(int i=0;i<d;i++){
        for(int t=i;t<h*w;t+=d){
            if(t==i){c[t]=0;}
            else{c[t]=c[t-d]+dis(t,t-d);}
        }
    }
    ll q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        cout<<c[r]-c[l]<<endl;
    }
    
    
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 1e9;
    for (int i = 0; i < s.size() - 3 + 1; i++) {
        string st = s.substr(i, 3);
        int a = abs(753 - stoi(st));
        ans = min(ans, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
icase=0
if icase==0:
    n=int(input())

    f=[]
    for i in range(n):
        fi=list(map(int,input().split()))
        f.append(fi)
    p=[]
    for i in range(n):
        pi=list(map(int,input().split()))
        p.append(pi)
elif icase==1: 
    n=1
    f=[[1, 1, 0, 1, 0, 0, 0, 1, 0, 1]]
    p=[[3, 4, 5, 6, 7, 8, 9, -2, -3, 4, -2]]
elif icase==2: 
    n=2
    f=[[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]
    p=[[0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
       [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]]
elif icase==3: 
    n=3
    f=[[1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
       [0, 1, 0, 1, 1, 1, 1, 0, 1, 0],
       [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]]
    p=[[-8, 6, -2, -8, -8, 4, 8, 7, -6, 2, 2],
       [-9, 2, 0, 1, 7, -5, 0, -2, -6, 5, 5],
       [6, -6, 7, -9, 6, -5, 8, 0, -9, -7, -7]]
    
import itertools
sumpmax=-10**11
for i in itertools.product([0,1], repeat=10):
    r=list(i)
    sump=0
    if sum(r)!=0:
        for jj in range(n):
            ci=0
            for j in range(10):
                ci=ci+r[j]*f[jj][j]
            sump=sump+p[jj][ci]
#            print(sump,r)
        sumpmax=max(sump,sumpmax)
print(sumpmax)

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int maxN = 8 + 5;
int n, m;
vector<vi> graph(maxN);
int ans;

void dfs(int current, int isStayed, int cnt) {
  if (cnt == n) {
    ans++;
    return;
  }
  isStayed += 1 << current;
  for (auto &v : graph[current]) {
    if (!((isStayed >> v) & 1))
      dfs(v, isStayed, cnt + 1);
  }
}

signed main() {
  std::cin >> n >> m;
  REP(i, m) {
    int a, b;
    std::cin >> a >> b;
    graph[a].PB(b);
    graph[b].PB(a);
  }
  int isStayed = 1;
  dfs(1, isStayed, 1);
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
ll W[ll(2e5+1)],V[ll(2e5+1)],n,w;
ll dp[ll(200)][ll(2e5+1)];
ll solve(ll idx,ll value){
if(idx>=n){
    if(value==0)return 0;
    else return 1e16;
}
if(value==0)return 0;
if(value<0)return 1e16;
ll ans=1e16;
if(dp[idx][value]!=-1)return dp[idx][value];
ans=min(ans,solve(idx+1,value));
ans=min(ans,solve(idx+1,value-V[idx])+W[idx]);
return dp[idx][value]=ans;
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    cin>>n>>w;
    for(ll i=0;i<n;i++)cin>>W[i]>>V[i];
    for(ll i=0;i<200;i++)for(ll j=0;j<=2e5;j++)dp[i][j]=-1;
    for(ll i=1e5;i>=0;i--){
        ll ans=solve(0,i);
        if(ans<=w){
            cout<<i<<endl;
            break;
        }

    }
    return 0;
}


Measured memory_bytes: 315648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

constexpr ll mod = 998244353;

#define NMAX 200010
ll fac[NMAX];
ll inv[NMAX];

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

void mae_nck(){
    fac[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < NMAX; i++){
        fac[i] = (fac[i-1] * i)%mod;
        inv[i] = (inv[i-1] * mod_inv(i, mod))%mod;
    }
}

ll mod_nck(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if(k == 0 || k == n) return 1;
    ll ret = ((fac[n] * inv[k])%mod * inv[n-k])%mod;
    return ret;
}

int main(){
    mae_nck();
    ll N, M, K;
    cin >> N >> M >> K;
    ll ans = 0;
    rep(i, 0, K+1){
        ll tmp = M * mod_pow(M-1, N-1-i, mod);
        tmp %= mod;
        if(i != 0) tmp *= mod_nck(N-1, i);
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6764
// Aizu Vol-2 0209: Scene in a Picture
// 2017.8.21 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef signed char schar;

#define N 53
typedef struct { int s, e; } T;
schar mado[100+2*N][100+N]; int n;
schar mono[4][N][N]; int m;
T info[4][N];

void rot90(int d, int s)
{
	int r, c;
	for (r = 0; r < m; r++) for (c = 0; c < m; c++) mono[d][c][m-1-r] = mono[s][r][c];
}

void ginfo(int k)
{
	int r, c;
	for (r = 0; r < m; r++) {
		info[k][r].s = -1, info[k][r].e = -1;
		for (c = 0; c < m; c++) {
			if (mono[k][r][c] >= 0) { info[k][r].s = c; break; }
		}
		for (c = m-1; c >= 0; c--) {
			if (mono[k][r][c] >= 0) { info[k][r].e = c; break; }
		}
		if (info[k][r].s < 0 || info[k][r].e < 0) while (1);
	}
}

int check(int k, int r0, int c0)
{
	int s, e, r, c, cc;

	cc = info[k][0].s;
	for (r = 0; r < m; r++) {
		s = info[k][r].s, e = info[k][r].e;
		for (c = s; c <= e; c++) {
			if (mono[k][r][c] >= 0 && mono[k][r][c] != mado[r0+r][c0+c-cc]) return 0;
		}
	}
	return 1;
}

int main()
{
	int i, r, c, t;

	while (scanf("%d%d", &n, &m) && n) {
		memset(mado, 0xaa, sizeof(mado));
		for (r = 0; r < n; r++) for (c = 0; c < n; c++) {
			scanf("%d", &t), mado[r][c+N] = t;
		}
		for (r = 0; r < m; r++) for (c = 0; c < m; c++) {
			scanf("%d", &t), mono[0][r][c] = t;
		}
		for (i = 0; i < 3; i++) rot90(i+1, i);
		for (i = 0; i < 4; i++) ginfo(i);
		for (r = 0; r < n; r++) for (c = 0; c < n; c++) {
			for (i = 0; i < 4; i++)
				if (check(i, r, c+N)) { printf("%d %d\n", c+1, r+1); goto Done; }
		}
		puts("NA");
		Done:;
	}
	return 0;
}

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

int main(){
  int N;string S;cin>>N>>S;
  priority_queue<int> ans;
  for(int i=1;i<N;i++){
    string A=S.substr(0,i);
    string B=S.substr(i,N-i);
    vector<bool> X(26,false);
    int count=0;
    for(int j=0;j<N-i;j++) X.at(B.at(j)-'a')=true;
    for(int j=0;j<i;j++){
      if(X.at(A.at(j)-'a')){
        X.at(A.at(j)-'a')=false;
        count++;
      }
    }
    ans.push(count);
  }
  cout<<ans.top()<<endl;
}



Measured memory_bytes: 3592
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n, a, b;
    cin >> n >> a >> b;

    vector<int> p(n);

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

    int f = 0;
    int s = 0;
    int t = 0;

    for(int i = 0; i < n; i++){
        if(p[i] <= a){
            f++;
        } else if(p[i] <= b){
            s++;
        } else {
            t++;
        }
    }

    cout << min({f, s, t}) << endl;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi cnt(n);
    rep(i, n) cnt[a[i]-1]++;
    RSORT(cnt);
    ll sum = 0;
    rep(i, k) sum += cnt[i];
    cout << (n-sum) << endl;
    return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 210;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow_mod(fact[n],-1);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    vector<vector<ll>> dp(n+1,vector<ll>(x+1,0));
    for (int i = 0;i < n;++i) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    create_table(200);
    dp[0][x] = 1;
    for (int i = 0;i < n;++i) {
        for (int j = 0;j <= x;++j) {
            dp[i+1][j%a[i]] += dp[i][j]*inv[n-i]%mod;
            dp[i+1][j] += dp[i][j]*(1-inv[n-i])%mod;
            dp[i+1][j%a[i]] %= mod;
            dp[i+1][j] %= mod;
        }
    }
    ll ans = 0;
    for (int i = 0;i <= x;++i) {
        ans += dp[n][i]*i;
        ans %= mod;
    }
    cout << (ans*fact[n]%mod+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 158592
import pdb
#pdb.set_trace()
K=int(input())
s=input().split(' ')
a=[int(s[i]) for i in range(len(s))]
n=len(s)

def solve():
	x,y=2,2
	for i in range(n-1,-1,-1):
		u=(x+a[i]-1)//a[i]
		v=y//a[i]
		if (a[i]*v<x): return -1,-1
		x=a[i]*u
		y=a[i]*(v+1)-1
	return x,y

x,y=solve()
if (x==-1): print(-1)
else: print('%d %d'%(x,y))

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

int main() {
    ll n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0)
            ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#define MOD 1000000007
typedef long long ll;
using namespace std;
ll a[100001];
ll n;

class BIT{
public:

  vector<ll> bit;
  BIT(){}
  BIT(int size){
    bit.resize(size,0);
  }

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&(-i);
    }
    return s;
  }

  void add(int i,int x){
    while(i<bit.size()){
      bit[i]+=x;
      i+=i&(-i);
    }
  }
};

bool check(ll m){
  int s[n+1]={};
  BIT bit(2*n+1);

  for(int i=1;i<=n;i++){
    if(a[i]>=m) s[i]=1;
    else s[i]=-1;
  }
  s[0]=0;
  for(int i=1;i<=n;i++) s[i]+=s[i-1];
  ll ans=0;
  for(int i=0;i<=n;i++){
    ans+=bit.sum(s[i]+n);
    bit.add(s[i]+n,1);
  }

  if(ans<n*(n+1)/4) return true;
  else return false;
}

int main(){
  cin>>n;
  ll ma=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    ma=max(ma,a[i]);
  }

  ll l=0,r=ma+1;
  while(r-l>1){
    int m=(r+l)/2;
    if(check(m)) r=m;
    else l=m;
  }
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

template <typename T, bool MIN = true> class ConvexHullTrick{
  deque<pair<T,T>> lines;
  bool is_needless(const pair<T,T> &a, const pair<T,T> &b, const pair<T,T> &c){
    return (a.snd-b.snd)*(a.fst-c.fst) >= (a.snd-c.snd)*(a.fst-b.fst);
  }
  
  T apply(const pair<T,T> &f, const T &x){
    return f.fst*x + f.snd;
  }

  function<bool(T,T)> comp;

public:
  ConvexHullTrick(){
    if(MIN) comp = [](const T &a, const T &b){return a > b;};
    else comp = [](const T &a, const T &b){return a < b;};
  }
  
  void add(const T &a, const T &b){
    if(!lines.empty()){
      pair<T,T> l = lines.back();
      
      if(l.fst == a){
	if(!comp(l.snd,b)) return;
	lines.pop_back();
      }
    }
    while(lines.size()>=2 && is_needless(make_pair(a,b), lines.back(), *(lines.end()-2))){
      lines.pop_back();
    }
    lines.push_back(make_pair(a,b));
  }

  T query(const T &x){
    while(lines.size()>=2 && comp(apply(lines[0],x), apply(lines[1],x))){
      lines.pop_front();
    }
    return apply(lines[0],x);
  }
};



LLI dp[201000];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LLI N,C;
  while(cin >> N >> C){
    vector<LLI> h(N); cin >> h;

    /*
      dp[i]
      = min(dp[j] + (hi-hj)^2 + C)
      = min(dp[j] + hi^2 - 2*hi*hj + hj^2 + C)
      = min(-2*hj*hi + hj^2 + dp[j]) + hi^2 + C
    */

    ConvexHullTrick<LLI,true> cht;

    dp[0] = 0;
    cht.add(-2*h[0],h[0]*h[0]+dp[0]);

    FOR(i,1,N){
      dp[i] = cht.query(h[i]) + h[i]*h[i] + C;
      cht.add(-2*h[i],h[i]*h[i]+dp[i]);
    }

    cout << dp[N-1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <locale>
#include <vector>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define maxn 1000005

using namespace std;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        long long a[100005];
        for(int i=0;i<n;i++)
            scanf("%lld",&a[i]);
        sort(a,a+n);
        long long x[2];
        x[0]=x[1]=0;
        int t=0;
        for(int i=n-1;i>0;i--)
        {
            if(t==2)
                break;
            if(a[i]==a[i-1])
            {
                x[t++]=a[i];
                i--;
            }
        }
        printf("%lld\n",x[0]*x[1]);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int a[1000005];
int main(void) {
	int n;
	cin >> n;
	ll count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 1 && (i + 1) % 2 == 1) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
unsigned long long xor128() {
    static unsigned long long rx = 123456789, ry = 362436069, rz = 521288629, rw = 88675123;
    unsigned long long rt = (rx ^ (rx << 11));
    rx = ry;
    ry = rz;
    rz = rw;
    return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));
}
bool used[100009];
int main(){
	int n,f=0;
	cin>>n;
	int a[n];
	vector<int>v,w,q;
	vector<P>r;
	if(n==3){
		cout<<2<<' '<<5<<' '<<63<<endl;
		return 0;
	}
	for(int i=2;i<=30000;i++){
		if(i%2==0)v.push_back(i);
		else if(i%3==0&&i!=3&&i!=9)w.push_back(i);
	}
	for(int i=0;i<(int)v.size();i++){
		if(v[i]%3==0){
			q.push_back(v[i]);
			v.erase(v.begin()+i);
			i--;
		}
	}
	for(int i=0;i<v.size();i++)if(!used[i]){
		for(int j=v.size()-1;j>i;j--)if(!used[j]){
			if((v[i]+v[j])%3==0){
				used[i]=1;
				used[j]=1;
				r.push_back(P(v[i],v[j]));
				goto L;
			}
		}L:;
	}
	int p=0;
	cout<<3<<' '<<9;
	n-=2;
	//if(n>=19990)exit(1);
	while(n){
		if(n>=2&&r.size()>=1){
			cout<<' '<<r[0].first<<' '<<r[0].second;
			r.erase(r.begin());
			n-=2;
		}
		else if(w.size()){
			if(n==1&&p%2==0)goto LL;
			cout<<' '<<w[0];
			w.erase(w.begin());
			n--;
			p++;
		}
		else if(q.size()){
			LL:;
			cout<<' '<<q[0];
			q.erase(q.begin());
			n--;
		}
	}cout<<endl;
}

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

int main(void){
  int n;
  cin >> n;
  int p[n];
  for(int i = 0; i < n; i++) cin >> p[i];
  int max = p[0];
  for(int i = 1; i < n; i++) if(max < p[i]) max = p[i];
  int ans = 0;
  for(int i = 0; i < n; i++) ans += p[i];
  ans -= max / 2;
  cout << ans << endl;
  return 0;
}


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

#define fr first
#define sc second
#define mk make_pair

using namespace std;

int n, m, mod[1000001], bo[1000001], ar[1000001], sum[1000001];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        ar[x]++;
    }

    for(int i = 1; i <= 1e5; i++)
        bo[i] = ar[i] % 2;

    for(int i = 1e5; i >= 0; i--)
        mod[i] = ar[i] + mod[i + m], bo[i] = bo[i] + bo[i + m], sum[i] = ar[i] / 2 + sum[i + m];

    long long ans = 0;
    for(int i = 1; i <= m / 2; i++)
    {
        if(i * 2 == m)
            continue;
        int a = i, b = m - i;
        if(bo[a] > bo[b])
            swap(a, b);

        ans += sum[b] + bo[a];
        bo[b] -= bo[a];

        if(sum[a] * 2 <= bo[b])
        {
            ans += sum[a] * 2;
        }else
        {
            ans += bo[b] / 2 * 2;
            ans += sum[a] - bo[b] / 2;
        }
        //cout << ans << endl;
    }
    ans += (mod[0] / 2);
    if(m % 2 == 0)
        ans += (mod[m / 2] / 2);

    cout << ans;
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,26){
        m[i] = INF;
    }
    rep(i,n){
        string s;
        cin >> s;
        map<int,int> h;
        rep(j,s.size()){
            h[s[j]-'a']++;
        }
        rep(j,26){
            if(m[j]>h[j]){
                m[j] = h[j];
            }
        }
    }
    string ans = "";
    rep(i,26){
        rep(j,m[i]){
            ans += 'a' + i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N = 2e5 + 7;

int n, k;
long long ans = 0;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	int p = n / k;
	ans += 1LL * p * p * p;
	if(k % 2 == 0){
		p = 0;
		int now = k / 2;
		if(now <= n){
			p++;
			n -= now;
			p += n / k;
			ans += 1LL * p * p * p;
		}
	}
	cout << ans;
}


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

int main()
{
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<(char)(s1[0]-32)<<(char)(s2[0]-32)<<(char)(s3[0]-32)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, x, a[101], ans;
int main() {
  scanf ("%d%d", &n, &x);
  for (int i =1; i <= n; i++) {
    scanf ("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (x >= a[i] && i != n) {
      ans++;
      x -= a[i];
    }
    else {
    	if (i == n && x == a[i]) ans++;
    	break;
		}
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_W = 50;
const int MAX_H = 50;
const int MAX_HW = MAX_H * MAX_W;
const int MAX_N = 1000;

const int INF = 1 << 29;

const int dxs[] = {1, 0, -1, 0}, dys[] = {0, 1, 0, -1};

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

int w, h, n, hw;
int ipos, opos;
int nbrs[MAX_HW][4];
int dists[MAX_HW], prvs[MAX_HW];
vpii cwls;

/* subroutines */

int min_dist() {
  for (int i = 0; i < hw; i++) dists[i] = INF;
  dists[ipos] = 0;
  prvs[ipos] = -1;

  queue<int> q;
  q.push(ipos);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    if (u == opos) break;

    for (int di = 0; di < 4; di++) {
      int v = nbrs[u][di];
      if (v >= 0 && dists[v] >= INF) {
	dists[v] = dists[u] + 1;
	q.push(v);
	prvs[v] = u;
      }
    }
  }

  return dists[opos];
}

/* main */

int main() {
  cin >> w >> h >> n;
  hw = h * w;

  int dpos[] = {1, w, -1, -w};
  
  for (int y = 0, pos = 0; y < h; y++)
    for (int x = 0; x < w; x++, pos++)
      for (int di = 0; di < 4; di++) {
	int x0 = x + dxs[di], y0 = y + dys[di], pos0 = pos + dpos[di];
	nbrs[pos][di] =
	  (x0 >= 0 && x0 < w && y0 >= 0 && y0 < h) ? pos0 : -1;
      }

  for (int i = 0; i < n; i++) {
    int sx, sy, dx, dy;
    cin >> sx >> sy >> dx >> dy;

    if (sy == dy) {
      if (sx > dx) swap(sx, dx);
      if (sy > 0)
	for (int x = sx; x < dx; x++) nbrs[(sy - 1) * w + x][1] = -1;
      if (sy < h)
	for (int x = sx; x < dx; x++) nbrs[sy * w + x][3] = -1;
    }
    else {
      if (sy > dy) swap(sy, dy);
      if (sx > 0)
	for (int y = sy; y < dy; y++) nbrs[y * w + sx - 1][0] = -1;
      if (sx < w)
	for (int y = sy; y < dy; y++) nbrs[y * w + sx][2] = -1;
    }
  }

  for (int pos = 0; false && pos < hw; pos++) {
    printf("nbrs[%d] =", pos);
    for (int di = 0; di < 4; di++) printf(" %d", nbrs[pos][di]);
    putchar('\n');
  }
  
  int ix, iy, ox, oy;
  cin >> ix >> iy;
  cin >> ox >> oy;

  ipos = iy * w + ix;
  opos = oy * w + ox;
  //printf("ipos=%d, opos=%d\n", ipos, opos);

  int mind = min_dist();
  //printf("mind=%d\n", mind);

  for (int pos = opos; prvs[pos] != -1; pos = prvs[pos]) {
    cwls.push_back(pii(pos, prvs[pos]));
    //printf("%d->%d\n", pos, prvs[pos]);
  }

  int max_diff = 0;
  
  for (vpii::iterator vit = cwls.begin(); vit != cwls.end(); vit++) {
    int p0 = vit->first, p1 = vit->second;
    int d0, d1;

    for (d0 = 0; d0 < 4 && nbrs[p0][d0] != p1; d0++);
    d1 = (d0 + 2) % 4;

    nbrs[p0][d0] = nbrs[p1][d1] = -1;

    int mind0 = min_dist();
    //if (mind0 < INF) printf("mind0=%d\n", mind0);

    nbrs[p0][d0] = p1;
    nbrs[p1][d1] = p0;

    if (mind0 < INF && max_diff < mind0 - mind) max_diff = mind0 - mind;
  }

  cout << max_diff << endl;

  return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

class UnionFind {
private:
  vector<int> par;
public:
  UnionFind(int N) {
    par.resize(N);
    rep0(i, N) par[i] = i;
  }
  int root(int x) { return (x == par[x])? x: (par[x] = root(par[x])); }
  void unite(int x, int y) { par[root(y)] = root(x); }
  bool same(int x, int y) { return (root(x) == root(y)); }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> p(N);
  rep0(i, N) cin >> p[i];

  UnionFind UF(N);

  rep0(i, M) {
    int x, y;
    cin >> x >> y;
    UF.unite(x - 1, y - 1);
  }

  int ans = 0;
  rep0(i, N) {
    if (UF.same(i, p[i] - 1)) ans++;
  }
  cout << ans << BR;

  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    if(str.charAt(0)==str.charAt(1) && str.charAt(1) == str.charAt(2)){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
  
}


Measured memory_bytes: 21972
s=input()
n=len(s)
for i in range(n//2):
  if (s[i] != s[n-1-i]):
    print("No")
    quit()

for i in range(n//4):
  if (s[i] != s[n//2-1-i]):
    print("No")
    quit()

print("Yes")

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

using namespace std;

const int MAXN = 200;
bool visited[MAXN];
vector<int> adjList[MAXN];

bool isBipartite()
{
    int color[MAXN];
    fill(color, color + MAXN, 0);
    queue<int> q;
    q.push(0);
    color[0] = 1;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int adj : adjList[v])
        {
            if (adj == v)
                continue;
            if (color[adj] == 0)
            {
                color[adj] = -color[v];
                q.push(adj);
            }
            else
            {
                if (color[adj] == color[v])
                {
                    return false;
                }
            }
        }
    }
    return true;
}

int level(int s, int n)
{
    fill(visited, visited + n, false);
    queue<pair<int, int>> q;
    q.push({s, 1});
    visited[s] = true;
    int ans = 1;
    while (!q.empty())
    {
        pair<int, int> p = q.front();
        q.pop();
        for (int adj : adjList[p.first])
        {
            if (!visited[adj])
            {
                visited[adj] = true;
                q.push({adj, p.second + 1});
            }
        }
        ans = max(ans, p.second);
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++)
        {
            int x = s[j] - '0';
            if (x)
            {
                adjList[i].push_back(j);
            }
        }
    }
    if (isBipartite())
    {
        int ans = 1;
        for (int i = 0; i < n; i++)
        {
            ans = max(ans, level(i, n));
        }
        cout << ans << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

int x, y, s;

int tax(int p, int r) {
  return p * (100 + r) / 100;
}

void solve() {
  int ans = 0;
  FOR(i, 1, s) {
    FOR(j, 1, s) {
      if (tax(i, x) + tax(j, x) == s) {
        chmax(ans, tax(i, y) + tax(j, y));
      }
    }
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  while (1) {
    cin >> x >> y >> s;
    if (x == 0 && y == 0 && s == 0) break;

    solve();
  }




  
  return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 12768
/*This is the solution from Ling2Feng1,
  no matter AC or not.
  OJ:
  ProblemID:
  Date:
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

const int INF=1e9+7;
const int dx[4]={-1,0,1,0};
const int dy[4]={0,-1,0,1};

int n;
int dp[100005];
vector<int> ve[100005];

void dfs(int cur,int par){
	int son=0,notleaf=0;
	for(int i=0;i<ve[cur].size();i++){
		int nxt=ve[cur][i];
		if(nxt==par) continue;
		son++;
		dfs(nxt,cur);
		dp[cur]+=dp[nxt];
		if(dp[nxt]) notleaf++;
	}
	dp[cur]+=max(son-notleaf-1,0);
	return;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		ve[u].push_back(v); 
		ve[v].push_back(u);
	}
	int mx=0;
	for(int i=0;i<n;i++){
		if(ve[i].size()>ve[mx].size()) mx=i;
	}
	dfs(mx,-1);
	printf("%d\n",max(1,dp[mx]));
	return 0;
} 

Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;
 
const int N = 505;
typedef long long ll;
ll n, m, h, w, d;
ll a[N][N], ans;
 
int main() {
    cin >> n >> m >> h >> w;
    d = 1000;
    rep(i, 1, n) {
        rep(j, 1, m) {
            if (i % h == 0 && j % w == 0) a[i][j] = -((h * w - 1) * d) - 1;
            else a[i][j] = d;
            ans += a[i][j];
        }
    }
    if (ans < 0) return puts("No"), 0;
    puts("Yes");
    rep(i, 1, n) {
        rep(j, 1, m) printf("%lld ", a[i][j]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 5648
import Control.Applicative

main :: IO ()
main = do
  xs <- (map read . words) <$> getLine
  putStrLn $ anstostr (qsort xs)

anstostr :: [Int] -> String
anstostr xs = show (xs !! 0) ++ " " ++ show (xs !! 1) ++ " " ++ show (xs !! 2)

qsort :: [Int] -> [Int]
qsort [] = []
qsort (x:xs) = qsort smaller ++ [x] ++ qsort larger
               where
                 smaller = [a | a <- xs, a <= x]
                 larger  = [b | b <- xs, x < b]
  

Measured memory_bytes: 3504
bingo_card = []

for i in range(3):
    bingo_card.append(list(map(int, input().split())))
    
n = int(input())
called_num = set()
for i in range(n):
    called_num.add(int(input()))
    
    
for i in range(3):
    for j in range(3):
        if bingo_card[i][j] in called_num:
            bingo_card[i][j] = -1
            
bingo = False

if bingo_card[0][0] + bingo_card[0][1] + bingo_card[0][2] == -3:
    bingo = True
if bingo_card[1][0] + bingo_card[1][1] + bingo_card[1][2] == -3:
    bingo = True
if bingo_card[2][0] + bingo_card[2][1] + bingo_card[2][2] == -3:
    bingo = True
if bingo_card[0][0] + bingo_card[1][0] + bingo_card[2][0] == -3:
    bingo = True
if bingo_card[0][1] + bingo_card[1][1] + bingo_card[2][1] == -3:
    bingo = True
if bingo_card[0][2] + bingo_card[1][2] + bingo_card[2][2] == -3:
    bingo = True
if bingo_card[0][0] + bingo_card[1][1] + bingo_card[2][2] == -3:
    bingo = True
if bingo_card[2][0] + bingo_card[1][1] + bingo_card[0][2] == -3:
    bingo = True
    
if bingo:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double x3 =pow(fabs(x1-x2),2);
    double y3 = pow(fabs(y1-y2),2);
    printf("%.5f",sqrt(x3+y3));
    return 0;
}


Measured memory_bytes: 3280
a, b, c = map(int, input().split())
n = int(input())

for i in range(n):

    if a >= b:
        b = b * 2
    elif b >= c:
        c = c * 2
    else:
        print('Yes')
        exit(0)

if a < b < c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8972
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-04 18:52:52
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

bool exist[101010];

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

  int n, m; cin >> n >> m;
  vector<int> cnt(101010, 1);

  exist[1] = true;

  for (int i = 0; i < m; ++i) {
    int x, y; cin >> x >> y;
    if (cnt[x] == 1) {
      if (exist[x]) {
        exist[x] = false;
        exist[y] = true;
      }
      --cnt[x]; ++cnt[y];
    } else {
      if (exist[x]) {
        exist[y] = true;
      }
      --cnt[x]; ++cnt[y];
    }
  }

  int ans = 0;

  for (int i = 0; i < 101010; ++i) ans += exist[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
N,M = map(int, input().split())
a = [-1]*(M+2)
a[M+1] = N+1
diff = 0
for i in range(1,M+2):
    if i != M+1: a[i] = int(input())
    diff = max(diff, a[i]-a[i-1])

inf = 10**9+7

dp = [0]*diff
dp[0] = 0
dp[1] = 1
for i in range(2,diff):
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i]%inf

cnt = 1
for i in range(1,M+2):
    da = a[i]-a[i-1]-1
    if da == 0:
        cnt = 0
        break
    else:
        cnt *= dp[da]
        cnt = cnt%inf

print(cnt%inf)


Measured memory_bytes: 6980
import sys
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline()
N,Q=map(int,input().split())
ab=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)

P=[0 for _ in range(N)]
for i in range(Q):
  p,x=map(int,input().split())
  P[p-1]+=x

def dfs(p,par):
  for i in ab[p-1]:
    if i!=par:
      P[i-1]+=P[p-1]
      dfs(i,p)

dfs(1,-12345)
print(" ".join(map(str,P)))

Measured memory_bytes: 232228
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int n,m;
    cin>>n>>m;
    vector<int64_t> a(m);
    int64_t sum=0;
    rep(i,m){
        cin>>a[i];
        sum += a[i];
    }
    if(n-sum>=0){
        cout<<n-sum<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3704
H, W  = map(int,input().split())
S = [list(map(str,input().split())) for i in range(H)]
char = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(H):
    for j in range(W):
        if S[i][j] == "snuke":
            tmp = [i,j]
ans = str(char[tmp[1]]) + str(tmp[0]+1)
print(ans)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	sx := readInt()
	sy := readInt()
	tx := readInt()
	ty := readInt()

	y := ty - sy
	x := tx - sx

	for i := 0; i < y; i++ {
		printf("U")
	}
	for i := 0; i < x; i++ {
		printf("R")
	}
	for i := 0; i < y; i++ {
		printf("D")
	}
	for i := 0; i < x; i++ {
		printf("L")
	}
	printf("L")
	for i := 0; i < y+1; i++ {
		printf("U")
	}
	for i := 0; i < x+1; i++ {
		printf("R")
	}
	printf("D")
	printf("R")
	for i := 0; i < y+1; i++ {
		printf("D")
	}
	for i := 0; i < x+1; i++ {
		printf("L")
	}
	printf("U")
	println()
}


Measured memory_bytes: 640