akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
pos = []
neg = []
for v in A:
	if v >= 0: pos.append(v)
	else: neg.append(-v)

pos.sort(reverse=True)
neg.sort(reverse=True)

MOD = 10 ** 9 + 7
ppos = [1] * (len(pos)+1)
pneg = [1] * (len(neg)+1)

for i, v in enumerate(pos):
	ppos[i+1] = ppos[i] * v % MOD
for i, v in enumerate(neg):
	pneg[i+1] = pneg[i] * v % MOD

i = j = 0

while i + j < K:
	if i == len(pos): j += 1
	elif j == len(neg) or pos[i] >= neg[j]: i += 1
	else: j += 1

if j % 2 == 1:
	v = (-1, -1, -1)
	if i and j < len(neg):
		v = (neg[j-1] * neg[j], i-1, j+1)

	if i < len(pos) and j:
		v = max(v, (pos[i-1] * pos[i], i+1, j-1))

	if v[0] == -1:
		X = pos + neg
		X.sort()
		r = 1
		for v in X[:K]: r = r * v % MOD
		print(-r % MOD)
		raise SystemExit

	i, j = v[1:]

r = 1
for x in pos[:i]: r = r * x % MOD
for x in neg[:j]: r = r * x % MOD
print(r)


Measured memory_bytes: 108156
#!/usr/bin/env python3


def solve(n, a, b):
    x = x0 = 10 ** 10
    for i in range(n):
        if b[i] < a[i]:
            x = min(x, b[i])

    if x == x0:
        return 0
    else:
        return sum(a) - x


def main():
    n = int(input())
    a = []
    b = []
    for _ in range(n):
        ai, bi = input().split()
        a.append(int(ai))
        b.append(int(bi))


    print(solve(n, a, b))


if __name__ == '__main__':
    main()



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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3620
#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;

    int nn = 0, orig_N = N;
    while (N > 0)
    {
        nn += N % 10;
        N /= 10;
    }

    if (orig_N % nn == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main() {
  int N,Q;
  cin >> N >> Q;
  
  //graphの代入 N-1本の辺
  Graph G(N);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);
  }

 vector<int> Ci(N,0);	//各頂点のカウンター
 rep(i,Q){
    int pi,xi;
    cin >> pi >> xi;
    Ci.at(pi-1) += xi;
  }

  queue<int> q;
  vector<bool> check(N,false);
  q.push(0);
  check.at(0) = true;
  
  while(!q.empty()){
    int x = q.front();
    rep(i,G.at(x).size()){
      int p = G.at(x).at(i);
      if(check.at(p)) continue;
      check.at(p) = true;
      Ci.at(p) += Ci.at(x);
      q.push(p);
    }
    q.pop();
  }

  rep(i,N){
    cout << Ci.at(i) << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 15604
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();

        int pow = 1;
        while (pow < n) {
            pow <<= 1;
        }

        final int[] tree = new int[2 * pow];
        for (int i = 0; i < pow; i++) {
            if (i >= n) {
                tree[i] = 0;
            } else {
                final int tmp = s.charAt(i) - 'a';
                tree[i + pow] = 1 << tmp;
            }
        }

        for (int i = pow - 1; i > 0; i--) {
            tree[i] = tree[2 * i] | tree[2 * i + 1];
        }

        final int q = scanner.nextInt();
        for (int _ = 0; _ < q; _++) {
            if (scanner.nextInt() == 1) {
                final int i = scanner.nextInt();
                final int c = scanner.next().toCharArray()[0] - 'a';

                tree[pow + i - 1] = 1 << c;
                int k = (pow + i - 1) / 2;
                while (k > 0) {
                    tree[k] = tree[2 * k] | tree[2 * k + 1];
                    k /= 2;
                }
            } else {
                final int l = scanner.nextInt();
                final int r = scanner.nextInt();

                final int value = recursive(tree, l - 1, r - 1, 0, pow - 1, pow);
                final String sValue = Integer.toBinaryString(value);
                final long count = IntStream.range(0, sValue.length())
                        .map(sValue::charAt)
                        .filter(c -> c == '1')
                        .count();
                System.out.println(count);
            }
        }

        System.out.println();
    }

    private static int recursive(final int[] tree, final int l, final int r, final int begin, final int end, final int pow) {
        if (l == begin && r == end) {
            return tree[(pow + l) / (r - l + 1)];
        }

        final int mid = (begin + end) / 2;
        if (l <= mid && r <= mid) {
            return recursive(tree, l, r, begin, mid, pow);
        } else if (l <= mid) {
            return recursive(tree, l, mid, begin, mid, pow) | recursive(tree, mid + 1, r, mid + 1, end, pow);
        } else {
            return recursive(tree, l, r, mid + 1, end, pow);
        }
    }
}


