akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	cin>>N;
	printf("AB%c\n",'C'+N/1000);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,c;
  scanf("%d%d",&a,&b);
  c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  printf("%d\n",b);
	  
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> B(N-1);
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }
    vector<int> A(N);
    for(int i=0;i<N;i++){
        if(i==0){
            A[i]=B[0];
        }
        else if(i==N-1){
            A[i]=B[N-2];
        }
        else{
            A[i]=min(B[i-1],B[i]);
        }
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans = ans + A[i];
    }
    cout << ans << endl;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e18
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;


//template< typename T1, typename T2 > struct pair {
  //T1 first;
  //T2 second;
//};
               
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  string s; cin >> s;
  int size = s.size();
  long x = 0;
  long y = 0;
  forn(i , 0 , size){
    if(s[i] == 'W') x += y;
    else y++;
  }  
  cout << x << endl;   
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 720
// 2020-09-11 23:24:32
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> b;
  rep(i, n) {
    ll cur = 0;
    REP(j, i, n) {
      cur += a[j];
      b.push_back(cur);
    }
  }
  sort(RALL(b));
  int bz = b.size();
  int c = -1;
  ll ans = -1;
  REPCM(i, 45, 0) {
    int tot = 0;
    rep(j, bz) if ((b[j] >> i) & 1) tot++;
    if (tot >= k) {
      c = i;
      ans = (1ll << i);
      break;
    }
  }
  REPCM(i, c - 1, 0) {
    int tot = 0;
    rep(j, bz) if (((b[j] & ans) == ans) && ((b[j] >> i) & 1)) tot++;
    if (tot >= k) ans |= (1ll << i);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)

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

typedef long long ll;

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

    string s;
    cin >> s;

    repi(i, 1, s.size()-1){
        if((s.size() - i) % 2 == 0){
            bool flag = true;
            int m_size = (s.size() - i) / 2;
            for(auto itr = s.begin(); itr != s.end() - i - m_size; itr++){
                flag = *itr == *(itr + m_size) && flag;
            }

            if(flag){
                cout << m_size * 2 << endl;
                break;
            }
        }
    }
}

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

