akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int h=sc.nextInt();
		int n=sc.nextInt();
		char map[][]=new char[h][w];
		int x,y,a;
		int p=0;
		while(p<n){
			x=sc.nextInt();
			y=sc.nextInt();
			a=sc.nextInt();
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				if(a==1&&i<x)map[j][i]='b';
				else if(a==2&&i>=x)map[j][i]='b';
				else if(a==3&&j<y)map[j][i]='b';
				else if(a==4&&j>=y)map[j][i]='b';
			}
			
		}p++;
		}
		int ans=0;
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				if(map[j][i]!='b')ans++;
				
			}
		}
		System.out.println(ans);
	}

}

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

#define ll long long
#define N 100010
int n, a[N];
ll b[N];

int main() {
    while (scanf("%d", &n) != EOF) {
        for (int i = 1; i <= n; ++i) {
            scanf("%d", a + i);
        }
        b[1] = 0;
        for (int i = 1; i <= n; ++i) {
            b[1] += a[i] * ((i & 1) ? 1 : -1);
        }
        b[n] = 2ll * a[n] - b[1]; 
        for (int i = n - 1; i > 1; --i) {
            b[i] = 2ll * a[i] - b[i + 1];
        }
        for (int i = 1; i <= n; ++i) printf("%lld%c", b[i], " \n"[i == n]); 
    }
    return 0;
}

Measured memory_bytes: 2432
from collections import defaultdict
import heapq
n,m,s,t =list(map(int,input().split()))

uvab =  [list(map(int,input().split())) for _ in range(m)]
en = [[] for _ in range(n) ]
snuke = [[] for _ in range(n)]

 
for u,v,a,b in uvab:
    u=u-1
    v=v-1
    en[u].append((a,v))
    en[v].append((a,u))
    snuke[u].append((b,v))
    snuke[v].append((b,u))
 
 
def dijkstra(edges, s):
    INF = 10 ** 15
    d = [INF for x in range(n)]
    d[s] = 0
    que = []
    heapq.heappush(que, (0,s))
 
    while len(que) > 0:
        u_d,u = heapq.heappop(que)
        if d[u] < u_d:
            continue
        for  v_d,v in edges[u]:
            if d[v] > d[u] + v_d:
                d[v] = d[u] + v_d
                heapq.heappush(que,(d[v],v))
    return d

en_ds =  dijkstra(en,s-1)
snuke_ds = dijkstra(snuke,t-1)
scores = [0] * n
for i in range(n):
  scores[i] = 10**15 - (en_ds[i] + snuke_ds[i])

ans = [ 10 ** 15 for _ in range(n)]
ans[n-1] = scores[n-1]
for i in range(n-2,-1,-1):
    ans[i] = max(ans[i+1],scores[i])
for a in ans:
    print(a)

Measured memory_bytes: 101024
#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back
#define FILE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);


using namespace std;

typedef long long ll;

int main(){
    inp_out_work
    int N, W;
    cin>>N>>W;

    ll dp[W+1], cpy[W+1];

    memset(dp, 0, sizeof(dp));

    int v[N], w[N];

    fr(i,N)cin>>w[i]>>v[i];

    for(int i = 0; i < N; i++){
        for(int wt = 0; wt <= W; wt++){
            cpy[wt] = dp[wt];
        }

        for(int wt = w[i]; wt <= W; wt++){
            dp[wt] = max(dp[wt], cpy[wt-w[i]] + v[i]);
        }
    }

    cout<< dp[W];

}


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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main(){
    string s;
    cin >> s;
    int n =s.length();
    rep(i,n) {
        cout << "x";
    }
}



Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a[10][110],s1[110],s2[110],i,j,n,ans;
int max(int a,int b){return a>b?a:b;}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=2;i++)
	  for (j=1;j<=n;j++)
	     scanf("%d",&a[i][j]);
	for (i=1;i<=n;i++) s1[i]=s1[i-1]+a[1][i];
	for (i=1;i<=n;i++) s2[i]=s2[i-1]+a[2][i];
	ans=0;
	for (i=1;i<=n;i++) ans=max(ans,s1[i]+s2[n]-s2[i-1]);
	printf("%d\n",ans);
}

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

