akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
 
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,q,a,b,c,d,e,f,g;
  cin>>n>>q>>a>>b>>c>>d>>e>>f>>g;
  using P = pair<Int, Int>;
  map<P, Int> mp;
  auto val=[&](Int y,Int x){
    if(x>y) swap(x,y);
    return ((y-n)*a+x*b)%c;
  };
  auto calc=[&](Int y,Int x){
    //cout<<y<<":"<<x<<endl;
    if(mp.count(minmax(y,x))) return mp[minmax(y,x)];
    else return val(y,x);
  };
 
  vector<Int> vx(n),vy(n);
  iota(vx.begin(),vx.end(),1);
  iota(vy.begin(),vy.end(),n+1);
  //for(Int i=0;i<n;i++) cout<<"vx:"<<i<<vx[i]<<endl;
  //for(Int i=0;i<n;i++) cout<<"vy:"<<i<<vy[i]<<endl;
 
  using It = vector<Int>::iterator;
  It px=vx.begin();
  It qx=--vx.end();
  It py=vy.begin();
  It qy=--vy.end();
 
  auto conv=[&](It it,Int x){
    if(it==--vx.end()||it==--vy.end()) return it-x;
    return it+x;
  }; 
   
  for(Int i=0;i<q;i++){
    string s;
    cin>>s;
    if(s=="WR"){
      Int r,c,v;
      cin>>r>>c>>v;
      r--;c--;
      mp[minmax(*conv(py,r),*conv(px,c))]=v;
    }
    if(s=="CP"){
      Int r1,c1,r2,c2;
      cin>>r1>>c1>>r2>>c2;
      r1--;c1--;r2--;c2--;
      mp[minmax(*conv(py,r2),*conv(px,c2))]=calc(*conv(py,r1),*conv(px,c1));
    }
    if(s=="SR"){
      Int r1,r2;
      cin>>r1>>r2;r1--;r2--;
      auto sy=(py<qy?py:qy);
      if(sy==vx.begin())
	swap(vx[conv(py,r1)-sy],vx[conv(py,r2)-sy]);
      else
	swap(vy[conv(py,r1)-sy],vy[conv(py,r2)-sy]);
    }
    if(s=="SC"){
      Int c1,c2;
      cin>>c1>>c2;c1--;c2--;
      auto sx=(px<qx?px:qx);
      if(sx==vx.begin())
	swap(vx[conv(px,c1)-sx],vx[conv(px,c2)-sx]);
      else
	swap(vy[conv(px,c1)-sx],vy[conv(px,c2)-sx]);
    }
    if(s=="RL"){
      It bpx=px,bqx=qx,bpy=py,bqy=qy;
      px=bpy;
      qx=bqy;
      py=bqx;
      qy=bpx;
    }
    if(s=="RR"){
      It bpx=px,bqx=qx,bpy=py,bqy=qy;
      px=bqy;
      qx=bpy;
      py=bpx;
      qy=bqx;
    }
    if(s=="RH"){
      swap(py,qy);
    }    
    if(s=="RV"){
      swap(px,qx);
    }
  }
 
  const Int MOD = 1e9+7;
  d--;f--;
  Int ans=314159265;
  for(Int i=d;i<e;i++)
    for(Int j=f;j<g;j++)
      ans=(ans*31+calc(*conv(py,i),*conv(px,j)))%MOD;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n,  color;
