akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

template<typename T, typename E>
struct SegmentTree{
  using F = function<T(T ,T)>;
  using G = function<T(T, E)>;
  using H = function<E(E, E)>;

  int n, height;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  vector<T> dat;
  vector<E> laz;

  SegmentTree(F f, G g, H h, T ti, E ei):
    f(f), g(g), h(h), ti(ti), ei(ei){}

  void init(int n_){
    n = 1; height = 0;
    while(n < n_) n<<=1, height++;
    dat.assign(2*n, ti);
    laz.assign(2*n, ei);
  }

  void build(const vector<T> &v){
    int n_ = v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i] = v[i];
    for(int i=n-1;i;i--)
      dat[i] = f(dat[(i<<1)|0], dat[(i<<1)|1]);
  }

  inline T reflect(int k){
    return laz[k] == ei? dat[k]:g(dat[k], laz[k]);
  }

  inline void eval(int k){
    if(laz[k] == ei) return;
    laz[(k<<1)|0] = h(laz[(k<<1)|0], laz[k]);
    laz[(k<<1)|1] = h(laz[(k<<1)|1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = ei;
  }

  inline void thrust(int k){
    for(int i=height;i;i--) eval(k>>i);
  }

  inline void recalc(int k){
    while(k>>=1)
      dat[k] = f(reflect((k<<1)|0), reflect((k<<1)|1));
  }

  void update(int a, int b, E x){
    thrust(a += n);
    thrust(b += n-1);
    for(int l=a, r=b+1;l<r;l>>=1, r>>=1){
      if(l&1) laz[l] = h(laz[l], x), l++;
      if(r&1) --r, laz[r] = h(laz[r], x);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int a, T x){
    thrust(a += n);
    dat[a] = x; laz[a] = ei;
    recalc(a);
  }

  T query(int a, int b){
    thrust(a += n);
    thrust(b += n-1);
    T vl = ti, vr = ti;
    for(int l=a, r=b+1;l<r;l>>=1, r>>=1){
      if(l&1) vl = f(vl, reflect(l++));
      if(r&1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }

};

#define F first
#define S second


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

  using pll = pair<ll,ll>;
  auto f1=[](ll a,ll b){return min(a,b);};
  auto f2=[](ll a,ll b){return a+b;};

  ll N,L;
  cin>>N>>L;
  vector<pll> A(N);
  map<ll,ll> M;
  ll cnt=0;
  const ll INF=N+100;
  for(auto &I:A){
    cin>>I.F>>I.S;
    M[I.F]=M[I.S]=0;
  }
  for(auto &I:M){I.S=cnt; cnt++;}
  for(auto &I:A){I.F=M[I.F]; I.S=M[I.S];}
  L=M[L];
  SegmentTree<ll,ll> dp(f1,f1,f1,INF,INF);
  SegmentTree<ll,ll> sumL(f2,f2,f2,0,0);
  SegmentTree<ll,ll> sumR(f2,f2,f2,0,0);
  dp.build(vector<ll>(cnt+100,INF));
  sumL.build(vector<ll>(cnt+100,0));
  sumR.build(vector<ll>(cnt+100,0));
  dp.update(0,1,0);
  sort(A.begin(),A.end());
  for(auto &I:A){
    ll x=dp.query(I.F,L+1);
    dp.update(I.S,I.S+1,x+1);
  }
  cout<<dp.query(L,L+1)<<" ";
  for(auto &I:A){
    sumL.update(I.F,I.F+1,1);
    sumR.update(I.S,I.S+1,1);
  }
  ll mx=0;
  for(ll i=0;i<=L;i++){
    ll c=sumL.query(i+1,L+10);
    if(i!=0){c+=sumR.query(0,i);}
    mx=max(mx,c);
  }
  cout<<mx+1<<endl;




  return 0;
}



Measured memory_bytes: 81932
#include<stdio.h>
int main(void){
    while(1){
        int H, W, x, y;
        scanf("%d%d", &H, &W);
        if(H == 0&&W == 0) break;
        
        for(x = 0; x < H; x++){
            for(y = 0; y < W; y++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2044
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res


N,K=LI()

print(len(list(filter(lambda x: x >= K, LI()))))


Measured memory_bytes: 11916
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        String formula = sc.nextLine();
        String[] formulaArray = formula.split(" ");
        int A = Integer.parseInt(formulaArray[0]);
        String op = formulaArray[1];
        int B = Integer.parseInt(formulaArray[2]);
        int ans = 0;
        switch (op) {
        case "+":
            ans = A + B;
            break;
        case "-":
            ans = A - B;
        default:
            break;
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 24148
/*redorblue*/
#import<stdio.h>
int main(void){
    int N, i, Rnumber = 0, Bnumber = 0;
    char s[100];

    scanf("%d", &N);
    scanf("%s", s);
    for(i = 0; i < N; i++){

    if(s[i] == 'R'){
        Rnumber += 1;
    }else{
        Bnumber += 1;
    }
    }

    if(Rnumber > Bnumber){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

int main()
{
    int S, h, m, s;
    cin >> S;
    s = S%60;
    S -= s;
    m = (S%3600)/60;
    S -= S%3600;
    h = S/3600;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using indx = size_t;

#define endl '\n'
#define get(type, args...) type args; read(args)
#define all(v) v.begin(), v.end()
#define debug(args...) { string _s = #args; \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s); istream_iterator<string> _it(_ss); \
    err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
template <typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
template <typename T>
void read(vector<T>& v) {
    for (auto& x : v) cin >> x;
}
template <typename... T>
void write(T&&... args) {
    ((cout << args << " "), ...);
    cout << '\n';
}
template <typename T>
void write(vector<T>& v) {
    for (auto x : v) cout << x << " ";
    cout << '\n';
}

int main() {
    get(ll, a, b, n);
    ll x = (n < b) ? n : b-1;
    ll ans = floor((a*x)/b);
    write(ans);
}


Measured memory_bytes: 3620
use std::io;
use std::str::FromStr;

type Range = (u64, u64);

fn input_int_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, m) = input_int_tuple();
    let mut range_vec: Vec<Range> = Vec::new();
    for i in 0..m {
        let range = input_int_tuple();
        range_vec.push(range);
    }
    range_vec.sort_by(|a, b| a.1.cmp(&b.1));
    let mut cut_points: Vec<usize> = Vec::new();
    let mut count = 0;
    for range in range_vec {
        let mut flag = false;
        for point in &cut_points {
            if range.0 <= *point as u64 {
                flag = true;
                break;
            }
        }
        if flag {
            continue;
        }
        cut_points.push(range.1 as usize - 1);
        count += 1;
    }
    // println!("{:?}", range_vec);
    println!("{}", count);
}


Measured memory_bytes: 6396
# -*- coding: utf-8 -*-

N, K = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(N)]

if N == 1:
    print(e[0][0])
    exit()

set_list = []

for i in e:
    set_list.append(set(i[1:]))


ok = set()
for i in set_list:
    for num, i2 in enumerate(set_list):
        if num == 0:
            continue
        if len(ok) >=1:
            ok = list(i2.intersection(ok))
        else:
            ok = list(i.intersection(i2))
    break

print(len(ok))


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    vl a(3);
    REP(i, 3) {
        cin >> a[i];
    }
    sort(ALL(a));
    ans = 0;
    REP(i, 2) {
        ans += a[i+1] - a[i];
    }

    MSG(ans)
}


Measured memory_bytes: 256
import heapq
N, M = map(int, input().strip().split())
A = list(map(lambda x: int(x)*(-1), input().strip().split())) # -1 for heap

heapq.heapify(A)
for i in range(M):
    mx=heapq.heappop(A)*(-1) #maximum
    heapq.heappush(A, mx//2*(-1))

print(sum(A)*(-1))

Measured memory_bytes: 14184
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
input()
ary = [int(s) for s in input().split()]

max_Hen = max(ary)
ary.remove(max(ary))
sum_Hen = sum(ary)

if(max_Hen < sum_Hen):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, m, c, ss, u[55], v[55], x[55];
vector<int> g[55];

void dfs(int p) {
	int i;
	if(x[p]) return;
	x[p] = 1;
	ss++;
	for(i=0; i<g[p].size(); i++) {
		dfs(g[p][i]);
	}
}

int f(int p) {
	int i;
	for(i=1; i<=n; i++) {
		g[i].clear();
		x[i] = 0;
	}
	ss = 0;
	for(i=0; i<m; i++) {
		if(i==p) continue;
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	dfs(1);
//	dfs(u[p]);
//	return x[v[p]];
	return (ss != n);
}


int main() {
	int i, j, k;
	cin>>n>>m;
	for(i=0; i<m; i++) {
		cin>>u[i]>>v[i];
	}
	for(i=0; i<m; i++) c += f(i);
	cout<<c;
	return 0;
}


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

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

    vector<ll> numCnt(100100);
    ll sum = 0;
    rep (i, n)
    {
        int a;
        cin >> a;
        numCnt[a]++;
        sum += a;
    }

    int q;
    cin >> q;

    vector<ll> ans(q + 1);
    ans[0] = sum;
    rep (i, q)
    {
        int b, c;
        cin >> b >> c;

        ans[i + 1] = ans[i] - numCnt[b] * b + numCnt[b] * c;
        numCnt[c] += numCnt[b];
        numCnt[b] = 0;
    }

    rep (i, q)
        cout << ans[i + 1] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

int s[52][52];

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;

    for(int i = 0; i < 52; i++){
        for(int j = 0; j < 52; j++){
            s[i][j] = -1;
        }
    }

    char tmp;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> tmp;
            if(tmp == '#'){
                s[i+1][j+1] = 1;
            }else{
                s[i+1][j+1] = 0;
            }
        }
    }

    //全探索すれば簡単。#の上下左右が 0 もしくは-1であったら不可

    bool ans = true;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(s[i][j] == 1){
                if(s[i-1][j] != 1 && s[i+1][j] != 1 && s[i][j-1] != 1 && s[i][j+1] != 1){
                    ans = false; //孤立しているマスがある
                }
            }
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


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

int main(void)
{
    long long a, b2;
    double b;

    scanf("%lld %lf", &a, &b);
    b2 = (long long)round(b * 100.0);

    long long c = a * b2;
    printf("%lld\n", c/100);

    return 0;
}

Measured memory_bytes: 2208
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a > b){
		    int temp = a;
		    a = b;
		    b = temp;
		}
		
		if(b > c){
		    int temp = b;
		    b = c;
		    c = temp;
		}
		
		if(a > b){
		    int temp = a;
		    a = b;
		    b = temp;
		}
		System.out.println(a + " " + b + " " + c);
    }
}




Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll x,k,d;
  cin >> x>>k>>d;
  ll ans;
  if(x<0){
    x=-x;
  }
  ll p=x/d;
  if(p>k){
    cout << x-k*d;
    return 0;
  }
  k=k-p;
  ans=x%d;
  if(k%2==1){
    cout <<abs(ans-d);
    return 0;
  }
  cout << ans;
}



Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>

int main() {
  int a, b;
  if (scanf("%d %d", &a, &b) < 0) {
    exit(1);
  }
  int product = a * b;
  if (product % 2 == 0) {
	printf("Even\n");
  } else {
    printf("Odd\n");
  }
  return 0;
}

Measured memory_bytes: 128
K = int(input())

S = set()
ans = 1
x = 7 % K
while True:
    if x in S:
        ans = -1
        break
    if x == 0:
        break
    ans += 1
    S.add(x)
    x = ((10 * x) % K + 7 % K ) % K

print(ans)


Measured memory_bytes: 200700
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string S,T; cin >> S >> T;
    cout << T+S << endl;
}
    



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

const int N=205;
int n,m,dep[N],fa[N][10],c[N];
int v[N],nxt[N],head[N],a[N][2];
long long ans,res;

void dfs(int x)
{
	for(int i=1;i<=5;i++) fa[x][i]=fa[fa[x][i-1]][i-1];
	for(int i=head[x];i>0;i=nxt[i])
	{
		if(v[i]==fa[x][0]) continue;
		fa[v[i]][0]=x,dep[v[i]]=dep[x]+1,dfs(v[i]);
	}
}

void dfs2(int x)
{
//	cout<<x<<' '<<c[x]<<endl;
	for(int i=head[x];i>0;i=nxt[i])
	{
		if(v[i]==fa[x][0]) continue;
		dfs2(v[i]),c[x]+=c[v[i]];
	}
	if(c[x]) res++;
}

int lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	int c=dep[x]-dep[y];
	for(int i=0;i<=5;i++) if(c&(1<<i)) x=fa[x][i];
	for(int i=5;i>=0;i--) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return x==y?x:fa[x][0];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&v[i],&v[i+n]);
		nxt[i]=head[v[i+n]],head[v[i+n]]=i;
		nxt[i+n]=head[v[i]],head[v[i]]=i+n;
	}
	dfs(1),scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i][0],&a[i][1]);
	for(int i=1;i<(1<<m);i++)
	{
		int cnt=0;
		for(int j=1;j<=n;j++) c[j]=0;
		for(int j=1;j<=m;j++)
		{
			if((i&(1<<j-1))==0) continue;
			cnt++;
			c[a[j][0]]++,c[a[j][1]]++;
			c[lca(a[j][0],a[j][1])]-=2;
		}
		res=0,dfs2(1);
//		cout<<res<<endl;
		if(cnt%2) ans+=(1ll<<n-1-res);
		else ans-=(1ll<<n-1-res);
	}
	printf("%lld\n",(1ll<<n-1)-ans);
}