int main() {
  long N, a;
  cin >> N;
  long ans = 0;
  vector<int> vec(N*3);
  for(int i = 0; i < N*3; i++){
    cin >> a;
    vec.at(i) = a;
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  int x = 0;
  for (int i = 1; i <= N; i++) {
    x = 2*i-1;
    ans += vec.at(x);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1408
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))
A.sort()

LEN = 1000000

ps = [[] for _ in range(LEN + 1)]
is_prime = [False] * (LEN + 1)
for i in range(2, LEN + 1):
    if not is_prime[i]:
        for j in range(i, LEN + 1, i):
            is_prime[j] = True
            ps[j].append(i)

def is_pairwise_coprime():
    s = set()
    for a in A:
        for p in ps[a]:
            if p in s:
                return False
            s.add(p)

    return True


def is_otherwise():
    m = min(A)

    for p in ps[m]:
        if all(map(lambda x: x % p == 0, A)):
            return True

    return False

if is_pairwise_coprime():
    print("pairwise coprime")
elif is_otherwise():
    print("not coprime")
else:
    print("setwise coprime")

Measured memory_bytes: 245100
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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 rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll X;
    cin >> X;
    ll ans=0;
    ans+=1000*(X/500);
    ans+=5*(X%500/5);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q;
    cin, q;
    while (q--) {
        ll a, b;
        cin, a, b;
        ll ans = 0;
        if (a > b) {
            swap(a, b);
        }
        if (a == b || a == b - 1) {
            ans = 2 * a - 2;
        } else {
            ll l = 1, r = b;
            ll res = 0;
            while (l <= r) {
                ll mid = (l + r) / 2;
                if (mid * mid < a * b) {
                    res = mid;
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            ans = 2 * res - 2;
            if (res * (res + 1) < a * b) {
                ans = 2 * res - 1;
            }
        }
        print(ans);
    }
    return 0;
}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/27/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int H,W,N; cin>>H>>W>>N;
  map<pair<int, int>, ll> sum_tb;
  for (int i = 0; i < N; i++) {
    int a,b; cin>>a>>b; a--; b--;
    for (int s = 0; s < 3; s++) {
      for (int t = 0; t < 3; t++) {
        sum_tb[{a-2+s,b-2+t}]++;
      }
    }
  }

  vector<ll> ans(10);
  ll zeros = ll(H-2)*(W-2);
  for (auto s : sum_tb) {
    auto a = s.first.first;
    auto b = s.first.second;
    if (a >= 0 and a < H-2 and b >= 0 and b < W-2) {
      ans[s.second]++;
      zeros -= 1;
    }
  }
  cout << zeros << endl;
  for (int i = 1; i <= 9; i++)
    cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 56576
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

int N, M;
multiset<int> D, T;
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N;
	F0R(i,N) {
	    int x; cin >> x; D.insert(x);
	}
	cin >> M;
	F0R(i,M) {
	    int x; cin >> x; T.insert(x);
	}
	while (T.size()) {
	    if (D.find(*T.begin()) == D.end()) {
	        cout << "NO";
	        return 0;
	    }
	    D.erase(D.find(*T.begin()));
	    T.erase(T.begin());
	}
	cout << "YES";
}

// read!
// ll vs. int!

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

int64_t calcGCD(int64_t a, int64_t b)
{
	while (a)
	{
		b %= a;
		std::swap(a, b);
	}
	return b;
}

int main()
{
	int64_t A, B;
	scanf("%lld%lld", &A, &B);
	int64_t gcd{calcGCD(A, B)};
	int count{1};
	for (int64_t i{2ll}; i * i <= gcd; i++)
	{
		if (gcd % i) continue;
		count++;
		while (gcd % i == 0) gcd /= i;
	}
	if (gcd > 1) count++;
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int m,a;
  cin>>m;
  a=48-m;
  cout<<a<<"\n";
  return 0;
}

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

#define mod 1000000007

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	long long *x = new long long[n], *y = new long long[m];
	for (int i = 0; i < n; i++)	scanf("%lld", x + i);
	for (int i = 0; i < m; i++)	scanf("%lld", y + i);
	long long sum1{};
	for (long long i = 0; i < n - 1; i++)
	{
		sum1 = (sum1 + (i + 1) * (n - i - 1) % mod * (x[i + 1] - x[i]) % mod) % mod;
	}
	long long sum2{};
	for (long long i = 0; i < m - 1; i++)
	{
		sum2 = (sum2 + (i + 1) * (m - i - 1) % mod * (y[i + 1] - y[i]) % mod) % mod;
	}
	printf("%lld\n", sum1 * sum2 % mod);

	delete[] x;
	delete[] y;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define eps 1e-3
#define debug(a) cout << #a": " << a << endl;
inline int lowbit(int x){ return x & -x; }
const int N = 3e5 + 10;
const int mod = (int) 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
using namespace std;

//char buf[100000],*p1=buf,*p2=buf;
//inline char nc(){
//  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline bool read(int & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//inline bool readL(LL & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//LL q_pow(LL base, LL b){LL res=1;for(base%=mod;b;b>>=1,base=base*base%mod)if(b&1){res=res*base%mod;}return res;}



int main(){
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
  int n, T;
  int ans = INF;

  scanf("%d%d", &n, &T);

  for(int i = 1; i <= n; i++) {
    int c, t;
    scanf("%d%d", &c, &t);
    if(t <= T) ans = min(ans, c);
  }

  if(ans == INF) printf("TLE\n");
  else printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
//#include <fstream>

#include <iostream>
#include <algorithm>

using namespace std;

const int INF = (1 << 31) - 1;
const int NMAX = 100005;
int n, k, cost[NMAX], dp[NMAX];

int main()
{
	//ifstream cin("test.in");
	//ofstream cout("test.out");
	cin >> n >> k;
	for (int i = 1;i <= n;++i)
	{
		cin >> cost[i];
		dp[i] = INF;
	}
	dp[1] = 0;
	for (int i = 2;i <= n;++i)
	{
		for (int j = max(1, i - k);j < i;++j)
			dp[i] = min(dp[i], dp[j] + abs(cost[i] - cost[j]));
	}
	cout << dp[n] << "\n";
	return 0;
}

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

using ll = long long;

int main() {
    long long int a,d=1,b=1,c;
    cin>>a;
    c=a;
    while((a/d)-d>=0){
		if(a%d==0 && ((a/d)-d)>=0){
			b = d;
			c = a/d; 
		}
		d++; 
	}
    cout<<abs(b-1)+abs(c-1)<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[105],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[i+1])
		{
			ans++;
			i++;
		}
	}
	printf("%d",ans);
}

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

