akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int mod=1e9+7;
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
ll solve(ll h,ll w){
	//cerr<<h<<" "<<w<<endl;
	ll t=__gcd(h,w),a=h/t*w;
	return ksm(2,t)+(ksm(2,h)-1)+(ksm(2,w)-1)-1;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int h=read(),w=read(),T=read();
	int hh=h/__gcd(h,T),ww=w/__gcd(w,T);
	cout<<ksm(solve(hh,ww),(ll)(h/hh)*(w/ww)%(mod-1))<<endl;
}


Measured memory_bytes: 3640
N,A,B= map(int,input().split())

m = abs(B-A)
if m%2==0:
    ans = m//2
else:
    ans1 = N-B+1
    A1 = A+N-B+1
    ans1 += (N-A1)//2
    
    ans2 = A
    B2 = B-A
    ans2 += (B2-1)//2
    ans = min(ans1,ans2)
    
    
print(ans)        

Measured memory_bytes: 3064
N = int(input())
T, A = map(int, input().split())
lst = list(map(int, input().split()))
ans_lst = []
for i in lst:
    tem = T - i * 0.006
    ans_lst.append(abs(A - tem))
index_num = ans_lst.index(min(ans_lst))
print(index_num + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	ll ans;
	cin >> N;
	if (N % 2 == 0) ans = (ll)N;
	else ans = (ll)N * 2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var s = sc.intarr;

        int n = s[0];
        int m = s[1];
        int x = s[2];

        var a = sc.intarr;

        int ans = 0;

        for (int i = 0; a[i] < x; ++i)
        {
            ans++;
        }
        wr.wri(Math.Max(0,Math.Min(ans, m - ans)));
        

    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, A, B; cin >> n >> A >> B;
  ll n1 = n/2, n2 = n-n1;
  vector<ll> a1(n1), b1(n1), c1(n1);
  vector<ll> a2(n2), b2(n2), c2(n2);
  rep(i, n1) cin >> a1[i] >> b1[i] >> c1[i];
  rep(i, n2) cin >> a2[i] >> b2[i] >> c2[i];
  ll m = n/2;
  map<ll, ll> v;
  rep(i, 1, 1LL<<n1) {
    ll a = 0, b = 0, c = 0;
    rep(j, n1) {
      if (i>>j & 1) {
        a += a1[j];
        b += b1[j];
        c += c1[j];
      }
    }
    ll x = a * B - b * A;
    if (v.count(x) > 0) chmin(v[x], c);
    else v[x] = c;
  }
  ll ans = linf;
  rep(i, 1LL<<n2) {
    ll a = 0, b = 0, c = 0;
    rep(j, n2) {
      if (i>>j & 1) {
        a += a2[j];
        b += b2[j];
        c += c2[j];
      }
    }
    ll x = b * A - a * B;
    if (i != 0 && x == 0) {
      chmin(ans, c);
    }
    else if (v.count(x) > 0) {
      chmin(ans, v[x] + c);
    }
  }
  if (ans == linf) cout << -1 << endl;
  else cout << ans << endl;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mod = 998244353;

int n, K;
int l[15], r[15];
int dp[1 << 18], s[1 << 18];

int qry(int a, int b) {
	a = max(a, 1);
	if (b < a) return 0;
	return (s[b] + mod - s[a - 1]) % mod;
}

int main() {
	scanf("%d %d", &n, &K);
	rep(i, K) scanf("%d %d", &l[i], &r[i]);
	dp[1] = s[1] = 1;
	for (int i = 2; i <= n; ++ i) {
		rep(j, K) (dp[i] += qry(i - r[j], i - l[j])) %= mod;
		s[i] = (s[i - 1] + dp[i]) % mod;
	}
	printf("%d\n", dp[n]);
	return 0;
}


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

int main(){
  int n,m,l[1000000],r[1000000];
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>l[i]>>r[i];
  }
  int mxl=0,mnr=n;
  for(int i=0;i<m;i++){
    mxl=max(mxl,l[i]);
    mnr=min(mnr,r[i]);
  }
  int ans=mnr-mxl+1;
  cout<<max(0,ans)<<endl;
}
  

  