Measured memory_bytes: 68776
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <deque>
using namespace std;
#define ll long long
#define F first
//#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
#define FOR for(int i=0;i<n;i++)for(int j=0;j<m;j++)
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	string s;int n;
	cin>>s;cin>>n;
	int cnt=0;string cnt2;
	for(unsigned ll i=0;i<s.size();i++){
		if(s[i]!='1'){cnt2=s[i];break;}
		else cnt++;}
	if(cnt<n)cout<<cnt2<<endl;
	else cout<<"1"<<endl;
		

    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>

using namespace std;

string s;
int n;

long long GetResult(long long size)
{
    return size / 2;
}

long long GetResult(const vector<long long>& parts)
{
    if (parts.size() == 1) {
        return GetResult(parts[0] * n);
    }
    long long result = GetResult(parts[0]);
    result += GetResult(parts.back());
    for (int i = 1; i + 1 < (int) parts.size(); ++i) {
        result += GetResult(parts[i]) * n;
    }
    if (s[0] == s.back()) {
        result += GetResult(parts[0] + parts.back()) * (n - 1);
    } else {
        result += GetResult(parts[0]) * (n - 1);
        result += GetResult(parts.back()) * (n - 1);
    }
    return result;
}

void Solve()
{
    vector<long long> parts;
    for (int i = 0; i < (int) s.size(); ++i) {
        int j = i;
        while (j + 1 < (int) s.size() && s[j + 1] == s[i]) {
            ++j;
        }
        parts.push_back(j - i + 1);
        i = j;
    }
    cout << GetResult(parts) << endl;
}

bool Read()
{
    if (!(cin >> s >> n)) {
        return false;
    }
    return true;
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 3100
N = int(input())

An = list(map(int, input().split()))

# res = max([abs(x - y) for x, y in itertools.combinations(An, 2)])
mn = An[0]
mx = An[0]
for i in An:
    if mn > i:
        mn = i
    if mx < i:
        mx = i

print(mx - mn)

Measured memory_bytes: 2940
h,w=map(int,input().split())
mapdata=[]
for i in range(h):
  line=(str(input()))
  line2=list(line)
  mapdata.append(line2)
result=[]
k=[]
def get_bomb(i,j):
  count=0
  for x in (i-1,i,i+1):
    for y in (j-1,j,j+1):
      if 0<=x<=h-1 and 0<=y<=w-1:
        if mapdata[x][y]=='#':
          count+=1
  return count
for i in range(h):
  for j in range(w):
    if mapdata[i][j]=='.':
      k.append(str(get_bomb(i,j)))
    else:
      k.append('#')
  result.append(k)
  k=[]
for i in range(len(result)):
  result2=''.join(result[i])
  print(result2)

Measured memory_bytes: 3188
n = gets.to_i
a = []
x = []
y = []
for i in 0...n do
  a[i] = gets.to_i
  x[i] = []
  y[i] = []
  for j in 0...a[i] do
    x[i][j], y[i][j] = gets.split.map(&:to_i)
  end
end
max_count = 0
for b in 0...(2 ** n) do
  ok = true
  count = 0
  for i in 0...n do
    h = (b >> i) & 1
    if h == 1
      count += 1
      for j in 0...a[i] do
        if (b >> (x[i][j] - 1)) & 1 != y[i][j]
          ok = false
          break
        end
      end
    end
  end
  if ok
    max_count = count if max_count < count
  end
end
puts max_count


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=1,a,b,c,cmp,cmpp=0,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       rrep(i,1,n+1){
           cmp=i;
           while(cmp%2==0 && cmp!=1){
               if(cmp%2==0){
               cmp/=2;
               cnt++;
               }
               else{
                   cmp/=2;
               }
           }
           if(cmpp<cnt){
               cmpp=cnt;
               ans=i;
           }
           cnt=0;
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double u=0;
	for(int i=1;i<=n;++i)
	{
		int x;
		cin>>x;
		u=u+1.0/x; 
	}
	printf("%.5f",1.0/u);
	return 0;
}


Measured memory_bytes: 256
w,h,x,y = list(map(int,input().split()))
ans = 0
if x == 0 and y == 0:
    print(h * w /2 , 0)
elif x == 0:
    print(h * w /2,0)
elif y == 0:
    print(h * w / 2, 0)
else:
    if x == (w /2) and y == (h / 2):
        print(h * w /2,1)
    else:
         
        print(h * w /2,0)


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>
 
using namespace std;
 
 
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007
 
#define IMIN INT_MIN;
#define IMAX INT_MAX;
 
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a%b);
}
vector<ll> divisors(ll num) {
    vector<ll> ans;
    for(ll i=1; i<=(ll)sqrt(num); i++) {
        if (num % i == 0) {
            ans.push_back(i);
            if (i != num/i) ans.push_back(num/i);
        }
    }
    return ans;
}
bool isprime (ll number) { 
    if (number < 2) return false;
    if (number == 2) return true;
    if (number % 2 == 0) return false;
    for (ll i=3; (i*i) <= number; i+=2) {
        if (number % i == 0) return false;
    }
    return true;
}
int n_primes(vector<ll>& divs) {
    int cnt = 0;
    for (auto div : divs) if (isprime(div)) cnt++;
    return cnt;
}
 