int main(){
    int A, B, K;
    cin >> A >> B >> K;

   int temp;
    for(int i = A; K > 0; i--){
        if((A % i == 0) && (B % i == 0)){
            K--;
            temp = i;
        }
    }

    cout << temp << endl;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  scanf("%d", &n);
  set<string> A;
  char s[20];
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    A.insert(string(s));
  }
  printf("%d\n", (int)A.size());
  return 0;
}


Measured memory_bytes: 19352
#include <iostream>
#include <vector>

using namespace std;

long gcd(long a, long b) {
  if(a < b) gcd(b, a);
  long r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    int N, X; cin >> N >> X;
    vector<long> vc;
    for (int i = 0; i < N; ++i) {
        long x; cin >> x;
        vc.push_back(x);
    }

    for (long &e: vc) e = abs(e - X);

    long ans = vc[0];
    for (int i = 1; i < N; ++i) ans = gcd(ans, vc[i]);

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

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

int main(){
    int N;
    int i;
    cin >> N;
    long A[N];

    for(i=0;i<N;i++){
        cin >> A[i];
    }
    int maxv = A[0];
    int minv = A[0];
    for(i = 0; i < N; ++i) {
        if( A[i] > maxv )
            maxv = A[i];
        if( A[i] < minv )
            minv = A[i];
    }
    cout << maxv - minv << endl;
    return 0;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;
	int ans = 0;
	for (auto c : S)
	{
		if (c == '1')ans++;
	}

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

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n,k;
  cin >> n >> k;
  n = n%k;
  if(k-n<n) cout << k-n << endl;
  else cout << n << endl;
  return 0;
}



Measured memory_bytes: 3680
// https://atcoder.jp/contests/abc144/tasks/abc144_c

#include <iostream>

int main()
{
	std::cin.sync_with_stdio(false);
	std::cout.sync_with_stdio(false);

	long long N;

	std::cin >> N;

	long long count = 0, i, j;
	for (i = 1; i * i <= N; ++i)
	{
		if (((N / i) * i) == N)
		{
			count = i - 2 + N / i;
		}
	}

	std::cout << count;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
c=0
if k==0:
 print(n**2)
else:
  for b in range(k,n+1):
    p=int(n/b)
    r=n%b
    c+=(b-k)*p
    if r>=k:
      c+=r-k+1
  print(c)


Measured memory_bytes: 2940
import java.util.*;
 
public class Main{
 
	public static void main(String[] args){
 
		Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        double tmp = 0;
        double road = 0;
      
        for(int i = 0; i < N ; i++){
          x[i] = sc.nextInt();
          y[i] = sc.nextInt();
        }
      
        for(int i = 0; i < N; i++){
          for(int j = i + 1; j < N; j++){
            tmp = Math.pow(x[i]-x[j],2) + Math.pow(y[i]-y[j],2);
            road += Math.sqrt(tmp);
          }
        }
      
        if(N == 2){
          System.out.println(road*2/2);
        }else{
         
         int n = 1;
         for(int i = 1; i <= N; i++){
           n *= i;
         }
          
        int C = N*(N-1);
        int c = C/2;
        int num = (n*(N-1))/c;

        double ans = num*road/n;
      
        System.out.println(ans);
     }
  }
}

Measured memory_bytes: 35796
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, a, b, c);
    if (a + b + c >= 22) {
        print("bust");
    } else {
        print("win");
    }

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<bool> f(100001);
	vector<int> c(100001);

	for (int i = 2; i < 100001; i++) {
		if (!f.at(i)) {
			for (int j = i * 2; j < 100001; j += i) {
				f.at(j) = true;
			}
		}
	}

	for (int i = 3; i < 100001; i+=2) {
		if (!f.at(i) && !f.at((i + 1) / 2)) c.at(i)++;
	}

	for (int i = 3; i < 100001; i++) {
		c.at(i) += c.at(i - 1);
	}

	for (int i = 0; i < Q; i++) {
		int L, R;
		cin >> L >> R;

		cout << c.at(R) - c.at(L - 1) << endl;
	}
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A;
int B;
int C;
int K;
int main(){
  int m, res;
  rd(A);
  rd(B);
  rd(C);
  rd(K);
  m =max_L(max_L(A, B), C);
  res = A + B + C + m * ((1<<K)-1);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B, C, K;
// {
//   int m, res;
//   rd(A,B,C,K);
//   m = max(A,B,C);
//   res = A + B + C + m * ((1<<K)-1);
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>

#define P 1000000007
#define N_MAX 200001

using namespace std;

long inv[N_MAX];
long fac[N_MAX];
long finv[N_MAX];

void init(){
    inv[0] = 1;
    fac[0] = 1;
    finv[0] = 1;
    inv[1] = 1;
    fac[1] = 1;
    finv[1] = 1;
    for(int i = 2; i < N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

int main(){
    int H, W, A, B;
    long ans = 0;
    cin >> H >> W >> A >> B;
    H--;W--;A--;B--;
    init();
    long comb0 = (((fac[H-A+B]*finv[B])%P)*finv[H-A])%P;
    //cout << comb0 << endl;
    if(A != 0){
        for(int i = B+1; i <= W; i++){
            long comb1, comb2;

            comb1 = (((fac[H-A+i]*finv[i])%P)*finv[H-A])%P;
            comb2 = (((fac[W-i+A-1]*finv[A-1])%P)*finv[W-i])%P;
            ans = (((ans+(comb1-comb0)*comb2)%P)+P)%P;
            //cout << ans << endl;
        }
    }else{
        long comb1 = (((fac[H+W]*finv[H])%P)*finv[W])%P;
        ans = (((comb1-comb0)%P)+P)%P;
    }
    cout << ans << endl;
}

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

int main() {
  string num;
  cin >> num;
  if (num.at(0) == num.at(1) || num.at(1) == num.at(2) || num.at(2) == num.at(3)) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static Scanner sc = new Scanner();

    static void Main(string[] args)
    {
        var L = sc.ReadInt();
        var R = sc.ReadInt();

        var ans = int.MaxValue;
        for (int i = L; i <= R; i++)
        {
            for (int j = i + 1; j <= R; j++)
            {
                var m = (i % 2019) * (j % 2019) % 2019;
                ans = Math.Min(ans, m);
                if (m == 0) break;
            }
            if (ans == 0) break;
        }

        Console.WriteLine(ans);
    }

    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}

class HashMap<K, V> : Dictionary<K, V> where V : new()
{
    private V DefaltValue = new V();
    public HashMap() { }
    public HashMap(V defaultValue)
    {
        this.DefaltValue = new V();
    }
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = this.DefaltValue;
        }
        set { base[i] = value; }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.4f\n", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));
    return 0;
}


Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {

    private static int f(char i, char j, int n) {
        int r = 0;
        for (int k = 1; k <= n; k++) {
            String s = Integer.toString(k);
            if (s.charAt(0) == i && s.charAt(s.length() - 1) == j)
                r++;
        }
        return r;
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = Integer.parseInt(scanner.next());
            int r = 0;
            for (int i = 0; i < 10; i++) {
                char is = Integer.toString(i).charAt(0);
                for (int j = 0; j < 10; j++) {
                    char js = Integer.toString(j).charAt(0);
                    r += f(is, js, n) * f(js, is, n);
                }
            }
            System.out.println(r);
        }
    }

}


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

public class Main {

    static long mod = (long) (1e9 + 7);

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        long k = in.nextLong();

        long[][] walk = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                walk[i][j] = in.nextInt();
            }
        }
        long[][] fin = powMat(walk, k);
        long ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ans = (ans + fin[i][j]) % mod;
            }
        }
        out.println(ans % mod);
        out.close();
    }

    static long[][] powMat(long[][] a, long pow) {
        if (pow == 1) {
            return a;
        } else {
            if (pow % 2 == 0) {
                return powMat(mul(a, a), pow / 2);
            } else {
                return mul(a, powMat(mul(a, a), pow / 2));
            }
        }
    }

    static long[][] mul(long[][] a, long[][] b) {
        int n = a.length;
        long[][] c = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    c[i][k] = (c[i][k] + (a[i][j] * b[j][k]) % mod) % mod;
                }
            }
        }
        return c;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }
}