int d[30][30];
int c[500][500];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>color;
    vector<int> mod0(31);
    vector<int> mod1(31);
    vector<int> mod2(31);
    for (int i = 0; i <=color; i++)
    {
        mod0[i]=0;
        mod1[i]=0;
        mod2[i]=0;
    }
    ll ans=INF;
    for (int i = 0; i < color; i++)
    {
        for(int j=0;j<color;j++)
        cin >> d[i][j];
    }
    for (int i = 0; i < n; i++)
    {
        for(int j=0;j<n;j++){
        cin >> c[i][j];
        if((i+j+2)%3==0){
            mod0[c[i][j]]++;
        }
        if((i+j+2)%3==1){
            mod1[c[i][j]]++;
        }
        if((i+j+2)%3==2){
            mod2[c[i][j]]++;
        }
        }
    } 
    for(int i=1;i<=color;i++){
        for(int j=1;j<=color;j++){
            if(i==j)continue;
            for(int k=1;k<=color;k++){
                ll sum=0;
                if(i==k||k==j) continue;
                for(int l=1;l<=color;l++){
                    sum+=mod0[l]*d[l-1][i-1];
                }
                for(int l=1;l<=color;l++){
                    sum+=mod1[l]*d[l-1][j-1];
                }
                for(int l=1;l<=color;l++){
                    sum+=mod2[l]*d[l-1][k-1];
                }
                 ans=min(sum,ans);
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {
	ll N; cin >> N;
	ll ans = 0;
	for (ll i = 1;i < N + 1;++i) {
		if (i * i <= N)ans = max(ans, i * i);
		else break;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double lld;
const ll mod = 1000000007;

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

	int n, k; cin >> n >> k;

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

	// dp[k][n] = dp[k][n - 1] + dp[k - 1][n - 1] ... dp[k - a[i]][n - 1]
	vector<ll> dp(k + 1, 0), sum(k + 1, 0);
	
	for(int i = 0; i <= a[0]; i++) dp[i] = 1;

	for(int i = 1; i < n; i++) {
		sum[0] = dp[0];
		for(int j = 1; j <= k; j++) sum[j] = (sum[j - 1] + dp[j]) % mod;
		for(int j = 0; j <= k; j++) {
			dp[j] = sum[j] + mod;
			if(j - (a[i] + 1) >= 0) dp[j] -= sum[j - (a[i] + 1)];
			if(dp[j] >= mod) dp[j] %= mod;
		}
	}
	cout << dp[k] << endl;
}

Measured memory_bytes: 1792
pair = []

N, T = map(int, input().split())

for i in range(0,N):
    c,t = map(int, input().split())
    pair.append((c,t))

ans = (1001,1001)
for tup in pair:
    if tup[1] <= T:
        if ans[0] > tup[0]:
            ans = tup

if ans[0] == 1001:
    print('TLE')
else:
    print(ans[0])


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
#define INF 1<<30

int main()
{
    int n, l[200]; cin >> n; n *= 2;
    for (int i = 0; i < n; i++) cin >> l[i];

    sort(l, l + n);
    reverse(l, l + n);

    int ans = 0;
    for (int i = 0; i < n; i += 2) ans += l[i + 1];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
lst = list(map(int, input().split()))

pos = []
neg = []
for i in lst:
    if i>=0:
        pos.append(i)
    else:
        neg.append(-i)
neg.sort()
pos = pos + [float("INF")]*max(k-len(pos),0)
neg = neg + [float("INF")]*max(k-len(neg),0)
# print(pos)
# print(neg)

ans = min(pos[k-1],neg[k-1])
for i in range(1,k):
    ans = min(ans, pos[i-1]*2+neg[k-i-1])
for i in range(1,k):
    ans = min(ans, neg[i-1]*2+pos[k-i-1])

print(ans)


Measured memory_bytes: 14480
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	string s1, s2; cin >> s1 >> s2;
	if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using LL = long long;
using namespace std;

int main() {
	LL N, D;
	cin >> N >> D;
	vector<LL> X(N), Y(N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
		if (X[i] * X[i] + Y[i] * Y[i] <= D * D) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 6356
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    string s = readln.chomp;
    foreach (i;0..3) if (s[i] == s[i + 1]) {
        writeln("Bad");
        return;
    }
    writeln("Good");
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    ll n,a,b;
    while(cin>>n>>a>>b)
    {
        ll k=n/(a+b);
        ll ans=k*a;
        if(n%(a+b)>=a)ans+=a;
        else ans+=n%(a+b);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()


int main(){
  ll n,k,sum=0;
  cin >> n >> k;
  vl h(n);
  rep(i,0,n){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  for(int i=0; i<k && i<n; i++){
    h[n-1-i]=0;
  }
  for(int i=0; i<n; i++){
    sum+= h[i];
  }
  cout << sum;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  
  vl vec(a[n-1]+1);
  rep(i, n) rep2(j, a[n-1]/a[i]) vec[a[i]*j]++;
  
  ll ans=0;
  rep(i, n) if(vec[a[i]]==1) ans++;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 12708
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int x, t;
	cin >> x >> t;
	if(x>t) cout << x - t << endl;
	else cout << "0" << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    K, X = LMIIS()
    for i in range(X-K+1,X+K):
        print(i)





    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#define maxn 100005
using namespace std;
int dp[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b, c;
	cin >> n >> a >> b;
	dp[2] = abs(b-a);
	for ( int i=3, x; i<=n; ++i ) {
		cin >> c;
		dp[i] = min(dp[i-2]+abs(c-a),dp[i-1]+abs(c-b));
		a = b;
		b = c;
	}
	cout << dp[n] << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%1000000007)

using namespace std;

int a[200], x, n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> x;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = 0, flg = 1;
    for(int i = 0; i < n; i++)
    {
        if(x < a[i])
        {
            flg = 0;
            break;
        }
        x -= a[i]; ans++;
    }

    if(x > 0 && flg) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
function main(input) {
    let [totalPrice , length] = input.split("\n")[0].split(" ").map( v => Number(v));
    
    const list = JSON.parse(JSON.stringify(input.split("\n")[1].split(" ").map(v => Number(v))));
    const hateNumbers = { list, length };
    // const favoriteNumber = Array.from({ length: 10 }, (v, i) => i);
    // favoriteNumber.filter(v => hateNumbers.list.includes(v) ? false : true)

    const matches = new RegExp(`[${hateNumbers.list.join("")}]`);
    while (matches.test(totalPrice.toString())) {
        totalPrice++;
    }
    console.log(totalPrice);

}


// let input = "1000 8" + '\n' +
//     "1 3 4 5 6 7 8 9";
// let input = "9999 1" + '\n' +
//     "0";

// main(input);
main(require("fs").readFileSync("/dev/stdin","utf8"));
  

Measured memory_bytes: 34540
from collections import deque
count = 0

def merge(A,left,mid,right):
    L = deque(A[left:mid])
    R = deque(A[mid:right])
    L.append(10**9)
    R.append(10**9)
    
    global count
    
    for k in range(left,right):
        count +=1
        if L[0] <= R[0]:
            A[k] = L.popleft()
 
        else:
            A[k] = R.popleft()

            
def mergeSort(A,left,right):
    if left + 1 < right:
        middle = (left + right) //2
        mergeSort(A,left,middle)
        mergeSort(A,middle,right)
        merge(A,left,middle,right)
        
input()
l = list(map(int,input().split()))
mergeSort(l,0,len(l))
print(" ".join(map(str,l)))
print(count)            
        

Measured memory_bytes: 72240
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

struct N {
  int p, y, i;
};

bool operator<(const N &l, const N &r) { return l.y < r.y; }

string toS(int i) {
  string s = to_string(i);
  for (int j = 0; s.size() < 6; j++) {
    s = "0" + s;
  }
  return s;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<string> ans(m);
  vector<N> ps(m);
  for (int i = 0; i < m; i++) {
    cin >> ps[i].p >> ps[i].y;
    ps[i].p--;
    ps[i].i = i;
  }
  sort(ps.begin(), ps.end());
  for (int i = 0; i < m; i++) {
    ans[ps[i].i] = toS(ps[i].p + 1) + toS(++k[ps[i].p]);
  }
  for (int i = 0; i < m; i++)
    cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 8576
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n; cin >> n; 
  int m = 0;
  forall(i,1,n+1) if( i%2 ) m++;
  cout << static_cast<double>(m) / n << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
    int N;
    cin >> N;
    int mx = 0, ans = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a>=mx)
            ans++;
        mx=max(mx,a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
  int a,b;
  cin >> a >> b;
  int add,sub,mul;
  add = a + b;
  sub = a - b;
  mul = a*b;
  int answer;
  answer = max(max(add,sub),mul);
  
  //出力
  cout << answer << endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (!(a%b))return b;
	long long c = a - b;
	return gcd(max(b, c), min(b, c));
}
int main() {
	int n; 
	long long p, x;
	cin >> n >> p;
	long long ans;
	for (int i = 0; i < n; i++) {
		cin >> x;
		x = abs(p - x);
		if (i)ans = gcd(max(ans, x), min(ans, x));
		else ans = x;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fn solve() {
    let n: usize = read();
    let mut a = vec![];
    let mut mask = 0;
    for i in 0..n {
        let v: usize = read();
        a.push(v);
        mask ^= v;
    }
    for i in 0..n {
        println!("{}", a[i] ^ mask);
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 4220
#include <iostream>
#include <cstring>
#include <map>
#include <queue>
#include <cstdio>
using namespace std;

const int N = 105;

int a[N], b[N], c[N], d[N], n, cnt;
int vis[N], link[N], g[N][N];

int dfs(int x){
	for (int i=1; i<=n; ++i) if (!vis[i] && g[x][i]){
		vis[i]=1;
		if (!link[i] || dfs(link[i])){
			link[i]=x; return 1;
		}
	}
	return 0;
}

int main(){
	scanf("%d", &n);
	for (int i=1; i<=n; ++i)
		scanf("%d%d", &a[i], &b[i]);
	for (int i=1; i<=n; ++i)
		scanf("%d%d", &c[i], &d[i]);
		
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=n; ++j)
			if (a[i]<c[j] && b[i]<d[j])
				g[i][j]=1;
	for (int i=1; i<=n; ++i){
		memset(vis, 0, sizeof vis);
		if (dfs(i)) ++cnt;
	}
	printf("%d\n", cnt);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
         
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
             
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 17188
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  int N, M; cin >> N >> M;
  double L[N], a[N], b[N]; FOR(i,0,N) cin >> L[i] >> a[i] >> b[i];
  double ans = 0;
  FOR(i,0,1<<N) {
    vector<int> v;
    FOR(j,0,N) {
      if((i>>j)&1) v.push_back(j);
    }
    if((int)v.size() == M) {
      double mx = 0;
      FOR(j,0,M) {
        FOR(k,j+1,M) {
          mx += (L[v[k]] - L[v[j]]) * (L[v[k]] - L[v[j]]);
          mx += (a[v[k]] - a[v[j]]) * (a[v[k]] - a[v[j]]);
          mx += (b[v[k]] - b[v[j]]) * (b[v[k]] - b[v[j]]);
        }
      }
      ans = max(ans, mx);
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 3312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <random>
#include <math.h>
#include <algorithm>
#include <queue>
#define LL long long

using namespace std;

const int mod = 1e9+7;
const int maxn = 11234567;

int id[112345];

int main()
{
    ios::sync_with_stdio(false);

    int t;
    int n, k, m;

    scanf("%d", &n);

    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &k);
        id[k] = i;
    }

    for (int i = 1; i <= n; ++i)
    {
        if (i != 1) putchar(' ');
        printf("%d", id[i]);
    }
    puts("");

    return 0;
}


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<vector<P>> g(n);
    vector<int> sl(m);
    for(int i=0; i<m; i++){
        int l, r, d; cin>>l>>r>>d;
        l--, r--;
        sl[i]=l;
        g[l].push_back(P(r, d));
        g[r].push_back(P(l, -d));
    }

    vector<bool> visited(n+10, false);
    for(int i=0; i<m; i++){
        if(visited[sl[i]]) continue;
        visited[sl[i]]=true;

        vector<int> dis(100010, MOD);
        dis[sl[i]]=0;

        queue<int> que;
        que.push(sl[i]);
        while(!que.empty()){
            int nl=que.front(); que.pop();
            visited[nl]=true;

            for(int i=0; i<g[nl].size(); i++){
                if(dis[g[nl][i].first] == MOD){
                    dis[g[nl][i].first] = dis[nl] + g[nl][i].second;
                    que.push(g[nl][i].first);
                }
                else if(dis[nl] + g[nl][i].second != dis[g[nl][i].first]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 10112
n,m=map(int,input().split())
edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(m)]
ans=0
for x in edges:
    C=list(range(n))
    for y in edges:
        if y==x: continue
        C=[C[y[0]] if C[i]==C[y[1]] else C[i] for i in range(n)]
    if len(set(C))!=1: ans+=1
print(ans)

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

const int MAX_N = 100010;

int group[MAX_N];
int p[MAX_N];
int sz[MAX_N];

int ufind(int u) {
	if(group[u] == u) {
		return u;
	}
	return group[u] = ufind(group[u]);
}

void umerge(int u, int v) {
	int pu = ufind(u);
	int pv = ufind(v);
	
	if(pu != pv) {
		if(sz[pu] < sz[pv]) {
			group[pu] = pv;
			sz[pv]++;
		} else {
			group[pv] = pu;
			sz[pu]++;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	
	int n, m;
	cin>>n>>m;
	
	for(int i = 1;i<=n;++i) {
		cin>>p[i];
		group[i] = i;
		sz[i] = 1;
	}
	
	for(int i = 1;i<=m;++i) {
		int u, v;
		cin>>u>>v;
		
		umerge(u, v);
	}
	
	int res = 0;
	
	for(int i = 1;i<=n;++i) {
		if(ufind(i) == ufind(p[i])) {
			res++;
		}
	}
	
	cout<<res<<endl;
	
	return 0;
}

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

//#define ll unsigned long long
#define ll long long
#define null NULL
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define first ff 
#define second ss 
#define endl '\n' 

int main (){
	IOS
	double r ;
	cin >> r ;
	cout << fixed << setprecision(20) << 2*3.14159265358979323846*r ;
	
	return 0 ;
}
		

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,a[1000001],b[1000001];
int find(int x) {
    int lx=0,rx=n;
    while (lx<rx) {
	int mid=(lx+rx+1)/2;
	if (b[mid]<=x) lx=mid;
	else rx=mid-1;
    }
    return lx;
}
int Query(int l,int r) {
    return find(r)-find(l-1);
}
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) scanf("%d",&b[i]);
    int ans=0;
    for (int i=28;i>=0;i--) {
	int k=(1<<i);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for (int j=1;j<=n;j++) {
	    int now=Query(k-a[j],k*2-1-a[j])+Query(3*k-a[j],4*k-1-a[j]);
	    if (now%2) ans^=k;
	}
	for (int j=1;j<=n;j++) {
	    if (a[j]&k) a[j]^=k;
	    if (b[j]&k) b[j]^=k;
	}
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5120
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let r = read double ()
printfn "%f" (r*2.0*Math.PI)

Measured memory_bytes: 30124
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


def solve():
    n = N - M + 1
    b = "".join(B)
    for i in range(n):
        for j in range(n):
            a = ""
            for k in range(M):
                a += A[i + k][j : j + M]
            if a == b:
                return "Yes"
    return "No"


def main():
    ans = solve()
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#define N 100

int n,x,y,A[N][N];

int main(){
    int i,j,ayane;
    for(i = 0;i < N;i++){
        for(j = 0;j < N; j++){
            A[i][j] = 0;
        }
    }

    scanf("%d",&n);
    for(i = 0;i < n; i++){
        scanf("%d %d",&x,&y);
            for(j = 0;j < y;j++){
                scanf("%d",&ayane);
                A[i][ayane - 1] = 1;
              }
    }

    for(i = 0;i < n; i++){
        for(j = 0; j < n; j++){
           printf("%d", A[i][j]);
           if(j!=n-1){
               printf(" ");
           }
        }

        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2112
n = gets.to_i
a = gets.chomp.split.map &:to_i

b_push = []
b_unshift = []

a.each_with_index do |an,i|
  i.even? ? b_push << an : b_unshift.unshift(an)
end

b = b_unshift + b_push
b.reverse! if a.length.odd? 

puts b.join(' ')


Measured memory_bytes: 40652
import java.util.Arrays;
import java.util.Scanner;

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

		int m = 1000000007;
		long answer = 1;
		int[] d = new int[3];
		Arrays.fill(d, -1);
		for (int i = 0; i < a.length; i++) {
			int c = 0;
			int ix = 0;
			for (int j = 0; j < d.length; j++) {
				if (d[j] + 1 == a[i]) {
					c++;
					ix = j;
				}
			}

			answer = (answer * c) % m;
			d[ix]++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 51200
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, a, b) = get!(usize, usize, usize);

    println!("{}", min(b, n * a));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int c = (n * (n + 1)) / 2;
  vector<P> keys;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    int x = 0;
    rep(j, 0, b) {
      int c;
      cin >> c;
      c--;
      x |= 1 << c;
    }
    keys.emplace_back(x, a);
  }

  vector<int> dp(1 << n, 1e9);
  dp[0] = 0;
  rep(s, 0, 1 << n) {
    rep(i, 0, m) {
      int t = s | keys[i].first;
      int cost = dp[s] + keys[i].second;
      chmin(dp[t], cost);
    }
  }

  int ans = dp[dp.size() - 1];
  if (ans == 1e9)
    ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a > b)
    {
        if(c > d)
        {
            cout << b + d << endl;
        }
        else
        {
            cout << b + c << endl;
        }
    }
    else
    {
        if(c > d)
        {
            cout << a + d << endl;
        }
        else
        {
            cout << a + c << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll mod=1000*1000*1000+7;

int n, k;

int tab[nax];

ll dp[107][100007];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i=1; i<=n; i++)
		scanf("%d", &tab[i]);
	dp[0][0]=1;
	for (int i=1; i<=n; i++)
	{
		ll s=0;
		for (int j=0; j<=k; j++)
		{
			s=(s+dp[i-1][j])%mod;
			dp[i][j]=s;
			if (j>=tab[i])
				s=(s-dp[i-1][j-tab[i]]+mod)%mod;
		}
	}
	printf("%lld\n", dp[n][k]);
	return 0;
}


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

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();
            var y = float.Parse(x) / 2;
            var z = Math.Round(y, MidpointRounding.AwayFromZero);
            Console.WriteLine(z);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
char table[60][60];
int flag[60][60], h, w;
void re_bfs(int y, int x)
{
	for(int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
		if(flag[ny][nx] == flag[y][x] - 1)
		{
			flag[y][x] = 0;
			re_bfs(ny, nx);
		}
		if(ny == 0 && nx == 0) return;
	}
}
void bfs(int y, int x)
{
	queue<P> que;
	que.push(P(y, x));
	flag[y][x] = 0;
	while(que.size())
	{
		P tmp = que.front();
		que.pop();
		if(tmp.first == h - 1 && tmp.second == w -1)
		{
			re_bfs(tmp.first, tmp.second);
			return;
		}
		for(int i = 0; i < 4; i++)
		{
			int ny = tmp.first + dy[i];
			int nx = tmp.second + dx[i];
			if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
			if(table[ny][nx] == '#') continue;
			if(flag[ny][nx] != -1) continue;
			flag[ny][nx] = flag[tmp.first][tmp.second] + 1;
			que.push(P(ny, nx));
		}
	}
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	memset(flag, -1, sizeof(flag));
	cin >> h >> w;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			cin >> table[i][j];
		}
	}
	bfs(0, 0);
	if(flag[h - 1][w - 1] == -1)
	{
		cout << -1 << endl;
	}
	else
	{
		int cnt = 0;
		for(int i = 0; i < h; i++)
		{
			for(int j = 0;j < w; j++)
			{
				if(flag[i][j] == 0 || table[i][j] == '#') cnt++;
			}
		}
		cout << h * w - cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()
	t := make([]int, n)

	var sum = 0
	for i := range t {
		temp := r()
		t[i] = temp
		sum += temp
	}

	m := r()
	for i := 0; i < m; i++ {
		p, x := r(), r()
		time := sum - t[p-1] + x
		fmt.Println(time)
	}
}


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) //cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m , k;
    cin >> n >> m >> k;
    vi a(n), b(m);
    cin >> a;
    cin >> b;
    int i, j;
    i = 0;
    int sm = 0;
    while(i < n){
        if(sm + a[i] > k) break;
        sm += a[i];
        i++;
    }
    j = 0;
    while(j < m){
        if(sm + b[j] > k) break;
        sm += b[j];
        j++;
    }
    assert(sm <= k);
    int ans = i+j;
    debug(i,j);
    while(i > 0){
        i--;
        sm -= a[i];
        while(j < m && (sm + b[j] <= k)){
            sm += b[j];
            j++;
        }
        debug(i,j);
        ans = max(ans , i+j);
    }
    cout << ans <<"\n";

    return 0;
}

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

typedef long long ll;

struct Data {
	ll one, size, ans;
};

struct st {
	ll one, size, ans;
	bool b;
	st *L, *R;
	void change() {
		ans = one*(size-one)-ans;
		one = size-one;
		b ^= 1;
	}
	void pull() {
		one = L->one+R->one;
		ans = L->ans+R->ans+(R->size-R->one)*L->one;
		b = 0;
	}
	void push() {
		if (b) {
			L->change();
			R->change();
		}
	}
};

st *build(int L, int R)
{
	st *c = new st;
	if (L == R) {
		scanf("%lld", &c->one);
		c->size = 1;
		c->ans = 0;
		return c;
	}
	int m = (L+R)/2;
	c->L = build(L, m);
	c->R = build(m+1, R);
	c->pull();
	c->size = R-L+1;
	return c;
}

void modify(st *c, int L, int R, int x, int y)
{
	if (y < L || R < x) return;
	if (x <= L && R <= y) {
		c->change();
		return;
	}
	c->push();
	int m = (L+R)/2;
	modify(c->L, L, m, x, y);
	modify(c->R, m+1, R, x, y);
	c->pull();
}

Data query(st *c, int L, int R, int x, int y)
{
	if (y < L || R < x) return Data{0, 0, 0};
	if (x <= L && R <= y) return Data{c->one, c->size, c->ans};
	c->push();
	int m = (L+R)/2;
	Data l = query(c->L, L, m, x, y), r = query(c->R, m+1, R, x, y);
	c->pull();
	return Data{l.one+r.one, l.size+r.size, l.ans+r.ans+(r.size-r.one)*l.one};
}

int main()
{
	int n, q, t, l, r;
	scanf("%d%d", &n, &q);
	st *c = build(1, n);
	while (q--) {
		scanf("%d%d%d", &t, &l, &r);
		if (t == 1) {
			modify(c, 1, n, l, r);
		}
		else {
			printf("%lld\n", query(c, 1, n, l, r).ans);
		}
	}
}

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

int main(void){
    int A[3];
    for(int i=0;i<3;i++)
        cin>>A[i];

    sort(A,A+3);
    int ans=0;
    for(int i=0;i<2;i++){
        ans+=A[i+1]-A[i];
    }

    cout<<ans<<endl;
    return 0;
}


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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    height, width = map(int, input().split())
    header = ''

    for _ in range(width + 2):
        header += header.join('#')

    print(header)

    for i in range(height):
        line = input()
        print('#' + line + '#')

    print(header)


Measured memory_bytes: 3060
n, m, X = map(int, input().split())

A = [[0] * m for _ in range(n)]
C = [0] * n

for i in range(n):
	a = list(map(int, input().split()))
	C[i] = a[0]
	A[i] = a[1:]


# 全組み合わせをためす
from itertools import product
bit = [0, 1]
lst = product(bit, repeat=n)


INF = 1 << 40
m_min = INF
for v in lst:
	res = [0] * m
	money = 0
	for i in range(n):
		if v[i] == 1: # 1->use
			for x in range(m):
				res[x] += A[i][x]
			money += C[i]
	if all([e >= X for e in res]):
		m_min = min(m_min, money)

print(m_min) if m_min != INF else print(-1)

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

int main()
{
	char a[3];
	scanf("%s",a);

	if(a[0]=='R'&&a[1]=='R'&&a[2]=='R')printf("3");
	else if(a[0]=='R'&&a[1]=='R')printf("2");
	else if(a[1]=='R'&&a[2]=='R')printf("2");
	else if(a[0]=='S'&&a[1]=='S'&&a[2]=='S')printf("0");
	else printf("1");
}

Measured memory_bytes: 1652
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

int N;
string S[200005];

int main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>S[i];
    sort(S,S+N);
    int k=1;
    for(int i=1;i<N;++i){
        if(S[i]!=S[i-1])k++;
    }
    cout<<k<<endl;
}

Measured memory_bytes: 9884
#https://atcoder.jp/contests/abc158/tasks/abc158_c
# -*- coding: utf-8 -*-
A,B = map(int,input().split())
for i in range(10,1009):
  if(int(i*0.08)==A and int(i*0.1)==B):
    print(i)
    flag=0
    break
  else:
    flag=1
if flag==1:
  print("-1")

Measured memory_bytes: 38256
n, m = (int(i) for i in input().split())
py = [[int(i) for i in input().split()] for j in range(m)]
pre = {}
for i in range(m):
    cur_p = py[i][0]
    cur_p_cities = pre.get(cur_p,[])
    cur_p_cities.append(i)
    pre[cur_p] = cur_p_cities

for i in pre.keys():
    pre[i].sort(key=lambda x:py[x][1])
    city_order = tuple(range(1,len(pre[i])+1))
    pre[i] = dict(zip(pre[i],city_order))

city_nums = []
for i in range(m):
    p = py[i][0]
    x = pre[py[i][0]][i]
    ans = "{:0>6d}".format(p)+"{:0>6d}".format(x)
    city_nums.append(ans)
    
for c_n in city_nums:
    print(c_n)

Measured memory_bytes: 120276
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(a: i32, b: i32);
    println!("{} {}", a * b, 2 * (a + b));
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long double A;
    long double B;
    cin>>A>>B;

    long double c=A*B;
    int ans=(long double)floor(A*B);

    cout << ans << endl;



    



}


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

vector<string>b;
vector<string>r;

int main(){

    int n, m;
    string a;
    scanf("%d", &n);
    for(int i=0; i<n; ++i){
        cin>>a;
        b.push_back(a);
    }
    scanf("%d", &m);
    for(int i=0; i<m; ++i){
        cin>>a;
        r.push_back(a);
    }

    int mx=0, num=0;
    for(int i=0; i<n; ++i){
        string s=b[i];
        num=0;
        for(int j=0; j<n; ++j){
            if(b[j]==s)
                ++num;
        }
        for(int j=0; j<m; ++j){
            if(r[j]==s)
                --num;
        }
        mx=max(mx, num);
    }

    for(int i=0; i<m; ++i){
        string s=r[i];
        num=0;
        for(int j=0; j<n; ++j){
            if(b[j]==s)
                ++num;
        }
        for(int j=0; j<m; ++j){
            if(r[j]==s)
                --num;
        }
        mx=max(mx, num);
    }

    printf("%d\n", mx);


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		System.out.println(s.substring(0, 1) + (s.length() - 2) + s.substring(s.length() - 1, s.length()));
	}
}


Measured memory_bytes: 21716
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 2e5 + 123;
int n, m, a[N], b[N], used[N];
char c[N];
vector <int> adj[N];

void add(int x, int y) {
    if (c[y] == 'A') {
        a[x]++;
    }
    if (c[y] == 'B') {
        b[x]++;
    }
}

void del(int x, int y) {
    if (c[y] == 'A') {
        a[x]--;
    }
    if (c[y] == 'B') {
        b[x]--;
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    int x, y;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
        add(x, y);
        if (y != x) {
            add(y, x);
        }
    }
    set <pii> st;
    for (int i = 1; i <= n; i++) {
        st.insert({min(a[i], b[i]), i});
    }
    pii v;
    while (!st.empty()) {
        v = *st.begin();
        st.erase(v);
        used[v.se] = 1;
        if (v.fi > 0) {
            cout << "Yes";
            return 0;
        }
        for (int to : adj[v.se]) {
            if (used[to]) {
                continue;
            }
            st.erase({min(a[to], b[to]), to});
            del(to, v.se);
            st.insert({min(a[to], b[to]), to});
        }
    }
    cout << "No";
}


Measured memory_bytes: 21632