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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int N;
int a[100010];
int b[100010];

int main() {
  cin >> N;
  rep(i, N) cin >> a[i] >> b[i];
  int64_t plus = 0;
  rep(i, N) {
    int k = N - i - 1;
    int poipoipoi_po_poipoipo_pi_ = b[k] - (a[k] + plus) % b[k];
    if (poipoipoi_po_poipoipo_pi_ < b[k]) {
      plus += b[k] - ((a[k] + plus) % b[k]);
    }
  }
  cout << plus << "\n";
}


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

int main() {
  int N;
  cin >> N;
  if (N >= 100) {
    N%=100;
    N%=10;
    if(N==2||N==4||N==5||N==7||N==9){
      cout<<"hon"<<endl;
    }
    else if(N==0||N==1||N==6||N==8){
      cout<<"pon"<<endl;
    }
    else {
      cout<<"bon"<<endl;
    }
  }
  else if (N >= 10) {
    N%=10;
    if(N==2||N==4||N==5||N==7||N==9){
      cout<<"hon"<<endl;
    }
    else if(N==0||N==1||N==6||N==8){
      cout<<"pon"<<endl;
    }
    else {
      cout<<"bon"<<endl;
    }
  }
  else{
    if(N==2||N==4||N==5||N==7||N==9){
      cout<<"hon"<<endl;
    }
    else if(N==0||N==1||N==6||N==8){
      cout<<"pon"<<endl;
    }
    else {
      cout<<"bon"<<endl;
    }
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> perm(n);
	for (int i = 0; i < n; ++i)
		cin >> perm[i];
	int cnt = 0;
	for (int i = 1; i < n - 1; ++i) {
		vector<int> little(perm.begin() + i - 1, perm.begin() + i + 2);
		sort(little.begin(), little.end());
		cnt += (perm[i] == little[1]);
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int N; 
    cin >> N;
    map<string, int> all;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        all[s]++;
    }
    ll total = 0;
    for (auto const &p: all) {
        ll val = p.second;
        total += val * (val - 1) / 2;
    }
    cout << total << "\n";
}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();

        int l = 1;
        int r = n;
        for (int i = 0; i < m; i++) {
            l = Math.max(l, in.nextInt());
            r = Math.min(r, in.nextInt());
        }
        out.println(Math.max(0, r - l + 1));
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

string s;
ll a, b, c;
int main(){
	cin >> a >> b;
	p(max<ll>(0, a-b*2));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    return b>0?gcd(b,a%b):a;
}
int main(){
	int n;
	cin >> n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3&&i%5){
			sum+=i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
M,D = map(int,input().split())
ans = 0

for i in range(1,M+1):
  for j in range(10,D+1):
    a,b = divmod(j,10)
    
    if a>=2 and b>=2:
      if i ==a*b:
        ans += 1
       
      
      
print(ans)
    
    

Measured memory_bytes: 2940
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
	char word[33];
	int len = 0;
	int mlen = 0;
	char mword[33];
	char dict[1000][33];
	int mode[1000];
	int st = 0;
	bool find = false;
	int i = 0;

	while(scanf("%s", word) != EOF){
		len = strlen(word);
		for(i=0; i<len; ++i){
			word[i] = tolower(word[i]);
		}

		if(mlen < len){
			mlen = len;
			strcpy(mword, word);
		}

		find = false;
		for(i=0; i<st; ++i){
			if(strcmp(dict[i], word) == 0){
				find = true;
				break;
			}
		}
		if(find){
			mode[i]++; 
		}else{
			strcpy(dict[st], word);
			mode[st] = 1;
			st++;
		}
	}

	int max = 0;
	int maxi = 0;
	for(i = 0; i<st; ++i){
		if(max < mode[i]){
			max = mode[i];
			maxi = i;
		}
	}
	printf("%s %s\n", dict[maxi], mword);

	getchar();
	return 0;
}

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

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

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var count = 0;
            var num = 1;
            do
            {
                count++;
                if (num == 9) num += 91;
                else if (num == 999) num += 9001;
                else if (num == 99999) num += 900001;
                else num++;
            }
            while (num <= n);
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define mi map<ll,ll>
#define mii map<pii,ll>
const ll N=(1e7+1);//mod=998244353;
ll n,m,k;//
ll a[N],dp[N];
string s;
ll l=(1e7+2);
int main(){
	int n;cin>>n;int ans=0,c[n],v[n];
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++){
		if(v[i]-c[i]>0){
			ans+=v[i]-c[i];
		}
	}
	cout<<ans<<endl;
}
/*
2
5 2
3 6 4 7 2
5 3
3 -5 6 3 10


*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e5 + 9;
int mn = 1e9;
int n, m, C[N], mm[N], k;
vector<int> v[N];

void backtrack(int idx, int money, vector<int> vv) {
	if(idx == n) {
		bool can = 1;
		for(auto it: vv)
			can &= it >= k;
		if(can)
			mn = min(mn, money);
		return;
	}
	backtrack(idx + 1, money, vv);
	for (int i = 0; i < v[idx].size(); ++i)
		vv[i] += v[idx][i];
	backtrack(idx + 1, money + mm[idx], vv);

}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	cin >> n >> m >> k;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		mm[i] = a;
		for (int j = 0; j < m; ++j) {
			cin >> a;
			v[i].push_back(a);
		}
	}
	vector<int> vv(m, 0);
	backtrack(0, 0, vv);
	if(mn == 1e9) mn = -1;
	cout << mn;
	return 0;
}


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

using namespace std;


int main()
{
    int tmp;
    vector<int> num;
    
    for (int i = 0; i < 10; i++)
    {
        cin >> tmp;
        num.push_back(tmp);
    }
    
    sort(num.begin(), num.begin() + 10);
    for (int i = 9; i >= 7; i--)
    {
        cout << num[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3164
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    String s[] = new String[n];
    for(int i = 0 ; i < n ; ++i){
      s[i] = sc.next();
    }
    Arrays.sort(s);
    
    String ans = "";

    for(int i = 0 ; i < n ; ++i){
      ans += s[i];
    }
    System.out.println(ans);    
  }
}


Measured memory_bytes: 40656
import math
n = int(input())
s = {}
ans = 0
for i in range(n):
    a = input()
    a = ''.join(sorted(a))
    if a in s:s[a] +=1
    else: s[a] = 1
for i in s:
    a = s[i]
    ans += a*(a-1)//2
print(ans)

Measured memory_bytes: 17932
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#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;
const ll INF=1e9+7;

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

int main(void) {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
/*	ll num = b - a;
	ll div1 = num / c;	//cで割り切れる個数
	ll div2 = num / d;	//dで割り切れる個数
	ll commulti = c * d / gcd(d, c);
	ll div3 = num / commulti;
	ll sum = div1 + div2 - div3;
	printf("%lld\n", num - sum);*/
	ll bc = b / c;
	ll bd = b / d;
	ll num = b - (bc + bd);
	ll commulti = c * d / gcd(d, c);
	ll num1 = b / commulti; //重複して引いた数

	ll ac = (a-1) / c;
	ll ad = (a-1) / d;
	ll num2 = (a-1) - (ac + ad);
	ll num3 = (a-1) / commulti; //重複して引いた数

	printf("%lld\n", (num+num1)-(num2+num3));

	return 0;
}