Measured memory_bytes: 25300
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,m = inpl()
cnt = [0]*(n+1)
for i in range(m):
    l,r = inpl()
    cnt[l-1] += 1
    cnt[r] -= 1
cntsum = list(itertools.accumulate(cnt))
print(cntsum.count(m))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int X = nextInt();
  vector<int> m(N);
  REP(i, N) m[i] = nextInt();
  int mi = *min_element(ALL(m));

  REP(i, N) {
    X -= m[i];
  }
  int ans = N + X / mi;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var S = int.Parse(cin.next + cin.next);
        int d = (int)Math.Sqrt(S);
        if (d * d == S)
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092
n=int(input())
a=[int(i) for i in input().split()]

def check(n):
    if(n<400):
        color='ash'
    elif(n<800):
        color='brown'
    elif(n<1200):
        color='green'
    elif(n<1600):
        color='water'
    elif(n<2000):
        color='blue'
    elif(n<2400):
        color='yellow'
    elif(n<2800):
        color='orange'
    elif(n<3200):
        color='red'
    else:
        color='free'
    return color
c=[]
r=0
for i in a:
    color=check(i)
    if(color not in c and color!='free'):
        c.append(color)
    elif(color=='free'):
        r+=1
print(max(len(c),1),len(c)+r)


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