int main(){
    ll A, B;
    cin >> A >> B;
    //cout << g << endl;
    vector<ll> divs;
    ll g = gcd(A, B);
    divs = divisors(g);
    //for(auto i:divs) cout << i << endl;
    int ans;
    ans = n_primes(divs);
    cout << ans+1 << endl;
 
 
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll n, w;
vll vs, wws;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> w;
    vs.resize(n), wws.resize(n);
    for (ll i = 0; i < n; i++) cin >> vs[i] >> wws[i];
    vvll dp(n + 1, vll(w + 1, 0));
    for (ll i = 0; i < n; i++) {
        for (ll j = 1; j <= w; j++) {
            dp[i + 1][j] = dp[i][j];
            if (j - wws[i] >= 0) chmax(dp[i + 1][j], dp[i][j - wws[i]] + vs[i]);
        }
    }
    cout << dp[n][w] << '\n';
    return 0;
}



Measured memory_bytes: 10752
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <numeric>
#include <cmath>
#include <set>

int main(){
   int n;
   int ans=0;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
       int a,b;
       scanf("%d %d",&a,&b);
       ans = ans + (b-a+1);
   } 
   printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll n,i,a,b,c,x,y,d,r,k,p,m;
  cin>>x>>y>>a>>b>>c;
  deque<ll>v,v1,v2;
  deque<ll>v3,v4;
  for(i=0;i<a;i++)
  {
      cin>>m;
      v.pb(m);
  }
  for(i=0;i<b;i++)
  {
      cin>>m;
      v1.pb(m);
  }
  for(i=0;i<c;i++)
  {
      cin>>m;
      v2.pb(m);
  }
  sort(v.begin(),v.end(),greater<ll>());
  sort(v1.begin(),v1.end(),greater<ll>());
  sort(v2.begin(),v2.end(),greater<ll>());
  for(i=0;i<x;i++)
    v3.pb(v[i]);
  for(i=0;i<y;i++)
    v3.pb(v1[i]);
  sort(v3.begin(),v3.end());
  r=0;
  while(v3.size())
  {
      if(v2.size())
      {
          if(v2[0]>v3[0])
          {
              r=r+v2[0];
              v2.pop_front();
          }
          else
            r=r+v3[0];
          v3.pop_front();
          continue;
      }
      r=r+v3[0];
      v3.pop_front();

  }
  cout<<r<<endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a==b&&b==c&&c==a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

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