Measured memory_bytes: 384
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

Tree tree;
Vec dist;
Vec color;

void dfs(ll node, ll prev){
	for(P p : tree[node]){
		if(p.fs != prev){
			dist[p.fs] = dist[node]+p.sc;
			dfs(p.fs, node);
		}
	}
}

int main(void){
	ll n;
	cin >> n;
	tree.resize(n);
	dist.assign(n, LINF);
	color.resize(n);

	rep(i, n-1){
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		tree[u].pb({v, w});
		tree[v].pb({u, w});
	}

	dist[0] = 0;
	dfs(0, 0);
	rep(i, n) color[i] = dist[i]%2;
	rep(i, n) co(color[i]);

	return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ld err=0.000000001;
#define    N       2000005
#define   ESP     1e-9
#define    pii      pair<int,int>
#define    vi       vector<int>
#define    vl       vector<ll>
#define    pb       push_back
#define    pp       pop_back
long long f(long long n)
{
    long long x = n&3;

    if(x == 0) return n;
    else if(x==1) return 1;
    else if(x==2) return n+1;
    return 0;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a==0) return cout<<f(b)<<endl,0;
    cout<<(f(b)^f(a-1))<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int D = Integer.parseInt(st.nextToken());
         int res = 0;
         while(N-->0)
         {
            st = new StringTokenizer(infile.readLine());
            double X = Double.parseDouble(st.nextToken());
            double Y = Double.parseDouble(st.nextToken());
            double dist = Math.sqrt(X*X+Y*Y);
            if(dist <= D)
            res++;
         }
         System.out.println(res);
      }
   }

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

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

  vector<long> A(3*N);
  for (int i = 0; i < 3*N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end(), greater<long>());

  long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A.at(2*i + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int h, w; cin >> h >> w;
  int r, c; cin >> r >> c;
  cout << h * w - (w * r + h * c - r * c) << endl;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 2e3+1;
int n, x, y, res[N];

int Get(int u, int v){
  return abs(u - v);
}

int main()
{
  fastio;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) res[i] = n - i;
  for (int i = 1; i < n; i++){
    for (int j = i + 1; j <= n; j++){
      int mn = min(Get(i, x) + Get(j, y), Get(i, y) + Get(j, x)) + 1;
      if (mn < j - i){
        res[j - i]--; res[mn]++;
      }
    }
  }
  for (int i = 1; i < n; i++) cout << res[i] << '\n';
  return 0;
}

