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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, q, x1[200000], yy[200000], x2[200000], y2[200000]; // y1......
string s[2000];

int c[2001][2001];
int v[2001][2001];
int h[2001][2001];

int main() {
	cin >> n >> m >> q;
	inc(i, n) { cin >> s[i]; }
	inc(i, q) { scanf("%d%d%d%d", &x1[i], &yy[i], &x2[i], &y2[i]); }
	
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] = s[i - 1][j - 1] - '0';
		v[i][j] = (j < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 1][j - 2] == '1');
		h[i][j] = (i < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 2][j - 1] == '1');
	}
	}
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] += c[i - 1][j];
		v[i][j] += v[i - 1][j];
		h[i][j] += h[i - 1][j];
	}
	}
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] += c[i][j - 1];
		v[i][j] += v[i][j - 1];
		h[i][j] += h[i][j - 1];
	}
	}
	
	inc(i, q) {
		x1[i]--;
		yy[i]--;
		
		#define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
		int C = R(c, x1[i]    , yy[i]    , x2[i], y2[i]);
		int V = R(v, x1[i]    , yy[i] + 1, x2[i], y2[i]);
		int H = R(h, x1[i] + 1, yy[i]    , x2[i], y2[i]);
		
		printf("%d\n", C - V - H);
	}
	
	return 0;
}


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

ll numOfFactor(ll n){
  ll ans=0;
  for(ll i=1;i*i<=n;i++){
    if(n % i == 0){
      ans++;
      if(n/i != i){
        ans++;
      }
    }
  }
  return ans;
}

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

  vector<ll> dp(n+1,1);
  
  for(ll i=2;i<=n;i++){
    ll x=i;
    while(x <= n){
      dp[x]++;
      x += i;
    }
  }
  
  ll cnt=0;
  
  for(ll c=1;c<=n-1;c++){
    cnt += dp[n-c];
  }
  
  cout << cnt << endl;

  return(0);
}

Measured memory_bytes: 11140
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 8;
int h, w, a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w >> a >> b;
  FOR(i, 0, h){
    FOR(j, 0, w) printf("%d", (i<b)^(j<a));
    printf("\n");
  }
}

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

using namespace std;
#define int long long
int d[10000][10000];
vector <int> h1[10000];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w;
    cin>>h>>w;
    bool a[h*w];
    bool g[h][w];
    for(int i=0;i<h;++i)
    {
        for(int j=0;j<w;++j)
        {
            char s;
            cin>>s;
            if(s=='#')
            {
                a[i*w+j]=false;
                g[i][j]=false;
            }
            else
            {
                a[i*w+j]=true;
                g[i][j]=true;
            }
        }
    }
    int sz=(h*w);
    for(int i=0;i<sz;++i)
    {
        for(int j=0;j<sz;++j)
        {
            if(i!=j)
            d[i][j]=1e18;
            else
            d[i][j]=0;
        }
    }
    for(int i=0;i<sz;++i)
    {
        int x=(i/w);
        int y=(i%w);
        if(x<(h-1) && g[x][y]==g[x+1][y])
        {
            d[i][i+w]=0;
            h1[i].push_back(i+w);
        }
        else if(x<(h-1))
        {
            d[i][i+w]=1;
            h1[i].push_back(i+w);
        }
        if(y<(w-1) && g[x][y]==g[x][y+1])
        {
            d[i][i+1]=0;
            h1[i].push_back(i+1);
        }
        else if(y<(w-1))
        {
            d[i][i+1]=1;
            h1[i].push_back(i+1);
        }
    }
    deque <int> q;
    q.push_back(0);
    int is[sz];
    bool used[sz];
    for(int i=0;i<sz;++i)
    {
        is[i]=1e18;
        used[i]=false;
    }
    is[0]=0;
    deque <int> q1;
    set <int> z1;
    while(!q.empty())
    {
        q1.clear();
        while(!q.empty())
        {
            int x=q.front();
            q.pop_front();
            used[x]=true;
            for(int i=0;i<h1[x].size();++i)
            {
                int v=h1[x][i];
                if(!used[v])
                {
                    is[v]=min(is[v],is[x]+d[x][v]);
                    if(is[v]==is[x])
                    {
                        used[v]=true;
                        q.push_back(v);
                    }
                    else
                    {
                        if(!z1.count(v))
                        {
                        q1.push_back(v);
                        z1.insert(v);
                        }
                    }
                }
            }
        }
        q=q1;
        z1.clear();
    }
    int ans=is[sz-1];
    if(ans%2==0)
    {
        if(g[0][0])
        cout<<ans/2;
        else
        cout<<(ans+2)/2;
    }
    else
    {
        cout<<(ans+1)/2;
    }
    return 0;
}