Measured memory_bytes: 3796
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int dp[1000002];
int rec(int a) {
  int prev = a;
  if (dp[a] >= 0) return dp[a];
  if (a == 1) return 0;
  if (a % 2) {
    a *= 3;
    a++;
  } else {
    a >>= 1;
  }
  return dp[prev] = 1 + rec(a);
}

int main() {
  memset(dp, -1, sizeof dp);
  int n;
  while (cin >> n, n) {
    cout << rec(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC target ("arch=ivybridge,tune=ivybridge")
#include <cstdio>
#include <vector>
#include <utility>
#include <map>

/*
\cap_{u,v} \cup_{i\in (u,v) path} E_i

g(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} = N}|
G(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} \subseteq N}|
     = |{E | {u,v\in M-N | \cap_{i\in (u,v) path} !E_i}}|
*/

int n, m;
std::vector<int> E[50];

long long int A[1<<20];
std::map<std::pair<int, int>, int> edges;

long long int dfs(int u, int v, int p){
  if(u == v) return 0;
  for(int x: E[u]){
    if(x == p) continue;
    long long int b = dfs(x, v, u);
    if(b != -1) return (1LL << edges[{u, x}]) | b;
  }
  return -1;
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    E[a-1].push_back(b-1);
    E[b-1].push_back(a-1);
    edges[{a-1,b-1}] = i;
    edges[{b-1,a-1}] = i;
  }
  scanf("%d", &m);
  for(int i = 0; i < m; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    A[1<<i] = dfs(a-1, b-1, -1);   
  }
  long long int ans = 1LL << (n-1);
  for(int i = 1; i < (1<<m); i<<=1){
    for(int j = 0; j < i; j++){
      int k = i + j;
      A[k] = A[j] | A[i];
      long long int x = 1LL << (n-1-__builtin_popcountll(A[k]));
      ans += (1-2*__builtin_parity(k))*x;
    }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 8448
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;

int main(){
    long double a;
    scanf("%Lf", &a);
    a/=3.0;
    printf("%.10Lf\n", a*a*a);
    
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	lint n, in; cin >> n;
	vector<lint> a;
	rep(i, n) {
		cin >> in;
		a.push_back(in);
	}
	co(abs(vmax(a) - vmin(a)));
	gc();
}

Measured memory_bytes: 256
import math
N = int(input())
A = list(map(int, input().split()))

ave = sum(A)//N
cost1 = 0
cost2 = 0
cost = []
for i in A:
    cost1 += math.pow((i - ave), 2)
cost.append(cost1)

for i in A:
    cost2 += math.pow((i - ave - 1), 2)
cost.append(cost2)


print(int(min(cost)))


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


int main(){

    int w, h, n;
    cin >> w >> h >> n;

    int big_x = w;
    int big_y = h;
    int small_x = 0;
    int small_y = 0;

    int x, y, a;

    for(int i=0; i<n; i++){
        cin >> x >> y >> a;

        switch (a){
        
            case 1:
                small_x = max(small_x, x);
                break;

            case 2:
                big_x = min(big_x, x);
                break;
            
            case 3:
                small_y = max(small_y, y);
                break;

            case 4:
                big_y = min(big_y, y);
                break;
        }
    }
   
    cout << max((big_x - small_x),0)*max(0,(big_y - small_y)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define maxn 200005
using namespace std;
int f[maxn][2];
struct node{ int l, r, mx[2]; }tree[maxn * 4];
void build(int rt, int l, int r){
	tree[rt].l = l, tree[rt].r = r;
	if (l == r)
		return;
	build(rt << 1, l, l + r >> 1);
	build(rt << 1 | 1, (l + r >> 1) + 1, r);
}
void update(int rt, int x, int y){
	if (tree[rt].r < x || x < tree[rt].l)
		return;
	if (tree[rt].l == tree[rt].r){
		tree[rt].mx[0] = f[y][0], tree[rt].mx[1] = f[y][1];
		return;
	}
	update(rt << 1, x, y);
	update(rt << 1 | 1, x, y);
	tree[rt].mx[0] = max(tree[rt << 1].mx[0], tree[rt << 1 | 1].mx[0]);
	tree[rt].mx[1] = max(tree[rt << 1].mx[1], tree[rt << 1 | 1].mx[1]);
}
pair <int, int> query(int rt, int l, int r){
	if (tree[rt].r < l || r < tree[rt].l)
		return make_pair(0, 0);
	if (l <= tree[rt].l && tree[rt].r <= r)
		return make_pair(tree[rt].mx[0], tree[rt].mx[1]);
	pair <int, int> p1 = query(rt << 1, l, r), p2 = query(rt << 1 | 1, l, r);
	return make_pair(max(p1.first, p2.first), max(p1.second, p2.second));
}

int n, a[maxn], great[maxn], s[maxn];
bool check(int x, int to){
	if (to < 0)
		return false;
	pair <int, int> p = query(1, x + 1, n);
	if ((p.first - to & 1) == 0)
		return p.first >= to;
	else
		return p.second >= to;
}
int read(){
	int cnt = 0;
	char ch = getchar();
	while (ch < '0' || '9' < ch)
		ch = getchar();
	while ('0' <= ch && ch <= '9'){
		cnt = cnt * 10 + ch - '0';
		ch = getchar();
	}
	return cnt;
}
int main(){
	n = read();
	for (int i = 1; i <= n; ++ i)
		a[i] = read();
	for (int i = 1, mx = 0; i <= n; ++ i)
		if (a[i] > mx){
			mx = a[i];
			great[i] = true;
		}
	for (int i = n; i; -- i)
		s[i] = great[i] + s[i + 1];
	build(1, 1, n);
	for (int i = n; i; -- i){
		int t = 1 + great[i];
		pair <int, int> p = query(1, a[i] + 1, n);
		f[i][p.first + t & 1] = max(f[i][p.first + t & 1], p.first + t);
		f[i][p.second + t & 1] = max(f[i][p.second + t & 1], p.second + t);
		update(1, a[i], i);
	}
	if (! check(0, s[1])){
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1, pos0 = 0, pos1 = 0, len0 = 0, len1 = 0; i <= n; ++ i){
		f[i][0] = f[i][1] = 0;
		update(1, a[i], i);
		int x = a[i] > a[pos0] ? i : pos0;
		int y = len0 + (x == i);
		if (check(a[x], len1 + s[i + 1] - y) || check(a[pos1], y + s[i + 1] - len1)){
			pos0 = x, len0 = y;
			printf("0");
		}
		else{
			pos1 = a[i] > a[pos1] ? i : pos1;
			len1 += pos1 == i;
			printf("1");
		}
	}
}


Measured memory_bytes: 14848
#![allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

const M: usize = 998244353;

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let d: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    if d[0] != 0 {
        println!("{}", 0);
        return;
    }

    let mut e = vec![0; n];
    let mut max_e = 0;
    for a in d {
        e[a] += 1;
        if a > max_e {
            max_e = a;
        }
    }

    // debugln!("{:?}", e);
    // debugln!("{}", max_e);

    if e[0] != 1 {
        println!("{}", 0);
        return;
    }

    let mut res = 1;
    for i in 1..(max_e + 1) {
        res *= pow_mod(e[i - 1], e[i]);
        res %= M;
    }

    println!("{}", res);

    // debugln!("{}", pow_mod(0, 0));
    // debugln!("{}", pow_mod(0, 1));
    // debugln!("{}", pow_mod(0, 2));
    // debugln!("{}", pow_mod(0, 3));
    // debugln!("{}", pow_mod(10, 0));
    // debugln!("{}", pow_mod(3, 1));
    // debugln!("{}", pow_mod(2, 2));
    // debugln!("{}", pow_mod(2, 3));
    // debugln!("{}", pow_mod(2, 10000000000000000000));
}

fn pow_mod(a: usize, b: usize) -> usize {
    if a == 0 {
        return 0;
    }
    if b == 0 {
        return 1;
    }

    if b % 2 == 0 {
        pow_mod(a, b / 2).pow(2) % M
    } else {
        (pow_mod(a, b - 1) * a) % M
    }
}


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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

const int N=1e6+5;
int k,n;
int s[N];

int main()
{
    k=read(),n=read();
    for(int i=1;i<=n;i++)s[i]=read();
    sort(s+1,s+n+1);
    int mx=-1;
    for(int i=1;i<n;i++)mx=max(mx,s[i+1]-s[i]);
    mx=max(mx,s[1]+k-s[n]);
    printf("%d",k-mx);
    return 0;
}


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

int gcd(int a, int b){
    if (b < a){
        int tmp = b;
        b = a;
        a = tmp;
    }
    if (a == 0){
        return b;
    }else{
        return gcd(b % a, a);
    }
}

int main(){
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
int main() {
	int k, s, sum = 0;
	cin >> k >> s;
	for (int i = 0; i <= k&&i<=s; i++) {
		for (int j = 0; j <= k&&i + j <= s; j++) {
			if (s - i - j <= k) sum++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		sx, sy, tx, ty int
	)
	fmt.Scan(&sx, &sy, &tx, &ty)
	dx, dy := tx-sx, ty-sy
	fmt.Printf("%s%s%s%s%s%s%s%s%s%s%s%s\n",
		strings.Repeat("U", dy),
		strings.Repeat("R", dx),
		strings.Repeat("D", dy),
		strings.Repeat("L", dx),
		strings.Repeat("L", 1),
		strings.Repeat("U", dy+1),
		strings.Repeat("R", dx+1),
		strings.Repeat("D", 1),
		strings.Repeat("R", 1),
		strings.Repeat("D", dy+1),
		strings.Repeat("L", dx+1),
		strings.Repeat("U", 1),
	)
}


Measured memory_bytes: 1920
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
//#include <iomanip.h>
#include <limits.h>
//#include <strstrea.h>
//#include <fstream.h>
#define ll long long
#define ull unsigned long long
//#define int64 long long
#define INF  0x3f3f3f3f

using namespace std;

const int maxn = 1e6 + 5;
int n;

int main() {
    cin >> n;
    if (n < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0)
				break;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y)
{
	return x==0?y:gcd(y%x,x);
}
long long a,b,c,d;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long lcm=c*d/gcd(c,d);
	printf("%lld",(b-a+1)-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/lcm-(a-1)/lcm));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 8
#define Free -1
#define NFree 1
#define true 1
#define false 0

int row[N], col[N], dleft[2 * N - 1], dright[2 * N - 1];
int board[N][N];

void initialize()
{
    int i;
    for (i = 0; i < N; i++)
    {
        row[i] = Free;
        col[i] = Free;
    }
    for (i = 0; i < 2 * N - 1; i++)
    {
        dleft[i] = Free;
        dright[i] = Free;
    }
}

void printBoard(void)
{
    int i, j;
    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            if (board[i][j])
            {
                if (row[i] != j)
                    return;
            }
        }
    }
    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            if (row[i] == j)
            {
                printf("Q");
            }
            else
                printf(".");
        }
        printf("\n");
    }
}

void recursive(int i)
{
    if (i == N)
    {
        printBoard();
        return;
    }
    int j;
    for (j = 0; j < N; j++)
    {
        if (NFree == col[j] || NFree == dleft[i + j] || NFree == dright[i - j + N - 1])
            continue;
        row[i] = j;
        col[j] = dleft[i + j] = dright[i - j + N - 1] = NFree;
        recursive(i + 1);
        row[i] = col[j] = dleft[i + j] = dright[i - j + N - 1] = Free;
    }
}
int main()
{
    initialize();
    int k, r, c, i, j;

    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            board[i][j] = false;
        }
    }

    scanf("%d", &k);
    for (i = 0; i < k; i++)
    {
        scanf("%d %d", &r, &c);
        board[r][c] = true;
    }

    recursive(0);

    return 0;
}