Measured memory_bytes: 256
'use strict'
 
function main(n) {
  let a0 = n.split("\n")[0].split(" ");
  let a1 = n.split("\n")[1].split(" ");
  let a2 = n.split("\n")[2].split(" ");
  let a0SumCheck = (a0.reduce((n,m)=>{return n*1+m*1}))%3;
  let a1SumCheck = (a1.reduce((n,m)=>{return n*1+m*1}))%3;
  let a2SumCheck = (a2.reduce((n,m)=>{return n*1+m*1}))%3;
  let b0SumCheck = (a0[0]*1+a1[0]*1+a2[0]*1)%3;
  let b1SumCheck = (a0[1]*1+a1[1]*1+a2[1]*1)%3;
  let b2SumCheck = (a0[2]*1+a1[2]*1+a2[2]*1)%3;
  let aCheck = ((a0SumCheck == a1SumCheck) && (a1SumCheck == a2SumCheck));
  let bCheck = ((b0SumCheck == b1SumCheck) && (b1SumCheck == b2SumCheck));
  if(aCheck&&bCheck){
  	console.log("Yes");
  } else {
   	console.log("No");
  }
}

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

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

string tobin(ll n) {
	string out = "";
	ll len = 1;
	ll div = 1;
	while (1) {
		if (n / div < 2) {
			break;
		}
		len++;
		div *= 2;
	}
	for (ll i = 0; i < len; i++) {
		if (n / div >= 1) {
			out = out + "1";
			n -= div;
		}
		else {
			out = out + "0";
		}
		div /= 2;
	}
	return out;
}