int h,w,B[20][20];

int dfs(int x,int y,int times){
	if(times>10) return INF;

	int res=INF;
	rep(k,4){
		int x2,y2,t;
		for(t=1;;t++){
			x2=x+t*dx[k];
			y2=y+t*dy[k];
			if(!(0<=x2 && x2<w && 0<=y2 && y2<h) || B[y2][x2]==1) break; // out or stop
			if(B[y2][x2]==3) return 1; // goal
		}
		if(0<=x2 && x2<w && 0<=y2 && y2<h && B[y2][x2]==1 && t>=2){
			B[y2][x2]=0;
			res=min(res,1+dfs(x2-dx[k],y2-dy[k],times+1));
			B[y2][x2]=1;
		}
	}
	return res;
}

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		int sx,sy;
		rep(i,h) rep(j,w) {
			scanf("%d",B[i]+j);
			if(B[i][j]==2) sx=j, sy=i;
		}

		int ans=dfs(sx,sy,1);
		printf("%d\n",ans<INF?ans:-1);
	}

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
	int N;  cin >> N;
	vector<string> S(N);
	vector<int> P(N);
	rep(i, N) {
		cin >> S[i] >> P[i];
	}
	
	pair<pair<string, int>, int> p[N];
	rep(i, N) {
		p[i] = make_pair(make_pair(S[i], -P[i]), i+1);
	}
	sort(p, p+N);
	rep(i, N) {
		print(p[i].second);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  int sum = 0;
  int tmp = 0;
  int tmp_p = 0;
  REP(i, n){
    cin >> tmp;
    sum += max(tmp - tmp_p, 0);
    tmp_p = tmp;
  }
  cout << sum << endl;
}


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

using namespace std;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i < j && s[i] == 'C' && s[j] == 'F') {
                puts("Yes");
                return 0;
            } 
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B;
    cin >> A >> B;
    if(A>=13)cout << B << endl;
    else if(A<=5)cout << 0 << endl;
    else cout << B/2 <<endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

int count_ds(int i)
{
    int r;
    while (i) {
        r += i%10;
        i /= 10;
    }
    return r;
}

void main()
{
    auto N = readln.chomp.to!int;

    int r = int.max;
    foreach (i; 1..N/2+1) {
        r = min(r, count_ds(i) + count_ds(N-i));
    }
    writeln(r);
}

Measured memory_bytes: 256
from collections import defaultdict
import math


def main():
    n = int(input())
    mod = 1000000007
    zeroes = 0
    counter1 = defaultdict(int)
    counter2 = defaultdict(int)
    for _ in range(n):
        x, y = [int(x) for x in input().split()]

        if x == y == 0:
            zeroes += 1
            continue

        denominator = math.gcd(x, y)
        x, y = x // denominator, y // denominator

        if y < 0:
            # quadrant III, IV -> I, II
            x, y = -x, -y

        if x <= 0:
            # round 90° from quadrant II to I
            x, y = y, -x
            counter2[(x, y)] += 1
            counter1[(x, y)] += 0
        else:
            counter1[(x, y)] += 1
            counter2[(x, y)] += 0

    ans = 1
    for k, v in counter1.items():
        now = 1
        now += pow(2, v, mod) - 1
        now += pow(2, counter2[k], mod) - 1
        ans = ans * now % mod
    ans += zeroes
    ans -= 1  # choose no fish
    return ans % mod


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


Measured memory_bytes: 68092
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<ll,pair<int,int>> P;