Measured memory_bytes: 2108
n = int(input())
sin60 = 3 ** 0.5 / 2
cos60 = 1 / 2

def kach(d, A, B):
    if d == n:
        print('{0:.8f} {1:.8f}'.format(*B))
        return True
    x0, y0 = A
    x1, y1 = B

    dx = (x1 - x0) / 3
    dy = (y1 - y0) / 3

    sx = x0 + dx
    sy = y0 + dy

    tx = x0 + 2 * dx
    ty = y0 + 2 * dy

    ux = sx + (dx * cos60 - dy * sin60)
    uy = sy + (dx * sin60 + dy * cos60)

    S, T, U = (sx, sy), (tx, ty), (ux, uy)
    d += 1
    kach(d, A, S), kach(d, S, U), kach(d, U, T), kach(d, T, B)
start = (0.0, 0.0)
end = (100.0, 0.0)
print('{0:.8f} {1:.8f}'.format(*start))
kach(0, start, end)





Measured memory_bytes: 5700
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = []
for _ in range(Q):
    b,c = map(int,input().split())
    BC.append((b,c))
from collections import Counter
AA = Counter(A)
S = sum(A)
for b,c in BC:
    S += (c-b)*AA[b]
    AA[c] += AA[b]
    AA[b] = 0
    print(S)