Measured memory_bytes: 782208
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
    string s; cin >> s;
    deque<char> q;
    for(char c: s) q.push_back(c);
    bool flip = false;
    int Q; cin >> Q;
    string t;
    rep(i,Q) {
        int ty;
        cin >> ty;
        if(ty==1){
            flip = !flip;
        }else{
            int f; char c;
            cin >> f >> c;
            if(flip) f=3-f;
            if(f==1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }
        }
    }
    if(flip) reverse(q.begin(), q.end());
    string ans;
    for(char c: q) ans += c;
    cout << ans;
}


Measured memory_bytes: 1340
s=input()
t=input()

S=[0]
for i in range(len(s)):
    if s[i]=="A":
        S.append(S[i]+1)
    else:
        S.append(S[i]+2)
#print(S)
T=[0]
for i in range(len(t)):
    if t[i]=="A":
        T.append(T[i]+1)
    else:
        T.append(T[i]+2)
Q=int(input())

for i in range(Q):
    a,b,c,d=map(int,input().split())
    if ((S[b]-S[a-1])%3)==((T[d]-T[c-1])%3):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 56876
S = int(input())

if S <= 10**9:
    ans = [0, 0, S, 0, 0, 1]
    print(*ans)
    exit()
else:
    if S == 10 ** 18:
        ans = [0, 0, 10 ** 9, 0, 0, 10 ** 9]
        print(*ans)
        exit()
    mod = S % (10 ** 9)
    syou = S // (10 ** 9)
    x3 = 10 ** 9 - mod
    y3 = syou + 1
    ans = [0, 0, 10 ** 9, 1, x3, y3]
    print(*ans)


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);
  sort(l.rbegin(), l.rend());
  ll res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (l.at(i) == l.at(j) || l.at(i) == l.at(k) || l.at(j) == l.at(k)) {
          continue;
        }
        if (l.at(i) < (l.at(j) + l.at(k))) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N,M;
int P[100000],Y[100000]; vector<int> yd[100001];
int main () {

    scanf("%d%d",&N,&M); rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]); rep(i,N)sort(yd[i+1].begin(),yd[i+1].end()); rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}


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

ll n;

int dfs(ll cur, bool f1, bool f2, bool f3)
{
    int ret = 0;
    if(cur > n) return ret;
    if(f1 && f2 && f3) ret++;

    ret += dfs(cur * 10 + 3, true, f2, f3);
    ret += dfs(cur * 10 + 5, f1, true, f3);
    ret += dfs(cur * 10 + 7, f1, f2, true);
    return ret;
}

int main()
{
    cin >> n;
    cout << dfs(0, false, false, false) << endl;
    
    return 0;
}

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