int main(){
	
	ll a,b; cin>>a>>b;
	ll best = 1e18+1;
	if(a > b){
		ll mul = a/b;
		a -= b*mul;
	}
	best = min(a,best);
	int j = 100000;
	while(j--){
		a = abs(a-b);
		best = min(a,best);
	}
	cout<<best<<"\n";
	
	
}

Measured memory_bytes: 256
def sol(l):
    n=1
    while n<27:
        ans=[]
        for i in l:
            x=''
            for j in i:
                s=ord(j)+n
                if s>=123:
                    s-=26
                if s<97:
                    s=46
                x+=chr(s)
            ans.append(x)
        if 'that' in ans or 'thet.' in ans or 'this' in ans or 'this.' in ans or 'the' in ans or 'the.' in ans:
            print ' '.join(ans)
            break
        n+=1

while 1:
    try:
        w=map(str,raw_input().split())
        sol(w)
    except:
        break

Measured memory_bytes: 6288
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

vvll matrixpro(vvll& a,vvll& b,ll m){
    ll as=a.size();ll bs=b[0].size();
    vvll c(as,vll(bs));
    rep(i,as)rep(k,b.size())rep(j,bs){
        c[i][j]+=(a[i][k]*b[k][j])%m;
        c[i][j]%=m;
    }
    return c;
}

vvll matrixpow(vvll a,ll n,ll m){
    ll s=a.size();
    vvll ans(s,vll(s));
    rep(i,s)ans[i][i]=1;
    while(n){
        if(n&1)ans=matrixpro(ans,a,m);
        a=matrixpro(a,a,m);
        n>>=1;
    }
    return ans;
}