Measured memory_bytes: 35116
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
ll V[100007];

int main(){
    cin >> A >>B >> C;
    cout << (A+B+C>=22 ? "bust" : "win") << endl;
}


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

int main() {
  int n; cin>>n;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++){
    int x; cin>>x;
    a[i]=x;
    b[i]=x;
  }
  sort(a.begin(),a.end());
  vector<int>c;
  for(int i=0;i<n;i++){
    if(a[i]!=b[i]) c.push_back(a[i]);
  }
  if(c.size()==2 ||c.size()==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bitset>
#include <cassert>
#include <iostream>
#include <stack>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> G(N);
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }

  int M;
  cin >> M;
  vector<int64_t> edge_info(M);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    stack<pair<int, int64_t>> dfs;
    dfs.emplace(u, 0);
    vector<bool> visit(N, false);
    visit[u] = true;
    while (!dfs.empty()) {
      int nu;
      int64_t info;
      tie(nu, info) = dfs.top();
      dfs.pop();
      if (nu == v) {
        edge_info[i] = info;
        break;
      }
      for (auto& nv : G[nu]) {
        if (visit[nv.first]) continue;
        visit[nv.first] = true;
        dfs.emplace(nv.first, info | (1LL << nv.second));
      }
    }
  }

  int64_t answer = 0;
  for (int m = 0; m < (1 << M); ++m) {
    int m_cnt = 0;
    int64_t edge_sum = 0;
    for (int n = 0; n < M; ++n) {
      if (m & (1 << n)) {
        edge_sum |= edge_info[n];
        ++m_cnt;
      }
    }

    int white = bitset<50>(edge_sum).count();
    int64_t conv = 1LL << (N - 1 - white);
    if (m_cnt % 2) {
      answer -= conv;
    } else {
      answer += conv;
    }
  }
  cout << answer << endl;
  return 0;
}


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
};