int main() {
  int s;
  cin >> s;
  int r=s%100;
  int l=s/100;
  
  if (1<=l&&l<=12){
    if (1<=r&&r<=12)cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else {
    if (1<=r&&r<=12)cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}

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

int main(void){
  int A,B,C,D,N;
  cin>>N>>A>>B>>C>>D;
  int X,Y;
  if(N%A==0){
    X=B*(N/A);
  }
  else{
    X=B*((N/A)+1);
  }
  if(N%C==0){
    Y=D*(N/C);
  }
  else{
    Y=D*((N/C)+1);
  }
  if(X<=Y){
    cout<<X<<endl;
  }
  else{
    cout<<Y<<endl;
  }
  return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			if(s[i]=='0')s[i]='1';
			else s[i]='0';
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

const int N = 3e3 + 5;
int n, t, a, b, res;
int dp[N * 2];
ii A[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp, 255, sizeof dp);

    cin >> n >> t;
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        A[i].first = a;
        A[i].second = b;
    }
    sort(A, A + n);
    for (int i = 0; i < n; ++i) {
        a = A[i].first;
        b = A[i].second;
        for (int tt = N * 2 - 1; tt - a >= 0; --tt) {
            if (dp[tt - a] != -1 && tt - a < t) {
                dp[tt] = max(dp[tt], dp[tt - a] + b);
            }
        }
    }
    for (int i = 0; i < N * 2; ++i) {
        res = max(res, dp[i]);
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ll l, r, d;
	cin >> l >> r >> d;

	ll ans = 0;
	for(ll i = l; i <= r; i++)
		if(i % d == 0)
			ans++;

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b,LL mod){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+10;
char ar[maxn];
int ans[maxn];

int main(void)
{
	cin>>(ar+1);
	int n = strlen(ar+1);
	for(int i = 1;i <= n;){
		int j = i;
		while(ar[j+1] == 'R')
			++j;
		int t = j;
		while(ar[j+1] == 'L')
			++j;

		// cout<<t<<endl;
		for(int k = i;k <= t; ++k){
			// cout<<k<<endl;
			if((t-k)&1)
				ans[t+1]++;
			else
				ans[t]++;
		}
		for(int k = t+1;k <= j; ++k){
			if((k-t)&1)
				ans[t+1]++;
			else
				ans[t]++;
		}
		i = j+1;
		// cout<<i<<endl;
	}
    for(int i= 1;i <= n; ++i)
    	cout<<ans[i]<<" ";

   return 0;
}

Measured memory_bytes: 896
#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() {
	
	int n;
	cin >> n;

	vector<pair<ll, ll>> v;
	REP(i, n) {
		ll x, l;
		cin >> x >> l;
		v.push_back({ x + l,x - l });
	}

	sort(ALL(v));

	int ans = 1;
	ll now = v[0].first;

	FOR(i, 1, n) {
		if (v[i].second >= now) {
			now = v[i].first;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3444
#include<stdio.h>
#define MAX 100000

int main(){
  int t,i;
  int A[MAX +1];

  scanf("%d",&t);
  for(i=1;i<=t;i++){
    scanf("%d",&A[i]);
}
  for(i=1;i<=t;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1){
      printf("parent key = %d, ",A[i/2]);
  }    
if(i*2<=t){
      printf("left key = %d, ",A[i*2]);
  }    
if(i*2+1<=t){
  printf("right key = %d, ",A[i*2+1]);
 }
  printf("\n");

}
  return 0;
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
void solve(){
    int n;
    cin>>n;
    ll ans = 0;
    ll mx = 0;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        mx = max(x,mx);
        ans+=mx-x;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

int cnt = 0;

void insertionSort(vector<int> &A, int n, int g){
	for(int i = g; i < n; i++){
		int v = A[i];
		int j = i - g;
		while(j >= 0 && A[j] > v){
			A[j+g] = A[j];
			j -= g;
			cnt++;
		}
		A[j+g] = v;
	}
}

void shellSort(vector<int> &A, int n){
	vector<int> g;
	int m;
	for(int i = 1; i <= n; i = 3 * i + 1)
		g.push_back(i);
	m = g.size();
	cout << m << endl;
	for(int i = m - 1; i >= 0; i--){
		cout << g[i];
		if(i == 0) cout << endl;
		else cout << " ";  
		insertionSort(A,n,g[i]);
	}
}

int main(){
	int n;
	vector<int> v;
	cin >> n;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	shellSort(v,n);
	cout << cnt << endl;
	for(int i = 0; i < n; i++)
		cout << v[i] << endl;	
}

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int X,Y,A,B,C,a[maxn],b[maxn],c[maxn];
long long ans;
priority_queue<int,vector<int>,greater<int>>Q;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	read(X,Y,A,B,C);
	for(int i=1;i<=A;i++)
		read(a[i]);
	for(int i=1;i<=B;i++)
		read(b[i]);
	for(int i=1;i<=C;i++)
		read(c[i]);
	sort(a+1,a+1+A,cmp);
	sort(b+1,b+1+B,cmp);
	sort(c+1,c+1+C,cmp);
	A=X,B=Y;
	for(int i=1;i<=A;i++)
		ans+=a[i],Q.push(a[i]);
	for(int i=1;i<=B;i++)
		ans+=b[i],Q.push(b[i]);
	for(int i=1;i<=C;i++)
	{
		if(Q.empty())
			break;
		int mn=Q.top();
		if(c[i]>mn)
		{
			Q.pop();
			ans-=mn;
			ans+=c[i];
			if(mn==a[A])
				A-=1;
			else
				B-=1;
		}
		else
			break;
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2552
using System;

public class C
{
    public const int INF = 999999999;
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var e = int.Parse(Console.ReadLine().Trim());
        var dp = new int[n, n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (i == j) dp[i, j] = 0;
                else dp[i, j] = C.INF;
        for (int i = 0; i < e; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(',');
            var a = Array.ConvertAll(line2, int.Parse);
            dp[a[0]-1, a[1]-1] = a[2];
            dp[a[1]-1, a[0]-1] = a[3];
        }
        goWarshall(dp);
        string[] line3 = Console.ReadLine().Trim().Split(',');
        var b = Array.ConvertAll(line3, int.Parse);
        var ret = b[2] - b[3] - dp[b[0] - 1, b[1] - 1] - dp[b[1] - 1, b[0] - 1];
        Console.WriteLine(ret);
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                        dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}

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

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<int> k(M + 1), l(M + 1);
    for(int i = 0, K; i < N; ++i){
        cin >> K;
        for(int j = 0, a; j < K; ++j){
            cin >> a;
            if(++k[a] == N)++l[a];
        }
    }
    
    cout << accumulate(l.begin(), l.end(), 0) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

string n;
int r=0;

int main(){
    cin>>n;
    for(int i=0;i<3;i++){
        r+=(n[i]=='1');
    }
    cout<<r<<endl;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = [0] * N
    for i in range(M):
        ks = list(map(int, input().split()))
        for s in ks[1:]:
            A[s - 1] |= 1 << i
    p = 0
    for i, j in enumerate(list(map(int, input().split()))):
        p |= j << i
    ans = 0
    for s in range(1 << N):
        t = 0
        for i in range(N):
            if s >> i & 1:
                t ^= A[i]
        if t == p:
            ans += 1
    print(ans)


main()


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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n) {
			int x1, y1, z1, w1, x2, y2, z2, w2;
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
			int x = x1*x2, y = x1*y2, z = x1*z2, w = x1*w2;
			x += -y1*y2; y += y1*x2; z += -y1*w2; w += y1*z2;
			x += -z1*z2; y += z1*w2; z += z1*x2; w += -z1*y2;
			x += -w1*w2; y += -w1*z2; z += w1*y2; w += w1*x2;
			cout << x << ' ' << y << ' ' << z << ' ' << w << endl;
		}
	}
}

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

using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

ll shop[110][20];
ll v[110], w[110];
ll p[110][20];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	rep(i, n) {
		rep(j, 10) {
			cin >> shop[i][j];
		}
	}
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	ll ans = -1 * INF;
	for (ll bit = 0;bit < (1 << 10);++bit) {
		bool flag = false;
		rep(i, 10) {
			if (bit & (1 << i)) {
				flag = true;
			}
		}
		if (flag == false)continue;
		vector<ll>open(n);
		rep(j, n) {
			rep(i, 10) {
				if (bit & (1 << i)) {
					if (shop[j][i])open[j]++;
				}
			}
		}
		ll res = 0;
		rep(i, n) {
			res += p[i][open[i]];
		}
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=gets.to_i
a = []
n.times do
    a << gets.to_i
end
a.sort!

ans = 0
if n % 2 == 0
    (n/2+1).upto(n-1) do |i|
        ans += a[i] * 2    
    end

    ans += a[n/2]
    (0).upto(n/2-2) do |i|
        ans -= a[i] * 2    
    end
    ans -= a[n/2-1]
else
    (n/2+1).upto(n-1) do |i|
        ans += a[i] * 2    
    end

    (0).upto(n/2-2) do |i|
        ans -= a[i] * 2    
    end
    ans -= a[n/2]
    ans -= a[n/2-1]

    tmp = ans
    ans = 0

    (n/2+2).upto(n-1) do |i|
        ans += a[i] * 2    
    end
    ans += a[n/2]
    ans += a[n/2+1]

    (0).upto(n/2-1) do |i|
        ans -= a[i] * 2    
    end

    ans = tmp if tmp > ans

end
puts ans


Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}

int main() {
	int k, sum = 0;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			int result = gcd(i, j);
			for (int q = 1; q <= k; q++) {
				if (result == 1) {
					sum += result;
					continue;
				}
				else {
					int h = gcd(result, q);
					sum += h;
				}
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3632
n, w = map(int, input().split())
nums = []
for _ in range(n):
  nums.append(list(map(int, input().split())))
  
total_v = sum(nums[i][1] for i in range(n))

dp = [[float('inf') for _ in range(total_v+1)] for _ in range(n+1)]
dp[0][0] = 0

for i in range(1, n+1):
  for j in range(total_v+1):
    if j < nums[i-1][1]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = min(dp[i-1][j], dp[i-1][j-nums[i-1][1]] + nums[i-1][0])
for i in range(total_v, -1, -1):
  if dp[n][i] != float('inf') and dp[n][i] <= w:
    print(i)
    break


Measured memory_bytes: 321220
import 'dart:io';
 
void main(List<String> args){
  int X = int.parse(stdin.readLineSync());
  int money = 100;
  int count = 1;
  while(true){
  	money = money + money~/100;
    if(money >= X) break;
    count = count + 1;
  }
  print(count);
}

Measured memory_bytes: 13148
#include <iostream>
#include <iomanip>
void DrawLineA(int b) {
	for (int i = 0; i < b; ++i) {
		if (i % 2 == 0) {
			std::cout << "#";
		}
		else {
			std::cout << ".";
		}
	}
}
void DrawLineB(int b) {
	for (int i = 0; i < b; ++i) {
		if (i % 2 == 0) {
			std::cout << ".";
		}
		else {
			std::cout << "#";
		}
	}
}

void Output(int a, int b, int arr[][2]) {
	for (int i = 0; i < a; ++i) {
		if (i % 2 == 0) {
			DrawLineA(b);
		}
		else {
			DrawLineB(b);
		}
		std::cout << "\n";
	}
	std::cout << "\n";
}

int main()
{
	int arr[1000][2];
	for (int i = 0; true; ++i) {
		int a, b;
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			for (int j = 0; j < i; ++j) {
				Output(arr[j][0], arr[j][1], arr);
			}
			break;
		}
		arr[i][0] = a;
		arr[i][1] = b;

	}

}



Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c||a+c==b||b+c==a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String arg[]) {
        try {
            Scanner scan = new Scanner(System.in);
            int a = scan.nextInt();
            int b = scan.nextInt();
            if (-1001 < a && a < 1001 && -1000 < b && b < 1001) {
                if (a > b) {
                    System.out.println("a > b");
                } else if (a < b) {
                    System.out.println("a < b");
                } else {
                    System.out.println("a == b");
                }
            } else {
                System.out.println("1??????100?????§???????????§???");
            }

        } catch (InputMismatchException ex) {
            System.out.println("1??????100?????§????????¶??°?????\?????????????????????");
        }
    }
}

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

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
}


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

int dp[1005][1005];

void ExtendedEditDistance(vector<string> s1, vector<string> s2){
  
  const int INF = 1e9;
  
  for(int i=0;i<1005;i++)
    for(int j=0;j<1005;j++) dp[i][j] = INF;
  
  dp[0][0] = 0;
  
  int sum1 = 0, sum2;
  
  for(int i=0;i<(int)s1.size();i++){
    
    for(int j=0;j<(int)s1[i].size();j++){
      
      int idx1 = sum1 + j;
      
      sum2 = 0;
      
      for(int k=0;k<(int)s2.size();k++){
	
	for(int l=0;l<(int)s2[k].size();l++){
	  
	  int idx2 = sum2 + l;
	  
	  if( s1[i][j] == s2[k][l] ) dp[idx1+1][idx2+1] = min( dp[idx1+1][idx2+1], dp[idx1][idx2] );
	  else{
	    
	    dp[idx1+1][idx2] = min( dp[idx1+1][idx2], dp[idx1][idx2] + 1 );
	    
	    dp[idx1][idx2+1] = min( dp[idx1][idx2+1], dp[idx1][idx2] + 1 );
	    
	    dp[idx1+1][idx2+1] = min( dp[idx1+1][idx2+1], dp[idx1][idx2] + 1 );
	    
	  }
	  /*
	  if( j == 0 ) dp[idx1+s1[i].size()][idx2] = min( dp[idx1+s1[i].size()][idx2], dp[idx1][idx2] + 1 );
	  
	  if( l == 0 ) dp[idx1][idx2+s2[k].size()] = min( dp[idx1][idx2+s2[k].size()], dp[idx1][idx2] + 1 );
	  */
	  if( i == (int)s1.size() - 1 ){
	  
	    int idx1 = sum1 + s1[i].size();
	    
	    dp[idx1][idx2+1] = min( dp[idx1][idx2+1], dp[idx1][idx2] + 1 );
	    
	    //if( l == 0 ) dp[idx1][idx2+s2[k].size()] = min( dp[idx1][idx2+s2[k].size()], dp[idx1][idx2] + 1 );
	    
	  }
	  
	}
	
	if( k == (int)s2.size() - 1 ){
	  
	  int idx2 = sum2 + s2[k].size();
	  
	  dp[idx1+1][idx2] = min( dp[idx1+1][idx2], dp[idx1][idx2] + 1 );
	  
	  //	  if( j == 0 ) dp[idx1+s1[i].size()][idx2] = min( dp[idx1+s1[i].size()][idx2], dp[idx1][idx2] + 1 );
	  
	}	
	
	sum2 += s2[k].size();
	
      }
      
    }
    
    sum1 += s1[i].size();
    
  }
  
  cout<<dp[sum1][sum2]<<endl;
  
  /*
    int ans = dp[sum1][sum2];
  
  for(int i=0;i<1005;i++) ans = min( ans, dp[sum1][i] + sum2 - i );
  
  for(int i=0;i<1005;i++) ans = min( ans, dp[i][sum2] + sum1 - i );
  
  cout<<ans<<endl;
  */
  
}

signed main(){
  
  vector<string> s1, s2;
  
  string A, B;
  cin>>A>>B;
  
  s1.push_back( A );
  
  s2.push_back( B );
  
  ExtendedEditDistance(s1,s2);
  
  return 0;
}



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

using namespace std;

constexpr int N = 2e5 + 10;

int n, a, cnt[N], mn = N, mx;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a, cnt[a]++, mn = min (mn, a), mx = max (mx, a);
    if (cnt[mn] > 2) {
        cout << "Impossible" << '\n';
        return 0;
    }
    if (cnt[mn] == 2) {
        if (mx != mn * 2 - 1) {
            cout << "Impossible" << '\n';
            return 0;
        }
    }
    else {
        if (mx != mn * 2) {
            cout << "Impossible" << '\n';
            return 0;
        }
    }
    cnt[mn] = 0;
    for (int i = mn + 1; i <= mx; i++) {
        if (cnt[i] < 2) {
            cout << "Impossible" << '\n';
            return 0;
        }
    }
    cout << "Possible" << '\n';
    return 0;
}


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

int main(){
  int N; cin >> N;
  long long num = 1;
  long long ans = 0;

  vector<int> A(N + 1); rep(i, N + 1) cin >> A[i];
  long long sum = 0;
  rep(i, N + 1) sum += A[i];
  vector<long long> rA(N + 2);
  rep(i, N + 2) {
    rA[i] = sum;
    sum -= A[i];
  }

  rep(i, N + 1) {
    if (A[i] > num) {
      ans = -1;
      break;
    }
    ans += num;
    num -= A[i];
    num = min(rA[i + 1], num * 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = acos(-1);

int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double ang1=0,ang2=0;
    ang1=30*h+(double)(m*0.5);//時針
    ang2=6*m;//分針
    double ang=0,ans=0;
    if(ang1>=ang2){
        ang=ang1-ang2;
    }else{
        ang=ang2-ang1;
    }
    double rad =ang*(PI/180.0);//角度差をradにする
    double c=cos(rad);
    ans=sqrt(a*a+b*b-2*a*b*c);
    
    cout<< fixed << setprecision(100) << ans << endl;
}

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

#define N_MAX (500000+10)
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

typedef struct RollingHash {
    vector<Int> hashed;
    vector<Int> power;

    RollingHash(const string &s,int base = 10007) {
        int n = s.size();
        hashed.assign(n+1,0);
        power.assign(n+1,0);
        power[0] = 1;
        for(int i = 0;i < n;i++) {
            power[i+1] = (power[i]*base) % MOD;
            hashed[i+1] = (hashed[i]*base+s[i]) % MOD;
        }
    }

    Int get(int l,int r) {
        Int ret = hashed[r] + MOD - (hashed[l] * power[r-l]) % MOD;
        if(ret >= MOD)
            ret -= MOD;

        return ret;
    }
}RH;

class UF {
    public:
        int par[N_MAX];
        int siz[N_MAX];
    
        UF(int n) {
            for(int i = 0;i <= n;i++) {
                par[i] = i;
                siz[i] = 1;
            }
        }

        int root(int x) {
            return x == par[x] ? x : par[x] = root(par[x]);
        }

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

        void merge(int x,int y) {
            x = root(x);
            y = root(y);
            if(x == y)
                return;
            par[x] = y;
            siz[y] += siz[x];
            
            return;
        }
        int size(int x) {
            return siz[root(x)];
        }
};

int main(void) {
    string s,t;
    cin>>s>>t;

    int n = s.size();
    string ss = s;
    while(ss.size() < t.size()) {
        ss += s;
    }
    ss += ss;

    RH sh(ss),th(t);
    UF uf(n);
    for(int i = 0;i < n;i++) {
        if(sh.get(i,i+t.size()) == th.get(0,t.size())) {
            int x = i % n;
            int y = (i+t.size()) % n;
            if(uf.same(x,y)) {
                cout<<-1<<endl;

                return 0;
            }
            uf.merge(x,y);
        }       
    }

    int ans = 0;
    for(int i = 0;i < n;i++) {
        ans = max(ans,uf.size(i) - 1);
    }

    cout<<ans<<endl;

    return 0;
}



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

using namespace std;

int main()
{int N, M; cin >> N >> M;
 vector<pair<int,int>> X(M);
 for(int i = 0; i < M ; i++)
 {cin >> X[i].first >> X[i].second;}
 
 sort(X.begin(),X.end());
 
 int anchor = 0;
 int cnt  = 0;
 
 for(int i = 0; i < M; i++)
 {if(anchor < X[i].first)
  {cnt++; anchor = X[i].second - 1;}
  else{anchor = min(anchor,X[i].second - 1);}}
                    cout << cnt << endl;
                    return 0;
                    }
  

Measured memory_bytes: 1024
#include <stdint.h>

#include <functional>
#include <vector>

using namespace std;

template <typename Monoid>
struct SegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;

  int64_t sz;
  vector<Monoid> seg;

  const F f;
  const Monoid e;

  SegmentTree(const int64_t n, const F f_, const Monoid &e_) : f(f_), e(e_) {
    sz = 1;
    while (sz < n) sz <<= int64_t(1);
    seg.assign(2 * sz, e);
  }

  void Set(const int64_t k, const Monoid &x) { seg[k + sz] = x; }

  void Build() {
    // Note: Root is seg[1]. seg[0] is not used.
    for (int64_t k = sz - 1; k > 0; --k) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  // Note k -> 0-indexedededed
  //      k in [0, sz)
  void Update(int64_t k, const Monoid &x) {
    // TODO: out of range error
    k += sz;
    seg[k] = x;
    while (k >>= int64_t(1)) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

#if 0
  // Note a, b -> 0-indexed
  //      a < b
  //      0 <= a < sz
  //      1 <= b <= sz
  //      sum in [a, b)
  Monoid Query(int64_t a, int64_t b) {
    Monoid L = e, R = e;
    // TODO: out of range error
    for (a += sz, b += sz; a < b; a >>= int64_t(1), b >>= int64_t(1)) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
#else
  Monoid Query(const int64_t a, const int64_t b, const int64_t k = 1,
               const int64_t l = 0, int64_t r = 0) {
    if (l >= r) r = sz;
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return seg[k];

    int64_t vl = Query(a, b, 2 * k, l, (l + r) / 2);
    int64_t vr = Query(a, b, 2 * k + 1, (l + r) / 2, r);

    return f(vl, vr);
  }
#endif

  Monoid operator[](const int64_t &k) const { return seg[k + sz]; }
};

#include <iostream>

#ifdef USE_STACK_TRACE_LOGGER
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <glog/logging.h>
#pragma clang diagnostic pop
#endif  //__clang__
#endif  // USE_STACK_TRACE_LOGGER

signed main(int argc, char *argv[]) {
  (void)argc;
#ifdef USE_STACK_TRACE_LOGGER
  google::InitGoogleLogging(argv[0]);
  google::InstallFailureSignalHandler();
#else
  (void)argv;
#endif  // USE_STACK_TRACE_LOGGER
  int64_t N, Q;

  cin >> N >> Q;

  const int64_t kInf = (int64_t(1) << int64_t(31)) - 1;
  SegmentTree<int64_t> seg_tree(
      N, [](int64_t a, int64_t b) { return min(a, b); }, kInf);

  while (Q--) {
    int64_t com, x, y;
    cin >> com >> x >> y;
    if (com == 0)
      seg_tree.Update(x, y);
    else
      cout << seg_tree.Query(x, y + 1) << endl;
  }
  return EXIT_SUCCESS;
}



Measured memory_bytes: 4884
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var count = 0;
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < n; j++)
                {
                    for (var k = 0; k < n; k++)
                    {
                        if (a[i] < a[j] + a[k] && a[j] < a[i] + a[k] && a[k] < a[i] + a[j] && i != j && j != k && k != i && a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) count++;
                    }
                }
            }
            Console.WriteLine(count / 6);
        }
    }
}

Measured memory_bytes: 28228
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=1000000009;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  int ans=0;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()-1-i])
    ans++;
  }
  cout<<ans<<endl;


  return 0;
}


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

