akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ff first
#define ss second

struct segtree{
    ll l,r,maxim;
    segtree *left, *right;

    segtree(ll a, ll b) : l(a) , r(b), maxim(0){
        if(l == r) maxim = 0;
        else {
            ll mid = (l+r)/2;
            left = new segtree(l,mid);
            right = new segtree(mid+1,r);
            maxim = max(left->maxim,right->maxim);
        }
    }

    void update(ll pos, ll val){
        if(pos < l || pos > r) return ;
        if(l == r) maxim = val;
        else{
            left->update(pos,val);
            right->update(pos,val);
            maxim = max(left->maxim,right->maxim);
        }
    }

    ll get(ll a, ll b){
        if(b < l || a > r) return INT_MIN;
        if(a <= l && r <= b) return maxim;
        return max(left->get(a,b), right->get(a,b));
    }
};



int main(){
    ll n;
    cin>>n;
    ll a[n], h[n];
    for(ll i = 0 ; i < n; i++) cin>>h[i];
    for(ll i = 0 ; i < n; i++) cin>>a[i];
    pair<int,pair<int,int> > arr[n];
    for(ll i = 0 ; i < n; i++){
        arr[i].ff = h[i];
        arr[i].ss.ff = a[i];
        arr[i].ss.ss = i;
    }
    sort(arr, arr + n);
    segtree tree(1,n);
    for(ll i = n-1 ; i >= 0; i--){
        tree.update(arr[i].ss.ss + 1,arr[i].ss.ff + tree.get(arr[i].ss.ss + 1,n));
    }
    cout<<tree.get(1,n);
}


Measured memory_bytes: 27864
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
#define max(a,b) (a>b?a:b)
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	cin>>n;
	vector< vector<int> > dp(n,vector<int>(3));
	int a,b,c;
	cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
	for(int i=1;i<n;i++){
		cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
		dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
	}
	int out=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	cout<<out<<endl;
	return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main{

public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[] mountains = new int[10];

for(int i=0; i<10; i++){
mountains[i] = sc.nextInt();
}

Arrays.sort(mountains);
System.out.println(mountains[9]);
System.out.println(mountains[8]);
System.out.println(mountains[7]);
}


}

Measured memory_bytes: 26428
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
string s1,s2;


int main(){
	cin>>s1>>s2;
	
	sort(s1.begin(),s1.end());
	sort(s2.begin(),s2.end(),greater<char>());
	
	if (s1 < s2) cout<<"Yes";
	else cout<<"No";
}


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