int get_r(Cube a, int x, int y){
  for ( int i = 0; i < 6; i++ ){
    for ( int j = 0; j < 4; j++ ){
      if ( a.f[0]==x && a.f[1]==y ) return a.f[2];
      a.roll_z();
    }
 
    if ( i%2 == 0 ) a.roll_y();
    else a.roll_x();
  }
}
int main(){
  Cube c;
  int q, tp, fr, r;

  for ( int i = 0; i < 6; i++ ) cin >> c.f[i];
  cin >> q;

  for ( int i = 0; i < q; i++ ){
    cin >> tp >> fr;

    r = get_r(c, tp, fr);
    cout << r << endl;
  }

  return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
    int m,n,i,sum=0,count=0;
    scanf("%d%d",&n,&m);
    int a[n];
    float res,temp;
    res=(1/(4.0*m));
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    for(i=0;i<n;i++)
    {
        temp=(a[i]*1.0)/(sum*1.0);
        if(temp>=res)
        {
            count++;
        }
    }
    if(count>=m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	int now=0;
	int cnt=0;
	while(cnt<=2*n){
		now=a[now];
		cnt++;
		if(now==1) break;
	}
	if(cnt<=2*n) cout<<cnt<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0 ; i < (n); ++i)
#define rrep(i,n) for(i  1; i <= (n); ++i)
#define drep(i,n) for(i  (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int i,a,b,ans,c;
ans = INF;
string s;
cin >> s;

rep(i,s.size()-2){
   c = STI(s.substr(i,3)); 
   ans = min(ans,abs(c-753));
}
cout << ans << endl;
///////////////////////////////////////////////////////
return 0;}

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

