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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
const int INF=1001001001001001001ll;

int L[333][333],S[333][333];

signed main(){
	int N,M;
	while(cin>>N>>M,N){
		fill_n(*L,333*333,INF);
		fill_n(*S,333*333,INF);
		rep(i,M){
			int a,b,d;
			char c;
			cin>>a>>b>>d>>c;
			a--;b--;
			if(c=='L'){
				chmin(L[a][b],d);
				chmin(L[b][a],d);
			}
			else{
				chmin(S[a][b],d);
				chmin(S[b][a],d);
			}
		}

		rep(i,N)L[i][i]=S[i][i]=0;
		rep(k,N)rep(i,N)rep(j,N){
			chmin(L[i][j],L[i][k]+L[k][j]);
			chmin(S[i][j],S[i][k]+S[k][j]);
		}

		int R;cin>>R;
		vint z(R);
		rep(i,R)cin>>z[i],z[i]--;

		vint dp(N,INF);
		dp[z[0]]=0;
		for(int i=1;i<R;i++){
			vint nex(N,INF);
			rep(j,N)rep(k,N){
				chmin(nex[k],dp[j]+L[z[i-1]][j]+S[j][k]+L[k][z[i]]);
			}
			rep(j,N)chmin(nex[j],dp[j]+L[z[i-1]][z[i]]);
			dp=nex;
		}
		int ans=*min_element(all(dp));
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 4904
N = int(input())
a = list(map(int,input().split()))

sunuke = 0
araiguma = sum(a)
for i in range(N-1):
  sunuke += a[i]
  araiguma -= a[i]
  if(i==0):
     result = abs(sunuke-araiguma)
  else:
     result = min(result, abs(sunuke-araiguma))

print(result)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,k,sum = 0;
  int ans = 0;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> a;
  int count = 1;
  if(s[0] == '0') a.push_back(0);
  rep(i,n-1) {
    if(s[i] == s[i+1]) count++;
    else {
      a.push_back(count);
      count = 1;
    }
  }
  a.push_back(count);
  if(s[n-1] == '0') a.push_back(0);
  if(a.size() == 1) {
    cout << a[0] << endl;
    return 0;
  }

  k = k*2+1;
  if(k >= a.size()) {
  	rep(i,a.size()) sum += a[i];
    cout << sum << endl;
    return 0;
  }
  rep(i,k) sum += a[i];
  ans = sum;
  int l = 0; int r = k;
  rep(i,(a.size()-k)/2) {
    sum -= a[l]; l++;
    sum -= a[l]; l++;
    sum += a[r]; r++;
    sum += a[r]; r++;
    ans = max(sum,ans);
  }
  cout << ans << endl;
  return 0;
}

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

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



int main() {
    ll H, W; cin >> H >> W;
    map<char, ll> M;
    for(int i = 0; i < H; i++){
        string S; cin >> S;
        for(auto ch : S) M[ch]++;
    }
    ll o=0, t=0;
    for(auto m : M) {
        if(m.second %2 != 0) o++;
        else if(m.second % 4 != 0 && m.second % 2 == 0) t++;
    }
    bool flag = false;
    if(H % 2 == 0 && W % 2 == 0){
        if(o == 0 && t == 0) flag = true;
    }
    else if(H % 2 == 0 || W % 2 == 0){
        ll temp;
        if(H %2 == 0) temp = H;
        else temp = W;
        if(o== 0 && t <= temp/2) flag = true;
    }
    else{
        if(o == 1 && t <= H/2 + W/2)flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int A, B;
signed main()
{
    cin >> A >> B;
    if (B % A == 0)
        cout << A + B << endl;
    else
        cout << B - A << endl;
    // system("pause");
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int gcd(int a, int b) {
	return (b == 0) ? a : gcd(b, a % b);
}

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

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int a, b;
	cin >> a >> b;

	cout << lcm(a, b) << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using I = long long;
int main() {
  I A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  I res = 1e18;
  for(I i=0; i<=max<I>(X,Y)*2+2; i+=2) {
    I x = max<I>(0, X-i/2);
    I y = max<I>(0, Y-i/2);
    I sum = A*x + B*y + C*i;
    res = min<I>(res, sum);
  }
  cout << res << endl;
}


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

int main() {
    int s[5];
    for(int i=0;i<5;++i){
        cin>>s[i];
    }
    int k;cin>>k;
    if(s[4]-s[0]<=k)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

vector<int> t[20], f[20];
int ch[20];

void dfs(int u, bool& ok) {
    for(auto&&v:t[u]) {
        if(ch[v] == -1) {
            ch[v] = 1;
            dfs(v, ok);
        }
        else if(ch[v] == 0) {
            ok = false;
            return ;
        }
    }
    for(auto&&v:f[u]) {
        if(ch[v] == -1) {
            ch[v] = 0;
        }
        else if(ch[v] == 1) {
            ok = false;
            return ;
        }
    }
    return ;
}

signed main() {    

    int n;
    
    cin >> n;

    int a, x, y;

    for(int i = 0; i < n; i++) {
        cin >> a;
        for(int j = 0; j < a; j++) {
            cin >> x >> y;
            if(y)
                t[i].bash(x-1);
            else
                f[i].bash(x-1);
        }
    }
    int maxi = 0;
    for(int bit = 0; bit < (1 << n); bit++) {
        memset(ch, -1, sizeof(ch));
        bool ok = true;
        
        for(int i = 0; i < n and ok; i++) {
            if((bit>>i)&1) {
                if(ch[i] == 0) {
                    ok = false;
                    break;
                }
                ch[i] = 1;
                dfs(i, ok);
            }
        }
        if(ok)
            chmax(maxi, __builtin_popcount(bit));
    }

    cout << maxi << endl;
    
    return 0;
}



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

long long cnt(long long a){
  if(a==1){
    return 1;
  }else{
    return cnt(a/2)*2+1;
  }
}
  

int main() {
  long long HP;
  cin>>HP;
  cout<<cnt(HP);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
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(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;

    int slen = s.length();
    int l=0, r=slen-1;

    bool good = true;
    int res = 0;
    while(l <= r){
        if(s[l] == 'x' && s[r] != 'x'){
            l++;
            res++;
            continue;
        }
        if(s[l] != 'x' && s[r] == 'x'){
            r--;
            res++;
            continue;
        }
        if(s[l] == s[r]){
            l++;
            r--;
        }else{
            good = false;
            break;
        }
    }

    if(good) cout << res << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s,t,k="";
long long n,m,f[4000][4000];
int main(){
	cin>>s>>t;
	n=s.length();
	m=t.length();
	s=" "+s;t=" "+t;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i]==t[j]){
				f[i][j]=f[i-1][j-1]+1;
			}else{
				f[i][j]=max(f[i-1][j],f[i][j-1]);
			}
		}
	}
	long long i1=n,j1=m;
	while(i1>0&&j1>0){
		if(f[i1][j1]==f[i1-1][j1]) i1--;
		else{
		    if(f[i1][j1]==f[i1][j1-1]) j1--;
		    else if(f[i1][j1]==f[i1-1][j1-1]+1){
			    k=s[i1]+k;
			    i1--;
			    j1--;
		    }
		}
	}
	cout<<k;
}

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

using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x;
    rep(i, m) {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    sort(x.begin(), x.end());
    vector<int> diff;
    rep(i, m - 1) { diff.push_back(x[i + 1] - x[i]); }
    sort(diff.begin(), diff.end(), greater<int>());

    int ans = 0;
    if(n >= m) {
        cout << 0 << endl;
    } else {
        for(int i = n - 1; i < m - 1; i++) {
            ans += diff[i];
        }
        cout << ans << endl;
    }
    return 0;
}

// n = 2;
// m = 5
// 1 2 10 12 14
//  1 8  2  2
// 8 → 2 → 2 → 1
// x
// 2 + 2 + 1


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  string S,T;
  cin>>S>>T;
  int answer=(int)T.size();
  for(int i=0;i<(int)S.size()-(int)T.size()+1;i++){
    int count=0;
    for(int j=0;j<(int)T.size();j++){
      if(S.at(i+j)!=T.at(j)){
        count++;
      }
    }
    answer=min(answer,count);
  }
  cout<<answer<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vec(N+1,vector<int>(3));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin >> vec.at(i+1).at(j);
    }
  }
  
  bool possible = true;
  for(int i=0; i<N; i++){
    int x = abs(vec.at(i).at(1) - vec.at(i+1).at(1));
    int y = abs(vec.at(i).at(2) - vec.at(i+1).at(2));
    if((x+y - vec.at(i+1).at(0) + vec.at(i).at(0)) %2 != 0 || x+y > vec.at(i+1).at(0) - vec.at(i).at(0)){
      possible = false;
      break;
    }
  }
  
  if(possible){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
  string s;
  std::cin >> s;
  bool flag=true;
  // rep(i,s.size())if(s[i]!=s[s.size-i])flag=false;
  // rep(i,(s.size()-1)/2+1)if(s[i]!=s[s.size-i])flag=false;
  //
  //
  // for (int i = (s.size()+3)/2-1; i <  s.size(); i++) {
  //   if(s[i]!=s[s.size-i])flag=false;
  // }

  string a,b;
  a=s;b=s;
  reverse(a.begin(),a.end());
  if(a!=s)flag=false;

  a=s.substr((s.size()+3)/2-1,s.size());
  b=a;
  reverse(a.begin(),a.end());
  if(a!=b)flag=false;


  a=s.substr(0,(s.size()-1)/2);
  b=a;
  reverse(a.begin(),a.end());
  if(a!=b)flag=false;



  if(flag)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200, maxm = 60;
long long sum(long long a, long long b){
	a += b;
	if(a >= (1ll<<60)) a = 1ll<<60;
	return a;
}
int nxt[maxm][maxn];
long long cost[maxm][maxn];
int a[maxn];
vector<int> wh[maxn];
int main(){
	int n; long long k; cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) wh[a[i]].push_back(i);
	for(int i = 0; i < maxn; i++){
		if(wh[i].empty()) continue;
		int len = wh[i].size();
		for(int j = 0; j < len; j++){
			int from = wh[i][j];
			int to = wh[i][(j + 1) % len];
			if(from == n - 1 && to == n - 1){
				cost[0][from] = 2;
				nxt[0][from] = (to + 1) % n;
			} else if(to <= from || to == n - 1){
				cost[0][from] = 1;
				nxt[0][from] = (to + 1) % n;
			} else {
				cost[0][from] = 0;
				nxt[0][from] = (to + 1) % n;
			}
		}
	}
	for(int j = 1; j < maxm; j++){
		for(int i = 0; i < n; i++){
			nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
			cost[j][i] = sum(cost[j - 1][i],cost[j - 1][nxt[j - 1][i]]);
		}
	}
	vector<int> seq;
	int cur = 0; k--;
	for(int i = maxm - 1; i >= 0; i--){
		if(cost[i][cur] <= k){
			k -= cost[i][cur];
			cur = nxt[i][cur];
		}
	}
	set<int> now;
	vector<int> ans;
	for(int i = cur; ;){
		if(now.count(a[i])){
			while(now.count(a[i])){
				now.erase(ans.back());
				ans.pop_back();
			}
		} else {
			ans.push_back(a[i]);
			now.insert(a[i]);
		}
		if(i == n - 1 && k == 0) break;
		if(i == n - 1) k--;
		i = (i + 1) % n;
	}
	for(int v : ans) cout << v << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 164084
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

alias Appeal = Tuple!(int, "from", int, "to", bool, "isHonest");

void main() {
  auto N = readln.chomp.to!int;
  Appeal[] appeals;
  foreach(i; 0..N) {
    auto appeal_count = readln.chomp.to!int;
  
    foreach(o; 0..appeal_count) {
      auto xy = readln.split.to!(int[]);
      appeals ~= Appeal(i, xy[0] - 1, xy[1] == 1);
    }
  }

  int solve() {
    foreach(i; N.iota(0, -1)) {
      combination: foreach(c; N.iota.array.combinations(i)) {
        bool[] honests = new bool[N];
        foreach(n; c) honests[n] = true;
        foreach(ap; appeals.filter!(ap => honests[ap.from] == true)) {
          if (ap.isHonest != honests[ap.to]) continue combination;
        }
        return i;
      }
    }
    return 0;
  }

  solve().writeln;
}


Measured memory_bytes: 12156
n,l = map(int,input().split())
a = []
for i in range(1, n+1):
    a.append(l+i-1)
if a[0] > 0:
    print(sum(a) - a[0])
elif a[-1] < 0:
    print(sum(a) - a[-1])
else:
    print(sum(a))


Measured memory_bytes: 3060
main :: IO ()
main = do
  sts <- getLine
  print $ solve sts

solve :: String -> Int
solve = length . go []
  where
    go acc       []        = acc
    go acc       ('S':sts) = go ('S':acc) sts
    go ('S':acc) ('T':sts) = go acc sts
    go acc       (c:sts)   = go (c:acc) sts


Measured memory_bytes: 13948
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long A, B, C;
	cin >> A >> B >> C;

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
	{
		cout << 0;
		return 0;
	}

	cout << min(min(B * C, A * C), A * B);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c,d;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  
  if((a+d-1)/d>=(c+b-1)/b){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}


Measured memory_bytes: 1680
import numpy as np
N, M, K = map(int, input().split())
MOD = 998244353

def prepare(n, MOD):
    """
    nCr mod MOD
    :param n:
    :param MOD:
    :return:
    """
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs

facts, invs = prepare(N, MOD)
ans = 0
col = M*(M-1)**(N-K-1)%MOD
for i in range(K+1)[::-1]:
    combi = facts[N-1]*invs[N-1-i]*invs[i]
    ans += col*combi
    ans %= MOD
    col *= (M - 1)
    col %= MOD
print(ans)


Measured memory_bytes: 44292
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>1:
  b = A[0:2]
  c = sum(i for i in b)
  A.append(c/2)
  del(A[0:2])
  A.sort()
z = [str(a) for a in A]
z = ''.join(z)
print(z)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] number = new int[3];
    int i;
    for(i = 0; i < 3; i++) {
      number[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(number);
    System.out.println(number[0] + " " + number[1] + " " + number[2]);
  }
}


Measured memory_bytes: 26052
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k,i;
	int a,b;
	cin>>k;
	cin>>a>>b;
	int flag=0;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			flag=1;
			cout<<"OK";
			break;
		}
	}
	if(!flag)
	cout<<"NG"<<"\n";
}