int main()
{
	string s;
	cin>>s;
	int f1=0,f2=0,f3=0;
	for (int i=0;i<=s.size();i++)
	{
		if (s[i]=='a')
		{
			f1=1;
		}
		if (s[i]=='b')
		{
			f2=1;
		}
		if (s[i]=='c')
		{
			f3=1;
		}
	}
	if (f1==1 && f2==1 && f3==1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w;
    
    for(;;){
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(i == 0 || i == h-1 || j == 0 || j == w-1)cout << "#";
                else cout <<".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

using namespace std;

int main(){
    int n,w;
    cin >> n >> w;
    int values[n+1],weights[n+1];
    for(int i=1; i<=n; i++){
        cin >> weights[i] >> values[i];
    }
    long long int ans[n+1][w+1];
    for(int i=0; i<=w; i++){
        ans[0][i] = 0;
    }
    for(int i=0; i<=n; i++){
        ans[i][0] = 0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(j-weights[i]>=0){
                ans[i][j] = max(ans[i-1][j-weights[i]]+values[i], ans[i-1][j]);
            }else{
                ans[i][j] = ans[i-1][j];
            }
        }
    }
    cout << ans[n][w];
    return 0;
}

Measured memory_bytes: 82476
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int n, x[101], y[101];
double d1 = 0, d2 = 0, d3 = 0, dm = 0;

int main(){
  cin >> n;
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < n; i++){
    cin >> y[i];
    d1 += abs(x[i] - y[i]);
    d2 += pow(x[i] - y[i], 2);
    d3 += pow(abs(x[i] - y[i]), 3);
    if(abs(x[i] - y[i]) > dm) dm = abs(x[i] - y[i]);
  }
  printf("%.8f\n%.8f\n%.8f\n%.8f\n", d1, sqrt(d2), pow(d3,  1.0 / 3), dm);
}

Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<pair<ll,ll>> a(n);
  for (ll i = 0; i < n; i++) {
    ll p, q;
    cin >> p >> q;
    a[i] = make_pair(p,q);
  }
  Sort(a);
  ll cnt = 0;
  for (ll i = 0; ; i++) {
    cnt += a[i].second;
    if (cnt >= k) {
      cout << a[i].first << '\n';
      return 0;
    }
  }
}