int main(){
	string s;
	int n,a;
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		s[i]+=n;
		if(s[i]>'Z'){
			s[i]-=26;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    A.sort(reverse=True)

    ans = 0
    now = 1000
    for i in range(n):
        if now > A[i]:
            ans += 1
            now = A[i]
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // Aiの値は周期性がありそう、M < 10^5
    ll N, X, M;
    cin >> N >> X >> M;
    set<ll> st;
    vector<ll> A;
    A.push_back(X);
    while (1) {
        X = X * X % M;
        if (st.find(X) != st.end()) break;
        A.push_back(X);
        st.insert(X);
    }
    ll ind = find(A.begin(), A.end(), X) - A.begin();
    ll length = sz(A) - ind;
    ll ans = 0;
    ll time = (N - ind) / length;
    ll remain = (N - ind) % length;
    for (int i = 0; i < sz(A); i++) {
        if (i < ind) ans += A[i];
        else {
            if (i - ind < remain) ans += A[i];
            ans += A[i] * time;
        }
    }
    cout << ans << '\n';
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 5924
n, W = map(int, input().split())
w, v = [], []
inf = 10 ** 13
for _ in range(n):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
V = sum(v)

#dp[i][j] = i個までで価値jの重みの最小値
dp = [[inf for _ in range(V+1)] for _ in range(n+1)]
dp[0][0] = 0
for i in range(1, n+1):
    for j in range(V+1):
        if j >= v[i-1]:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j - v[i-1]] + w[i-1])
        else:
            dp[i][j] = dp[i-1][j]