int main(){
    ll n,k;cin>>n>>k;
    vvll a(n,vll(n));
    rep(i,n)rep(j,n)cin>>a[i][j];
    vvll ans=matrixpow(a,k,(ll)inf);
    ll res=0;
    rep(i,n)rep(j,n){
        res+=ans[i][j];
        res%=(ll)inf;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int a[26];fill(a,a+26,0);
  for(int i=0;i<s.size();i++){
    int x=s[i]-'a';
    a[x]++;
  }
  for(int i=0;i<26;i++){
    if(a[i]%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var N = int.Parse(Console.ReadLine());
            var vArr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var cArr = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();

            var pArr = new int[N];
            for (int i = 0; i < N; i++) {
                pArr[i] = vArr[i] - cArr[i];
            }

            var ans = pArr.Where(p => p >= 0).Sum();
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

const int mod = 1'000'000'007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    int x = 0;
    for(int i = 0; i < n; ++i) {
        ans = (ans+(ll)a[i]*x) % mod;
        x = (x+a[i]) % mod;
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut a = get!([usize]);

    let mut count = 0;
    loop {
        let mut s = 0;
        for i in 0..n {
            s += a[i]/n;
        }
        count += s;
        for i in 0..n {
            a[i] = a[i]+s-a[i]/n-a[i]/n*n;
        }
        if a.iter().all(|&e| e < n) {
            break;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int a, b; cin >> a >> b;
  printf("%s\n",(a*b)%2?"Odd":"Even");
}


Measured memory_bytes: 256
import sys
X = int(input())
from math import sqrt,floor
cand = []
for i in range(1,floor(sqrt(X))+1):
    #print(i)
    if X%i == 0:
        k = X//i
        #print(i,k)
        for j in range(10000):
            eq = (j-i)**4 + (j-i)**3 * j + (j-i)**2 * j**2 + (j-i) * j**3 + j**4
            #print(j,i,eq)
            if eq == k:
                print(j,j-i)
                sys.exit()

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  ll n;
  cin>>n;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  V divisor;
  for(ll i=1;i*i<=n;++i)if(n%i==0)divisor.pb(i);
  //call(divisor);
  ll res=0;
  for(const auto&m:divisor){
    ll k = (n-m)/m;
    if(n%k == n/k)res+=k;
  }

  out(res);

  
  return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int N = 3e5 + 5;
const int M = 1e5 + 5;
int n , m;
int l[N] , r[N];
int ans[M];
vector < int > v[M];
vector < pair < int , pair < int , int > > > q[M];
int bit[M];
void update(int idx){
    while(idx){
        ++bit[idx];
        idx -= idx & -idx;
    }
}
int query(int idx){
    int res = 0;
    while(idx <= m){
        res += bit[idx];
        idx += idx & -idx;
    }
    return res;
}
int main(){
    scanf("%d %d" , &n , &m);
    for(int i = 0 ; i <= m ; ++i){
        ans[i] = 0;
        v[i].clear();
        q[i].clear();
        bit[i] = 0;
    }
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d %d" , l + i , r + i);
        v[l[i]].emplace_back(r[i]);
    }
    for(int d = 1 ; d <= m ; ++d){
        for(int i = d ; i <= m ; i += d){
            int lft = i - d + 1;
            int rgt = i;
            q[rgt].emplace_back(make_pair(d , make_pair(i , 1)));
            q[lft - 1].emplace_back(make_pair(d , make_pair(i , -1)));
        }
    }
    for(int i = 0 ; i <= m ; ++i){
        for(int x : v[i]){
            update(x);
        }
        for(auto it : q[i]){
            ans[it.first] += query(it.second.first) * it.second.second;
        }
    }
    for(int i = 1 ; i <= m ; ++i){
        printf("%d\n" , ans[i]);
    }
}

Measured memory_bytes: 49076
#include<iostream>
using namespace std;
int main(){
  long long H; long long r = 2;
  cin >> H;
  if(H == 0) r = 1;
  while(H > 0){
    H = H >> 1;
    if(H > 0) r *= 2;
  }
  r--;
  cout << r;
  return 0;
}

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

#define frs first
#define scn second
#define mkp make_pair

using namespace std;

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

int N, M;
Pr nset[100010];

void soups_on();
void union_set(int, int, ll);
Pr find_set(int);

int main() {
  ios::sync_with_stdio(false);
  while (cin >> N >> M, N + M)
    soups_on();

  return 0;
}

void soups_on() {
  char c;
  int a, b;
  ll w;

  fill(&nset[0], &nset[N + 1], mkp(-1, 0));
  for (int i = 0; i < M; ++i) {
    cin >> c >> a >> b;
    if (c == '!') {
      cin >> w;
      union_set(a, b, w);
    }
    else {
      Pr pa = find_set(a), pb = find_set(b);
      if (pa.frs == pb.frs)
        cout << pa.scn - pb.scn << "\n";
      else
        cout << "UNKNOWN\n";
    }
  }
}

void union_set(int x, int y, ll w) {
  if (find_set(x).frs != find_set(y).frs) {
    Pr px = find_set(x), py = find_set(y);
    nset[py.frs] = mkp(px.frs, -w + px.scn - py.scn);
  }
}

Pr find_set(int x) {
  if (nset[x].frs == -1)
    return mkp(x, 0);
  else {
    Pr px = find_set(nset[x].frs);
    return nset[x] = mkp(px.frs, nset[x].scn + px.scn);
  }
}

Measured memory_bytes: 9004
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

class UnionFind {
public:
	vector<ll> parent;
	vector<ll> gap;//強化前の、素の値
	vector<ll> up;//強化量

	UnionFind(ll n) : parent(n), gap(n, 0), up(n, 0) {
		REP(i, 0, n) parent[i] = i;
	}

	ll find(ll i) {
		if (parent[i] == i) return i;

		int tmp = parent[i];
		ll p = find(parent[i]);
		//cerr << "find  " << i+1 << " ,," << tmp+1 << "p: " << p+1 << endl;
		gap[i] += gap[tmp];
		return parent[i] = p;
	}

	void unite(ll i, ll j, ll c) {
		ll p = find(i), q = find(j);
		if (p != q) {
			gap[p] = c + get(j) - get(i);
			parent[p] = q;
		}
		up[i] += c;
		up[j] += c;
	}

	ll get(ll i) {
		return  - up[i] + gap[i];
		//return up[find(i)] - up[i] + gap[i];
	}
};

int main(void) {
	ll N, Q;
	cin >> N >> Q;
	vector<ll> T(Q), A(Q), B(Q), C(Q);
	REP(i, 0, Q) {
		string type;
		cin >> type >> A[i] >> B[i]; A[i]--; B[i]--;
		if (type == "IN") {
			T[i] = 0;
			cin >> C[i];
		}
		if (type == "COMPARE") T[i] = 1;
	}

	UnionFind uf(N);
	REP(i, 0, Q) {
		//cerr << endl<<endl<<"   debug" << endl;
		if (T[i] == 0) {
			uf.unite(A[i], B[i], C[i]);
		}
		if (T[i] == 1) {
			if (uf.find(A[i]) != uf.find(B[i])) cout << "WARNING" << endl;
			else {
				//uf.find(A[i]);
				//uf.find(B[i]);
				//cerr << "testing" << endl;
				cout << uf.get(A[i]) - uf.get(B[i]) << endl;
			}
		}
		//cerr << "====" << endl;
		//cerr << "way::" << A[i]+1 << " " << B[i]+1 << endl;
		//REP(i, 0, N) cerr <<"me:"<<i+1<< " par:" << uf.parent[i] + 1 << ",  gap:" << uf.gap[i] << ",  up:" << uf.up[i] << endl;
	}
	//cerr << "==FINISH==" << endl;
	//REP(i, 0, N) cerr << "par:" << uf.parent[i] << ",  gap:" << uf.gap[i] << ",  up:" << uf.up[i] << endl;
	int n;
	cin >> n;

}


Measured memory_bytes: 8372
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    char c; cin>>c;

    cout << char(c + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

const ll INF=1e9+7;

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << a*b << endl;
    
    return 0;
} 

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

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

	int x = 1;
	for (int i = 0; i < n; i++) {
		if (x * 2 < x + k) {
			x *= 2;
		}
		else {
			x += k;
		}
	}
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let cost: usize = sc.read();
    let x: Vec<usize> = sc.vec(n);

    let mut sum = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + x[i];
    }

    let mut m = std::usize::MAX;
    for k in 1..(n + 1) {
        let mut pos = n;
        let mut ans = 0;
        let mut cur = 0;
        while pos > 0 {
            let z = if cur == 0 { 5 } else { cur * 2 + 3 };
            let next = cmp::max(pos, k) - k;
            ans += z * (sum[pos] - sum[next]);
            pos = next;
            cur += 1;
        }
        m = cmp::min(m, ans + k * cost);
    }
    println!("{}", m + cost * n);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define Sec     second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    string s;
    cin>>s;
    
    lli N=s.length(),i=0,j=0,cnt=0;
    
    while(i<N and j<N)
    {
        j=i+1;
        while(j<N and s[i]==s[j])
        {
            j++;
        }
        
        if(j!=N and s[i]!=s[j])
        {
            cnt++;
        }
        
        i=j;
    }
    
    cout<<cnt;
    
    
    
    









 return 0;
}


Measured memory_bytes: 512