Measured memory_bytes: 3604
from collections import deque

process,quantum=map(int,input().split())

que=deque()

for i in range(process):
    name,t=input().split()
    que.append([name,int(t)])

time=0
    
while que:
    name_t=que.popleft()
    if name_t[1]<=quantum:
        time+=name_t[1]
        print(name_t[0],time)
    else:
        time+=quantum
        name_t[1]-=quantum
        que.append(name_t)


Measured memory_bytes: 13272
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, t;
  cin >> n >> t;
  vector<P> v(n);
  rep(i, 0, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());

  vector<vector<int>> dp(n + 1, vector<int>(3001, 0));
  int ans = 0;
  rep(i, 0, n) {
    rep(j, 0, t) {
      chmax(dp[i + 1][j], dp[i][j]);
      if (j + v[i].first < t)
        chmax(dp[i + 1][j + v[i].first], dp[i][j] + v[i].second);
    }
    int now = dp[i][t - 1] + v[i].second;
    chmax(ans, now);
  }

  cout << ans << endl;
}


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

#define INF 1e9
using namespace std;

int main() {

    int N, K; cin >> N >> K;

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

    vector<long long> dp(N+K);
    for (int i = 0; i < N; ++i) {
        dp[i] = INF;
    }

    //初期値設定
    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < K; ++j) {
            dp[i+j+1] = min(dp[i+j+1], dp[i] + abs(h[i+j+1] - h[i]));
        }
    }

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a;
   cin>>a;
   int b[a];
   int ans=0;
   for(int i=0;i<a;i++){
       cin>>b[i];
   }
   int c;
   cin>>c;
   pair<int,int> d[c];
   for(int i=0;i<c;i++){
    cin>>d[i].first>>d[i].second;   
   }
   for(int i=0;i<c;i++){
    for(int j=0;j<a;j++){
     if(d[i].first==j+1){
      ans=ans+d[i].second;
     }
     else{
      ans=ans+b[j];   
     }
    }
    cout<<ans<<endl;;
    ans=0;
   }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main(void)
{
	int N;
	scanf("%d", &N);
	if (N % 2 == 0) {
		printf("0.5");
		return 0;
	}
	double K;
	K = (double)((N / 2)+1)/N;
	printf("%lf", K);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int a,b;
    cin >> a >> b;
    if(a>=13){
        cout << b << endl;
        return 0;
    }
    else if(a>=6 && a<=12){
        cout << b/2 << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 3596
#ifndef ___Class_Point
#define ___Class_Point

#include <cmath>

class Point
{
private:

	double x_;
	double y_;

public:

	Point() : x_(0), y_(0) { }

	explicit Point(double x, double y) : x_(x), y_(y) { }

	explicit Point(double x1, double y1, double x2, double y2) : x_(x2 - x1), y_(y2 - y1) { }

	double x() const { return x_; }
	double y() const { return y_; }

	void operator= (Point& p) { x_ = p.x_; y_ = p.y_; }
	
	Point operator+ (Point p) { return Point(x_ + p.x_, y_ + p.y_); }
	Point operator- (Point p) { return Point(x_ - p.x_, y_ + p.y_); }

	Point operator* (double s) { return Point(x_ * s, y_ * s); }
	Point operator/ (double s) { return Point(x_ / s, y_ / s); }
};

#endif

#ifndef ___Class_Vector
#define ___Class_Vector

typedef Point Vector;

double norm(Vector p1)
{
	return p1.x() * p1.x() + p1.y() * p1.y();
}

double abs(Vector p1)
{
	return sqrt(norm(p1));
}

double cross(Vector p1, Vector p2)
{
	return p1.x() * p2.y() - p1.y() * p2.x();
}

double dot(Vector p1, Vector p2)
{
	return p1.x() * p2.x() + p1.y() * p2.y();
}

#endif

#ifndef ___Computational_Geometry
#define ___Computational_Geometry

bool palarell(Vector p1, Vector p2)
{
	return cross(p1, p2) == 0;
}

bool palarell(Point p1_s, Point p1_e, Point p2_s, Point p2_e)
{
	return palarell(p1_e - p1_s, p2_e - p2_s);
}

bool orthogonal(Vector p1, Vector p2)
{
	return dot(p1, p2) == 0;
}

bool orthogonal(Point p1_s, Point p1_e, Point p2_s, Point p2_e)
{
	return orthogonal(p1_e - p1_s, p2_e - p2_s);
}

double dist_sqr(Point p1, Point p2)
{
	return pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2);
}

double distance(Point p1, Point p2)
{
	return sqrt(dist_sqr(p1, p2));
}

Vector projection(Vector hypo, Vector base)
{
	return base * (dot(hypo, base) / norm(base));
}

Vector reflection(Point hypo, Point base)
{
	return base + (projection(hypo, base) - hypo) * 2.0;
}

#endif

#include <cstdio>

#pragma warning(disable: 4996)

int main()
{
	int x1, y1, x2, y2, x3, y3, q;

	scanf("%d", &x1);
	scanf("%d", &y1);
	scanf("%d", &x2);
	scanf("%d", &y2);

	Point p(x1, y1, x2, y2);

	scanf("%d", &q);

	for (int i = 0; i < q; i++)
	{
		scanf("%d", &x3);
		scanf("%d", &y3);

		Point a(x1, y1, x3, y3);

		Point c = projection(a, p);

		printf("%.15f %.15f\n", x1 + c.x(), y1 + c.y());
	}

	return 0;
}

Measured memory_bytes: 2752
#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<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    ll s,t;
    cin>>s>>t;
    s--; t--;
    vector<vector<pll>> edge(n); //行き先、距離
    for(int i=0;i<m;i++){
        ll u,v,d;
        cin>>u>>v>>d;
        u--; v--;
        edge[u].push_back({v,d});
        edge[v].push_back({u,d});
    }
    vector<pll> dp(n,{E,0}); //距離、通り数
    priority_queue<pll,vector<pll>,greater<pll>> q; //距離、場所
    q.push({0,s});
    dp[s]={0,1};
    while(!q.empty()){
        pll w=q.top();
        q.pop();
        if(w.F>dp[w.S].F){continue;}
        for(const auto &e:edge[w.S]){
            if(dp[e.F].F>w.F+e.S){
                dp[e.F].F=w.F+e.S;
                dp[e.F].S=dp[w.S].S;
                q.push({dp[e.F].F,e.F});
            }
            else if(dp[e.F].F==w.F+e.S){
                dp[e.F].S+=dp[w.S].S;
                dp[e.F].S%=MOD;
            }
        }
    }
    vector<pll> dps(n,{E,0}); //距離、通り数
    q.push({0,t});
    dps[t]={0,1};
    while(!q.empty()){
        pll w=q.top();
        q.pop();
        if(w.F>dps[w.S].F){continue;}
        //cout<<w.S<<" "<<dps[w.S].F<<endl;
        for(auto &e:edge[w.S]){
            if(dps[e.F].F>w.F+e.S){
                dps[e.F].F=w.F+e.S;
                dps[e.F].S=dps[w.S].S;
                q.push({dps[e.F].F,e.F});
            }
            else if(dps[e.F].F==w.F+e.S){
                dps[e.F].S+=dps[w.S].S;
                dps[e.F].S%=MOD;
            }
        }
    }
    //for(int i=0;i<n;i++){cout<<dps[i].F<<endl;}
    ll ans=dp[t].S*dps[s].S%MOD;
    //cout<<ans<<endl;
    for(int i=0;i<n;i++){
        if(dp[i].F==dps[i].F && dp[i].F*2==dp[t].F){
            //cout<<dp[i].S*dp[i].S%MOD*dps[i].S%MOD*dps[i].S%MOD<<endl;
            ans-=dp[i].S*dp[i].S%MOD*dps[i].S%MOD*dps[i].S;
            ans%=MOD;
        }
        for(const auto &e:edge[i]){
            if(i>e.F){continue;}
            ll a=i,b=e.F;
            if(dp[a].F*2<dp[t].F && dp[b].F*2>dp[t].F && dp[a].F+e.S==dp[b].F && dp[a].F+dps[a].F==dp[t].F && dp[b].F+dps[b].F==dp[t].F){
                ans-=dp[a].S*dp[a].S%MOD*dps[b].S%MOD*dps[b].S;
                ans%=MOD;
            }
            swap(a,b);
            if(dp[a].F*2<dp[t].F && dp[b].F*2>dp[t].F && dp[a].F+e.S==dp[b].F && dp[a].F+dps[a].F==dp[t].F && dp[b].F+dps[b].F==dp[t].F){
                ans-=dp[a].S*dp[a].S%MOD*dps[b].S%MOD*dps[b].S;
                ans%=MOD;
            }
        }
    }
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 17016
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt

  var ans = 0
  while (ans == 0) {
    if (isPrime3(n)) ans = n
    n += 1
  }
  println(ans)

  def isPrime3(x: Int): Boolean = {
    if (x == 1) false
    else (2 to math.sqrt(x).toInt).forall(x % _ != 0)
  }

  def isPrime(x: Int): Boolean = {
    var result = true
    if (x > 1) {
      for (i <- 2 until x) {
        if (x % i == 0) {
          result = false
        }
      }
    } else {
      result = false
    }
    result
  }

  def isPrime2(x: Int): Boolean = {
    var result = true
    if (x > 1) {
      for (i <- 2 to math.sqrt(x).toInt) {
        if (x % i == 0) {
          result = false
        }
      }
    } else {
      result = false
    }
    result
  }
}


