akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main(void) {
    ll N, M, i;
    cin >> N >> M;
    P p[100001] ;
    ll ans=0, t=-1;
    for(i=0; i<M; i++) {
        cin >> p[i].second >> p[i].first;
    }
    sort(p, p+M);
    
    for(i=0; i<M; i++) {
        if(p[i].second<=t && t<p[i].first) continue;
        else {
            ans++;
            t=p[i].first-1;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1920
#include <stdio.h>

int 
main(){
	double W,H,x,y;
	int L[100];

	scanf("%lf %lf %lf %lf",&W ,&H,&x,&y);
	
	if(x==W/2 && y==H/2){
		printf("%lf 1\n",(double)(W/2*H));	
		return 0;
	}
	if(x==W/2){
		printf("%lf 0\n",(double)(W/2*H));	
		return 0;
	}
	else if(y==H/2){
		printf("%lf 0\n",(double)(H/2*W));	
		return 0;
	}
	else{
		printf("%lf 0\n",(double)(H/2*W));	
		
	}

 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;

/*Starry Sky Tree*/
/*Range Add Min(Max) Query*/
/*区間加算、区間Min,区間Max*/

class RMAQ{
public: 
  
  //遅延用の型  
  struct T{
    bool type; //0 - empty   , 1 - update
    int value;
    T():type(0),value(0){}
    T(bool type,int value):type(type),value(value){}
  };

  //比較可能な主データ型
  struct D{
    int value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(int value):value(value){}
    bool operator < (D a)const {return value < a.value;} //merge用
  };
  
  D INF = D(1LL<<55); /*!!!!!!!!!!!!!!!!!!!!!!!!*/

  int n;
  vector<D> dat;
  vector<T> td;
  int toMax; //0 -> RangeMin, 1 -> RangeMax
  
  RMAQ(){n=-1;}
  RMAQ(int n_,int toMax = 0){
    this->toMax = toMax;
    n=1;
    while(n<n_)n*=2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  D merge(D a,D b){return min(a,b);}
  
  void delay(int k){
    if(td[k].type==0) return;
    int v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    
    int l = k*2+1,r = k*2+2;
    dat[l].value += v; td[l].type = 1; td[l].value += v;
    dat[r].value += v; td[r].type = 1; td[r].value += v;
  }

  D update(int k,int x){
    td[k].type = 1;
    td[k].value += x;
    dat[k].value += x;
    return dat[k];
  }
  
  //[a,b)の値をx加算　add(a,b,x)
  D add(int a,int b,int x,bool flg=true,int k=0,int l=0,int r=-1){
    if(r==-1 && toMax) x *= -1; 
    if(r==-1) r=n, assert(a < n && b <= n);
    if(r<=a||b<=l) return flg? dat[k]:INF;
    if(a<=l&&r<=b) return flg? update(k,x):dat[k];
    
    delay(k);
    D vl = add(a,b,x,flg,k*2+1,l,(l+r)/2);
    D vr = add(a,b,x,flg,k*2+2,(l+r)/2,r);
    if(flg) dat[k] = merge(vl,vr);
    return merge(vl,vr);
  }
  
  //[a,b)の最小値を得る　find(a,b);
  int find(int a,int b){
    D res = add(a,b,0,false);
    if(toMax) res.value *= -1; 
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RMAQ rmaq(n);
  while(q--){
    int ord;
    cin>>ord;
    if(ord == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rmaq.add(s,t+1,x);
    }
    if(ord == 1){
      int s,t;
      cin>>s>>t;
      cout<<rmaq.find(s,t+1)<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 8920
#include <stdio.h>

int main(void)
{
	int a[31]={0},i,m;
	for(i=1;i<=28;i++){
	scanf("%d",&m);
	a[m]=1;
	}
	for(i=1;i<=30;i++){
	if(a[i]==0)
	{
		printf("%d\n",i);
	}
	}
	return 0;
}


Measured memory_bytes: 2048
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //

// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::pair;using std::set;using std::string;using std::vector;
using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;
#define ff first
#define ss second
#define pb emplace_back
template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}
template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#endif
}}init;

const int N = 228;
ll a[N];

int main() {

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

    ll ans = 0;
    while (1) {
        int ok = 1;
        for (int i = 0; i < n; ++i)
            if (a[i] >= n)
                ok = 0;
        if (ok) break;
        int w = std::max_element(a, a + n) - a;
        ll c = a[w] / n;
        a[w] %= n;
        ans += c;
        for (int i = 0; i < n; ++i)
            if (i ^ w) 
                a[i] += c;
    }

    cout << ans << '\n';

    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll beki(ll A,ll B){ //A^B
    ll C=1;
    if(B==0){
        return 1;
    }
    else{
        for (ll i = 0; i < B; i++){
        C *= A;
        }
    }
    return C;
}

vector<ll> A1;

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

    ll A;
    

    cin >> A;


    REPS(i,31){
        for (ll j = 2; j <= 10; j++) {
            
        
            ll tmp = beki(i, j);
            if(tmp<=1000){
                A1.push_back(tmp);
            }
        }
    }

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

    ll a_s = A1.size();

    RREP(i,a_s){
        if(A1.at(i)<=A){
            cout << A1.at(i) << endl;
            break;
        }
    }


    
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[60][60];
int main()
{
    ll n,t,m,x,i,j,c=0,k,l,z,maxi = INT_MIN,mini = INT_MAX,flag =0,sum=0;
    vector<ll>vi;
    cin>>n>>m;
    string s[n+1];

    for(i = 0 ;i<n ;i++)
    {
        cin>>s[i];
    }
    for(i = 0 ;i<n ;i++)
    {
        for(j = 0 ;j<m ;j++)
        {
        c=0;
            if(s[i][j]=='.')
            {
                for(l = -1 ;l<2;l++)
                {
                    for( z = -1 ;z<2 ;z++)
                    {
                        if(l+i>=0 && l+i<n && z+j>=0 && z+j<m)
                        if(s[l+i][z+j]=='#')
                            c++;
                    }
                }
                arr[i][j]=c;
            }
        }
    }
    for(i = 0 ;i<n ;i++)
    {
        for(j = 0 ;j<m ;j++)
        {
            if(arr[i][j]>0)
                cout<<arr[i][j];
            else if(s[i][j]=='.')
                cout<<0;
            else
                cout<<s[i][j];
        }
        cout<<endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
    return x * x;
}

signed main () {
int N ,M;
    cin >> N >> M;
vector<int> A(M);
int sum = 0;
rep(i,M){
    cin >> A.at(i);
sum += A.at(i);
}
if( N-sum < 0){
    cout << -1 << endl;
}else {
    cout << N -sum << endl; 
}
return 0;
}



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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt N, K, A[200000]; cin >> N >> K;
	REP(i, N) cin >> A[i];
	lnt left = 0, right = 1000000010;
	while(right - left > 1){
		lnt mid = (left + right) / 2;
		lnt cnt = 0;
		REP(i, N){
			cnt += (A[i]-1) / mid;
		}
		if(cnt <= K) right = mid;
		else left = mid;
	}
	cout << right << ln;
}

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

const int NMAX = 200010;

int tata[NMAX];
vector <int> adia[NMAX];

struct Raport {
	int nr0 = 0, nr1 = 1, nod;
	friend bool operator< (const Raport & a, const Raport & b) {
		long long x = 1LL * a.nr0 * b.nr1 - 1LL * a.nr1 * b.nr0;
		if (x != 0)
			return x > 0;
		return a.nod < b.nod;
	}
};

set <Raport> noduri;
int nr0[NMAX], nr1[NMAX];

namespace UF {
	int tata[NMAX];
	
	int find(int x) {
		if (tata[x] != tata[tata[x]])
			tata[x] = find(tata[x]);
		return tata[x];
	}
	
	void init(int n) {
		iota(tata, tata + n + 1, 0);
	}
}


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	UF::init(n);
	
	for (int i = 2; i <= n; i++) {
		cin >> tata[i];
		adia[tata[i]].push_back(i);
	}
	
	for (int i = 1; i <= n; i++) {
		int nr;
		cin >> nr;
		if (nr == 0)
			nr0[i]++;
		else
			nr1[i]++;
		if (i != 1)
			noduri.insert({ nr0[i], nr1[i], i });
	}
	
	long long ans = 0;
	
	while (!noduri.empty()) {
		int nod = noduri.begin()->nod;
		noduri.erase(noduri.begin());
		nod = UF::find(nod);
		int t = tata[nod];
		t = UF::find(t);
		/// ma unesc cu tata
		ans += 1LL * nr1[t] * nr0[nod];
		
		if (t != 1)
			noduri.erase({ nr0[t], nr1[t], t });
		
		nr1[t] += nr1[nod];
		nr0[t] += nr0[nod];
		UF::tata[nod] = t;
		if (t != 1)
			noduri.insert({ nr0[t], nr1[t], t });
	}
	
	cout << ans << '\n';
	
	return 0;
}


























Measured memory_bytes: 26880
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    int n;
    char c;
    int r = 0, b = 0;
    cin >> n;
    REP(i, n) {
    	cin >> c;
    	if(c == 'R') ++r;
    	else ++b;
    }
    cout << (r > b ? "Yes" : "No") << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size())
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

typedef pair<int, int> ii;

int A[200005];
int B[200005];

int D[100005];
ii D2[100005];

vector<int> AdjList[100005];

char c[100005];

map<ii, int> m;
int W[200005];

int main(){
    int N, M;
    scanf("%d%d", &N, &M);

    set<ii> pq;
    for(int i = 1; i <= N; i ++){
        scanf("%d", &D[i]);
        //D2[i] = ii(D[i], i);
        pq.insert(ii(D[i], i));
    }

    set<ii> s;
    for(int i = 1; i <= M; i ++){
        scanf("%d%d", &A[i], &B[i]);

        AdjList[A[i]].push_back(B[i]);
        AdjList[B[i]].push_back(A[i]);
        s.insert(ii(A[i], B[i]));
        s.insert(ii(B[i], A[i]));
        m[ii(A[i], B[i])] = i;
        m[ii(B[i], A[i])] = i;
    }

    for(int i = 1; i <= M; i ++){
        W[i] = 1000000000;
    }

    memset(c, 0, sizeof(c));
    while(!pq.empty()){
        ii temp = *pq.begin(); pq.erase(pq.begin());
        int w = temp.first;
        int u = temp.second;

        //printf("w=%d u=%d\n", w, u);

        if(c[u] == 0){
            bool found = false;
            for(int v: AdjList[u]){
                if(c[v] == 'W'){
                    W[m[ii(u, v)]] = w;
                    c[u] = 'B';
                    found = true;
                    //printf("c[%d]=%c c[%d]=%c\n", u, c[u], v, c[v]);
                    break;
                }else if(c[v] == 'B'){
                    W[m[ii(u, v)]] = w;
                    c[u] = 'W';
                    found = true;
                    //printf("c[%d]=%c c[%d]=%c\n", u, c[u], v, c[v]);
                    break;
                }
            }

            if(!found){
                if(pq.empty()){
                    printf("-1");
                    return 0;
                }
                ii temp = *pq.begin();
                int w2 = temp.first;
                int v = temp.second;
                if(w != w2){
                    printf("-1");
                    return 0;
                }

                for(int v: AdjList[u]){
                    if(D[v] == D[u] && c[v] == 0){
                        c[u] = 'W';
                        c[v] = 'B';
                        pq.erase(ii(D[v], v));
                        W[m[ii(u, v)]] = w;
                        found = true;
                        //printf("c[%d]=%c c[%d]=%c\n", u, c[u], v, c[v]);
                        break;
                    }
                }

                if(!found){
                    printf("-1");
                    return 0;
                }
            }
        }else{
            throw;
        }
    }

    for(int i = 1; i <= N; i ++){
        printf("%c", c[i]);
    }
    printf("\n");

    for(int i = 1; i <= M; i ++){
        printf("%d\n", W[i]);
    }
    return 0;
}


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

using namespace std;

const int MAX = 1000005;

string A;

int N;
int K;

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

    N = (int) A.length();

    for (int i = 0; i < N; ++i) {
        if (A[i] != 'a' && K >= ('z' - A[i] + 1)) {
            K -= ('z' - A[i] + 1);
            A[i] = 'a';
        }
    }

    K = K % 26;

    A[N-1] += K;

    cout << A << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i = 1 ; i <= 9; ++i){
      for(int j = 1; j <= 9; ++j){
        if(i*j == n){
          System.out.println("Yes");
          return;
        }
      }
    }
    
    System.out.println("No");
    
  }
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,ans = 0;
	cin >> n >> k;
	while (n > 0) {
		++ans;
		n = n/k;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3640
n,d=map(int,input().split())
x= [list(map(int, input().split())) for i in range(n)]
lis=list(i**2 for i in range(0,128))
ans=0
for i in range(n):
    for k in range(i+1,n):
        check=0
        for j in range(d):
            check+=(x[i][j]-x[k][j])**2
        if check in lis:
            ans+=1
print(ans)

Measured memory_bytes: 61972
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> a(n),cnt(9);
	for (int i = 0; i < n; i++){
		cin>>a[i];
		a[i]/=400;
		if(a[i]>8) a[i] = 8;
		cnt[a[i]]++;
	}
	int num = 0;
	for (int i = 0; i < 8; i++){
		if(cnt[i]>0) num++;
	}
	cout<<(num>0?num:1)<< " "<<num+cnt[8]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int H1, M1, H2, M2;
  int K;
  scanf("%d", &H1);
  scanf("%d", &M1);
  scanf("%d", &H2);
  scanf("%d", &M2);
  scanf("%d", &K);
  int h1 = H1*60+M1;
  int h2 = H2*60+M2;
  int ans=h2-h1-K;
  std::cout << ans << std::endl;
  return 0;
}

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

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

  int x; cin >> x;
  double ans = 1;
  double power = 0;

  for (double i = 1; i <= x; i++) {
    for (double j = 2; j <= x; j++) {
      power = pow(i, j);
      if (power <= x) {
        ans = max(ans, power);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <ios>
#include <string>
using namespace std;
int main(void){
  int l;
  cin >> l;
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i=0;i<l-2;i++){
    string ss = s.substr(i,3);
    if(ss == "ABC") ans ++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string c;
	cin>>c;
	int f=0,t=0;
	for(int i=0;i<c.size();i++) f|=c[i]=='B',t|=c[i]=='A';
	if(!f||!t) cout<<"No";
	else cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)>abs(x-b)){
    cout << 'B' << endl;
  }else{
    cout << 'A' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
int div1[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    int j = 1;
    for (int i = 2; i < 1001; i++)
    {
        if (!vis[i * j])
        {
            while (i * j < 1001)
            {
                div1[i * j] = i;
                vis[i * j] = 1;
                j++;
            }
        }
        j = 1;
    }
    div1[1] = 1;
    // for (int i = 1; i < 20; i++)
    //   cout << div1[i] << "\n";
    int n, a, b;
    cin >> n >> a >> b;
    int dp[n];
    for (int i = 0; i < n; i++)
        cin >> dp[i];
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        ans += min((dp[i] - dp[i - 1]) * a, b);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 6684
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>s;
 rep(i,0,s.length())
 {
   if(i==n) break;
   cout<<s[i];
 }
 if(i!=s. length())
 cout<<"...";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    x=0;char c=getchar();bool f=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7,N=2e6+5;
int x,y,xx,yy,fac[N],inv[N],n;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

int C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int calc(int n,int m){
	int tot=0;
	for(int i=1;i<=m;i++) tot=(tot+C(n+i+1,i+1))%mod;
	return ((tot-m)%mod+mod)%mod;
}

signed main(){
	read(x);read(y);read(xx);read(yy);
	n=max(xx,yy)*2+1;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=fpow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	write(((calc(xx,yy)-calc(x-1,yy)-calc(xx,y-1)+calc(x-1,y-1))%mod+mod)%mod);
}


Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
  int ab = a + b;
  int ac = a + c;
  int bc = b + c;
  

  
  if (ab == c){
    
      cout << "Yes" << endl;
    return 0;
  }
 
  if (ac == b){
    
      cout << "Yes" << endl;
    return 0;
  }
  
  if (bc == a){
    
      cout << "Yes" << endl;
    
    return 0;
  }
  
   cout << "No" << endl;
  

  
  return 0;
}

Measured memory_bytes: 256
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    ll n;
    cin >> n;
    ll m = 1000;
    ll s = 0;
    ll a[n+1];
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(ll i = 0; i < n-1; i++)
    {
        if(a[i] > a[i+1])
        {
            m+=s*a[i];
            s = 0;
        }
        if(a[i] < a[i+1])
        {
            s += m/a[i];
            m = m%a[i];
        }
    }
    m+=s*a[n-1];
    cout << m << endl;
}


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

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

            string ans = "No";

            for (int i = Math.Min((int)Math.Sqrt(N), 9) ; i >= 1; i--) {
                if (N % i == 0 && (N / i) <= 9) {
                    ans = "Yes";
                    break;
                }

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+2];
		a[0] = 0;
		for(int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		a[n+1] = 0;

		// 全ルートの計算
		int sum = 0;
		int pos = 0;
		for(int i = 0; i <= n; i++) {
			sum += Math.abs(pos - a[i]);
			pos = a[i];
		}
		sum += Math.abs(pos);

		StringBuilder sb = new StringBuilder();
		for(int i = 1; i <= n; i++) {
			int sum2 = sum;
			if( (a[i] - a[i - 1]) >= 0 && ((a[i+1] - a[i]) >= 0) || (a[i] - a[i - 1]) <= 0 && ((a[i+1] - a[i]) <= 0) ) {
				sb.append(sum2);
				sb.append("\n");
				continue;
			}
			sum2 -= Math.abs(a[i - 1] - a[i]);
			sum2 -= Math.abs(a[i] - a[i + 1]);
			sum2 += Math.abs(a[i - 1] - a[i+1]);
			sb.append(sum2);
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 53880
#include <stdio.h>

int main() {
  int i, n = 0;
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  for (i = a; i <= b; i++) {
    if (c % i == 0) n++;
  }
  printf("%d\n", n);
  return 0;
}



Measured memory_bytes: 2104
fn main() {
    let n = read::<i32>();
    let mut v: Vec<i32> = vec![];
    let mut res: i32 = 0;
    for _ in 0..n {
        let i = read::<i32>();
        v.push(i);
        res += i;
    }
    println!("{}", res - (v.iter().max().unwrap() / 2));
}

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

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

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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var inputIntArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i));

            long a = inputIntArray.ElementAt(0);
            int b = inputIntArray.ElementAt(1);
            double x = inputIntArray.ElementAt(2);

            //水が入っていない体積を求める
            double max = a * a * b;
            double empty = max - x;

            if (x < max / 2)
            {
                //水の入っている領域が、xと一致すればいい
                double tan = (2 * x) / (b * b * a);
                var radian = Math.Atan(tan);
                var theta = radian * 180 / Math.PI;
                Console.WriteLine(90 - theta);
            }
            else
            {
                //この体積になるような角度を求める
                //これがa^3 * tan0 が一致すればいい
                double tan = (2 * empty) / (a * a * a);
                var radian = Math.Atan(tan);
                var result = radian * 180 / Math.PI;
                Console.WriteLine(result);
            }
        }
    }
}

Measured memory_bytes: 11220
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;


//#[proconio::fastout]
fn main() {
    input! {
        mut n: u64,
        k: u64,
    }

    if n >= k {
        n = n % k;
    }
    println!("{}", min(n, k - n));
}


Measured memory_bytes: 2148
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int d[n+1];
  for(int i=0;i<n;i++){
scanf("%d",&d[i]);
  }
  int ans=0;
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
ans+=d[i]*d[j];
  }
}
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
using System;