Measured memory_bytes: 6528
n,m,x=input().split()
N=int(n);M=int(m);X=int(x)
a=[int(x) for x in input().split()]

L=0
R=0
i=X
while i!=0:
    if i-1 in a:
        L+=1
    i-=1
i=X
while i!=N:
    if i+1 in a:
        R+=1
    i+=1
print(min(L,R))
    


Measured memory_bytes: 3060
class BIT:
  def __init__(self,n,li):
    self.n = n
    self.el = [0] + li
    self.data = [0]*(n+1)
    for i in range(1,n+1):
      self.data[i] = sum(self.el[i+1-(i&-i):i+1])
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self,i,x):
    self.el[i] += x
    while  i <= self.n:
      self.data[i] += x
      i += i & -i
  def get(self,i,j=None):
    if j is None:
      return self.el[i]
    return self.sum(j)-self.sum(i-1)
n,q = map(int,input().split())
a = list(map(int,input().split()))
bt = BIT(n,a)
for _ in range(q):
  i,j,k = map(int,input().split())
  if i == 0:
    bt.add(j+1,k)
  else:
    print(bt.get(j+1,k))


Measured memory_bytes: 136016
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    int N;
    long[] A;
    List<int>[] es;
    
    public bool calc2()
    {
        N = cin.nextInt();
        A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextLong();
        }
        es = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            es[i] = new List<int>();
        }

        for (int i = 0; i < N - 1; i++)
        {
            int a = cin.nextInt() - 1;
            int b = cin.nextInt() - 1;
            es[a].Add(b);
            es[b].Add(a);
        }


        max = new long[N];
        min = new long[N];
        if (!dfs(0, -1)) return false;
        if (max[0] >= 0 && min[0] <= 0) return true;
        return false;
    }

    long[] max, min;

    bool dfs(int now, int pre)
    {
        long T = A[now];

        foreach (var next in es[now])
        {
            if (next == pre) continue;
            if (!dfs(next, now)) break;
        }

        long minsum = 0;
        foreach (var next in es[now])
        {
            if (next == pre) continue;
            minsum += min[next];
            if (min[next] > T) return false;
        }
        if (minsum > 2 * T) return false;

        long maxsum = 0;
        foreach (var next in es[now])
        {
            maxsum += Math.Min(T, max[next]);
        }

        if(es[now].Count == 1)
        {
            min[now] = Math.Max(0, T - maxsum);
            max[now] = Math.Min(T, 2 * T - minsum);
        }
        else
        {
            min[now] = Math.Max(0, 2 * T - maxsum);
            max[now] = Math.Min(T, 2 * T - minsum);
        }

        if (min[now] > max[now]) return false;
        return true;
    }

    public void calc()
    {
        if (calc2()) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
    
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

using namespace std;

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

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

  vector<int> q(p);
  sort(q.begin(), q.end());

  int cnt = 0;
  for(int i = 0; i < n; i++) if(p[i] != q[i]) cnt++;
  cout << (cnt == 0 || cnt == 2 ? "YES" : "NO") << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3120
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


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

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int> > a(n, vector<int>(m));

    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }

    int res = LINF;

    for(int bit = 1; bit < 1 << n; ++bit){
        int cost = 0;
        vector<int> sum(m);
        rep(i,n){
            if(bit & 1 << i){
                cost += c[i];
                rep(j,m){
                    sum[j] += a[i][j];
                }
            }
        }
        rep(i,m){
            if(sum[i] < x) goto ng;
        }
        chmin(res, cost);
        ng:;
    }

    cout << (res != LINF ? res : -1ll) << '\n';

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int MAX_N=8;
int n,A,B,C;
int L[MAX_N];
int use[MAX_N];
int ans=INF;
void calc()
{
	int a[MAX_N]={};
	int c[MAX_N]={};
	for(int i=0;i<n;i++)a[use[i]]+=L[i],c[use[i]]++;
	int ret=0;
	for(int i=0;i<n;i++)ret=ret+max((c[i]-1)*10,0);
	int mi=INF;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				if(i==j || i==k || j==k || a[i]==0 || a[j]==0 || a[k]==0)continue;
				mi=min(mi,abs(a[i]-A)+abs(a[j]-B)+abs(a[k]-C));
			}
		}
	}
	ans=min(ans,ret+mi);