int main(){
    int n,k;
    cin >> n >> k;
    vector<P> da(n);
    map<int,P> ma;
    rip(i,n,0){
        cin >> da[i].second.first >> da[i].first;
        da[i].second.second=i;
        if(ma.count(da[i].second.first)){
            ma[da[i].second.first]=max(da[i],ma[da[i].second.first]);
        }
        else{
            ma[da[i].second.first]=da[i];
        }
    }
    vector<bool> top(n,true);
    for(auto i:ma){
        top[i.second.second.second]=false;
    }
    sort(all(da));
    reverse(all(da));
    priority_queue<P,vector<P>,greater<P>> pq;
    ll ans=0;
    int co=k;
    set<int> check;
    rip(i,k,0){
        ans+=da[i].first;
        pq.push(da[i]);
        if(!check.count(da[i].second.first)){
            check.insert(da[i].second.first);
            //top[da[i].second.second]=false;
        }
    }
    ll now=ans;
    ans+=(ll) check.size()*check.size();
    while(co<n){
        if(!top[da[co].second.second]){
            check.insert(da[co].second.first);
            while(!pq.empty()){
                P ju=pq.top();
                pq.pop();
                //cout << ju.second .second << endl;
                if(top[ju.second.second]){
                    now-=ju.first;
                    now+=da[co].first;
                    ll siz=check.size();
                    ans=max(ans,now+siz*siz);
                    //cout << now << endl;
                    break;
                }
            }
        }
        co++;
    }
    cout << ans << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            string n = s[0];
            int k = int.Parse(s[1]);

            var d = Console.ReadLine().Split().Select(char.Parse).ToArray();
            

            for (int i = int.Parse(n); i < 10 * int.Parse(n) + 1; i++)
            {
                bool f = true;
                foreach (var item in i.ToString())
                {
                    if(d.Contains(item))
                    {
                        f = false;
                        break;
                    }
                }
                if (f)
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 13396
import statistics


N = int(input())
A = list(map(int, input().split()))
sum_a = 0
B = [0]*len(A)
for i in range(N):
    B[i] = A[i] - i
B.sort()
sum_b = 0
b = statistics.median_low(B)
for i in range(N):
    sum_b += abs(B[i]-b)
print(sum_b)

Measured memory_bytes: 27268
N,S =map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
q=[0]*(S+1)
for i in range(N):
    q2=q.copy()
    if A[i]<=S:
        for j in range(A[i],S+1):
            q[j]+=q2[j-A[i]]
        q[A[i]]+=i+1
    ans+=q[S]
    ans%=mod
print(ans)


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<int> a(n);
	rep(i,n){
		int p; cin >>p; p--;
		a[p] = i;
	}
	int ct=1, mx=1;
	rep(i,n-1){
		if(a[i] < a[i+1]) ct++;
		else ct = 1;
		mx = max(mx, ct);
	}
	
	cout << n - mx <<"\n";
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()

b = 0
e = 0
for s in S:
    if s == ')':
        e += 1
    else:
        b += 1
    S = '(' * max(e-b, 0) + S
    b += max(e-b, 0)
S += ')' * max(b-e, 0)
print(S)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    ll n; cin>>n;
  cout << n*(n-1)/2 << '\n';

    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
import java.math.BigDecimal;
import java.lang.Double;
public class Main{

public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  //double a = sc.nextDouble();
  //double b = sc.nextDouble();
  //double c = sc.nextDouble();

//BigDecimal b1 = new BigDecimal(sc.nextDouble());
//BigDecimal b2 = new BigDecimal(sc.nextDouble());
//BigDecimal b3 = new BigDecimal(sc.nextDouble());

//double a = b1.divide(b2);


int a = sc.nextInt();
int b = sc.nextInt();
String stra = Integer.toString(a);
String strb = Integer.toString(b);
BigDecimal da = new BigDecimal(stra);
BigDecimal db = new BigDecimal(strb);
//System.out.println("da/db "+da.divide(db)+";");
//double db = Double.parseDouble(strb);
BigDecimal dr = da.divide(db,6,BigDecimal.ROUND_HALF_UP);
//System.out.println(dr);
System.out.println(a/b+" "+a%b+" "+dr);
}


}


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


void solve()
{
	ll n,i,j,k,x,y,z,m;
	ll ans;
	for(i=1;i<=5;i++)
	{
		cin>>x;
		if(x==0)
		{
			ans=i;
		}
	}
	cout<<ans<<endl;
	
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  string s;
  cin >> s;
  s[5] = s[13] = ' ';
  cout << s << "\n";
  return 0;
}


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

using namespace std;

typedef long long ll;
const int mod = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    
    ll ans = 1;
    if(N % 2 == 0){
        int cnt;
        for(int i = 1; i <= N - 1; i += 2){
            cnt = upper_bound(A.begin(), A.end(), i) - lower_bound(A.begin(), A.end(), i);
            if(cnt != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    else{
        int cnt;
        for(int i = 0; i <= N - 1; i += 2){
            cnt = upper_bound(A.begin(), A.end(), i) - lower_bound(A.begin(), A.end(), i);
            if(i == 0){
                if(cnt != 1){
                    cout << 0 << endl;
                    return 0;
                }
            }
            else{
                if(cnt != 2){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }
    
    for(int i = 0; i < N / 2; i++){
        ans *= 2;
        ans %= mod;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;

int main() {
    int N;
    cin >> N;
    map<string, int> m;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        m[s]++;
    } 
    int M;
    cin >> M;
    for(int i = 0; i < M; i++){
        string t;
        cin >> t;
        m[t]--;
    } 
    
    int mx = 0;
    for(auto& kv: m) mx = max(mx, kv.second);

    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int n, q;
    vector<int> S;
    vector<int> T;
    
    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
	int v;
	scanf("%d", &v);
	S.push_back(v);
    }

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

    scanf("%d", &q);

    for ( int i = 0; i < q; i++ ) {
	int v;
	scanf("%d", &v);
	T.push_back(v);
    }

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

    int index_s = 0;
    int ans = 0;
    for ( int i = 0; i < T.size(); i++ ) {
	while ( index_s < S.size() && T[i] > S[index_s] ) {
	    index_s++;
	}
	if ( index_s >= S.size() ) {
	    break;
	}
	
	if ( T[i] == S[index_s] ) {
	    ans++;
	}
    }
    
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1656
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using STR = System.String;
using INT = System.Int32;
using DEC = System.Double;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        INT N = IO.I();
        INT[][] AB = IO.I(N, ' ');
        INT MAXKEY = -1;
        INT MAXVALUE = -1;
        for (int i = 0; i < N; i++)
        {
            if (AB[i][0] > MAXKEY) { MAXKEY = AB[i][0]; MAXVALUE = AB[i][1]; }
        }
        IO.W(MAXKEY + MAXVALUE);
        IO.F();
    }
}

public class IO
{
    private const int WMAX = 1000;
    private StringBuilder SB = new StringBuilder();
    private T R<T>(Func<STR, T> f) { return f(Console.ReadLine()); }
    private T[] R<T>(Func<STR, T> f, char c) { return S().Split(c).Select(f).ToArray(); }
    private T[] R<T>(Func<STR, T> f, INT l) { T[] r = new T[l]; for (INT i = 0; i < l; i++) { r[i] = R(f); } return r; }
    private T[][] R<T>(Func<STR, T> f, INT l, char c) { T[][] r = new T[l][]; for (INT i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
    private void W<T>(Func<T, STR> f, T v, bool lf = true) { SB.Append(f(v)); if (lf) { SB.Append('\n'); } if (SB.Length >= WMAX) { F(); } }
    public STR S() { return R(s => s); }
    public STR[] S(char c) { return R(s => s, c); }
    public STR[] S(INT l) { return R(s => s, l); }
    public STR[][] S(INT l, char c) { return R(s => s, l, c); }
    public INT I() { return R(INT.Parse); }
    public INT[] I(char c) { return R(INT.Parse, c); }
    public INT[] I(INT l) { return R(INT.Parse, l); }
    public INT[][] I(INT l, char c) { return R(INT.Parse, l, c); }
    public DEC D() { return R(DEC.Parse); }
    public DEC[] D(char c) { return R(DEC.Parse, c); }
    public DEC[] D(INT l) { return R(DEC.Parse, l); }
    public DEC[][] D(INT l, char c) { return R(DEC.Parse, l, c); }
    public void W(object s, bool lf = true) { W(v => v.ToString(), s, lf); }
    public void F() { Console.Write(SB); SB.Length = 0; }
}

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

int main() {
	vector<int> ab_count( 26 );

	for( ;; ) {
		string s;
		cin >> s;

		if( s.empty() ) {
			break;
		}

		for( int i = 0; i < s.size(); ++i ) {
			char ch = s.at( i );

			if( ch >= 'A' && ch <= 'Z' ) {
				ab_count.at( ch - 'A' ) += 1;
			}
			else if( ch >= 'a' && ch <= 'z' ) {
				ab_count.at( ch - 'a' ) += 1;
			}
		}
	}

	for( int i = 0; i < ab_count.size(); ++i ) {
		char ch = 'a' + i;
		cout << ch << " : " << ab_count.at( i ) << endl;
	}
}



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

int main() {
	string s;
  cin >> s;
  if(s=="SUN")cout<<"7"<<endl;
  else if(s=="MON")cout<<"6"<<endl;
  else if(s=="TUE")cout<<"5"<<endl;
  else if(s=="WED")cout<<"4"<<endl;  
  else if(s=="THU")cout<<"3"<<endl;  
  else if(s=="FRI")cout<<"2"<<endl;  
  else if(s=="SAT")cout<<"1"<<endl;  
  
}


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

bool IsOneBit(int bits, int i) {
	return (bits & (1 << i)) > 0;
}
int DFS(vector<vector<bool>>& Graph, int Visited, int now) {
	int ans = 0;
	int N = Graph.size();
	if (Visited == (1 << N) - 1) return 1;
	for (int i = 0; i < N; i++) {
		if (Graph[now][i] == 1 && !IsOneBit(Visited, i)) {
			Visited += (1 << i);
			ans += DFS(Graph, Visited, i);
			Visited -= (1 << i);
		}
	}
	return ans;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<bool>> Graph(N, vector<bool>(N, false));

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		Graph[a-1][b-1] = true;
		Graph[b-1][a-1] = true;
	}

	int Visited = 1;
	cout << DFS(Graph, Visited, 0) << endl;
}

Measured memory_bytes: 256
n=int(input())
s=[]
h=[]
c=[]
d=[]

for i in range(n):
    k=input().split()
    
    if k[0]=="S":
        s.append(int(k[1]))
    if k[0]=="H":
        h.append(int(k[1]))
    if k[0]=="C":
        c.append(int(k[1]))
    if k[0]=="D":
        d.append(int(k[1]))

for i in range(1,14):
    if i not in s:
        print("S", i)

for i in range(1,14):
    if i not in h:
        print("H", i)
        
for i in range(1,14):
    if i not in c:
        print("C", i)
        
for i in range(1,14):
    if i not in d:
        print("D", i)


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

template <typename T>
vector<int> tpsort_Kahn(const vector< vector< T > > &g) {
    const int V = g.size();
    vector<int> indeg(V, 0);
    stack<int> S;

    rep(i,0,V) rep(j,0,g[i].size())
        indeg[ g[i][j] ]++;
    rep(i,0,V) if(indeg[i] == 0) S.push(i);

    vector<int> ans;
    while(S.size() > 0) {
        int u = S.top(); S.pop();
        ans.push_back(u);
        rep(i,0,g[u].size()) {
            indeg[ g[u][i] ]--;
            if(indeg[ g[u][i] ] ==  0)
                S.push( g[u][i] );
        }
    }
    return ans;
}

int H, W;
char board[60][60];
int min_x[35], max_x[35], min_y[35], max_y[35];

signed main() {
    int DATA; cin >> DATA;
    while(DATA--) {
        // initialize
        fill(min_x, min_x + 35, INF);
        fill(min_y, min_y + 35, INF);

        fill(max_x, max_x + 35, -1);
        fill(max_y, max_y + 35, -1);

        cin >> H >> W;
        rep(i,0,H) rep(j,0,W) {
            cin >> board[i][j];
            if(board[i][j] == '.') continue;
            int alph = board[i][j] - 'A';

            chmin(min_x[alph], i);
            chmin(min_y[alph], j);

            chmax(max_x[alph], i+1);
            chmax(max_y[alph], j+1);
        }

        bool ng = false;
        vector< vector<int> > G(30);
        rep(f,0,26) {
            if(min_x[f] == INF) continue;
            // printf("search: character %c\n", (char)('A' + f));
            // printf("debug: min_x = %lld, max_x = %lld, min_y = %lld, max_y = %lld\n", min_x[f], max_x[f], min_y[f], max_y[f]);
            rep(i,min_x[f],max_x[f]) {
                rep(j,min_y[f],max_y[f]) {
                    if(board[i][j] == '.') ng = true;
                    else if(board[i][j] - 'A' != f) {
                        int v = board[i][j] - 'A';
                        G[f].push_back(v);
                    }
                }
            }
        }

        vector<int> ans = tpsort_Kahn(G);
        if(ans.size() != 30) ng = true;

        cout << (ng ? "SUSPICIOUS" : "SAFE") << endl;
    }
    return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    int dis[n];
    rep(i,n) dis[i] = 0;

    rep(i,n-1) REP(j,i+1,n)
    {
        int tmpn = min(j-i, abs(x-i)+1+abs(y-j));
        // cout << tmpn << endl;

        dis[tmpn]++;
    }
    REP(i,1,n)
    {
        cout << dis[i] << endl;
    }
    
    
}




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

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

	int N, K;
	cin >> N >> K;
	double Ans=0,tmp;
	int t = 0;
	for (int i = 1; i <= N; ++i) {
		tmp = 1;
		t = i;
		while (t<K) {
			tmp /= 2;
			t *= 2;
		}
		Ans += tmp;
	}
	Ans/=N;
	printf("%.12f", Ans);
	return 0;
}

Measured memory_bytes: 256
#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 std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n,x,d;
map<ll,vector<pair<ll,ll>>>M;

int main(){
	cin >> n >> x >> d;
	if(d == 0){
	    if(x != 0) cout<<n+1<<endl; else cout<<1<<endl; return 0;
	}
	int j = 0;
	for(ll i=-n;i<=n;i+=2){
		ll val = x*i;
		ll K =  (val%d+d)%d;
		val -= (val%d+d)%d;
		ll beg = 1LL*(j-1)*(j)/2; beg = -1LL*n*(n-1)/2+beg*2;
		ll en = 1LL*(n-j-1)*(n-j)/2; en = 1LL*n*(n-1)/2-en*2;
        assert(beg <= en);
		ll L = val/d+beg;
		ll R = val/d+en;
		assert( (L+R)%2 == 0 );
		K = K*2+(L%2+2)%2;
		L -= (L%2+2)%2; L /= 2;
		R -= (R%2+2)%2; R /= 2;
		j++;
		M[K].pb(mp(L,R));
		assert(L <= R);
	}
	unsigned long long ans = 0;
	for(auto a:M){
		vector<pair<ll,ll>>vec = a.sc;
		vector<ll>za;
		vector<ll>rui;
		rep(i,vec.size()) {za.pb(vec[i].fi); za.pb(vec[i].sc+1);}
		SORT(za); ERASE(za);
		rui.resize(za.size()+2,0);
		rep(i,vec.size()){
			int a = POSL(za,vec[i].fi);
			int b = POSL(za,vec[i].sc+1);
			rui[a]++;
			rui[b]--;
		}
		for(int i=1;i<rui.size();i++){
			rui[i]+=rui[i-1];
		}
		rep(i,rui.size()-1){
			if(rui[i]) ans += za[i+1]-za[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 22144
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String args[]) {
        int n = sc.nextInt();
        pw.println(3*n*n);
        pw.flush();
    }

    static FastScanner sc = new FastScanner();
    static PrintWriter pw = new PrintWriter(System.out);
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private static int[] make_cost = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    public static void Main()
    {
        string s = NextString();
        int a = -1, b = -1;
        for (int i = 0; i < s.Length - 1; i++)
        {
            if (s[i] == s[i + 1]) { a = i + 1; b = i + 2; }
            if (i != s.Length - 2 && s[i] == s[i + 2]) { a = i + 1;b = i + 3; }
        }
        Console.WriteLine(a+" "+b);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

int main() {
 int d,n;
 long int a;
 cin >> d >> n;
 a = (pow(100,d))*(n+1);
 if(d==0){
   if(n !=100){
    cout << n << endl;
   }
   else{
    cout << 101 << endl; 
   }
 }
 else{
   if(n !=100){
   cout << (pow(100,d))*n << endl;
   }
   else{
   cout << a << endl;
   }
 }
}

Measured memory_bytes: 256