int main() {
	ll i, j;

	ll N, M;
	cin >> N >> M;
	vll K, P;
	vector<vll> S;
	for (i = 0; i < M; i++) {
		ll k;
		vll s;
		cin >> k;
		K.push_back(k);
		for (j = 0; j < k; j++) {
			ll sj;
			cin >> sj;
			s.push_back(sj);
		}
		S.push_back(s);
	}
	for (i = 0; i < M; i++) {
		ll p;
		cin >> p;
		P.push_back(p);
	}

	ll ans = 0;
	for (ll n = 0; n < pow(2, N); n++) {
		string binaryn = tobin(n);
		if (binaryn.length() < N) {
		string zeros = string(N - binaryn.length(), '0');
		binaryn = zeros + binaryn;
		}
		ll on_count = 0;
		for (i = 0; i < M; i++) {
			ll k = K[i];
			ll count = 0;
			for (j = 0; j < k; j++) {
				if (binaryn[S[i][j] - 1] == '1') {
					count++;
				}
			}
			if (count % 2 == P[i]) {
				on_count++;
			}
		}
		if (on_count == M) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int dp[2000];

int main()
{
	int N, K, C, G;
	cin >> N >> K;
	vector<int> b[11], v[11];

	for (int i = 0; i < N; i++) {
		cin >> C >> G;
		b[G].push_back(C);
	}

	for (int i = 1; i <= 10; i++) {
		sort(b[i].begin(),b[i].end(),greater<int>());
		v[i].push_back(0);
	}

	for (int i = 1; i <= 10; i++) {
		for (int j = 0; j < b[i].size(); j++) {
			v[i].push_back(v[i][j]+b[i][j]+j*2);
		}
	}

	for (int i = 1; i <= 10; i++) {
		for (int j = K; j >= 0; j--) {
			for (int h = max(0, j - (int)v[i].size() + 1); h < j; h++) {
				dp[j] = max(dp[j],dp[h]+v[i][j-h]);
			}
		}
	}
	cout << dp[K] << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
int main(){
  long long n, a[100009];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  long long odd=0, even=0;
  for(int i=0;i<n;i++){
    if(a[i]%2==1)odd++;
  }
  cout << (odd%2==0?"YES":"NO") << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 15;

int n, m, x;
int arr[N][N], c[N];
int val[N];

int main() {
  scanf("%d %d %d", &n, &m, &x);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    for (int j = 1; j <= m; ++j) scanf("%d", &arr[i][j]);
  }
  int mini = INT_MAX;
  for (int msk = 0; msk < (1 << n); ++msk) {
    mem(val, 0);
    int cost = 0;
    for (int i = 0; i < n; ++i) {
      if (msk & (1 << i)) {
        cost += c[i];
        for (int j = 1; j <= m; ++j) val[j] += arr[i][j];
      }
    }
    bool flag = true;
    for (int j = 1; j <= m; ++j) {
      if (val[j] < x) {
        flag = false;
        break;
      }
    }
    if (flag) mini = min(mini, cost);
  }
  if (mini == INT_MAX) mini = -1;
  printf("%d\n", mini);
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    vector<ll> A(n), B(n);
    for (ll i = 0; i < n; ++i) {
        cin >> A[i] >> B[i];
    }

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

    ll medA, medB;

    if ((n % 2) == 0) {
        medA = A[n/2-1] + A[n/2];
        medB = B[n/2-1] + B[n/2];
       ll res = medB-medA+1;
       cout << res << endl;
    } else {
        medA = A[n/2];
        medB = B[n/2];
        ll res = medB-medA+1;
        cout << res<< endl;
    }
}


Measured memory_bytes: 6320
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
D eps=1e-9;
D cro(P a,P b){return imag(conj(a)*b);}
bool compxy(const P& a,const P& b){
	return a.real()==b.real()?a.imag()<b.imag():a.real()<b.real();
}
bool onseg(L l,P p){
	return abs(abs(l.fs-p)+abs(l.sc-p)-abs(l.fs-l.sc))<eps;
}
bool iSS(L a,L b){
	return onseg(a,b.fs)||onseg(a,b.sc)||onseg(b,a.fs)||onseg(b,a.sc);
}
int N,ans[10];
int par[1000];
vector<int> g[1000];
void init(int n){rep(i,n) par[i]=i;}
int find(int x){
	if(par[x]==x) return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x),y=find(y);
	par[x]=y;
}
vector<L> l;
int main(){
	while(true){
		cin>>N;
		if(N==0) break;
		init(N);
		rep(i,N) g[i].clear();
		l.clear();
		rep(i,10) ans[i]=0;
		rep(i,N){
			D a,b,c,d;
			cin>>a>>b>>c>>d;
			l.pb(L(P(a,b),P(c,d)));
		}
		rep(i,N) rep(j,i) if(iSS(l[i],l[j])) unite(i,j);
		rep(i,N) g[find(i)].pb(i);
		rep(i,N){
			if(g[i].size()==0||find(i)!=i) continue;
			vector<P> ps;
			for(int v:g[i]) ps.pb(l[v].fs),ps.pb(l[v].sc);
			sort(all(ps),compxy);
			ps.erase(unique(all(ps)),ps.end());
			if(g[i].size()==1){
				ans[1]++;
			}else if(g[i].size()==3){
				if(ps.size()==4) ans[7]++;
				else ans[4]++;
			}else if(g[i].size()==4){
				if(ps.size()==4) ans[0]++;
				else if(ps.size()==5) ans[9]++;
				else ans[3]++;
			}else{
				vector<P> es;
				for(P p:ps){
					int cnt=0;
					for(int v:g[i]) if(onseg(l[v],p)) cnt++;
					if(cnt==1) es.pb(p);
				}
				if(es.size()==0) ans[8]++;
				else if(es.size()==1) ans[6]++;
				else{
					P e=es[0];
					int id,id2;
					for(int v:g[i]) if(onseg(l[v],e)) id=v;
					P f=l[id].fs;
					if(f==e) f=l[id].sc;
					for(int v:g[i]) if(onseg(l[v],f)&&v!=id) id2=v;
					P h=l[id2].fs;
					if(h==f) h=l[id2].sc;
					if(cro(f-e,f-h)>0) ans[2]++;
					else ans[5]++;
				} 
			}
		}
		rep(i,9) cout<<ans[i]<<" ";
		cout<<ans[9]<<endl;
	}
}

Measured memory_bytes: 1368
#include <stdio.h>
#include <math.h>

int main() {
double x1,y1,x2,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
printf("%.8lf\n",hypot(x1-x2,y1-y2));
return 0; 
}


Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(){
	long a,b,k;
	cin >> a >> b >> k;
	if(a>=k)
	{
		cout << a-k << ' ' << b <<endl;
	}
	else if(b >= k-a)
	{
		cout << 0 << ' ' << b-(k-a) <<endl;
	}
	else
	{
		cout << 0 <<' '<<0 <<endl;
	}
}


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		double x1 = Double.parseDouble(s.next());
		double y1 = Double.parseDouble(s.next());
		double x2 = Double.parseDouble(s.next());
		double y2 = Double.parseDouble(s.next());
		s.close();

		double a = Math.pow(x2 - x1, 2);
		double b = Math.pow(y2 - y1, 2);
		System.out.println(String.format("%.8f", Math.sqrt(a + b)));
	}
}