/*	if(a[0]==300 && a[1]==777 && a[2]==1000)
	{
		for(int i=0;i<n;i++)cout<<c[i]<<" ";
		cout<<endl;
		for(int i=0;i<n;i++)cout<<a[i]<<" ";
		cout<<endl;
		cout<<ret<<' '<<mi<<endl;
	}*/
//	cout<<ret<<' '<<mi<<endl;
}
void dfs(int k)
{
	if(k==n)
	{
		calc();
		return;
	}
	for(int i=0;i<=k;i++)
	{
		use[k]=i;
		dfs(k+1);
	}
}
int main()
{
	cin>>n>>C>>B>>A;
	for(int i=0;i<n;i++)cin>>L[i];
	dfs(0);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    char s[12],t[12];
    int n;
    scanf("%s",s);
    scanf("%s",t);
    
    n = strlen(s);
    
    if(strncmp(s,t,n) == 0)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 3752
#include <cstdio>
#include <vector>
using namespace std;

int main(){
	int n, m;
	vector<int> a;
	scanf("%d %d", &n, &m);
	for (int i=0; i<2*n; i++){
		a.push_back(i+1);
	}
	int k;
	for (int i=0; i<m; i++){
		vector<int> t1, t2;
		scanf("%d", &k);
		if(k == 0){
			for (int j=0; j<n; j++){
				t1.push_back(a[j]);
				t2.push_back(a[n+j]);
			}
			a.clear();
			for (int j=0; j<n; j++){
				a.push_back(t1[j]);
				a.push_back(t2[j]);
			}
		}else{
			for (int j=0; j<k; j++){
				t1.push_back(a[j]);
			}
			for (int j=0; j<2*n-k; j++){
				t2.push_back(a[k+j]);
			}
			a.clear();
			for (int j=0; j<2*n-k; j++){
				a.push_back(t2[j]);
			}
			for (int j=0; j<k; j++){
				a.push_back(t1[j]);
			}
		}
	}
	for (int i=0; i<2*n; i++){
		printf("%d\n", a[i]);
	}

	return 0;
}

Measured memory_bytes: 1052
/* https://atcoder.jp/contests/abc106/tasks/abc106_b */
#include <bits/stdc++.h>

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

bool hasEightDivisor(const int N)
{
    int num_divisor = 0;
    reb(i, 1, N+1) {
        if (N%i == 0) num_divisor++;
    }
    return (num_divisor == 8);
}

int main(int argc, char *argv[])
{
    int N;
    cin >> N;

    int ans = 0;
    for (int i=1; i<=N; i+=2) {
        if (hasEightDivisor(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for i in range(3)] for j in range(N+1)]
for i in range(N):
    dp[i+1][0] = max(dp[i][1]+abc[i][0], dp[i][2]+abc[i][0])
    dp[i+1][1] = max(dp[i][0]+abc[i][1], dp[i][2]+abc[i][1])
    dp[i+1][2] = max(dp[i][0]+abc[i][2], dp[i][1]+abc[i][2])
print(max(dp[-1]))

Measured memory_bytes: 76760
#include <bits/stdc++.h>
using namespace std;
int f(string s) {
  int r = 0;
  for (int i = 0; i < s.size(); i++) {
    r *= 10;
    r += s[i] - '0';
  }
  return r;
}
int mx(string s) {
  sort(s.begin(), s.end());
  return f(s);
}
int mn(string s) {
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  return f(s);
}
int main() {
  while (true) {
    string s;
    int n;
    map<int, int> mp;
    cin >> s >> n;

    if (n == 0)
      break;
    mp[f(s)] = 0;
    while (s.size() < n)
      s.push_back('0');
    int j = 0;
    while (true) {
      j++;
      int r = mn(s);
      int l = mx(s);
      int next = r - l;
      if (mp.find(next) != mp.end()) {
        cout << mp[next] << " " << next << " " << j - mp[next] << endl;
        break;
      }
      mp[next] = j;
      s = to_string(next);
      while (s.size() < n)
        s.push_back('0');
    }
  }
  return 0;
}


Measured memory_bytes: 3280
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e8
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int h,w;
char s[25][25];

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

int len[50][50];

int f(int sx, int sy, int gx, int gy){

    rep(i,50)rep(j,50) len[i][j] = INF;
    len[sx][sy] = 0;

    queue<pii> q;
    q.push(pii(sx,sy));

    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        rep(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
            if(s[nx][ny] == 'x') continue;
            if(len[nx][ny] > len[x][y] + 1){
                len[nx][ny] = len[x][y] + 1;
                q.push(pii(nx,ny));
            }
        }
    }

    return len[gx][gy];

}

int main(void) {

    while(cin >> w >> h, w){

        rep(i,h) cin >> s[i];
        vector<pii> v;
        int sx,sy;
        rep(i,h)rep(j,w)
            if(s[i][j] == '*'){
                v.push_back(pii(i,j));
            }else if(s[i][j] == 'o'){
                sx=i,sy=j;
            }

        int n = v.size();

        vi s_dis(n);
        rep(i,n){//(sx,sy) -> v[i]
            s_dis[i] = f(sx,sy,v[i].first,v[i].second);
        }
        vector<vi> dis(n,vi(n));
        rep(i,n)loop(j,i+1,n){
            if(i != j){//v[i] -> v[j]
                dis[i][j] = dis[j][i] = f(v[i].first,v[i].second,v[j].first,v[j].second);
            }
        }

        vi ord(n);
        rep(i,n){
            ord[i] = i;
        }
        int ans = INF;
        do{
            int tmp = s_dis[ord[0]];
            rep(i,n-1)tmp += dis[ord[i]][ord[i+1]];
            ans = min(ans, tmp);
        }while(next_permutation(all(ord)));

        if(ans < INF){
            cout << ans << endl;
        }else{
            cout << -1 << endl;
        }
    }
}



Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main() {

    int H; cin >> H;
    int W; cin >> W;

    while (!(H == 0 && W == 0)) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1 || j == 0 || j == W -1) {
                    cout << "#";
                } else {
                    cout << '.';
                }
            }
            cout << '\n';
        }
        cout << '\n';
        cin >> H;
        cin >> W;
    }

    return 0;
}