Measured memory_bytes: 25540
#include <stdio.h>

int main(void){

  char s[5];
  scanf("%s", s);

  if (s[0] == s[1]) {
    if (s[0] != s[2] && s[2] == s[3]) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  } else {
    if (s[0] == s[2] && s[1] == s[3]) {
      printf("Yes\n");
    } else if (s[0] == s[3] && s[1] == s[2]) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }

  return 0;
}

Measured memory_bytes: 128
// D - Handstand 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using PII = pair<int,int>;

int N;

PII first_bottom(int x){
	int f=0, b=x%10;
	while(x){
		f = x;
		x/=10;
	}
	return PII(f,b);
}

ll solve(){
	ll ans=0;
	map<PII,int> C;//[{i,j}]<int>=count

	rp(k,1,N+1) C[first_bottom(k)]++;

	rp(k,1,N+1){
		PII p = first_bottom(k);
		ans += C[{p.second, p.first}];
	}

	return ans;
}

int main(){
	cin>>N;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
x,y = map(int, input().split())
ans = 0
if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000

if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

if x + y == 2:
    ans += 400000

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[100010][3],d[100010][3];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
	d[0][0]=d[0][1]=d[0][2]=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<3;j++)
		{
			for (int k=0;k<3;k++)
			{
				if (k==j) continue;
				d[i][j]=max(d[i][j],a[i][j]+d[i-1][k]);
			}
		}
	}
	cout <<max(d[n][0],max(d[n][1],d[n][2]));
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