Measured memory_bytes: 1792
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
int fact[10001],invfact[10001];
int mod = 1e9+7;
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int power(int a,int b)
{
    int res = 1;
    while(b!=0)
    {
        if(b&1)
            res = mul(res,a);
        b  = b>>1;
        a = mul(a,a);
    }
    return res;
}
int imodulo(int a)
{
    int ans = power(a,mod-2);
    return ans;
}
void pre()
{
    fact[0] = 1;
    invfact[0] = 1;
    for(int i=1;i<=10000;i++)
    {
        fact[i] = mul(i,fact[i-1]);
        invfact[i] = imodulo(fact[i]);
    }
}
int ncr(int n,int r)
{
    if(r>n)
        return 0;
    return mul(fact[n],mul(invfact[r],invfact[n-r]));
}
signed main()
{
    fast;
    pre();
    int n,k;
    cin>>n>>k;
    int r = n-k;
    for(int i=1;i<=k;i++)
    {
        int ans = mul(ncr(r+1,i),ncr(k-1,i-1));
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 384
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define REP(i,a) for(ll i=0;i<a;i++)
typedef long long ll;
typedef pair<ll, ll> Pi;

ll h, w;
vector<vector<int> > s(400, vector<int>(400));
vector<vector<bool>> used(400, vector<bool>(400));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    cin >> h >> w;
    REP(i, h)REP(j, w){
        char ch;
        cin >> ch;
        s[i][j] = (ch == '#');
    }
    //when input[i][j] == black them the value is 1, while 0 when input[i][j] == white
    ll ans = 0;
    REP(y, h)REP(x, w){
        if(used[y][x] || !s[y][x])continue;
        queue<pair<ll, Pi>> que;
        ll black = 1, white = 0;
        que.push(make_pair(1, make_pair(y, x)));
        used[y][x] = true;
        while(!que.empty()){
            auto top = que.front();
            que.pop();
            bool color = top.first;
            auto grid = top.second;
            ll nowY = grid.first;
            ll nowX = grid.second;
            REP(k, 4){
                int nextY = nowY + dy[k];
                int nextX = nowX + dx[k];
                if(nextY < 0 || nextY >= h || nextX < 0 || nextX >= w ||
                   used[nextY][nextX] || s[nextY][nextX] == color)continue;
                used[nextY][nextX] = 1;
                if(!s[nextY][nextX])white++;
                if(s[nextY][nextX])black++;
                que.push(make_pair(s[nextY][nextX], make_pair(nextY, nextX)));
            }
        }
        ans += black * white;
    }
    print(ans);
}




Measured memory_bytes: 896
# frozen_string_literal: true

# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1, 0)
      arg.each.with_index(1) { |e, i| add(i, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1, 0)
    else
      raise ArgumentError
    end
  end

  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i &= i - 1
    end
    res
  end
end

FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree

n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end


Measured memory_bytes: 57424
l=[list(map(int,input().split())) for i in range(3)]
x=l[0][0]
y=l[0][1]
z=l[0][2]
a=0
b=l[1][0]-x
c=l[2][0]-x
if b+y==l[1][1] and b+z==l[1][2] and c+y==l[2][1] and c+z==l[2][2]:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9180
def c_typical_stairs(N, M, A, MOD=10**9 + 7):
    a = set(A)
    way_go_up_the_stairs = [1] + [0] * (N)
    for i in range(1, N + 1):
        if i not in a:
            way_go_up_the_stairs[i] = (
                way_go_up_the_stairs[i]
                + (way_go_up_the_stairs[i - 1] if i - 1 >= 0 else 0)
                + (way_go_up_the_stairs[i - 2] if i - 2 >= 0 else 0)) % MOD
    return way_go_up_the_stairs[N]

N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]
print(c_typical_stairs(N, M, A))

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

struct UnionFind{
  vector<int> d;
  //コンストラクタ
  UnionFind(int n=0): d(n,-1){}
  //根の探索と張り替え
  int find(int x){
    if(d[x] < 0) return x;
    //根のはりかえ
    return d[x] = find(d[x]);
  }
  //根の結合
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    //大きい方に小さい方をくっつける
    if(x < y) swap(x,y);
    //サイズの更新
    d[x] += d[y];
    //結合
    d[y] = x; 
    return true;
  }
  //サイズの取得
  int size(int x){ return -d[find(x)];}
  //同じ集合に属しているか
  bool same(int x, int y){ return (find(x) == find(y)); }
};
 