Measured memory_bytes: 3068
#include<iostream>
using namespace std;
int main(){
  int n,ans = 100000;
  cin >>n;
  while(n--){
    ans = (int)(ans*1.05);
    if(ans%1000){ans = (ans/1000+1)*1000;}
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    cin >> s;

    stack<char> st;
    rep (i, s.size())
    {
        if (s[i] == 'S')
        {
            st.push('S');
        }
        else if (s[i] == 'T')
        {
            if (!st.empty() && st.top() == 'S')
            {
                st.pop();
            }
            else
            {
                st.push('T');
            }
        }
    }

    cout << st.size() << "\n";
    return 0;
}



Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		String A = scan.next();
		String x = scan.next();
		String C = scan.next();
		
		StringBuilder sb = new StringBuilder();
		sb.append(A.charAt(0));
		sb.append(x.charAt(0));
		sb.append(C.charAt(0));
		
	
		
		
		System.out.println(sb.toString());
		
		
		
		
	}

}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, W; cin >> n >> W;
    vector<int> w(n+1), v(n+1);
    for(int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
    }

    vector<vector<int>> dp(n+1, vector<int>(W+1, 0));

    for(int i = 1; i <= n; ++i) {
        int curw = w[i], curv = v[i];
        for(int j = 1; j <= W; ++j) {
            if(j >= curw) {
                dp[i][j] = max(dp[i-1][j], curv+dp[i-1][j-curw]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[n][W] << endl;
    
    return 0;
}


Measured memory_bytes: 80256
from time import time


def fact(x):
    i = 1
    while i * i <= x:
        if x % i == 0:
            yield i
            yield x // i
        i += 1


def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    now = time()

    c = [0] * (max(a) + 1)

    for e in a:
        c[e] += 1

    ans = n
    for e in a:
        c[e] -= 1
        for fct in fact(e):
            if c[fct]:
                ans -= 1
                break

        if time() - now >= 1.8:
            print(n)
            exit()

        c[e] += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 108048
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=1000000007;
const int inf=0x7fffffff;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
using namespace std;
int f[100010],n,m;
void init()
{
    for(int i=1;i<=n;i++) f[i]=i;
}

int Find(int x)
{
   if(x!=f[x]) return Find(f[x]);
   else return x;
}

int main()
{
   while(scanf("%d%d",&n,&m)&&n&&m){
       init();
       for(int i=2;i<=n;i++){
          scanf("%d",&f[i]);
       }
       ll ans=0;
       for(int i=1;i<=m;i++){
          char c;int a;
          scanf("\n%c%d",&c,&a);
          getchar();
          if(c=='Q'){
            ans+=Find(a);
          }
          else if(c=='M'){
              f[a]=a;
          }
       }
       printf("%lld\n",ans);
   }
}

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

int main() {
	long long N;
	long long K;
	long long i;
	long long p;


	cin >> N >> K;
	p=0;
	for(i=K;i<=N+1;i++){
		p+=(N-i+1)*i+1;
		p = p % 1000000007;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 3624
use proconio::input;
//use proconio::marker::{Bytes, Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
    }
    let mut ans = 0;
    if n % 1000 != 0 {
        ans = 1000 - n % 1000;
    }
    println!("{}", ans);
}


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

#define fcout cout<<fixed<<setprecision(10)
const double pi=acos(-1);

struct Point
{
    double x,y;
    Point(double x=0,double y=0):x(x),y(y){}
    void print(){
        fcout<<x<<' '<<y<<endl;
    }
};

Point rotate(Point p,Point c,double rad)
{
    Point q=p;
    p.x=(q.x-c.x)*cos(rad)-(q.y-c.y)*sin(rad)+c.x;
    p.y=(q.x-c.x)*sin(rad)+(q.y-c.y)*cos(rad)+c.y;
    return p;
}

int main()
{
    int N; cin>>N;
    Point p(0,0),q(100,0);

    function<void(int,Point,Point)> rec=[&](int d,Point p,Point q)
    {
        if(d==0) return;
        Point s,t,u;
        s.x=(2.0*p.x+1.0*q.x)/3.0; s.y=(2.0*p.y+1.0*q.y)/3.0;
        u.x=(1.0*p.x+2.0*q.x)/3.0; u.y=(1.0*p.y+2.0*q.y)/3.0;
        t=rotate(u,s,pi/3);

        rec(d-1,p,s); s.print();
        rec(d-1,s,t); t.print();
        rec(d-1,t,u); u.print();
        rec(d-1,u,q);
    };

    p.print();
    rec(N,p,q);
    q.print();
    return 0;
}


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

ll a(ll n) { return (9 * pow(5, n - 1) - 1) * pow(2, n) / 16; }

int main() {
  string s;
  cin >> s;
  reverse(all(s));
  ll ans = 0;
  rep(i, s.size()) {
    int x = s[i] - '0';
    ans += pow(2, s.size() - i - 1) * a(i + 1) * x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1e5+5;
struct node
{
    int x,y;
} f[N];
bool cmp(node a,node b)
{
    if(a.y==b.y) return a.x<b.x;
    return a.y<b.y;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        f[i].x=a-b;
        f[i].y=a+b;
    }
    sort(f+1,f+n+1,cmp);
    int ans=1,now=f[1].y;
    for(int i=2;i<=n;i++){
        if(f[i].x>=now){
            ans++;
            now=f[i].y;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a,b=[0],[0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans = 0
j = M
for i in range(N + 1): 
  if a[i]>K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 47448
N = int(input())
M = A = R = C = H = 0
for _ in range(N):
    s = input()
    if s[0] == 'M':
        M += 1
    elif s[0] == 'A':
        A += 1
    elif s[0] == 'R':
        R += 1
    elif s[0] == 'C':
        C += 1
    elif s[0] == 'H':
        H += 1

ans = M * A * R + M * R * C + M * C * H + M * A * C + M * A * H + M * R * H + A * R * C + A * C * H + A * R * H + R * C * H

print(ans)


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using ull = unsigned long long;
using P = std::tuple<int,int>;

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

int N, C, D;
ll powers[19], numbers101[9];
std::mt19937 engine;

ll product(ll a, ll b, ll m){
    ll res = 0ll;

    for(int i=60;i>=0;i-=4){
        res = (res * 16 + a * (b >> i & 15)) % m;
    }
    
    return res;
}

template <typename T>
T expt(T a, T n, T mod = std::numeric_limits<T>::max()){
    T res = 1;
    while(n){
        if(n & 1){res = product(res, a, mod);}
        a = product(a, a, mod);
        n >>= 1;
    }
    return res;
}

inline ll isPrime(ll x){
    if(x % 2 == 0){return x == 2;}

    ll d = x - 1;
    int s = 0;
    while(d % 2 == 0){
        ++s;
        d /= 2;
    }

    static int t = 10;    
    for(int i=0;i<t;++i){
        ll a = engine() % x, po = expt(a, d, x);
        
        bool flag = po == 1;
        for(int j=0;j<s;++j){
            if(po == x - 1){flag = true; break;}
            po = product(po, po, x);
        }

        if(!flag){return false;}
    }

    return true;
}

inline ll reverseNumber(ll x){
    std::string s = std::to_string(x);
    reverse(s.begin(), s.end());
    return std::stoll(s) * powers[N - 1 - s.size()];
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    for(int i=0;i<=18;++i){
        powers[i] = expt(10ll, 1ll * i);
    }
    
    std::cin >> N >> C;
    
    D = 2 * N + (C >= 0) - 1;

    if(N >= 2 && C < 0){
        std::cout << std::string(D + 1, '9') << std::endl;
        return 0;
    }
    
    for(int i=0;i<N;++i){
        numbers101[i] = powers[D-i] + powers[i];
    }

    bool founded = false;
    ll res = -1ll;
    for(int i=9;!founded&&i>=1;i-=2){
        for(ll j=powers[N-1]-1;!founded&&j>=0;--j){
            ll x = (C >= 0 ? powers[N] * C : 0ll) + numbers101[0] * i + (j * powers[N - 1 + (C >= 0 ? 1 : 0)] + reverseNumber(j)) * 10;

            if(isPrime(x)){
                founded = true;
                res = x;
            }
        }
    }
    
    if(res >= 0){
        std::cout << res << std::endl;
    }else{
        std::cout << std::string(D + 1, '9') << std::endl;
    }
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    string s,t; cin >> s >> t;
    bool ans = true;
    rep(i,s.size()) {
        if(s[i] != t[i]) ans = false;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
    ll n;
    vector<ll> a;

    cin >> n;
    for (int i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }

    ll div4 = 0;
    ll odd = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1) {
            odd++;
        }
        if (a[i] % 4 == 0) {
            div4++;
        }
    }
    if (div4 == odd - 1 && n == div4 + odd) {
        cout << "Yes" << endl;
    } else if (div4 >= odd) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
        



Measured memory_bytes: 1400
N = int(input())
li = []
for i in range(N):
  l = list(map(int, input().split()))
  li.append(l)
li.sort(key=lambda x: x[1])

cnt = 0
flag = True
for l in li:
  cnt += l[0]
  if cnt > l[1]:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 47168
test :: Char -> [Char] -> Bool
test c cs = all (\x -> c == x) cs
        
solve :: String -> String
solve argList = if any (==True) [t1, t2, t3]
                then "Yes"
                else "No"
    where
        h = head argList
        l = last argList
        t1 = test h argList
        t2 = test h $ take 3 argList
        t3 = test l $ tail argList

main = do
    argList <- getLine
    putStrLn $ solve argList

Measured memory_bytes: 380
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K,Q = LI()
A = LI()

# 最小値を決め打ちすると区間を分割できる

Aval = set(A)
ans = float('inf')
for a in Aval:
    now = []
    mins = []
    num = 0
    for i in range(N):
        if A[i] >= a:
            now.append(A[i])
        else:
            if len(now) >= K:
                now.sort()
                mins.extend(now[:len(now)-K+1])
                num += len(now)-K+1
            now = []
    if len(now) >= K:
        now.sort()
        mins.extend(now[:len(now)-K+1])
        num += len(now)-K+1
    if num >= Q:
        mins.sort()
        if mins[Q-1]-a < ans:
            ans = mins[Q-1]-a

print(ans)

Measured memory_bytes: 45020
my $str = <STDIN>;
chomp $str;
my $q = <STDIN>;
chomp $q;
my $reverse = 1;
my @l = ($str);
for (my $i = 0; $i < $q; $i++) {
    my $s = <STDIN>;
    chomp $s;
    my ($t, $f, $c) = split ' ', $s;
    if ($t == 1) {
        $reverse = 3 - $reverse;
    }
    elsif ($t == 2 and $f == $reverse) {
        unshift @l, $c;
    }
    elsif ($t == 2 and $f != $reverse) {
        push @l, $c;
    }
}
$str = join '', @l;
if ($reverse == 2) {
    $_ = $str;
    $str = scalar reverse;
}
print "$str\n";


Measured memory_bytes: 20864
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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 main()
{
    double T, X;
    cin >> T >> X;
    cout << fixed << setprecision(6) << T / X << endl;
    return 0;
}

Measured memory_bytes: 3772
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> c[i][j];
    }
  }

  ll ans = 0;
  for (int i = 0; i < (1 << H); i++) {
    bitset<6> h_set(i);

    vector<vector<char>> h_c = c;

    for (int j = 0; j < H; j++) {
      if (h_set[j]) {
        for (int k = 0; k < W; k++) {
          h_c[j][k] = 'r';
        }
      }
    }
    for (int j = 0; j < (1 << W); j++) {
      vector<vector<char>> hw_c = h_c;
      bitset<6> w_set(j);
      for (int k = 0; k < W; k++) {
        if (w_set[k]) {
          for (int l = 0; l < H; l++) {
            hw_c[l][k] = 'r';
          }
        }
      }

      int b_num = 0;
      for (int k = 0; k < H; k++) {
        for (int l = 0; l < W; l++) {
          if (hw_c[k][l] == '#') {
            b_num++;
          }
        }
      }
      if (b_num == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#define int long long
inline int min(int a,int b){return a<b?a:b;}
const int N=2e5+3,INF=4e18;
int n,m,a[N],dp[N],q[N],l,r;
inline int X(int i){return a[i];}
inline int Y(int i){return dp[i]+a[i]*a[i];}
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	dp[1]=0;
	q[l=r=0]=1;
	for(int i=2;i<=n;i++){
	  for(;l<r&&Y(q[l+1])-Y(q[l])<2*a[i]*(X(q[l+1])-X(q[l]));l++);
	  dp[i]=dp[q[l]]+(a[i]-a[q[l]])*(a[i]-a[q[l]])+m;
	  for(;l<r&&(Y(i)-Y(q[r]))*(X(q[r])-X(q[r-1]))<(Y(q[r])-Y(q[r-1]))*(X(i)-X(q[r]));r--);
	  q[++r]=i;
	}printf("%lld",dp[n]);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
typedef long long ll;
typedef vector<ll> vi;
int sum(vector<int> vec){
  return accumulate(vec.begin(), vec.end(), 0);
}
int main() {
  int N, ans = 0, S;
  cin >> N;
  vector<int> d(N);
  rep(i,N){
    cin >> d[i];
  }
  S = sum(d);
  rep(i, N-1){
    S -= d[i];
    ans += d[i]*S;
  }
  print(ans);
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

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

int main(){
  int i,j,k,n;
  double in[100];

  rep(i,100) in[i] = 0;
  i = 0;
  while(scanf("%lf",&in[i]) != EOF) i++;
  rep(i,100){
    if(0 < in[i] && in[i] <= 48.00) printf("light fly\n");
    if(48.00 < in[i] && in[i] <= 51.00) printf("fly\n");
    if(51.00 < in[i] && in[i] <= 54.00) printf("bantam\n");
    if(54.00 < in[i] && in[i] <= 57.00) printf("feather\n");
    if(57.00 < in[i] && in[i] <= 60.00) printf("light\n");
    if(60.00 < in[i] && in[i] <= 64.00) printf("light welter\n");
    if(64.00 < in[i] && in[i] <= 69.00) printf("welter\n");
    if(69.00 < in[i] && in[i] <= 75.00) printf("light middle\n");
    if(75.00 < in[i] && in[i] <= 81.00) printf("middle\n");
    if(81.00 < in[i] && in[i] <= 91.00) printf("light heavy\n");
    if(91.00 < in[i]) printf("heavy\n");
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();
        String s3 = scanner.next();

        scanner.close();
        System.out.println(String.format("%s%s%s", String.valueOf(s1.charAt(0)).toUpperCase(), String.valueOf(s2.charAt(0)).toUpperCase(), String.valueOf(s3.charAt(0)).toUpperCase()));
    }
}


Measured memory_bytes: 23764
#line 1 "main.cpp"

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { ++i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_) noexcept : l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const noexcept { return l; }
  constexpr iterator end() const noexcept { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { --i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_) noexcept : l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const noexcept { return r; }
  constexpr iterator end() const noexcept { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  i32 N;
  std::cin >> N;
  std::vector<i32> ans(N + 1);
  for (i32 x = 1; x * x <= N; ++x) {
    for (i32 y = 1; y * y <= N; ++y) {
      for (i32 z = 1; z * z <= N; ++z) {
        i32 n = x * x + y * y + z * z + x * y + y * z + z * x;
        if (n <= N) {
          ++ans[n];
        }
      }
    }
  }
  for (i32 i = 1; i <= N; ++i) {
    std::cout << ans[i] << '\n';
  }
  return 0;
}

/**
 * @title Template
 */


Measured memory_bytes: 3656
def resolve():
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    if n==1:
        for l in range(0,10):
            ans = str(l)
            k=0
            for j in range(m):
            	if int(ans[(a[j])-1]) == b[j]:
                	k=k+1
            if k==m:
                print(ans)
                exit()
    if n == 2:
        for l in range(10, 100):
            ans = str(l)
            k=0
            for j in range(m):
            	if int(ans[(a[j])-1]) == b[j]:
                	k=k+1
            if k==m:
                print(ans)
                exit()
    if n == 3:
        for l in range(100, 1000):
            ans = str(l)
            k=0
            for j in range(m):
            	if int(ans[(a[j])-1]) == b[j]:
                	k=k+1
            if k==m:
                print(ans)
                exit()
    print(-1)
resolve()

Measured memory_bytes: 39024
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long ans;
            ans = (N * (N + 1) / 2) - N;
            Console.WriteLine(ans);

        }

    }
}


Measured memory_bytes: 27532