const int MAX_N = (int)2e5 + 5;
map<char, vector<int>> mp;
vector<pii> vec;
int order[MAX_N];
lint bit[MAX_N];

lint sum(int i){
    lint res = 0;
    while(i) {res += bit[i]; i -= i & -i;}
    return res;
}

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

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string S;
    cin>>S;
    int N = S.size();
    for(int i=0;i<N;i++){
        mp[S[i]].push_back(i);
    }
    char odd_c = '*';
    int idx = -1;
    for(auto &p : mp){
        int M = p.second.size();
        if(M%2){
            if(idx>-1) {cout<<-1<<endl; return 0;}
            else odd_c = p.first;
        }
        for(int i=0;i<M/2;i++){
            vec.emplace_back(pii(p.second[i], p.second[M-i-1]));
        }
        if(p.first==odd_c) idx = p.second[M/2];
    }

    lint ans = 0;
    sort(vec.begin(), vec.end());
    for(int i=0;i<vec.size();i++){
        pii p = vec[i];
        order[p.first] = i, order[p.second] = N - i - 1;
    }
    if(idx>-1) order[idx] = N / 2;
    for(int i=0;i<N;i++){
        ans += i - sum(order[i]+1);
        add(order[i]+1, 1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5388
# coding: utf-8
import math
n,d = map(int,input().split())
ans_count = 0
for i in range(n):
    x,y = map(int,input().split())
    length = math.sqrt(x*x + y*y)
    if (length <= d):
        ans_count+=1
        
print(ans_count)

Measured memory_bytes: 9188
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n;
  cin >> n;
  print("ABC" + to_string(n));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ds = deque<string>;
using msi = map<string, int>;

int main () {

  int times, ok = 0, res = 0;
  string aux, base;
  msi ans;
  cin >> times;
  times--;
  int all = times;
  cin >> base;
  ans[base]++;
  while (times--) {
    cin >> aux;
    ans[aux]++;
    if (aux[0] == base[base.size() - 1]) {
      ok++;
    }
    base = aux;
  }
  for (auto elem : ans) {
    if (elem.second > 1) {
      res++;
    }
  }
  if (res == 0 && ok == all) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s[n];
    for ( int i = 0 ; i < n ; i++ ) cin >> s[i];
    for ( int i = 0 ; i < 26 ; i++ ) {
        char a = i + 'a';
        int x = 0 , y = 0;
        for ( int j = 0 ; j < n ; j++ ) {
            x = 0;
            for ( int k = 0 ; k < s[j].length() ; k++ ) {
                if ( s[j][k] == a ) x++;
            }
            if( j == 0 ) y = x;
            y = min( x , y );
        }
        for ( int j = 0 ; j < y ; j++ ) cout << a;
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())

sunuke = list(range(1, N + 1, 1))

for c in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for co in range(d):
        try:
            sunuke.remove(A[co])
        except ValueError:
            pass

print(len(sunuke))

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


int main() 
{ 
    ios_base::sync_with_stdio(false);
    int r;
    cin >> r;
    double ans = 2*3.141592*r;
    printf("%.5f", ans);
    return 0; 
} 

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int main()
{
    vector<int>v;
    vector<int>v1;
    vector<int>v2;
    set <char>s;
    //int t,coun1=0,a,ans3,coun2=0,x,y=0,ans1=0,b,sum=0,flag=0,ans2;




    long long ai,t,n,a,b,sum=0,c=0,k,e,f,g;
    string str;
    string str1;

    getline(cin,str);


    if(str == "ARC")
    {
        cout << "ABC";
    }
    else
    {
        cout << "ARC";
    }




return 0;
}



Measured memory_bytes: 3572
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
def min(a,b)
  return a>b ? b : a
end
n,w=get_i
vwm=array(n,1)
n.times do|i|
  vwm[i]=get_i
end
vwm.sort!{|x,y| y[1]<=>x[1]}
dp=array(w+1,1,0)

n.times do|i|
  k=0
  while vwm[i][2]>0
    x=min(vwm[i][2],2**k)
    vwm[i][2]-=x
    w.downto(x*vwm[i][1]) do|j|
      dp[j]=max(dp[j],dp[j-x*vwm[i][1]]+x*vwm[i][0])
    end
    k+=1
  end
end
puts dp[w]


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

fn naive(xs : &Vec<i32>) -> i32 {
    xs.iter().enumerate().fold(
        std::i32::MIN,
        |ans, (i, x)| xs[0..i].iter().fold(
            ans,
            |max, y| std::cmp::max(max, (x - y).abs())
        )
    )
}

fn solve(xs : &Vec<i32>) -> i32 {
    xs.iter().max().unwrap().clone() - xs.iter().min().unwrap().clone()
}

fn main() {
    let _ : i32 = read();
    let xs : Vec<i32> = reads();
    assert_eq!(naive(&xs), solve(&xs));
    println!("{}", solve(&xs));
}


#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] s = scanner.next().toCharArray(),t = scanner.next().toCharArray();
		boolean check = false;
		for(int i=s.length-t.length;i>=0;i--){
			boolean check2 = true;
			for(int j=0;j<t.length;j++){
				if(s[i+j] != '?' && s[i+j] != t[j]){
					check2 = false;
				}
			}
			if(check2){
				check = true;
				for(int j=0;j<t.length;j++){
					s[i+j] = t[j];
				}
			}
			if(check){
				break;
			}
		}
		if(check){
			for(int i=0;i<s.length;i++){
				if(s[i] == '?'){
					System.out.print("a");
				}else{
					System.out.print(s[i]);
				}
			}
			System.out.println();
		}else{
			System.out.println("UNRESTORABLE");
		}
	}

}


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

a.sort()
b.sort()
c.sort()

ans = 0
i,k = 0,0
for j in range(n):
    bj = b[j]
    while(i<n):
        if(a[i] >= bj):
            break
        i += 1
    while(k<n):
        if(c[k] > bj):
            break
        k += 1
    ans += i * (n-k)

print(ans)

Measured memory_bytes: 115084
#include<cstdio>
using namespace std;
void func(int,int);
int h,w;
char za[101][101];
int cnt;
int flg,flg1,flg2;
int main(void)
{
	int i,j;
	
	scanf("%d %d",&h,&w);
	while(!(h==0 && w==0)){
		for(i=0;i<h;i++){
			scanf("%s",za[i]);
		}
		cnt=0;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				flg=0;
				flg1=0;
				flg2=0;
				if(za[i][j]=='#'){
					cnt++;
					flg=1;
					func(i,j);
					
				}
				else if(za[i][j]=='*'){
					cnt++;
					flg1=1;
					func(i,j);
				}
				else if(za[i][j]=='@'){
					cnt++;
					flg2=1;
					func(i,j);
				}
			}
		}
		printf("%d\n",cnt);
		scanf("%d %d",&h,&w);
	}
	return 0;
}	
void func(int y,int x)
{
	int i,j;
	if(y+1<=h){
		if(flg==1){
			if(za[y+1][x]=='#'){
				za[y+1][x]='0';
				func(y+1,x);
			}
		}
		else if(flg1==1){
			if(za[y+1][x]=='*'){
				za[y+1][x]='0';
				func(y+1,x);
			}
		}
		else if(flg2==1){
			if(za[y+1][x]=='@'){
				za[y+1][x]='0';
				func(y+1,x);
			}
		}
	}
	if(x+1<=w){
		if(flg==1){
			if(za[y][x+1]=='#'){
				za[y][x+1]='0';
				func(y,x+1);
			}
		}
		else if(flg1==1){
			if(za[y][x+1]=='*'){
				za[y][x+1]='0';
				func(y,x+1);
			}
		}
		else if(flg2==1){
			if(za[y][x+1]=='@'){
				za[y][x+1]='0';
				func(y,x+1);
			}
		}
	}
	if(y-1>=0){
		if(flg==1){
			if(za[y-1][x]=='#'){
				za[y-1][x]='0';
				func(y-1,x);
			}
		}
		else if(flg1==1){
			if(za[y-1][x]=='*'){
				za[y-1][x]='0';
				func(y-1,x);
			}
		}
		else if(flg2==1){
			if(za[y-1][x]=='@'){
				za[y-1][x]='0';
				func(y-1,x);
			}
		}
	}
	if(x-1>=0){
		if(flg==1){
			if(za[y][x-1]=='#'){
				za[y][x-1]='0';
				func(y,x-1);
			}
		}
		else if(flg1==1){
			if(za[y][x-1]=='*'){
				za[y][x-1]='0';
				func(y,x-1);
			}
		}
		else if(flg2==1){
			if(za[y][x-1]=='@'){
				za[y][x-1]='0';
				func(y,x-1);
			}
		}
	}	
}

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