class Program {

    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int r = int.Parse( values[ 0 ] );
        int c = int.Parse( values[ 1 ] );

        int[ , ] data = new int[ r + 1, c + 1 ];

        for( int i = 0; i < r; ++i ) {
            input = Console.ReadLine();
            values = input.Split( ' ' );

            int sum = 0;
            for( int j = 0; j < c; ++j ) {
                var value = int.Parse( values[ j ] );
                data[ i, j ] = value;
                data[ r, j ] += value;
                sum += value;
            }
            data[ i, c ] = sum;
            data[ r, c ] += sum;
        }

        for( int i = 0; i < r + 1; ++i ) {
            for( int j = 0; j < c + 1; ++j ) {
                var output = string.Format( "{0}{1}", data[ i, j ], ( j != c ) ? " " : string.Empty );
                Console.Write( output );
            }
            Console.WriteLine();
        }

        return 0;
    }

}

Measured memory_bytes: 18124
//
// Created by maze on 2019/11/03.
//

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

#define INF_LL (int64)le18
#define INF (int32)le9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

class UnionFind{
private:
  size_t n;
public:
  vector<int32> par;
  UnionFind(size_t n):n(n){
    par.resize(n, -1);
  }

  int32 root(int32 x){
    if(par[x] < 0)return x;
    return par[x] = root(par[x]);
  }