int main(){
    ll ans = 0;
    string s;
    cin >> s;
    for(auto ss : s){
        if(ss == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b;
  cin >>a >>b;
  int N = 0;
  if(b<10) N += 10*a + b;
  else if(b==100) N += 1000*a+b;
  else N += 100*a+b;
  bool sq = false;
  rep(i,N/2){
    if(i*i == N) sq = true;
  }
  if(sq) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int cnt = 0;
		for(int i = 0 ; i <= K ; i++) {
			for(int j = 0 ; j <= K ; j++) {
				if(S - i - j >= 0 && S - i - j <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;


int main() {
	const long long int mod = 1000000007;

	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int  n, m, b, c, d, k, h, w,left=1,right=0;
	long long int sc, sr, num2, no[1005][1005] = {};
	char a[1005][1005];
	string s, t;
	cin >> h >> w >> n >> sr >> sc >> s >> t;
	right = w ;
	for (int i = n - 1; i >= 0; i--) {
		if (t[i] == 'R') { left--; }
		if (t[i] == 'L') { right++; }
		left = max(1LL, left);
		right = min(right, w);
		if (s[i] == 'R') { right--; }
		if (s[i] == 'L') { left++; }

		if (left > right || right<1 || left>w) { cout << "NO"; return 0; }
	}
	if (sc < left || right < sc) { cout << "NO"; return 0; }

	left = 1;
	right = h;

	for (int i = n - 1; i >= 0; i--) {
		if (t[i] == 'U') { right++; }
		if (t[i] == 'D') { left--; }
		left = max(1LL, left);
		right = min(right, h);
		if (s[i] == 'U') { left++; }
		if (s[i] == 'D') { right--; }
		
		if (left > right || right<1 || left>h) { cout << "NO"; return 0; }
		
	}
	if (sr < left || right < sr) { cout << "NO"; return 0; }
	cout << "YES";
}

Measured memory_bytes: 776
import fractions
from functools import reduce

n, m = map(int, input().split())
a = list(map( (lambda x: int(x)//2), input().split()))

div_num = [0 for _ in range(n)]
same = True
for i in range(n):
    tmp = a[i]
    while tmp%2 == 0:
        tmp //= 2
        div_num[i] += 1
if len(set(div_num)) != 1:
    same = False

if same:
    lcm = reduce(lambda x, y: (x*y)//fractions.gcd(x, y), a)
    print(int((m/lcm + 1)//2))
else:
    print(0)


Measured memory_bytes: 16344
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Robot struct {
	L, R int
}

func main() {
	N := ReadInt()
	robots := make([]Robot, N)
	for i := 0; i < N; i++ {
		X, L := ReadInt(), ReadInt()
		robots[i].L, robots[i].R = X-L, X+L
	}
	sort.Slice(robots, func(i, j int) bool {
		return robots[i].R < robots[j].R
	})
	cur := robots[0]
	rem := 0
	for i := 1; i < N; i++ {
		if robots[i].L < cur.R {
			rem++
		} else {
			cur = robots[i]
		}
	}
	fmt.Println(N - rem)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void go();
int main() {
#ifdef tokitsukaze
    freopen("TEST.txt", "r", stdin);
#endif
    go();
    return 0;
}

/*********************************  head  *********************************/


char a;
void go() {
    cin>>a;
    a++;
    cout<<a<<endl;
}

Measured memory_bytes: 256
import math


def main():
    N = int(input())

    # A < B として、探索する
    # A <= 10^5
    keta = int(math.log10(N))+1
    for A in range(1, int(pow(N, 0.5)) + 1):
        if N % A == 0:
            B = N // A
            # print(B, int(math.log10(B))+1)
            keta = min(keta, int(math.log10(B))+1)

    print(keta)


main()


Measured memory_bytes: 9264
#ここで求めるのはジャッジ終了時間の期待値である。
#よって1回の実行時間T=max(0,N-M)*100+1900*M、成功率p=1/2^Mとして、
#求める値yは
#y=1*T*p+2*T*p(1-p)+3*T*p(1-p)(1-p)+…
#=(lim N→∞)Σ(1<=i<=N)i*T*p*(1-p)^(i-1)
#=Tp*(lim N→∞)Σ(1<=i<=N)i*(1-p)^(i-1)
#ここで摂動法を用いればΣ(1<=i<=N)i*(1-p)^(i-1)=1/p^2-((1-p)^(N+1))/p^2-((N+1)(1-p)^N)/p
#よってここで1-p<1,p<1より(lim N→∞)Σ(1<=i<=N)i*(1-p)^(i-1)=1/p^2
#よってy=Tp/p^2=T/p=T*2^M

import math
N,M=map(int,input().split())
time=max(0,N-M)*100+1900*M
print(time*pow(2,M))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
inline int read()
{int x=0,f=0;
char c=getchar();
while (c<'0'||c>'9') 
{if (c=='-') f=1;
c=getchar();
}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
if (f) x=-x;
return x;
}
bitset <4000005> t;
int a[2005],n;
int main (){
	int i,s=0;
	scanf ("%d",&n);
	for (int i=1;i<=n;i++)
	{scanf ("%d",&a[i]);
	s+=a[i];
	}
	t[0]=1;
	for (int i=1;i<=n;i++)
	{t|=(t<<a[i]);}
	for (int i=(s+1)/2;i<=s;i++)
	{if (t[i]) {printf ("%d\n",i);return 0;}
	}
}

Measured memory_bytes: 1792
n = gets.to_i
a1 = gets.split.map(&:to_i)
a2 = gets.split.map(&:to_i)

n.times do |i|
  next if i.zero?
  a1[i] += a1[i - 1]
  a2[i] += a2[i - 1]
end

max = 0
n.times do |i|
  if i.zero?
    max = a1[0] + a2[-1]
  else
    cand = a1[i] + a2[-1] - a2[i - 1]
    max = cand if max < cand
  end
end

p max

Measured memory_bytes: 1788
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<bits/stdc++.h>
/*#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>*/
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;


 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	 
	double n , ans ;
	cin >> n ;
	n /= 3 ;
	ans = n*n ;
	ans *= n ;
	cout << fixed << setprecision(10) << ans << endl ;
	return 0;
}

Measured memory_bytes: 256