akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e5+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;







void sol()
{   
    cin>>n>>a>>b;

    x=y=l=r=1;
    FO(i,n-a+1,n)
    {
        x=(x*i)%mod;
    }
    FO(i,n-b+1,n)
    {
        y=(y*i)%mod;
    }
    FO(i,1,a)
    {
        l=(l*i)%mod;
    }
    FO(i,1,b)
    {
        r=(r*i)%mod;
    }

    l=inv(l);
    r=inv(r);
    
    
    cout<<((po(2,n,mod)-1-x*l-y*r)%mod+mod)%mod<<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3616
#include <bitset>
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  string s;
  cin >> s;
//  bitset b(s);
  int t=s[0];
  int ans=0;
  for (int i=1; i<s.length(); ++i) {
    if (s[i] == t) ++ans;
    t = t=='0' ? '1' : '0';
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<double>> vec(N, vector<double>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  int seisu = 0;
  for (int i = 0; i < N-1; i++){
    for (int j = i+1 ; j < N; j++){
      double dis_squared = 0;
      for (int k = 0 ; k < D; k++){
        dis_squared += pow(vec.at(j).at(k) - vec.at(i).at(k), 2);
      }
      //cout << dis_squared << sqrt(dis_squared) << endl;
      if (sqrt(dis_squared) == (int)sqrt(dis_squared)){
        seisu++;
      }
      else{
        continue;
      }
    }
  }
  cout << seisu << endl;
}

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

using namespace std;

int main(){
    long long n,m;
    cin >> n >> m;

    vector<pair<long long ,long long >> ab(n);
    for(long long i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(),ab.end());


    long long cnt = 0;
    long long sum = 0;
    bool flag = false;
    for(long long i = 0; i < n; i++){
        cnt += ab[i].second;
        if(cnt >= m){
            cnt -= ab[i].second;
            for(long long j = 0; j <= ab[i].second; j++){
                if(cnt == m){
                    flag = true;
                    break;
                }
                cnt++;
                sum += ab[i].first;
            }
        }
        if(flag == true) break;
        sum += ab[i].first * ab[i].second;
    }


    cout << sum << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a,b;
    cin>>a>>b;
    rep(0,i,2000){
        if(((8*i)/100)==a && ((10*i)/100)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1e5+5;
int A[maxn];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        FOR(i,0,n) {            
            cin >> A[i];
        }
        map<int,int> x,y;
        for (int i = 0; i < n; i+=2)
            x[A[i]]++;
        for (int i = 1; i < n; i+=2)
            y[A[i]]++;
        vector<PII> X,Y;
        FOR_ALL(k,x) {
            X.push_back(PII(k->second,k->first));
        }
        FOR_ALL(k,y) {
            Y.push_back(PII(k->second,k->first));
        }
        sort(ALL(X)); reverse(ALL(X));
        sort(ALL(Y)); reverse(ALL(Y));
        int ans = n;
        FOR(i,0,min(2,(int)X.size())) FOR(j,0,min(2,(int)Y.size())) {
            const int c1 = X[i].first;
            const int a1 = X[i].second;
            const int c2 = Y[j].first;
            const int a2 = Y[j].second;
            int res = n/2 - c1 + n/2 - c2;
            if (a1 == a2) {
                if (c1 < c2)
                    res += c1;
                else
                    res += c2;
            }
            ans = min(ans,res);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6524
#include"bits/stdc++.h"
using namespace std;
typedef vector<int> vi;
vector<vi> graph;
vector<int> ans;

int main(void) {
	string S;
	string T;

	cin >> S;
	cin >> T;

	int j = S.length();

	for (int i = 0; i < j;i++) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3624
while True:
    s = input()
    s, order = s.split()
    if order == 'X':
        break
    if '_' in s:
        if order == 'U':
            s = s.split('_')
            a = ''
            for i in s:
                a += i.capitalize()
            print(a)
        elif order == 'L':
            s = s.split('_')
            a = ''
            a += s[0].lower()
            for i in s[1:]:
                a += i.capitalize()
            print(a)
        else:
            print(s.lower())
    else:
        if order == 'U':
            if s[0].isupper():
                print(s)
            else:
                s = s[0].upper() + s[1:]
                print(s)
        elif order == 'L':
            if s[0].islower():
                print(s)
            else:
                s = s[0].lower() + s[1:]
                print(s)
        else: 
            index = []
            c = 0
            for i in range(len(s[1:])):
                if s[i+1].isupper():
                    index.append(i + 1+c)
                    c += 1
            for j in index:
                s = s[: j] + '_' + s[j:]
            print(s.lower())


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

int main(){
   string a,b,c;
   cin >> a >> b >> c;
   if(a.back()==b.front()&&b.back()==c.front()) cout <<"YES" << endl;
   else cout << "NO" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << num[k-1] << endl;
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;

int main() {



	char a;
	cin >> a;
	cout << (char)(a + 1) << endl;

}

Measured memory_bytes: 256
#define MOD 1000007

#include<iostream>
#include<cstring>
#include<cmath>
#include<set>

using namespace std;

const int AIM=87654321;
const int inic[]={2,0,1,2,0,1,2,0,1};
const int inir[]={2,0,0,0,1,1,1,2,2};
const int incr[]={-1,0,1,0};
const int incc[]={0,-1,0,1};

int gragh[3][3];
int zeror,zeroc;
int dis(0);

set<int> hash;

int maxdep(0);

inline int trans()
{
	int mpow(1);
	int data(0);
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
		{
			data+=mpow*gragh[i][j];
			mpow*=10;
		}
	return data;
}
inline int calu()
{
	int ans(0);
	for(int i=0;i<=2;++i)
		for(int j=0;j<=2;++j)
			ans+=abs(inir[gragh[i][j]]-i)+abs(inic[gragh[i][j]]-j);
	return ans;
}
inline int swap(int &a,int &b)
{
	a^=b;b^=a;a^=b;
}
bool dfs(int dep)
{
	if(trans()==AIM)
	{
		cout<<maxdep<<endl;
		return 1;
	}
	if(dep>=maxdep)
		return false;
	if(dis>(maxdep-dep)*2)
		return false;
	int nr,nc;
	for(int i=0;i<4;++i)
	{
		nr=zeror+incr[i];
		nc=zeroc+incc[i];
		if(nr<0||nc<0||nr>2||nc>2)
			continue;
		int olddis=dis;
		swap(nr,zeror);swap(nc,zeroc);
		swap(gragh[nr][nc],gragh[zeror][zeroc]);
		int data=trans();dis=calu();
		if(!hash.count(data))
		{
			hash.insert(data);
			if(dfs(dep+1))
				return 1;
			hash.erase(data);
		}
		dis=olddis;
		swap(nr,zeror);swap(nc,zeroc);
		swap(gragh[nr][nc],gragh[zeror][zeroc]);
	}
	return false;
}
	
int main()
{
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
		{
			cin>>gragh[i][j];
			if(!gragh[i][j])
				zeror=i,zeroc=j;
		}
	dis=calu();
	while(!dfs(0))
	{
		hash.clear();
		hash.insert(trans());
		++maxdep;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<algorithm>
    #include<iostream>
    using namespace std;
    int main()
    {
        long long n,i,j;
        long long ans=0;
        cin>>n;
      	long long a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        ans+=a[n-1];
        j=n-2;
        for(i=n-3;i>=0;)
        {
          if(i>=0)
          {
          ans+=a[j];
          i--;
          }
          if(i>=0)
          {
          ans+=a[j];
          i--;
          }
          j--;
        }
        cout<<ans<<endl;
      return(0);
    }

Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n;
  cin>>n;
  vector<ll> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  ll ans=LLONG_MAX;
  for(int i=1;i<=100;i++)
  {
    ll curr=0;
    for(int j=0;j<n;j++)
    {
      curr+=((v[j]-i)*(v[j]-i));
    }
    ans=min(ans,curr);
  }
  cout<<ans;
  return 0;
}

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

int main(void){
  using namespace std;
  int n;
  int d1[100],d2[100],f[100],x;
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> d1[i] >> d2[i];
    if (d1[i]==d2[i]) f[i]=1;
    else f[i]=0;
  }
  x=0;
  for(int i=0;i<n-2;i++){
    if((f[i]==1) && (f[i+1]==1) && (f[i+2]==1)) x=1;
  }
  if(x==1)  cout <<  "Yes" << endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 3616
from heapq import heappush, heappop
import sys

que = []
ans = []
for line in sys.stdin.readlines():
    cmd, *v = line.split()
    if cmd == 'insert':
        heappush(que, -int(v[0]))
    elif cmd == 'extract':
        ans.append("%d\n" % -heappop(que))
sys.stdout.writelines(ans)




Measured memory_bytes: 219532
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N){
        cin >> A[i];
    }

    int B[N];
    rep(i, N){
        B[A[i] - 1] = i + 1;
    }

    rep(i, N){
        cout << B[i] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k)
    {
        cout << s << "\n";
    }
    else
    {
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

ll calKeta(ll n){
    int keta = 0;
    while(n>0){
        n /= 10;
        keta++;
    }
    return keta;
}


int main(void){
    ll N;
    cin >> N;
    ll ans = 0;
    for(int i = 1; i<=sqrt(N); ++i){
        if(N%i==0) ans = N / i;
    }
    cout << min(calKeta(N), calKeta(ans)) << endl;
}

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

void dump(vector<int> &data, string name) {
  cout << name << "= { ";
  for(int i = 0; i<data.size(); i++)
    cout << data[i] << " ";
  cout << "} " << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> x(n);
  rep(i,n) cin >> a[i];
  int x0 = 0;
  rep(i,n){
    if(i%2==0)
      x0+=a[i];
    else
      x0-=a[i];
  }
  x[0] = x0/2;
  for(int i = 1; i<n; i++)
    x[i] = a[i-1] - x[i-1];
  // dump(x, "x");
  for(int i = 0; i<n; i++){
    if(i<n-1)
      cout << 2 * x[i] << " ";
    else
      cout << 2 * x[i] << endl;    
  }
  return 0;
}


Measured memory_bytes: 2048
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        PrintWriter out = new PrintWriter(System.out);
        while(true){
            int height = Integer.parseInt(in.next()), width = Integer.parseInt(in.next());
            
            if(height == 0 && width == 0) break;

            draw_rect(height, width, out);
        }

        out.flush();
    }

    static void draw_rect(int height, int width, PrintWriter out){
        for(int i = 0; i < height; i++){
            for(int j = 0; j < width; j++){
                if(i == 0 || i == height - 1 || j == 0 || j == width -1){
                    out.print("#");
                }
                else out.print(".");
            }
            out.println();
        }
        out.println();
    }
}


Measured memory_bytes: 28404
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int cnt = 0;
	char s[4],t[4];
	scanf("%s",s);
	scanf("%s",t);

	for (int i = 0; i < 3; ++i)
	{
		if(s[i] == t[i])	++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	cout<<n*800-n/15*200;
	re 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main() {
  uint64_t N, K;
  cin >> N >> K;
  vector<uint32_t> A(N);
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
  uint64_t cnt1 = 0, cnt2 = 0;
  uint64_t res = 0;

  for (uint32_t i = 0; i < N - 1; ++i) {
    for (uint32_t j = i + 1; j < N; ++j) {
      if (A[i] > A[j]) {
        cnt1++;
      }
    }
  }
  vector<uint32_t> B(2 * N);
  copy(A.begin(), A.end(), B.begin());
  copy(A.begin(), A.end(), B.begin() + (1 * N));
  for (uint32_t i = 0; i < (2 * N) - 1; ++i) {
    for (uint32_t j = i + 1; j < 2 * N; ++j) {
      if (B[i] > B[j]) {
        cnt2++;
      }
    }
  }
  uint64_t dif = cnt2 - (3 * cnt1);
  uint64_t tmp1 = (K * (K + 1) / 2) % 1000000007;
  uint64_t tmp2 = (K * (K - 1) / 2) % 1000000007;
  res = cnt1 * tmp1 + dif * tmp2;
  res %= 1000000007;

  cout << res << endl;
  return 0;
}


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

int main()
{
	int count = 0, x = 0, a[10000] = { 0 };
	while (1){
		cin >> x;
		if (x == 0) break;
		a[count] = x, count++;
	}
	for (int i = 1; i <= count; i++) cout << "Case " << i << ": " << a[i - 1] << endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long  ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vvl edge(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    queue<int> que;
    vl dist(n,L_INF);
    vl prev(n);
    dist[0] = 0;
    que.push(0);
    while(!que.empty()){
        int node = que.front();
        que.pop();
        for(auto nv:edge[node]){
            if(dist[nv] == L_INF){
                dist[nv] = dist[node]+1;
                prev[nv] = node;
                que.push(nv);
            }
        }
    }
    ll half_dist = (dist[n-1]-1)/2 + 1;
    ll from_n = n-1;
    ll to_n;
    //nから1までの経路半分探索
    rep(i,half_dist){
        to_n = prev[from_n];
        if(i != half_dist-1)from_n = to_n;
    }
    ll to_1 = from_n;

    //out(to_1);
    //out(to_n);

    //ノード1から幅優先で,to_1になったら探索中止
    ll res1 = 0;
    vl dist1(n,L_INF);
    dist1[0] = 0;
    queue<int> que1;
    que1.push(0);
    while(!que1.empty()){
        int node = que1.front();
        que1.pop();
        for(auto nv:edge[node]){
            if(dist1[nv] == L_INF && nv != to_1){
                res1++;
                dist1[nv] = dist1[node]+1;
                que1.push(nv);
            }
        }
    }
    //out(res1);

    //ノードnから幅優先で,to_nになったら探索中止
    ll resn = 0;
    dist1[n-1] = 0;
    que1.push(n-1);
    while(!que1.empty()){
        int node = que1.front();
        que1.pop();
        for(auto nv:edge[node]){
            if(dist1[nv] == L_INF && nv != to_n){
                resn++;
                dist1[nv] = dist1[node]+1;
                que1.push(nv);
            }
        }
    }
    //out(resn);
    if(res1 > resn)out("Fennec");
    else out("Snuke");
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
#define INF 100000000

int main(){
    ll X,now=100,cnt=0;
    cin >> X;
    
    while(now<X){
        cnt ++;
        now *= 1.01;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3620
N,D = map(int, input().split())
X = [0]*N
Y = [0]*N

for i in range(N):
    X[i], Y[i] = map(int, input().split())

ans = 0
for i in range(N):
    dist = X[i]*X[i] + Y[i]*Y[i]
    if dist <= D*D:
        ans += 1

print(ans)
    

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  for(int i = 1; i <= N ; i++) {
    cin >> a.at(i);
  }
  
  int now = 1;
  int count = -1;
  for(int i = 1; i < N; i++) {
    now = a.at(now);
    if(now == 2) {
      count = i;
      break;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3724
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  int dis[11] = {};
  for(int i = 0; i < k; i++) {
    int tmp;
    cin >> tmp;
    dis[tmp] = 1;
  }
  int ans = n;
  while(true) {
    int c = ans;
    bool ok = true;
    while(c > 0) {
      if(dis[c % 10] == 0) {
        c /= 10;
        continue;
      } else {
        ok = false;
        break;
      }
    }
    if(ok) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  return 0;
}

Measured memory_bytes: 3580
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,i,j,k,x,y,z;
LL a[N],b[N];
char c[N];

struct Data{
	LL x,y;
}d[N];

IL LL Abs(LL x){return (x<0)?-x:x;}
IL void Swap(LL &a,LL &b){a^=b^=a^=b;}
IL LL Min(LL a,LL b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();	k=read();
	for (i=1;i<=n;i++)	a[i]=read();
	for (i=k+1;i<=n;i++){
		if (a[i]>a[i-k])	puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 5208
#include<iostream>

#define REP(i,j,k) for(int i=j;i<=k;++i)
int A[9]={1,2,4,7,12,20,29,38,52}; long long B[11][11],N;

int main(){
	std::cin>>N; long long MX=1;
	REP(i,2,N){REP(j,1,i-1){B[i][j]=B[j][i]=MX*A[j - 1];}MX+=B[i][i-1]+B[i][i-2]-B[i-1][i-2];}
	REP(i,1,N) REP(j,1,N) std::cout << B[i][j] << " \n"[j == N];
}

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

typedef pair<int,int> P;
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;

	static int n;
	static string s[200010];

ll ret=0;
int sum[26];
struct trie{
	int cnt[26];
	trie* nex[26];
	void init(){
		for(int i=0;i<26;i++){
			cnt[i]=0;
			nex[i]=nullptr;
		}
	}
	void add(int i,int j){
		for(int k=0;k<26;k++){
			sum[k]+=cnt[k];
		}
		ret+=sum[s[i][j]-'a'];
		sum[s[i][j]-'a']=0;
		if(j+1==s[i].size()){
			cnt[s[i][j]-'a']++;
			return;
		}
		if(nex[s[i][j]-'a']==nullptr){
			nex[s[i][j]-'a']=new trie;
			nex[s[i][j]-'a']->init();
		}
		nex[s[i][j]-'a']->add(i,j+1);
	}
}root;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		reverse(s[i].begin(),s[i].end());
	}
	
	vector<P> vec;
	for(int i=0;i<n;i++){
		vec.push_back(P(s[i].size(),i));
	}
	sort(vec.begin(),vec.end());
	
	root.init();
	for(int i=0;i<vec.size();i++){
		for(int k=0;k<26;k++)sum[k]=0;
		root.add(vec[i].sc,0);
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 323048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j*100+k*50==x){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 3564
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
    int N;
    scanf("%d",&N);
    ll t,a;
    ll anst,ansa;
    anst=ansa=1;
    ll m,n;
    while(N--)
    {
        scanf("%lld%lld",&t,&a);
        m=anst/t;
        n=ansa/a;
        if(m*t!=anst)
            m++;
        if(n*a!=ansa)
            n++;
        n=max(n,m);
        anst=t*n;
        ansa=a*n;
    }
    printf("%lld\n",anst+ansa);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 50 + 11;

int n,m,a[N][N],b[N][N],ans[N][N];


void prod1(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                b[i][j] += ans[i][k]*a[k][j];
                b[i][j] %= mod;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            ans[i][j] = b[i][j];
            b[i][j] = 0;
        }
    }
}

void prod2(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                b[i][j] += a[i][k]*a[k][j];
                b[i][j] %= mod;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            a[i][j] = b[i][j];
            b[i][j] = 0;
        }
    }
}

void poww(int p){
    while(p){
        if(p%2)prod1();
        prod2();
        p /= 2;
    }
}

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);


    cin >> n >> m;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> a[i][j];
            ans[i][j] = (i == j ? 1 : 0);
        }
    }

    poww(m);

    int rs = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            rs += ans[i][j];
            rs = (rs + mod)%mod;
        }
    }

    rc(rs);
return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
priority_queue<double,vector<double>,greater<double> > Q;
int i,j,k,n,m;
int main() {
	cin>>n;
    for (int i = 1,x;i <= n;i++) scanf("%d",&x),Q.push(x);
    for (int i = 1;i < n;i++) {
        double x,y;
      	x = Q.top(); Q.pop(); 
      	y = Q.top(); Q.pop();
        Q.push((x+y)/2.);
    }
    printf("%.5f",Q.top());
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int N = 0;
    int K = 0;
    int d = 0;
    int count = 0;
    scanf("%d %d", &N, &K);

    int S[100] = {0};
    int A[K][N];
    for (int i = 0; i < K; i++){
        scanf("%d", &d);
        for (int j = 0; j < d; j++){
            scanf("%d", &A[i][j]);
            S[A[i][j] - 1] = 1;
        }
    }

    for (int k = 0; k < N; k++){
        if (S[k] == 0){
            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1736
import heapq
n, m = map(int,input().split())
jobs = [list(map(int, input().split())) for _ in range(n)]
jobs.sort(reverse=True)
q = []
sum = 0

for i in range(m+1):
    #1行後でpopで取り出すので，-1で指定しないといけない
    while jobs and jobs[-1][0] < i+1:
        a,b = jobs.pop()#jobsの一番最後の要素を取り出して削除
        #あとで最大の要素を取り出したいが，heappopは最小の要素を取り出すので-1倍して格納
        heapq.heappush(q,-b)
            
    
    if q:#リストqが空のときはskip
        #heappopで最小の要素を-1倍して取り出すと最大の要素
        sum += -heapq.heappop(q)
print(sum)

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

class State {
public:
	int p[31];
	int n;
	bool is_over()
	{
		return p[1] == p[2] && p[2] == p[3] && p[3] == p[4] && p[4] == p[5]
			&& p[5] == p[6] && p[6] == p[7] && p[7] == p[8] && p[8] == p[9]
			&& p[10] == p[11] && p[11] == p[12]
			&& p[13] == p[14] && p[14] == p[15]
			&& p[16] == p[17] && p[17] == p[18]
			&& p[19] == p[20] && p[20] == p[21];
	}

	void rot1()
	{
		swap(p[7], p[22]);  swap(p[8], p[23]);  swap(p[9], p[24]);
		swap(p[10], p[12]);  swap(p[13], p[18]);
	}

	void rot2()
	{
		swap(p[1], p[28]);  swap(p[2], p[29]);  swap(p[3], p[30]);
		swap(p[19], p[21]);  swap(p[15], p[16]);
	}

	void rot3()
	{
		swap(p[1], p[24]);  swap(p[4], p[27]);  swap(p[7], p[30]);
		swap(p[16], p[18]);  swap(p[10], p[21]);
	}

	void rot4()
	{
		swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p[9], p[28]);
		swap(p[13], p[15]);  swap(p[12], p[19]);
	}
};

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

	for (int i = 0; i<N; i++) {
		State now;
		for (int j = 1; j <= 30; j++) {
			cin >> now.p[j];
		}
		now.n = 0;

		queue<State> que;
		que.push(now);

		while (!que.empty()) {
			now = que.front();
			que.pop();

			if (now.is_over()) {
				cout << now.n << endl;
				break;
			}

			State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
			State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
			State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
			State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
		}
	}

	return 0;
}

Measured memory_bytes: 13896
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::greater<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> m >> n;
  vector<pair<int, int>> a(n);
  for (auto& pr : a) {
    cin >> pr.first >> pr.second;
  }
  vector<int64> d(m + 1, inf64);
  d[0] = 0;
  for (int i = 0; i < m; ++i) {
    for (const auto& pr : a) {
      int to = min(m, i + pr.first);
      d[to] = min(d[to], d[i] + pr.second);
    }
  }
  cout << d[m] << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
int n, q;

long long int d[100000000];
 
struct edge{
    int to;
    int cost;
};
 
void dfs(int a, const vector<vector<edge> >&v, int b){
    d[a-1] += b;
    for(int i = 0; i < v[a-1].size(); i++){
        dfs(v[a-1][i].to, v , d[a-1]);
    }
}
int main(){
    cin >> n >> q;
    vector<vector<edge> > tree(n);
    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        edge e = {b, 0};
        tree[a-1].emplace_back(e);
    }
 
    for(int i = 0; i < q; i++){
        int a, b;cin >> a >> b;
        d[a-1] += b;
    }

    dfs(1, tree, 0);
 
    for(int i = 0; i < n; i++){
        cout << d[i] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 24320
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nd = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
            Console.WriteLine((long)Math.Ceiling(nd[0] / (2 * nd[1] + 1)));
        }
    }
}


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

void Main() {
	int N, A, B;
	cin >> N >> A >> B;

	int sum = 0;
	for (int i = 1; i <= N; i++) {
		int num = i;
		int keta_sum = 0;
		while (num) {
			int dig = num % 10;
			keta_sum += dig;
			num /= 10;
		}
		if (keta_sum >= A && keta_sum <= B) {
			sum += i;
		}
	}
	cout << sum << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

stack<int>S;
char O[10];
int a,b;
int POP()
{
	int t=S.top();
	S.pop();
	return t;
}

int main()
{
	for(;~scanf("%s",O);)
	{
		switch(O[0])
		{
		case '+':b=POP();a=POP();S.push(a+b);break;
		case '-':b=POP();a=POP();S.push(a-b);break;
		case '*':b=POP();a=POP();S.push(a*b);break;
		default:S.push(atoi(O));
		}
	}
	printf("%d\n",S.top());
}

Measured memory_bytes: 1180
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[21], B[21], C[21];
    rep(i, N) cin >> A[i];
    rep(i, N) A[i]--;
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];
    int ans = 0;
    rep(i, N) {
        ans += B[i];
    }
    rep(i, N - 1) {
        if(A[i] + 1 == A[i + 1]) ans += C[A[i]];
    }
    cout << ans << endl;
    


    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  int pos = -1, neg = 0, poskeep, negkeep;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    if(a.at(i) > pos){
      pos = a.at(i);
      poskeep = i;
    }
    if(a.at(i) < neg){
      neg = a.at(i);
      negkeep = i;
    }
  }
  
  vector<pair<int, int>> ans;
  if(pos >= neg * (-1)){
    for(int i = 0; i < n; i++){
      if(a.at(i) < 0){
        ans.push_back(make_pair(poskeep + 1, i + 1));
        a.at(i) += pos;
      }
    }
    for(int i = 1; i < n; i++){
      if(a.at(i - 1) > a.at(i)){
        ans.push_back(make_pair(i, i + 1));
        a.at(i) += a.at(i - 1);
      }
    }
  }
  else{
    for(int i = 0; i < n; i++){
      if(a.at(i) > 0){
        ans.push_back(make_pair(negkeep + 1, i + 1));
        a.at(i) += neg;
      }
    }
    for(int i = n - 2; i >= 0; i--){
      if(a.at(i) > a.at(i + 1)){
        ans.push_back(make_pair(i + 2, i + 1));
        a.at(i) += a.at(i + 1);
      }
    }
  }
  
  cout << ans.size() << '\n';
  for(int i = 0; i < ans.size(); i++){
    cout << ans.at(i).first << " " << ans.at(i).second << '\n';
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int a[210],sum = 0,mn = 10000000,ans;
int main(){
	int i,l,n;
	cin >> n >> l;
	for(i=1;i<=n;i++){
		a[i] = l + i - 1;
		sum += a[i];
	}
	for(i=1;i<=n;i++){
		if(mn>abs(a[i])){
			mn = abs(a[i]);
			ans = sum - a[i];
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 256
import Data.Int (Int64)

findCand :: Integral a => a -> a -> Maybe (a, a, a)
findCand n y
    | null cands = Nothing
    | otherwise = Just $ head cands
    where
        y0 = div y 1000
        cands = [(a, b, c) | a <- [0 .. n], b <- [0 .. n],
                             let c = n - a - b, c >= 0,
                             10 * a + 5 * b + c == y0]

main :: IO ()
main = do
    [n, y] <- fmap read . words <$> getLine :: IO [Int64]
    let res = case findCand n y of
                Just (a, b, c) -> [a, b, c]
                Nothing -> [-1, -1, -1]
    putStrLn $ unwords $ fmap show res


Measured memory_bytes: 1020
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V s,x,z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V &Mx(const V &_x){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
void O(const V &r){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
s.resize(99);
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		//V x(n*n);
		x.resize(0);
		x.resize(n*n);
		V e(n*n);
		//e.resize(0);
		//e.resize(n*n);
		z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1)e=Me(e,x);
			x=Mx(x);
		}
		O(e);
	}
}

Measured memory_bytes: 1088
if __name__ == '__main__':
    n = int(input())
    for _ in range(n):
        x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
        #print((y2-y1)/(x2-x1) - (y4-y3)/(x4-x3))
        '''if math.fabs(x1 - x2) <= 0.00001 and math.fabs( x3 - x4) <= 0.00001:
            print("YES")
        elif math.fabs(x1 - x2) <= 0.00001:
            print("NO")
        elif math.fabs(x3 - x4) <= 0.00001:
            print("NO")
        else:
        '''
        if abs((x2-x1) * (y4-y3)-(x4-x3)*(y2-y1)) < 1e-10:
            print("YES")
        else:
            print("NO")

Measured memory_bytes: 7716
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    R = []
    for _ in range(N):
        a, b = map(int, input().split())
        R.append([a, b])
    B = []
    for _ in range(N):
        c, d =  map(int, input().split())
        B.append([c, d])
    R = sorted(R, key=lambda x: x[0])
    B = sorted(B, key=lambda x: x[0])

    ans = 0
    used = []
    for i in range(N):
        x, y = -1, -1
        j = 0
        while j < N and R[j][0] < B[i][0]:
            s, t = R[j][0], R[j][1]
            if t < B[i][1] and t > y and s not in set(used):
                x = s
                y = t
            j += 1
                
        if x >= 0:
            used.append(x)
    print(len(used))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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


int main(){
    string s;
    cin >> s;
    string ans;
    rep(i, s.size()){
        if(s[i] == '0'){
            ans += '0';
        }else if(s[i] == '1'){
            ans += '1';
        }else if(ans.size() > 0){
            ans.pop_back();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<P1>edge[10005];
int n,m;
ll dist[10005];
int main(){
	while(1){
		cin>>n>>m;
		if(n==0 && m==0) return 0;
		rep(i,10005){
			edge[i].clear();
			dist[i] = 1e18;
		}
		rep(i,m){
			int u,v,d,c;
			scanf("%d%d%d%d",&u,&v,&d,&c);
			edge[u].pb(mp(v,mp(d,c)));
			edge[v].pb(mp(u,mp(d,c)));
		}
		priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > >que;
		que.push(mp(0,1));
		dist[1] = 0;
		while(!que.empty()){
			pair<ll,int> p = que.top(); que.pop();
			if(dist[p.sc] != p.fi) continue;
			for(int i=0;i<edge[p.sc].size();i++){
				int to = edge[p.sc][i].fi;
				int add = edge[p.sc][i].sc.fi;
				if(dist[to] > dist[p.sc]+add){
					dist[to] = dist[p.sc]+add;
					que.push(mp(dist[to],to));
				}
			}
		}
		ll ans = 0;
		for(int i=2;i<=n;i++){
			int x = INF;
			for(int j=0;j<edge[i].size();j++){
				int to = edge[i][j].fi;
				int add = edge[i][j].sc.fi;
				int cs = edge[i][j].sc.sc;
				if(dist[i] == dist[to]+add){
					x = min(x,cs);
				}
			}
			ans += x;
		}
		cout<<ans<<endl;
	}
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int dp[1<<20];
Int a[20][20];

int main() {
    Int n;
    while (cin >> n and n) {
        for (Int i = 0; i < n; i++) {
            for (Int j = 0; j < n + 1; j++) {
                cin >> a[i][j];
            }
        }
        queue<Int> q;
        q.push(0);
        for (Int i = 0; i < (1<<n); i++) {
            dp[i] = INF;
        }
        dp[0] = 0;
        while (not q.empty()) {
            Int p = q.front();
            q.pop();
            for (Int i = 0; i < n; i++) {
                if (p & (1<<i)) continue;
                Int cost = a[i][0];
                for (Int j = 0; j < n; j++) {
                    if (p & (1<<j)) {
                        cost = min(cost, a[i][j + 1]);
                    }
                }
                if (dp[p | (1<<i)] > dp[p] + cost) {
                    dp[p | (1<<i)] = dp[p] + cost;
                    q.push(p | (1<<i));
                }
            }
        }
        print(dp[(1<<n) - 1]);
    }
    return 0;
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  ll ans = 0;
  REP(i, N) {
    cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384