int main(){
  string s, t;
  cin >> s >> t;
  
  int n = s.size();
  
  int ans = 0;
  for (int i=0 ; i<n ; i++){
    if (s == t){
      ans = 1;
      break;
    }
    char push = s.at(0);
    s.erase(s.begin() + 0);
    s.push_back(push);
  }
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=2005;
int n;
int l[N],ans;
signed main(){
	n=read();
	for(int i=1;i<=n;i++) l[i]=read();
	sort(l+1,l+1+n);
	l[0]=999999999999999999;l[n+1]=0;
//	for(int i=1;i<=n;i++) cout<<l[i]<<" ";
//	cout<<endl;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			int pos,CH;
			if(i!=1){
				pos=i-1,CH=abs(l[i]-l[j]);
				for(pos;pos>=1;pos--){
					if(l[pos]>CH) ans++;else break;
				}
			}
			if(i!=n-1){
				pos=j+1;CH=l[i]+l[j];
				for(pos;pos<=n;pos++){
					if(l[pos]<CH) ans++;else break;
				}
			}
		}
		
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

data YesNo = Yes | No deriving(Show)

solver :: Int -> YesNo
solver n
    | n < 0      = No
    | n `mod` 7 == 0 = Yes
    | n `mod` 4 == 0 = Yes
    | otherwise  = solver (n-7)

main :: IO ()
main = do
    n <- (read :: String -> Int) <$> getLine
    print $ solver n


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e12;

int p[21], q[21][51], r[21][51];
int costTable[21][100010];
int d[21][110][110];

signed main(){
    int n, m, c, s, g;
    while(cin >> n >> m >> c >> s >> g, n){
        s--; g--;
        rep(i, 0, c + 1){
            rep(j, 0, n){
                rep(k, 0, n){
                    d[i][j][k] = INF;
                }
                d[i][j][j] = 0;
            }
        }
        rep(i, 0, m){
            int x, y, di, ci;
            cin >> x >> y >> di >> ci;
            x--; y--; ci--;
            d[ci][x][y] = min(d[ci][x][y], di);
            d[ci][y][x] = min(d[ci][y][x], di);
        }
        rep(i, 0, c){
            cin >> p[i];
        }
        rep(i, 0, c){
            rep(j, 0, p[i] - 1) cin >> q[i][j];
            q[i][p[i] - 1] = 100000;
            rep(j, 0, p[i]) cin >> r[i][j];
        }
        rep(i, 0, c){
            int idx = 0;
            costTable[i][0] = 0;
            rep(j, 1, 100010){
                costTable[i][j] = costTable[i][j - 1] + r[i][idx];
                // if(j <= 10) cout << i << ' ' << j << ' ' << costTable[i][j] << endl;
                if(j == q[i][idx]) idx++;
            }
        }
        rep(l, 0, c){
            rep(k, 0, n){
                rep(i, 0, n){
                    rep(j, 0, n){
                        d[l][i][j] = min(d[l][i][j], d[l][i][k] + d[l][k][j]);
                    }
                }
            }
        }
        rep(i, 0, n){
            rep(j, 0, n){
                rep(k, 0, c){
                    if(d[k][i][j] >= 100010) continue;
                    int tmp = costTable[k][d[k][i][j]];
                    d[c][i][j] = min(d[c][i][j], tmp);
                }
                // cout << i << ' ' << j << ' ' << d[c][i][j] << endl;
            }
        }
        rep(k, 0, n){
            rep(i, 0, n){
                rep(j, 0, n){
                    d[c][i][j] = min(d[c][i][j], d[c][i][k] + d[c][k][j]);
                }
            }
        }
        if(d[c][s][g] >= INF) cout << -1 << endl;
        else cout << d[c][s][g] << endl;
    }
}


Measured memory_bytes: 20604
#include<bits/stdc++.h>
#define ll long long
using  namespace std;
map<string,int> mp;
string s;
vector<string> ans;
int main () {
    ios_base::sync_with_stdio(false);
    int n,mx=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
        mx = max(mx,mp[s]);
    }
    for(auto k:mp){
        if(k.second==mx)
            ans.push_back(k.first);
    }
    //sort(ans.begin(),ans.end());
    for(auto k:ans)
        cout<<k<<'\n';
}

Measured memory_bytes: 25584
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  int64_t a, b;
  cin >> a >> b;
  auto ans = (a + b) / 2;
  if ((a + b) % 2 == 0) {
    cout << ans << endl;
  } else {
    cout << "IMPOSSIBLE\n";
  }

  return 0;
}

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

void writeRectangle(int w, int h)
{
    for (int i=0; i<w; ++i)
    {
        for (int j=0; j<h; ++j)
        {
            cout << '#';
        }
        cout << endl;
    }
}

int main()
{
    int w=0, h=0;
    
    while(true)
    {
        cin >> w >> h;
        if (w == 0 && h == 0)   break;

        writeRectangle(w, h);
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int kam = a - b;
    cout << max(0, c - kam) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define MOD 1000000007
    //for(int i=0; i<n; ++i)
    using namespace std;
    #define all(c) c.begin(), c.end()
    #define watch(x) cout << (#x) << " is " << (x) << endl
    #define ll long long
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
     
        int x, y, z;
        cin >> x >> y >> z;
        if (x == y && y != z)
            cout << "Yes";
        else if (z == y && y != x)
            cout << "Yes";
      	else if (z == x && y != x)
            cout << "Yes";
        else
            cout << "No";
        cout << endl;
        return 0;
    }

Measured memory_bytes: 256
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())



Taka_end1 = t1*a1
Taka_end2 = t2*a2
Taka_end_all = Taka_end1+Taka_end2

Taka = [t1*a1,t2*a2,Taka_end_all]

Aok_end1 = t1*b1
Aok_end2 = t2*b2
Aok_end_all = Aok_end1+Aok_end2

Aok = [t1*b1,t2*b2,Aok_end_all]



Taka_fast = False
if Taka_end1 > Aok_end1:
    Taka_fast = True