Measured memory_bytes: 17376
/*author : Yashvardhan
Sunday, May 10, 2020
5:55 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

const int N = 2e5 + 5;
int vis[N];

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,k;
	cin >> n >> k;

	vi arr(n + 1);
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}

	if(arr[1] == 1){
		cout << 1 << endl;
		return 0;
	}

	int curr = 1;
	int a,b;
	int clen;
	for(int i = 0; i < n; i++){
		int nxt = arr[curr];
		if(vis[nxt]){
			int ct = 0;
			int tmp = nxt;
			while(tmp != curr){
				ct++;
				tmp = arr[tmp];
			}
			clen = ct + 1;
			a = nxt;
			b = curr;
			break;
		}
		vis[curr] = 1;
		curr = nxt; 
	}

	int ct = 0;
	curr = 1;
	while(curr != a){
		ct++;
		curr = arr[curr];
		if(ct == k){
			cout << curr << endl;
			return 0;
		}
	}

	k -= ct;

	int rem = k % clen;
	while(rem--){
		curr = arr[curr];
	}

	cout << curr << endl;


	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 6484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);//cout.tie(NULL);
#define mod 1000000007

int F[1000000];

int cost(int n, int* h){
    if(n>2) for(int i=3;i<=n;i++) F[i] = min(F[i-1] + abs(h[i]-h[i-1]) ,F[i-2] + abs(h[i]-h[i-2]));
}

int main()
{
    //io
    memset(F, -1, sizeof(F));
    int n;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++) cin>>h[i];
    h[0]  = F[1] = 0;
    F[2] = abs(h[2] - h[1]);
    cost(n,h);
    cout<<F[n];
    return 0;
}



Measured memory_bytes: 4480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            int[] nx = ReadAndParseIntArr();
            int n = nx[0];
            int x = nx[1];
            int[] m = new int[n];
            for(int i=0;i<n;++i)
            {
                m[i] = ReadAndParseInt();
            }
            m = m.OrderBy(p => p).ToArray();
            int ans = n;
            x -= m.Sum();
            // 残りで可能な限り作る
            ans += (int)Math.Floor((double)x / m[0]);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main()
{
    vector<string> s(100005);
    map <string, long long> mp; 
    long long i, ans=0, n, f=0, j, k;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        ans=ans+mp[s[i]];
        mp[s[i]]++;
    }

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

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> hight(n);
    for (int i = 0; i < n; ++i){
        cin >> hight.at(i);
    }
    vector<int> vec = {0, abs(hight.at(1)-hight.at(0))};

    for (int i = 2; i < n; ++i){
        vector<int> pattern;
        for (int j = 1; j <= min(k, i); ++j){
            pattern.push_back(vec.at(i-j) + abs(hight.at(i)-hight.at(i-j)));
        }
        sort(pattern.begin(), pattern.end());
        vec.push_back(pattern.front());
    }

    cout << vec.at(n-1) << endl;
}

Measured memory_bytes: 1276
s = gets.chomp
K = gets.to_i
n = s.length
ss = []
0.upto(n - 1) do |l|
	0.upto(4) do |i|
		ss.push(s[l..(l + i)]) if l + i < n
	end
end
ss = ss.uniq.sort
puts ss[K - 1]

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define v32 vector<int>
#define v64 vector<ll>
 
using namespace std;
 
void solve()
{
    ll n;
    cin >> n;
    ll *a = new ll[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll balance = 1000;
    ll stocks = 0;
    ll i;
    for (i = 0; i < n - 1; i++)
    { // if increasing
        if (a[i + 1] > a[i])
        {
            if ((balance / a[i]) > 0)
            {
                ll s = balance / a[i];
                stocks = stocks + s;
                balance = balance - (s * a[i]);
            }
        }
        // if constant
      /*  else if (a[i + 1] == a[i])
        {
            if (i == 0)
            {
 
                if ((balance / a[i]) > 0)
                {
                    ll s = balance / a[i];
                    stocks = stocks + s;
                    balance = balance - (s * a[i]);
                }
            }
 
            continue;
        }*/
        // if decreasing
        else if(a[i]>a[i+1])
        {
            if (stocks > 0)
            {
                balance = balance + (stocks * a[i]);
                stocks = 0;
            }
        }
    }
    balance = balance + (stocks)*a[n - 1];
    stocks = 0;
    cout << balance << endl;
}
int main()
{
    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int inf = (1<<28);
const ll infl = (1LL<<60);
const int mod = 1e9+7;
const int MAX_LEN = 100000;

int main() {
    string s; cin >> s;
    deque<char> S;
    for (auto c : s) S.push_back(c);

    int q; cin >> q;
    int dir = 0;
    for (int i = 0; i < q; ++i) {
        int t; cin >> t;
        if (t == 1) dir = 1 - dir;
        if (t == 2) {
            int f; cin >> f; f--;
            char c; cin >> c;
            if (f ^ dir == 0) {
                S.push_front(c);
            }
            if (f ^ dir == 1) {
                S.push_back(c);
            }
        }
    }
    if (dir == 0) {
        for (const auto& c : S) {
            cout << c;
        } cout << endl;
    }
    if (dir == 1) {
        for (auto it = S.rbegin(); it != S.rend(); ++it) {
            cout << *it;
        } cout << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

#define NUM_MAX 1000000

int table[NUM_MAX];

void bit_add(int n,int pos) {
	while(pos<=NUM_MAX) {
		table[pos-1]+=n;
		pos+=(pos & (-pos));
	}
}

int bit_sum(int pos) {
	int result=0;
	while(pos>0) {
		result+=table[pos-1];
		pos-=(pos & (-pos));
	}
	return result;
}

void get_hamming_num(void) {
	int now,now2,now3;
	for(now=1;now<=NUM_MAX;now*=2) {
		for(now2=now;now2<=NUM_MAX;now2*=3) {
			for(now3=now2;now3<=NUM_MAX;now3*=5) {
				bit_add(1,now3);
			}
		}
	}
}

int main(void) {
	int start,end;
	get_hamming_num();
	while(1) {
		scanf("%d",&start);
		if(start==0)break;
		scanf("%d",&end);
		printf("%d\n",bit_sum(end)-bit_sum(start-1));
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long w,a,b;
    scanf("%ld%ld%ld", &w, &a, &b);
    if(a+w<=b) {
        printf("%ld\n", b-(a+w));
    }
    else if(b+w<=a) {
        printf("%ld\n", a-(b+w));
    }
    else {
        printf("0\n");
    }

    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#define MAX 200000
int main(void){
	int R[MAX],n;
	int i,j;
	
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&R[i]);
	}
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(j = 1;j < n;j++){
		if(maxv < (R[j]-minv)){
			maxv = R[j]-minv;
		}
		if(minv>R[j]){
			minv = R[j];
		}
	}
	printf("%d\n",maxv);
	return 0;
}


Measured memory_bytes: 2560
/**-------------------------
|--------From A.R.A--------|
-------------------------**/
#include <bits/stdc++.h>

#define ll long long int
#define ull unsigned long long int
#define FOR(i,n) for(ll i=0;i<n;i++)
#define input (a,i,n)for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n)for(ll i=0;i<n;i++){cout<<a[i]<<" ";}
#define pb push_back
#define sz(c) (c).size()
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define sall(c) sort((c).begin(),(c).end())
#define rsall(c) sort((c).rbegin(),(c).rend())
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
int64_t TN=1;
using namespace std;
void  solution(){
    string s;
    cin>>s;
    int64_t n=0;
    for(int i=0;i<sz(s);i++){
        //cout<<s[i]-48<<endl;
        n+=(s[i]-48);
    }
    //cout<<n<<endl;
    if(n%9==0){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}

int main()
{
    //cout<<'0'-0<<endl;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //cin>>TN;
    while(TN--){
        solution();
    }
    return 0;
}


Measured memory_bytes: 3732
from bisect import bisect_left
import string 

dic={c:[] for c in string.ascii_lowercase}
N=int(input())
S=list(input())
Q=int(input())
for i in range(len(S)):
  dic[S[i]].append(i+1)

for i in range(Q):
  a,b,c=map(str,input().split())
  if a=='1':
    if S[int(b)-1]==c:
      continue
    b=int(b)
    f=S[b-1]
    d=bisect_left(dic[f],b)
    e=bisect_left(dic[c],b)
    dic[f].pop(d)
    dic[c].insert(e,b)
    S[b-1]=c
  else:
    ans=0
    b,c=int(b),int(c)
    for j in string.ascii_lowercase:
      d=bisect_left(dic[j],b)
      if d<len(dic[j]):
        if dic[j][d]<=c:
          ans+=1
    print(ans)


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] A = new int[n + 1];
    Arrays.setAll(A, i -> sc.nextInt());
    long result = 0;
    int b;
    for (int i = 0; i < n; i++) {
      b = sc.nextInt();
      if (b > A[i]) {
        result += A[i];
        b -= A[i];
        result += Math.min(A[i + 1], b);
        A[i + 1] = Math.max(0, A[i + 1] - b);
      } else
        result += b;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 65536
w,h,n = map(int,input().split())
x1 = 0
x2 = w
y3 = 0
y4 = h

for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        x1 = max(x1,x)
    elif a == 2:
        x2 = min(x2,x)
    elif a == 3:
        y3 = max(y3,y)
    else:
        y4 = min(y4,y)
X = x2 - x1
Y = y4 - y3
s = X * Y
if X < 0 or Y < 0:
    print(0)
else:
    print(s)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    cout << (K == 1 ? 0 : N - K) << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        abs: [(i64, i64); n],
    }
    let mut a_s = abs.iter().map(|(a, _)| *a).collect::<Vec<_>>();
    let mut b_s = abs.iter().map(|(_, b)| *b).collect::<Vec<_>>();
    a_s.sort();
    b_s.sort();
    let ans = if n % 2 == 0 {
        (b_s[n / 2 - 1] + b_s[n / 2]) - (a_s[n / 2 - 1] + a_s[n / 2]) + 1
    } else {
        b_s[n / 2] - a_s[n / 2] + 1
    };
    println!("{}", ans);
}


Measured memory_bytes: 12984
#include <iostream>
#include <algorithm>
using namespace std;
int k,x;
int main()
{
	ios::sync_with_stdio(false);
	cin>>k>>x;
	for(register int i=x-k+1;i<=x+k-1;++i)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vl A = vl(n, 0);
  vvl dp = vvl(n, vl(n, 0));
  REP(i, n)
  {
    cin >> A[i];
  }
  if (n % 2 != 0)
  {
    REP(i, n)
    {
      dp[i][i] = A[i];
    }
  }
  for (int piece = 2; piece <= n; piece++)
  {
    REP(i, n)
    {
      int j = i + piece - 1;

      //IOI
      if ((piece % 2 == 0 && n % 2 != 0) || (piece % 2 != 0 && n % 2 == 0))
      {
        if (A[i] > A[j % n])
        {
          dp[i][j % n] = dp[(i + 1) % n][j % n];
        }
        else if (A[i] < A[j % n])
        {
          dp[i][j % n] = dp[i][(j - 1 + n) % n];
        }
      }
      //JOI
      else
      {
        dp[i % n][j % n] = max(dp[i % n][(j - 1 + n) % n] + A[j % n], dp[(i + 1 + n) % n][j % n] + A[i % n]);
      }
    }
  }
  ll res = 0;
  REP(i, n)
  {
    res = max(res, dp[i][(i + n - 1) % n]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 34312
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int p[105];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x,n;
    cin >> x >> n ;
    rep(i,n){
        int t;
        cin >> t;
        p[t]++;
    }
    if(p[x] == 0 )cout << x << endl;
    else{
        for(int i=0;i<101;i++){
            if(x-i >= 0 && p[x-i] == 0 ){
                cout << x - i << endl;
                return 0;
            }else if(x-i<0){
                cout << x-i << endl;
                return 0;
            }else if(p[x+i] == 0 ){
                cout << x + i << endl;
                return 0;
            }
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    int M = 1000;
    while (M < N)
    {
        M += 1000;
    }
    
    cout << M - N << endl;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;

public class Main {

	public static final int SIZE = 15;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			final int a = sc.nextInt();
			final int b = sc.nextInt();

			if(a == 0 && b == 0){
				break;
			}
			
			final int sqrt_a = (int) (Math.ceil(Math.sqrt(a)));
			final int sqrt_b = (int) (Math.ceil(Math.sqrt(b)));

			TreeSet<Integer> set = new TreeSet<Integer>(
					Collections.reverseOrder());
			Stack<Integer> stack = new Stack<Integer>();

			long min = Long.MAX_VALUE;
			for (int div_a = 1; div_a <= sqrt_a; div_a++) {
				if (a % div_a != 0) {
					continue;
				}

				stack.push(div_a);
				stack.push(a / div_a);

				for (int div_b = 1; div_b <= sqrt_b; div_b++) {
					if (b % div_b != 0) {
						continue;
					}

					stack.push(div_b);
					stack.push(b / div_b);

					set.clear();
					set.addAll(stack);
					//System.out.println(set);
					
					long prev = -1;
					long sum = 0;
					for (int number : set) {
						if (prev != -1) {
							sum += (prev - number) * (prev - number);
						}
						prev = number;
					}

					min = Math.min(sum, min);
					
					stack.pop();
					stack.pop();
				}
				
				stack.pop();
				stack.pop();
			}

			System.out.println(min);
		}
	}

}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    string s; cin >> s;
    ll r = count(s.begin(), s.end(), 'R');
    ll g = count(s.begin(), s.end(), 'G');
    ll b = count(s.begin(), s.end(), 'B');

    ll ans = r * g * b;
    for (int i = 0; i < n; i++) {
        for (int len = 1; len < n; len++) {
            int j = i + len;
            int k = j + len;
            if (k >= n) break;

            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660