using namespace std;
#define INF 1000000001


int main()
{
    string s,t;
    int ls,lt;
    cin >> s;
    cin >> t;
    ls = s.length();
    lt = t.length();

    vector<vector<int> > dp(ls+1,vector<int>(lt+1,0));

    for(int i = 1;i <= ls; i++){
        for(int j = 1;j <= lt;j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else if(s[i-1] != t[j-1]){
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    
    int ind_lcs = dp[ls][lt];
    int i = ls,j = lt;
    string ans;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans = s[i-1] + ans;
            i--;j--;   
        }else if(dp[i][j-1] > dp[i-1][j]){
            j--;
        }else{
            i--; 
        }
    }
    cout << ans << endl;
    return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n;
      scan(n);
      std::vector<long> xs(3*n);
      for(long i = 0; i < 3 * n; ++i) {
         scan(xs[i]);
      }
      std::vector<long> ys(3*n);
      std::vector<long> zs(3*n);
      {
         std::priority_queue<long> q1;
         long t = 0;
         for(long i = 0; i < n; ++i) {
            t += xs[i];
            q1.push(-xs[i]);
         }
         ys[n-1] = t;
         for(long i = n; i < 2 * n; ++i) {
            q1.push(-xs[i]);
            long s = -q1.top(); q1.pop();
            t = t - s + xs[i];
            ys[i] = t;
         }
      }
      {
         std::priority_queue<long> q2;
         long t = 0;
         for(long i = 3 * n - 1; i >= 2 * n; --i) {
            t += xs[i];
            q2.push(xs[i]);
         }
         zs[2*n] = t;
         for(long i = 2 * n - 1; i >= n; --i) {
            q2.push(xs[i]);
            long s = q2.top(); q2.pop();
            t = t - s + xs[i];
            zs[i] = t;
         }
      }
      long res = -(1LL << 60);
      for(long i = n-1; i < 2 * n; ++i) {
         res = std::max(res, ys[i] - zs[i+1]);
      }
      // for(long i = 0; i < 3 * n; ++i) {
      //    printf("%3ld ", ys[i]);
      // }
      // putchar('\n');
      // for(long i = 0; i < 3 * n; ++i) {
      //    printf("%3ld ", zs[i]);
      // }
      // putchar('\n');
      printf("%ld\n", res);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 9188
N,K = map(int, input().split())
MOD = 10**9+7
A = list(map(int, input().split()))
A.sort()




if N == 1 or K == 1:
    print(0)
    exit()


def nCr(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    # nCr = n!  / (r! * (n-r)!)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = MOD
#N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    # (a * b * c) % MOD = (a * b % MOD) * c % MOD みたいなやつを利用して、大きな値にならないように一ステップごとにMODをとる
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

# A_iがminに選ばれる回数と、maxに選ばれる回数それぞれをわけて考えて足していく
ans = 0
for i in range(N):
    # minになれるのは、iの右からK-1個選べる場合
    if N - (i+1) >= K-1:
        ans -= A[i] * nCr(N - (i+1), K-1, MOD)
    # maxになれるのは、iの左からK-1個選べる場合
    if i >= K-1:
        ans += A[i] * nCr(i, K-1, MOD)

    ans %= MOD

print(ans)

Measured memory_bytes: 20052
def rect(h, w):
    a = '#.' * 150
    b = '.#' * 150
    while h > 0:
        print(a[:w])
        a, b = b, a
        h -= 1
    print()
    return

while True:
    n = list(map(int, input().split()))
    H = n[0]
    W = n[1]
    if (H == 0 and W == 0):
        break
    rect(H, W)

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

using namespace std;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, x, y; cin >> n >> x >> y;
  x--; y--;
  vector<int> dists(n, 0);
  for(int i = 0; i<n; ++i) {
    for(int j = i+1; j<n; ++j) {
      int dist = j-i;
      if(j >= y && i <= x) {
        dist = j-y + 1 + x-i;
      }
      else if(j >= y) {
        dist = min(dist, j-y+1+i-x);
      }
      else if(i <= x) {
        dist = min(dist, y-j+1+x-i);
      }
      else {
        dist = min(dist, y-j+1+i-x);
      }

      //cout << i << " " << j << " " << dist << endl;
      dists[dist]++;
    }
  }

  for(int i = 1; i<n; ++i) {
    cout << dists[i] << endl;
  }
}


Measured memory_bytes: 256