int main()
{
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  
  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a, --b;
    uf.unite(a,b);
  }
  
  int ans = 0;
  rep(i,n) ans = max(ans, uf.size(i));
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10348
#include<iostream>
#include<climits>
#include<cstdlib>
using namespace std;
int main()
{
  
  int n,k,m;
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  
  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
   int start;
  for(int i=2;i<n;i++)
  {
      m=INT_MAX;
		if(i<k)
         start=0;
    	else 
      	start=i-k;         
          for(int j=start;j<i;j++)
            if(dp[j]+abs(h[j]-h[i])<m)
              m=dp[j]+abs(h[j]-h[i]);
    
   dp[i]=m;
  }
     
   
         
  cout<<dp[n-1];
         
  return 0;
  }


Measured memory_bytes: 1024
N = int(input())
a = [[] for _ in range(N)]
for i in range(N):
  A_i = int(input())
  for j in range(A_i):
    a[i].append(list(map(int, input().split())))
 
max_honest = 0
for i in range(2**N):
  contradiction = False
  honest_p = []
  unkind_p = []
  doubt_honest_p = []
  doubt_unkind_p = []
  length = len(format(2**N-1, "b"))
  bin_num = format(i, "b").zfill(length)
  for j in range(length):
    if (i >> j) & 1:
      if not j+1 in honest_p:
      	honest_p.append(j+1)
      if not j+1 in doubt_honest_p:
      	doubt_honest_p.append(j+1)
      for k in a[j]:
        p = k[0]
        t = k[1]
        if t:
          if not p in honest_p:
          	honest_p.append(p)
        else:
          if not p in unkind_p: 
          	unkind_p.append(p)
    else:
      if not j+1 in unkind_p:
        unkind_p.append(j+1)
      if not j+1 in doubt_unkind_p:
      	doubt_unkind_p.append(j+1)
  if len(list(set(honest_p) & set(unkind_p))) != 0:
    contradiction = True
  if not contradiction and max_honest <= len(doubt_honest_p):
    max_honest = len(doubt_honest_p)
    
print(max_honest)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll W;
ll v[40],w[40];
void calc(ll val,ll wei,ll loc,ll end, vector<P>& list){
  if(W<wei) return;
  list.push_back(make_pair(wei,val));
  if(loc==end)return;
  calc(val,wei,loc+1,end,list);
  calc(val+v[loc],wei+w[loc],loc+1,end,list);
}
void erase_v(vector<P>& list){
  P tmp;
  ll val,wei;
  val=list[0].second;
  wei=list[0].first;
  sort(list.begin(),list.end());
  vector<P> true_list;
  for(auto i=list.begin();i!=list.end();i++){
    tmp = *i;
    if(tmp.first!=wei){
      true_list.push_back(make_pair(wei,val));
      wei=tmp.first;
      val=tmp.second;
    }else{
      val=max(val,tmp.second);
    }
  }
  true_list.push_back(make_pair(wei,val));
  val=true_list[0].second;
  for(auto it=true_list.begin();it!=true_list.end();){
    if(val>it->second){
      true_list.erase(it);
    }else{
      val=it->second;
      it++;
    }
  }
  list=true_list;
}
int main(){
  vector<P> fi,se,th,fo;
  ll n;
  ll tmp,ma_v,cnt=0;
  cin >> n >> W;
  fill(v,v+40,0);
  fill(w,w+40,0);
  for(int i=0;i<n;i++){
    cin >> v[i] >> w[i];
  }
  calc(0,0,0,10,fi);
  calc(0,0,10,20,se);
  calc(0,0,20,30,th);
  calc(0,0,30,40,fo);
  erase_v(fi);
  erase_v(se);
  erase_v(th);
  erase_v(fo);
  ma_v=0;
  for(int i=0;i<fi.size();i++){
    for(int j=0;j<se.size();j++){
      if(fi[i].first+se[j].first>W) break;
      for(int k=0;k<th.size();k++){
        if(fi[i].first+se[j].first+th[k].first>W) break;
        for(int l=0;l<fo.size();l++){
          tmp=fi[i].first+se[j].first+th[k].first+fo[l].first;
          if(tmp<=W){
            cnt++;
            tmp=fi[i].second+se[j].second+th[k].second+fo[l].second;
            ma_v=max(ma_v,tmp);
          }else{
            break;
          }
        }
      }
    }
  }
  cout << ma_v<<endl;
}