  int32 size(int32 x){
    return -par[root(x)];
  }

  bool unite(int32 x, int32 y){
    x = root(x);
    y = root(y);
    if(x == y)return false;
    if(size(x) < size(y))swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  bool same(int32 x, int32 y){
    return root(x) == root(y);
  }

};
//
//int main() {
//  int64 n;
//  cin >> n;
//  map<int64, vector<PII>> mp;
//  vector<int64> a(n);
//  REP(i, n) cin >> a[i];
//  sort(all(a));
//  REP(i, n) {
//    FOR(j, i+1, n) {
//      if (abs(a[i]-a[j]) * 2 >= abs(a[0]-a.back())) continue;
////      cout << i << " " << j << endl;
//      mp[abs(a[i]-a[j])].emplace_back(i, j);
//    }
//  }
//
//  int64 res = 2;
//  UnionFind uf(n);
//  for (auto &v : mp) {
//    for (auto &p : v.sc) {
//      uf.unite(p.fs, p.sc);
//      res = max(res, (int64)max(uf.size(p.fs), uf.size(p.sc)));
//    }
//
//    for (auto &p : v.sc) {
//      uf.par[p.fs] = -1;
//      uf.par[p.sc] = -1;
//    }
//  }
//  cout << res << endl;
//}

int main(void) {
  int64 n;
  cin >> n;
  vector<int64> a(n);
  REP(i, n) cin >> a[i];

  sort(all(a));
  int64 res = 0;
  REP(i, n) {
    FOR(j, i+1, n) {
      int64 d =a[j] - a[i];
      int64 cnt = 2;
      if (*lower_bound(all(a), a[i]-d) == a[i]-d) continue;
      int64 v = a[j];
      while (*lower_bound(all(a), v+d) == v+d) {
        v += d;
        cnt++;
      }
      res = max(res, cnt);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3172
#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;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);

    REP(i, N){
        cin >> A[i];
        B[i] = A[i] - (i+1);
    }

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

    ll ans = 0;
    if(N%2 == 1){
        ll c = B[N/2];
        REP(i, N){
            ans += abs(B[i]-c);
        }
    }
    else{
        ll c1 = B[N/2-1];
        ll c2 = B[N/2];
        ll temp1 = 0;
        ll temp2 = 0;
        REP(i, N){
            temp1 += abs(B[i]-c1);
        }
        REP(i, N){
            temp2 += abs(B[i]-c2);
        }
        ans = min(temp1, temp2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
import heapq


# input values
n, m = list(map(int, input().split()))
A = list(map(lambda x: int(x)*(-1), input().split()))

# use priority queue
heapq.heapify(A)

for _ in range(m):
    tmp_min = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmp_min//2))
print(-sum(A))
    


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

long long L, A[1 << 18], dp[1 << 18][5], S[1 << 18][5];

int main() {
	cin >> L;
	for (int i = 1; i <= L; i++) {
		cin >> A[i];
		S[i][0] = A[i];
		S[i][4] = A[i];
		S[i][2] = ((A[i] % 2) ^ 1);
		if (A[i] == 0) {
			S[i][1] = 2;
			S[i][3] = 2;
		}
		else {
			S[i][1] = (A[i] % 2);
			S[i][3] = (A[i] % 2);
		}
	}

	for (int i = 0; i <= L; i++) {
		for (int j = 0; j <= 4; j++) dp[i][j] = (1LL << 60);
	}
	dp[0][0] = 0;
	for (int i = 1; i <= L; i++) {
		for (int j = 1; j <= 4; j++) dp[i - 1][j] = min(dp[i - 1][j], dp[i - 1][j - 1]);
		for (int j = 0; j <= 4; j++) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + S[i][j]);
		}
	}

	long long ans = (1LL << 60);
	for (int i = 0; i <= 4; i++) ans = min(ans, dp[L][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18688
n, m = map(int, input().split())
sc = []
for i in range(m):
    s, c = map(int, input().split())
    sc.append((s, c))

ans = [-1] * n

if m == 0:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
    exit()

if n == 1 and m == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()

if n == 1:
    for i in range(m):
        if sc[i][1] == 0:
            print(-1)
            exit()
        if ans[0] != sc[i][1] and ans[0] != -1:
            print(-1)
            exit()
        ans[0] = sc[i][1]
    print(sc[0][1])
    exit()

for i in range(m):
    if ans[sc[i][0]-1] != sc[i][1] and ans[sc[i][0]-1] != -1:
        print(-1)
        exit()
    if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        exit()
    ans[sc[i][0]-1] = sc[i][1]

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

for i in ans:
    print(i, end="")
print()


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,Q; cin >> N >> M >> Q;
  vvl a(N,vl(N)),s(N,vl(N+1));
  rep(i,M){
    int l,r; cin >> l >> r ;
    l--; r--;
    a[l][r]++;
  }
  rep(i,N) rep(j,N) s[i][j+1] = s[i][j] + a[i][j];
  rep(i,Q){
    int p,q; cin >> p >> q ;
    p--; q--;
    ll ans = 0;
    REP(j,p,q+1) ans += s[j][q+1];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4864
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll x,a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>x>>a>>b;
	cout<<(x-a)%b;
	return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp

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

int dp[110][10010];

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> vl(n);
    vector<int> wt(n);
    rep(i, n) {
        cin >> vl.at(i) >> wt.at(i);
    }

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

    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= w; j++) {
            if(j < wt.at(i)) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i][j-wt.at(i)] + vl.at(i));
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string X; 
  cin >> X;

  int cnt_S = 0;
  int ans = 0;
  for(int i = 0; i < X.length(); i++){

    if(X[i] == 'S'){
      cnt_S++;
    }else{
      if(cnt_S > 0){
        cnt_S--;
        ans += 2;
      }

    }
  }

  cout << X.length() - ans << endl;


  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
double R, l;
cin >> R;

l = 2 * R * 3.141592;

std::setprecision(2);

cout << l << endl;
}


Measured memory_bytes: 3784
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

long dp[11][1001][101];
int n,s;
const int N=100;

long rec(int a, int b, int c){
	if(dp[a][b][c]>=0) return dp[a][b][c];
	
	long ret=0;	
	if(a==n && b>=0){
		if(b==0) ret=1;
		else ret=0;
	}
	else if(b<0) ret=0;
	else for(int i=c-1; i>=0; --i) ret+=rec(a+1, b-i, i);	
	
	return dp[a][b][c]=ret;
}

int main(){
	while(1){
		scanf(" %d %d", &n, &s);
		if(n==0) break;
			
		memset(dp, -1, sizeof(dp));
		printf("%ld\n", rec(0, s, N+1));
	}
}

Measured memory_bytes: 9888
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String word = scan.next();
      	int subWordLength = 0;
      	int longestWordLength = 0;
      	for(int i=0; i < word.length(); i++){
        	String x = word.substring(i,i+1);
          	if(x.equals("A")||x.equals("C")||x.equals("G")||x.equals("T")){
            	subWordLength++;
            } else {
            	if(longestWordLength < subWordLength){
                	longestWordLength = subWordLength;
                }
              	subWordLength = 0;
            }
        }
        if(longestWordLength < subWordLength){
            longestWordLength = subWordLength;
        }      	
      	System.out.println(longestWordLength);
    }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    int ans = 0;
    inc(i, a, b+1){
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if(s == t) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define eps 1e-8
#define pi acos(-1.0)
using namespace std;
void test(){cerr<<"\n";}
template<typename T,typename... Args>void test(T x,Args... args){cerr<<x<<" ";test(args...);}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN=(int)1e5+5;
const int MOD=(int)1e9+7;
pii a[MAXN];
ll f(ll x){
    ll res=0;
    while(x%4!=3&&x>0){
        res^=x;
        x--;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<(f(a-1)^f(b))<<"\n";
    return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int, input().split()))
a_c = collections.Counter(a)
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]
s_old = 0
for k, v in a_c.items():
    s_old += k*v
for bc in BC:
  b = bc[0]
  c = bc[1]
  s = s_old
  if b in a_c:
    n = a_c.pop(b)
    a_c[c]+=n
    s-=n*b
    s+=n*c
  print(s)
  s_old = s

Measured memory_bytes: 36800
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, i] = input[0].map(Number);

  return N - i + 1;
};

console.log(main(read()));


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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> v(2 * n);
  for (auto &&x : v) {
    cin >> x;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    ans += v[i];
  }
  cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
	int xd=x2-x1,yd=y2-y1;
	int x3=x2-yd,y3=y2+xd,x4=x3-xd,y4=y3-yd;
	cout<<x3<<" "<<y3<<" "s<<x4<<" "s<<y4<<"\n"s;
}


Measured memory_bytes: 3592