if Taka_fast:
    d1 = Taka_end1-Aok_end1
    d2 = Aok_end_all-Taka_end_all

    # print("Taka")
    # print(d1,d2)

    if d2 < 0:
        print(0)
    elif d2 == 0:
        print("infinity")
    else:
        if d1 % d2 == 0:
            print((d1//d2)*2)
        else:
            print((d1 // d2) * 2 + 1)
else:
    d1 = -(Taka_end1-Aok_end1)
    d2 = -(Aok_end_all-Taka_end_all)
    #
    # print("Aok")
    # print(d1,d2)

    if d2 < 0:
        print(0)
    elif d2 == 0:
        print("infinity")
    else:
        if d1 % d2 == 0:
            print((d1 // d2) * 2)
        else:
            print((d1 // d2)*2 + 1)


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin >> d[i];
  
  sort(d.begin(),d.end());
  
  int center=(n-1)/2;
  if(d[center]==d[center+1]) cout << 0 << endl;
  else cout << d[center+1]-d[center] << endl;
    
  
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

vector<vector<int>> edge;

void dfs(int v, int p, int d, vector<int>& dist) {
  dist[v] = d;
  for (int c : edge[v]) {
    if (p == c) continue;
    dfs(c, v, d + 1, dist);
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  int u, v; cin >> u >> v; u--, v--;
  edge.resize(N);
  REP(i, N-1) {
    int a, b; cin >> a >> b; a--, b--;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }

  vector<int> taka(N), aoki(N);
  dfs(u, -1, 0, taka);
  dfs(v, -1, 0, aoki);
  int ans = 0;
  REP(i, N) {
    if (taka[i] < aoki[i]) {
      ans = max(ans, aoki[i] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


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

s_l = input()
num = 0
for i, s in enumerate(s_l):
    num = i +1
    if num % 2 == 0:
        if s_l[i] == 'R':
            print('No')
            exit()
    else:
        if s_l[i] == 'L':
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3060
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c,d,e,g=0;cin>>a>>b>>c>>d>>e;
  vector<char> f(a+b);
  rep(i,b)f[i]='a';
  rep(i,a){
    cin>>f[i+b];
    if(f[i]!=f[i+b]){
      if(f[i+b]=='s')g+=c;
      else if(f[i+b]=='p')g+=d;
      else g+=e;
    }
    else f[i+b]='a';
  }
  cout<<g;
  }


Measured memory_bytes: 23808
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  for(ll i=0;i<n;i++)
  cin>>v[i];
  sort(v.begin(),v.end());
  ll sum=0;
  for(ll i=0;i<k;i++)
  sum+=v[i];
  cout<<sum<<endl;
   return 0;
    
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

int lcm(int x,int y){
    return x*y/gcd(x,y);
}

signed main(){
    int a, b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int n,m;
int tab[1010];
int cost[1010];
int dp[1010][5010]; //[indeks][mask]

int rec(int indeks,int mask)
{
    if (__builtin_popcount(mask) == n) return 0;
    if (indeks > m) return INF;
    if (dp[indeks][mask] != -1) return dp[indeks][mask];
    int ret = INF;
    ret = min(ret,rec(indeks + 1,mask));
    ret = min(ret,cost[indeks] + rec(indeks + 1,mask | tab[indeks]));
    return dp[indeks][mask] = ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1 ; i <= m ; i++)
    {
        int k;
        cin >> cost[i] >> k;
        for (int j = 1 ; j <= k ; j++)
        {
            int ta;
            cin >> ta;
            --ta;
            tab[i] |= (1 << ta);
        }
    }
    memset(dp,-1,sizeof(dp));
    int ans = rec(1,0);
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<pair<ll, int>> res = prime_div(n);
  int ans = 0;
  for (auto v : res){
  int b = 1;
    while (b <= v.second){
      ans++;
      v.second -= b;
      b++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[223456];
int n,k;
bool check(int t){
	ll sum=0;
	for(int i=1;i<=n;i++){
		sum+=(int)ceil(a[i]*1.0/t)-1;
	}
	if(sum>k)return false;
	return true;
}
int main(){
	
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	int l=1,r=1e9;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
} 


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010];
ll gcd(ll l,ll r){
	if(r==0){
		return l;
	}
	gcd(r,l%r);
}
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=a[0];
	for(int i=1;i<n;i++){
		ans=gcd(max(ans,a[i]),min(ans,a[i]));
	}
	cout <<ans;
}

Measured memory_bytes: 1024
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in l:
    for j in l:
        for k in l:
            if i != j != k != i:
                if i + j > k and j + k > i and k + i > j:
                    ans += 1
print(int(ans/6))


Measured memory_bytes: 9076
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


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

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

    int j = b - a;

    int ans = -a;
    REP(i, j) ans += i;

    print(ans);


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int n; cin >> n;
    vector<string> v;
    int all[26];
    for(int i=0;i<26;i++){
        all[i] = 100;
    }
    for(int i=0;i<n;i++){
        string str; cin >> str;
        int tmp[26];
        for(int j=0;j<26;j++){
            tmp[j] = 0;
        }
        for(int j=0;j<str.size();j++){
            int num = str[j]- 'a';
            tmp[num]++;
        }
        for(int j=0;j<26;j++){
            if(all[j] > tmp[j])
                all[j] = tmp[j];
        }
    }
    for(int i=0;i<26;i++){
        int num = all[i];
        if(num==100)
            continue;
        char c = 'a' + i;
        for(int j=0;j<num;j++){
            cout << c;
        }
    }
    cout << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll N,M;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(false);
	cin>>N>>M;
	REP(i,M){
		ll a;
		cin>>a;
		N-=a;
	}
	if(N>=0){
		cout<<N<<endl;
	}else{
		cout<<-1<<endl;
	}

}


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

int main()
{
  string s;
  int cnt = 0;
  cin >> s;
  for(int i = 0;i <= 3;i++){
    if(s[i] == '1'){
      cnt += 1;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// dijkstra
// depend:edge
vector<long long int> dijkstra(vector<vector<edge>>& g, int start) {
    using lint = long long int;
    vector<lint> res(g.size(), LLONG_MAX);
    res[start] = 0;
    // first:距離、second:行き先
    priority_queue<pair<lint, lint>, vector<pair<lint, lint>>,
                   greater<pair<lint, lint>>>
        pq;
    pq.push({0, start});
    while (!pq.empty()) {
        lint dist = pq.top().first, now = pq.top().second;
        pq.pop();
        if (res[now] < dist) continue;
        for (int i = 0; i < (int)g[now].size(); i++) {
            edge e = g[now][i];
            if (res[e.to] > res[now] + e.cost) {
                res[e.to] = res[now] + e.cost;
                pq.push(make_pair(res[e.to], e.to));
            }
        }
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> g(3 * n);
    for (int i = 0; i < m; i++) {
        int v, w;
        cin >> v >> w;
        v--, w--;
        g[v].push_back(edge(w + n));
        g[v + n].push_back(edge(w + 2 * n));
        g[v + 2 * n].push_back(edge(w));
    }
    int s, t;
    cin >> s >> t;
    s--, t--;
    vector<lint> dist = dijkstra(g, s);
    if (dist[t] == LLONG_MAX) {
        cout << -1 << endl;
    } else {
        cout << dist[t] / 3 << endl;
    }
}

Measured memory_bytes: 18944
#include<stdio.h>
int main(void){
  int S,W;
  scanf("%d %d",&S,&W);
  if(1>S || 100<S || 1>W || 100<W){
    printf("error");
    return 0;
  }
  if(S>W){
     printf("safe");
  }
  else{
    printf("unsafe");
  }
  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int g[15][15];  //証言の格納

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

  REP(i,n)REP(j,n) g[i][j] = -1;  //i番目の人がj番目を正直だと証言した，−１は証言していない状態を -1として保存
  REP(i,n){
    int m;
    cin >> m;
    REP(j,m){
      int a, x;
      cin >> a >> x;
      --a;
      g[i][a] = x;
    }
  }


  int ans = 0;
  REP(i, 1 << n){
    vector<int> d(n);
    REP(j,n) if(i >> j & 1){
      d[j] = 1;
    }
    bool ok = true;
    REP(j,n){
      //正直者の発言のみを確認
      if(d[j]){
        REP(k,n){
          if (g[j][k] == -1) continue;
          if (g[j][k] != d[k]) ok = false;
        }
      }
    }

    if(ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}


// int main(){
//   int n;
//   cin  >> n;
//   vector<int> honest(n);
//
//
//   //全員が正直者の場合
//   REP(i,n) honest[i] = 1;
//
//   for(int bit = 0; bit < (1 << n); ++bit){
//
//   }
//
//
//
// //----check
//   bool ok = true;
//   REP(i, n){
//     int a;
//     cin >> a;
//     REP(j,a){
//       int x, y;
//       cin >> x >> y;
//       --x;
//       if(honest[x] != y ) ok = false;
//     }
//   }
//
//   if(ok){
//     int ans = 0;
//     REP(i,n) ans += honest[i];
//     cout << ans;
//   }
// //--------------
//   else cout << "0" << endl;
//   return 0;
// }

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

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

int main(){
    
    ll A,B,C,D;cin>>A>>B>>C>>D;
    A--;
    ll cnt1=A,cnt2=B;
    cnt1-=A/C;
    cnt1-=A/D;
    cnt1+=A/(C*D/gcd(C,D));
    cnt2-=B/C;
    cnt2-=B/D;
    cnt2+=B/(C*D/gcd(C,D));
    
    cout<<cnt2-cnt1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second > b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
int main()
{
     fast;
     //int t;
     //cin>>t;
     //while(t--)
     {
      ll i,j,c=0,d=0,sum=0,e=0,f=0,g=0,h=0,n,maxi=0;
       cin>>n;
       while(n>0)
       {
           c=n%10;
           if(c==7)
           {
               d++;
               break;
           }
           n/=10;
       }
       if(d!=0)
       {
           cout<<"Yes";
       }
       else
        cout<<"No";
     }

}



Measured memory_bytes: 3640
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val n,m,x = sc.nextInt()
  val a = List.fill(m)(sc.nextInt)
  val costA = (x+1 to n-1).map(i=>if(a.contains(i)){1}else{0}).sum
  val costB = (1 to x-1).map(i=>if(a.contains(i)){1}else{0}).sum
  println(Array(costA,costB).min)
}

Measured memory_bytes: 25640
#include <iostream> 
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int x[5], ans = 0; 
    vector<int>y(5);
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
        y[i] = x[i]%10;
        ans += x[i] - y[i];
    }
    sort(y.begin(),y.end());
    for (int i = 0; i < 5; i++) {
        if (y[i] != 0) {
            ans += y[i] + 10 * (4 - i);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = gets.chomp.split(" ").map(&:to_i)
ans = h*w
if h%3 == 0 || w%3 == 0
  ans = 0
else
  for i in h/3..h/3+1
    s = [i*w,(h-i)*(w/2),(h-i)*(w-w/2)]
    ans = [ans,[(s[0]-s[1]).abs,(s[1]-s[2]).abs,(s[2]-s[0]).abs].max].min
  end
  for i in w/3..w/3+1
    s = [i*h,(w-i)*(h/2),(w-i)*(h-h/2)]
    ans = [ans,[(s[0]-s[1]).abs,(s[1]-s[2]).abs,(s[2]-s[0]).abs].max].min
  end
  ans = [ans,h,w].min
end
puts ans

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	ll n, t;
	cin >> n >> t;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	ll mi = a[0]; // 一番小さい要素
	ll M = -1; //  買う　-> 売る　で得られる利益の最大値
	map<ll,ll> mp;
	rep(i,n){
		ll diff = a[i] - mi;
		mp[diff]++;
		chmax(M,diff);
		chmin(mi,a[i]);
	}
	cout << mp[M] << endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

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

const long long INF = 1LL << 60;

int N,K;
long long h[100010];

long long dp[100010];

int main(){
    int N,K; cin >> N >> K;
    for(int i = 0; i < N; ++i) cin >> h[i];

    for(int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for(int i = 0; i < N; i++) for(int j = 1; j <= K; j++) chmin(dp[i+j], dp[i]+abs(h[i] - h[i+j]));
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int h,w,maxi=-1;
char s[25][25];
bool book[25][25];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
struct ch {
	int x,y,step;
};
queue<ch> q;
int main() {
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>s[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			for(int a=1;a<=h;a++)
				for(int b=1;b<=w;b++) {
					if(s[i][j]=='#' || s[a][b]=='#') continue;
					if(i==a && j==b) continue;
					while(!q.empty()) q.pop();
					memset(book,0,sizeof(book));
					q.push((ch){i,j,0});
					book[i][j]=true;
//					
					while(!q.empty()) {
						ch p=q.front();q.pop();
//						cout<<"p.x:"<<p.x<<" p.y:"<<p.y<<" p.step:"<<p.step<<'\n'; 
						if(p.x==a && p.y==b) {
//							cout<<"i:"<<i<<" j:"<<j<<" a:"<<a<<" b:"<<b<<'\n';
//							cout<<"p.step = "<<p.step<<'\n'; 
							maxi=max(maxi,p.step);
							break;
						}
						for(int i=0;i<4;i++) {
							if(!book[p.x+dx[i]][p.y+dy[i]] && s[p.x+dx[i]][p.y+dy[i]]!='#' && p.x+dx[i]>=1 && p.x+dx[i]<=h && p.y+dy[i]>=1 && p.y+dy[i]<=w) {
								book[p.x+dx[i]][p.y+dy[i]]=true; 
								q.push((ch){p.x+dx[i],p.y+dy[i],p.step+1});
							} 
						}
					}
				}
	cout<<maxi;
	return 0;
}

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

int main() {
  int X, x;
  cin >> X;
  x = X;
  int A;
  int Y, Z;
    Y=10;
    Z=1;
  for (int i; i<8; i++){
    A+=(X%Y)/Z;
    X-=(X%Y);
    Y*=10; Z*=10;
  }
  if(x%A==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r,d,x; cin >> r >> d >> x;
    FOR(i,0,10)
    {
    	x = r*x-d;
    	cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	q := scanInt()
	s := scanString()

	sum := make([]int, n+1)
	for i := 0; i < n-1; i++ {
		sum[i+1] += sum[i]
		if s[i:i+2] == "AC" {
			sum[i+2]++
		}
	}
	sum[n] += sum[n-1]

	for i := 0; i < q; i++ {
		l := scanInt()
		r := scanInt()
		fmt.Fprintln(wr, sum[r]-sum[l])
	}

	debug(q,sum)
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  int wa,sa,seki;
  wa = A+B;
  sa = A-B;
  seki = A*B;
  
  cout << max(max(wa,sa),seki) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] abc = br.readLine().split(" ");
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);
        int c = Integer.parseInt(abc[2]);
        
        int max = Math.max(Math.max(a,b),c);
        a = max - a;
        b = max - b;
        c = max - c;
        
        int ans = 0;
        int res = a%2 + b%2 + c%2;
        
        ans += a/2 + b/2 + c/2;
        
        if(res == 0) System.out.println(ans);
        else if(res == 1) System.out.println(ans+2);
        else System.out.println(ans+1);
    }

}


Measured memory_bytes: 21204
//結構苦労した

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int H, W;
  cin >> H >> W;

  //入力
  vector<string> vec(H);
  rep(i,H){
      cin >> vec.at(i);
  }

  //"#"が含まれる行と列をマーク
  vector<bool> row(H, false);  //行 rows
  vector<bool> col(W, false);  //列 columns

  rep(i,H){
    rep(j,W){
      if (vec.at(i).at(j) == '#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  //出力
  rep(i,H){
      if (row[i]){
        rep(j,W){
          if (col[j]){
            cout << vec.at(i).at(j);
          }
        }
        cout << endl;
      }
  }

}


Measured memory_bytes: 3652
H,W = map(int, input().split())

S = ['.'*(W + 2)] + ['.' + input() + '.' for _ in range(H)] + ['.'*(W + 2)]

for x in range(1, H+1):
    for y in range(1, W+1):
        if S[x][y] == '.':
            Bomb = (S[x-1][y-1:y+2] + S[x][y-1:y+2] + S[x+1][y-1:y+2]).count('#')
            S[x] = S[x][:y] + str(Bomb) +S[x][y+1:]

for i in range(1, H+1):
    print(S[i][1:W+1])

Measured memory_bytes: 9168
#include <iostream>
#include <cstdio>


int main(void){
  int r1, r2;
  std::cin >> r1 >> r2;

  double r3 = 1.0/r1 + 1.0/r2;
  r3 = 1.0/r3;

  std::printf("%.10f\n", r3);
  return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int R = GetInt();
		int G = GetInt();
		int B = GetInt();
		int N = GetInt();

		int ans = 0;
		for(int r = 0; r <= N/R; r++)
		{
			int rest1 = N - r * R;
			for(int g = 0; g <= rest1/G; g++)
			{
				int rest2 = rest1 - g * G;
				if(rest2 % B == 0)
					ans++;
			}
		}
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include "iostream"
using namespace std;

int main()
{
	int x, a;
	cin >> x;
	for (int i = 1; i <= x; i++)
	{
		if (i % 3 == 0)
		{
			cout << " " << i;
		}
		else
		{
			a = i;
			do
			{
				if (a %10==3)
				{
					cout << " " << i;
					break;
				}
				a /= 10;
			} while (a);
		}
	}
	cout << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
#define PI (atan(1)*4)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e5 + 7;
const int md = 1e9 + 7;
void sol() {
  int R;
  cin >> R;
  long double ans = (long double)(2.0 * PI * R);
  cout << setprecision(16) << fixed << ans << "\n";
}

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;

  /*COMMENT BELOW WITHOUT FAIL*/
  //freopen("input.txt", "r", stdin);
  /*REMOVE ABOVE WITHOUT FAIL BEFORE SUBMITTING */

  //cin >> T;
  for(int i = 1; i <= T; i++) {
    //cout << "Case " << "#" << i << ": ";
    sol();
  }
  return 0;
}


Measured memory_bytes: 3796
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();

    long[] a = new long[n];
    for(int i=0; i<n; i++){
      a[i] = sc.nextLong();
    }

    for(int i=k; i< n; i++){
      if(a[i - k] >= a[i]){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
    }
  }
}

Measured memory_bytes: 88776
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename T> T minimum(T head, T tail) { return std::min(head, tail); }
template<typename Head, typename... Tail> Head minimum(Head head, Tail... tail) {
  return std::min(head, minimum(tail...));
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  //std::ostringstream oss;
  //oss << "ABC" << N;
  //std::string ans = oss.str();

  std::vector<ll> vcnt(10, 0LL);
  std::string N;
  std::cin >> N;

  ll ans = 0;
  ll cnt = 0;
  ll x = '#';
  for (auto c : N) {
    if (c == x) {
      cnt++;
      ans = std::max(ans, cnt);
    } else {
      cnt = 1;
      x = c;
    }
  }

  if (ans >= 3) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) (v).begin(),(v).end()
const ll MOD = 1e9 + 7;

int main() {
	int N, L;
	cin >> N >> L;
	ll ans = (2 * L + N - 1)*N / 2;
	ll x = L;
	for (int i = 0; i < N; i++) {
		if (abs(x) > abs(L + i)) {
			x = L + i;
		}
	}
	ans -= x;
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        
        System.out.println(cal(0,a,0));

    }
    public static int cal(int i,int[]a,int sum){
        if(a[i]==2) return ++sum;
        if(sum==a.length) return -1;
        sum++;
        return cal(a[i]-1,a,sum);
    }
}

Measured memory_bytes: 54332
#include<stdio.h>
int main()
{
    long long int x;
    scanf("%lld",&x);
    long long int a=100,count=0;
    while(a<x)
    {
        a=a+a*0.01;
        count++;
    }
    printf("%lld\n",count);
    return 0;
}


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

int main()
{
	int N;
	int p;
	int Cost = 0;
	int MaxP = 0;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> p;
		Cost += p;
		if (MaxP < p) MaxP = p;
	}
	Cost -= MaxP / 2;

	cout << Cost << endl;
    
	return(0);
}


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

using namespace std;

int main(){
	int s[10],i;
	for(i=0;i<10;i++){
		std::cin>>s[i];
	}
	cout<<s[0]+s[1]+s[2]+s[3]+s[4]+s[5]+s[6]+s[7]+s[8]+s[9]<<endl;
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K, S;
    cin >> N >> K >> S;

    if(S < INF){
        if(K != N){
            REP(i, K){
                cout << S << " ";
            }
            REP(i, N-K){
                if(i == N-K-1){
                    cout << INF << endl;
                }
                else{
                    cout << INF << " ";
                }
            }
        }
        else{
            REP(i, N){
                if(i == N-1){
                    cout << S << endl;
                }
                else{
                    cout << S << " ";
                }
            }
        }
    }
    else{
        if(K != N){
            REP(i, K){
                cout << INF << " ";
            }
            REP(i, N-K){
                if(i == N-K-1){
                    cout << 1 << endl;
                }
                else{
                    cout << 1 << " ";
                }
            }
        }
        else{
            REP(i, N){
                if(i == N-1){
                    cout << INF << endl;
                }
                else{
                    cout << INF << " ";
                }
            }
        }
    }
    
    return 0;
}

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

int main() {
  int n,d;cin>>n>>d;
  int cnt=0;
  rep(i,n){
    ll x,y;cin>>x>>y;
    double ans=(double)sqrt(x*x+y*y);
    if(ans<=d)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const double PI  = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF  = 0x3f3f3f3f3f3f3f3f;
const int N=3e5+10;
const int M=1e6+10;
const int mod=1e9+7;
inline LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
inline LL lcm(LL a, LL b) { return a * b / gcd(a, b); }
inline LL read(){LL x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}return x*f;}
inline LL qpow(LL x,LL k=mod-2,LL m=mod){LL res=1;while(k){if(k&1) res=res*x%m;x=x*x%m;k>>=1;}return res;}
/*=================================================================================================================*/


int main(){
    LL ans=0,n;
    cin>>n;
    for(int a=1;a<=n;a++)
        for(int b=1;a*b<n;b++)
            ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/2/ITP2_2_D
#include <iostream>
#include <vector>
#include <list>

int main()
{
    int n, q;
    std::cin >> n >> q;
    std::vector<std::list<int>> List(n);

    int m, s, t, x;
    for (int i = 0; i < q; i++)
    {
        std::cin >> m;
        if (m == 0)
        {
            std::cin >> t >> x;
            List[t].push_back(x);
        }
        else if (m == 1)
        {
            std::cin >> t;
            for (auto itr = List[t].begin(); itr != List[t].end(); itr++)
            {
                std::cout << *itr;
                if (next(itr) != List[t].end())
                    std::cout << " ";
            }
            std::cout << std::endl;
        }
        else if (m == 2)
        {
            std::cin >> s >> t;
            auto itr = List[t].end();
            List[t].splice(itr, List[s]);
        }
    }
}


Measured memory_bytes: 18644
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n,m,z, a,b,c, d;
string s;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b >> c >> d >> s;
    --a;--b;--c;--d;
    if(c < d){
        while(b != d){
            int y = b;
            if(b+1 < n && b+1 <= d && s[b+1] == '.' && b+1 != a)b += 1;
            if(b+2 < n && b+2 <= d && s[b+2] == '.' && b+2 != a)b += 2;
            if(b == y)break;
        }


        while(a != c){
            int y = a;
            if(a+1 < n && a+1 <= c && s[a+1] == '.' && a+1 != b)a += 1;
            if(a+2 < n && a+2 <= c && s[a+2] == '.' && a+2 != b)a += 2;
            if(a == y)break;
        }

        
    }
    else {
        


        while(a != c){
            int y = a;
            if(a+1 < n && a+1 <= c && s[a+1] == '.' && a+1 != b)a += 1;
            else if(a+2 < n && a+2 <= c && s[a+2] == '.' && a+2 != b)a += 2;
            
            if(a == y){
                if(b+1 < n && b+1 <= d && s[b+1] == '.' && b+1 != a)b += 1;
                else if(b+2 < n && b+2 <= d && s[b+2] == '.' && b+2 != a)b += 2;
            }

            if(a+1 < n && a+1 <= c && s[a+1] == '.' && a+1 != b)a += 1;
            else if(a+2 < n && a+2 <= c && s[a+2] == '.' && a+2 != b)a += 2;

            if(a == y)break;
        }


        while(b != d){
            int y = b;
            if(b+1 < n && b+1 <= d && s[b+1] == '.' && b+1 != a)b += 1;
            else if(b+2 < n && b+2 <= d && s[b+2] == '.' && b+2 != a)b += 2;
            if(b == y)break;
        }
    }
    if(a == c && b == d){
            cout <<"Yes\n";
        } 
        else cout <<"No\n";
}

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

ll abs64(ll x) {
	if (x>=0) return x;
	else return -x;
}

ll f(vector<ll> a, ll b, ll n) {
	ll ans = 0;
	rep(i,n) ans += abs64(a[i] - b);
	return ans;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) {
		cin >> a[i];
		a[i] -= i+1;
	}
	sort(a.begin(), a.end());
	cout << f(a,a[n/2],n) << endl;
	return 0;
}


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

int main() {
int n;
cin >> n;
if ( n == 0 )
cout << 1 << endl;
else if ( n == 1 )
cout << 2 << endl;
else if ( n == 2 )
cout << 1 << endl;
else
cout << 0 << endl;
return 0;
}

Measured memory_bytes: 1164