Measured memory_bytes: 3248
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
num_of_number = int(input())

numbers = []

for _ in range(num_of_number):
    numbers.append(int(input()))

for number in numbers:
    for i, A in enumerate(A1):
        if A in numbers:
            A1[i] = -1

    for i, A in enumerate(A2):
        if A in numbers:
            A2[i] = -1

    for i, A in enumerate(A3):
        if A in numbers:
            A3[i] = -1

# 横の確認
if A1.count(-1) == 3 or A2.count(-1) == 3 or A3.count(-1) == 3:
    print('Yes')
    exit()

# 縦の確認
V1_count = [A1[0], A2[0], A3[0]].count(-1)
V2_count = [A1[1], A2[1], A3[1]].count(-1)
V3_count = [A1[2], A2[2], A3[2]].count(-1)
if V1_count == 3 or V2_count == 3 or V3_count == 3:
    print('Yes')
    exit()

# 斜めの確認
D1_count = [A1[0], A2[1], A3[2]].count(-1)
D2_count = [A1[2], A2[1], A3[0]].count(-1)
if D1_count == 3 or D2_count == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum ^= a[i];
    }

    rep(i, n) {
        cout << (sum^a[i]) << (i == n-1?'\n':' ');
    }
}

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

using namespace std;

bool isprime[300001];

bool f(int b) {
	for (int i = 2; i * i <= b; i++) {
		if (b % i == 0 && (i % 7 == 1 || i % 7 == 6))return false;
	}
	return true;
}