for i in range(V, -1, -1):
    if dp[n][i] <= W:
        print(i)
        break

Measured memory_bytes: 171120
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: a,b,c,d
    
    read*, a,b,c
    d = (c-(a+b))

    if (d <= 0 ) then
        print'(a)', 'No'
        stop
    end if

    if (d*d > 4*a*b) then
        print'(a)', 'Yes'
    else
        print'(a)', 'No'
    end if
end program name

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define USE 2

using namespace std;

bool Find;
vector<int> soe,check,vl,cu;
vector< vector<int> > el;

void dfs(int nov) {
	if (!Find) {
		int ind = 0;
		int v = vl[nov-1];
		check[v] = 1;
		for (int i = 0; i < soe[v]; ++i) {
			if (cu[el[v][i]] == 1) {
				cu[el[v][i]] = -v;
			}
			else if (cu[el[v][i]] == USE) {
				for (int j = ind; j < nov; ++j) {
					if (vl[j] == el[v][i]) {
						ind = j;
						Find = true;
					}
				}
			}
		}
		if (Find) {
			cout << nov-ind << endl;
			for (int i = ind; i < nov; ++i) {
				cout << vl[i]+1 << endl;
			}
			return;
		}
		for (int i = 0; i < soe[v]; ++i) {
			if (cu[el[v][i]] == -v) {
				cu[el[v][i]] = USE;
				vl[nov] = el[v][i];
				dfs(nov+1);
				cu[el[v][i]] = -v;
			}
		}
		for (int i = 0; i < soe[v]; ++i) {
			if (cu[el[v][i]] == -v) {
				cu[el[v][i]] = 1;
			}
		}
	}
	return;
}