int main() {

	for (int i = 1; i <= 300000; i++) {
		if (f(i))isprime[i] = true;
	}

	while (1) {
		int a;
		cin >> a;
		if (a == 1)break;
		
		int N = 1;
		bool f[300001] = {};
		int ct = 0;
		while (1) {
			if (N * 7 - 1 > a)break;
			if (a % (N * 7 - 1) == 0 && isprime[N * 7 - 1]) {
				if (!f[N * 7 - 1]) {
					f[N * 7 - 1] = true;
					ct++;
				}
			}
			if (N * 7 + 1 > a)break;
			if (a % (N * 7 + 1) == 0 && isprime[N * 7 + 1]) {
				if (!f[N * 7 + 1]) {
					f[N * 7 + 1] = true;
					ct++;
				}
			}
			N++;
		}
		cout << a << ": ";
		for (int i = 1; i <= 300000; i++) {
			if (f[i]) {
				cout << i, ct--;
				if (ct != 0)cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+88;
int n,m,a[N];
int x,y;
inline int read(){
	char c=getchar();int s=0;
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9'){
		s=s*10+c-'0';c=getchar();
	}return s;
}
int main(){
	n=read();m=read();
	for(int i=1;i<=m;i++){
		a[i]=read();
		if(a[i]%2==1){
			if(!x)x=i;
			else if(!y)y=i;
			else{
				puts("Impossible");
				return 0;
			}
		}
	}
	if(!x){
		for(int i=1;i<=m;i++)cout<<a[i]<<" ";
		cout<<endl;
		cout<<m+1<<endl;
		cout<<1<<" ";
		for(int i=1;i<m;i++){
			cout<<a[i]<<" ";
		}
		cout<<a[m]-1;
		return 0;
	}
	if(x&&!y){
		swap(a[x],a[m]);
		for(int i=1;i<=m;i++)cout<<a[i]<<" ";
		if(a[m]==1)cout<<endl<<m<<endl;
		else cout<<endl<<m+1<<endl;
		cout<<1<<" ";
		for(int i=1;i<m;i++){
			cout<<a[i]<<" ";
		}
		if(a[m]>1)cout<<a[m]-1;
		return 0;
	}
	if(x&&y){
		swap(a[x],a[1]);
		swap(a[y],a[m]);
		for(int i=1;i<=m;i++)cout<<a[i]<<" ";
		cout<<endl;
		if(a[m]>1)cout<<m;
		else cout<<m-1;
		cout<<endl;
		cout<<a[1]+1<<" ";
		for(int i=2;i<m;i++){
			cout<<a[i]<<" ";
		}
		if(a[m]>1)cout<<a[m]-1;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.14159265358979323846
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

/*vector<int> parent, rak;

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rank[a]+=rank[b];
    }
}*/

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;

//vector<vector<ll>>v;
//vector<ll>vis,d;
  

int main() {
    IOS;
    cin>>x>>y>>z>>h>>p>>k;
    if(p-x<=k)cout<<"Yay!";
    else cout<<":(";
    return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    sort(all(p));

    vector<int> ans;
    ans.pb(-1);

    rep(i, 102)
    {
        if (!binary_search(all(p), i))
        {
            ans.pb(i);
        }
    }

    int m = 999;
    int a = 0;
    for (auto t : ans)
    {
        int temp = abs(t - x);
        if (temp < m)
        {
            m = temp;
            a = t;
        }
    }
    cout << a << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    string S;
    int ans;
    cin >> S;
    if(S=="SRR"){
        ans = 2;
    }
    else if(S=="RRS"){
        ans = 2;
    }
    else if(S=="RRR"){
        ans = 3;
    }
    else if(S=="SSS"){
        ans = 0;
    }
    else ans = 1;
    
    cout << ans;
    
	return 0;
}



Measured memory_bytes: 3624
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

template <typename T>
class SegmentTree {
    using F = function<T(T, T)>;
    int n;
    F f;
    T t;
    vector <T> dat;
public:
    SegmentTree(F f, T t) : f(f), t(t) {}
    void init(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        dat.assign(n << 1, t);
    }
    void build(const vector <T> &v) {
        auto n_ = (int)v.size();
        init(n_);
        for (int i = 0; i < n_; i++) dat[n + i] = v[i];
        for (int i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }
    void set_val(int k, T x) {
        dat[k += n] = x;
        while (k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
    T query(int a, int b) {
        T vl = t, vr = t;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = f(vl, dat[l++]);
            if (r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

typedef pair<int, int> P;

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

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

    auto f = [](int a, int b) { return a + b; };
    SegmentTree<int> seg(f, 0);
    seg.build(vector<int>(n, 0));

    vector<int> l(q);
    vector<P> query(q);
    for (int i = 0; i < q; i++) {
        int r;
        cin >> l[i] >> r;
        l[i]--;
        query[i] = {r, i};
    }
    sort(query.begin(), query.end());

    map<int, int> right;
    for (int i = 1; i <= n; i++) {
        right[i] = -1;
    }

    vector<int> ans(q);

    int cur = 0;
    for (auto p : query) {
        int r = p.first, idx = p.second;
        for (; cur < r; cur++) {
            int color = c[cur];
            seg.set_val(cur, 1);
            if (right[color] != -1) {
                seg.set_val(right[color], 0);
            }
            right[color] = cur;
        }

        ans[idx] = seg.query(l[idx], r);
    }

    for (int i = 0; i < q; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 41016
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
int a[101];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; sum += a[i];
	}

	if (sum % (m * 4) != 0) {
		sum /= (m * 4); sum += 1;
	}
	else
		sum /= (m * 4);
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= sum) {
			ans += 1;
		}
	}

	if (ans >= m) {
		cout << "Yes" << '\n';
	}
	else cout << "No" << '\n';





}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int gcd(int a,int b)
{
    if(a==0)return b;
    return gcd(b%a,a);
}
int lcm(int x,int y)
{
    return (x*1ll*y/gcd(x,y));
}
int32_t main()
{
	IOS;
    int n;
    cin>>n;
    int j=0,k=0;
    string s,s2,s3;
    cin>>s>>s2;
    for(int i=0;i<(2*n);i++)
    {
        if((i%2)==0)
        {
               s3+=s[j];
               j++;
        }
        else
        {
               s3+=s2[k];
               k++;
        }
    }
    cout<<s3<<endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    n,x=map(int, input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count+=1
        print(count)


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

int main(){
  vi a(3);
  rep(i,0,3)cin >> a[i];
  sort(all(a));
  if((a[0]+a[1])==a[2]){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
  return 0;
}


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

int main(){
    int n;
    string str;
    cin >> n >> str;
    int len = str.size();
    for (int i=0; i<len; i++){
        //char a = str[i];
        int b = (str[i] - 'A' + n) % 26;
        char c = 'A' + b;
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<climits>
#include<vector>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#define mod 1000000007
using namespace std;
#define LL long long int
int main() 
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL N;
    cin >> N;
    vector< bool > arr;
    for(LL i=0;i<N;i++)
    {
        LL x;
        LL y;
        cin >> x >> y;
        arr.push_back(x==y);
    }
    bool  ok=false;
    for(LL i=0;i<=N-3;i++)
    {

        if(arr[i]==true and arr[i+1] and arr[i+2])
        {
            ok=true;
            break;
        }
    }
    if(ok)
        cout<<"Yes";
    else
        cout<<"No";
}


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



int main(void){
    int n;
    vector<pair<int,int>> task;
    cin>>n;
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      task.push_back(pair<int,int>(b,a));
    }
    sort(task.begin(),task.end());
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=task[i].second;
      if(sum>task[i].first){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 2420
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

int solve(int A, int B, int C) {
	if (C==0)
		return B;
	if (B>0)
		return solve(A, B-min(B, C), C-min(B, C)) + min(B, C)*2;
	if (A>0)
		return solve(A-min(A, C), B, C-min(A, C)) + min(A, C);
	return 1;
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int A, B, C;
	cin >> A >> B >> C;
	cout << solve(A, B, C);
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}
}


Measured memory_bytes: 10320
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    int n;
    cin>>n;
    vector<int> ar(n);
    int t=0;
    for(auto &i:ar)
    {
        cin>>i;
        t^=i;
    }
    for(int i=0;i<n;i++)
    {
        int temp=t^ar[i];
        cout<<temp<<" ";
    }
}
int32_t main()
{
    //_READ
    _FAST
    int t;
    t=1;
    while(t--)
        solve();
    
    
    return 0;
}

Measured memory_bytes: 4780
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	h, w := io.NextInt(), io.NextInt()
	stage := make([]string, h)
	for i := 0; i < h; i++ {
		stage[i] = io.Next()
	}
	ans := solve(h, w, stage)
	io.Println(ans)
}

func solve(h, w int, stage []string) (ans int) {
	visited := make([][]bool, h)
	for i := range visited {
		visited[i] = make([]bool, w)
	}
	for x := 0; x < h; x++ {
		for y := 0; y < w; y++ {
			if visited[x][y] {
				continue
			}
			ans += bfs(x, y, visited, stage)
		}
	}
	return ans
}

func bfs(x, y int, visited [][]bool, stage []string) int {
	h, w := len(stage), len(stage[0])
	count := make(map[byte]int, 2)
	q := newQueue()
	visited[x][y] = true
	count[stage[x][y]]++
	q.push(pair{x, y})
	for len(*q) > 0 {
		p := q.pop()
		for i := range dx {
			nx, ny := p.x+dx[i], p.y+dy[i]
			if nx < 0 || h <= nx || ny < 0 || w <= ny {
				continue
			}
			if visited[nx][ny] {
				continue
			}
			if stage[nx][ny] == stage[p.x][p.y] {
				continue
			}
			visited[nx][ny] = true
			count[stage[nx][ny]]++
			q.push(pair{nx, ny})
		}
	}
	return count['#'] * count['.']
}

type pair struct{ x, y int }

type queue []pair

func newQueue() *queue {
	return &queue{}
}

func (q *queue) push(p pair) {
	*q = append(*q, p)
}

func (q *queue) pop() pair {
	p := (*q)[0]
	*q = (*q)[1:]
	return p
}

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

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 6100