int main(void) {
	int u,v,N,M;
	scanf("%d %d",&N,&M);
	soe = vector<int>(N,0);
	el = vector< vector<int> >(N,vector<int>(N));
	for (int i = 0; i < M; ++i) {
		scanf("%d %d",&u,&v);
		el[u-1][soe[u-1]] = v-1;
		++soe[u-1];
	}
	int s = 0;
	check = vector<int>(N,0);
	cu = vector<int>(N,1);
	vl = vector<int>(N);
	Find = false;
	while (!Find && s < N) {
		if (check[s] == 0) {
			vl[0] = s;
			cu[s] = USE;
			dfs(1);
			cu[s] = 1;
		}
		++s;
	}
	if (!Find) {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
int cnt=0;int ans=9999;  str s,t;
  cin>>s>>t;
  rep(i,s.size()-t.size()+1){
   cnt=0;
    rep(j,t.size()){
      cnt+=(!(s[i+j]==t[j]));
    }
    ans=min(ans,cnt);}cout<<ans;
}

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

using namespace std;

const int MAXN = 100010;

int n;
pair < int, int > a[MAXN];

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

  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;

  sort(a, a + n);

  vector<int> f(n + 1);

  fill(f.begin(), f.end(), (int) 1e9 + 7);
  f[0] *= -1;

  int ans = 0;
  for(int i = 0; i < n; ++i) {
    auto p = upper_bound(f.begin(), f.end(), a[i].first - a[i].second) - f.begin();
    ans = max(ans, (int)p);
    f[p] = min(f[p], a[i].first + a[i].second);
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            int L = S.length();
            for (int i = 1; i < L; i++) {
                String sub = S.substring(0, L - 1 - i);
                if (is(sub)) {
                    System.out.println(sub.length());
                    return;
                }
            }
        }
    }

    private static boolean is(String sub) {
        int L = sub.length();
        if (L % 2 == 1) {
            return false;
        }
        int L2 = L / 2;
        for (int i = 0; i < L2; i++) {
            if (sub.charAt(i) != sub.charAt(L2 + i)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String o = sc.next();
        String e = sc.next();
        String newStr = new String();
        int tempO = o.length();
        int tempE = e.length();
        int i;
        for (i = 0; i < tempE; i++) {
                newStr+=o.charAt(i);
                newStr+=e.charAt(i);
        }
        if (tempO > i)
            newStr+=o.charAt(tempO - 1);
        System.out.println(newStr);
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + c == 2 * b ? "YES\n" : "NO\n");
}

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

int main()
{
	int n;
	
	while (cin >> n, n){
		int ice[10] = {0};
		int num;
		
		for (int i = 0; i < n; i++){
			cin >> num;
			ice[num]++;
		}
		
		for (int i = 0; i < 10; i++){
			if (ice[i]){
				for (int j = 0; j < ice[i]; j++){
					cout << "*";
				}
			}
			else {
				cout << "-";
			}
			cout << endl;
		}
	}
	
	return (0);
}

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

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

    double ans = 0;

    REP(i,n) {
        double x; cin >> x;
        ans += 1.0 / x;
    }

    ans = 1.0 / ans;

    cout << setprecision(10) << ans << endl;
    
    return 0;
}

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

int main(){
      int n;cin >> n;
      int arr[n + 10];
      int ans = 0;
      for(int i = 0;i < n;i++)cin >> arr[i];
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            arr[i] -= t;
            if(arr[i] > 0)ans += arr[i];
      }
      cout << ans;
}

Measured memory_bytes: 384