akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr ll INF = 1e18;

int main() {
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<ll>> dist(n, vector<ll> (n,INF));
  for (int i = 0; i < m; i++) {
    int a,b,c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = dist[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  vector<vector<ll>> dist2(n, vector<ll> (n, INF));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if(dist[i][j] <= l) dist2[i][j] = 1;
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
      }
    }
  }
  int Q;
  cin >> Q;
  while(Q--) {
    int s,t;
    cin >> s >> t;
    s--, t--;
    ll ans = dist2[s][t] - 1;
    if(ans == INF - 1) ans = -1;
    cout << ans << '\n';
  }
  return 0;
}

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

E = [0]*(N+2)
W = [0]*(N+2)
for i in range(1,N+1):
    if S[i-1] == 'E':
        E[i] = E[i-1] + 1
        W[i] = W[i-1]
    else:
        W[i] = W[i-1] + 1
        E[i] = E[i-1]

ans = 300000
for L in range(1,N+1):
    num = E[N] - E[L] + W[L-1] -W[0]
    if ans > num:
        ans = num

print(ans)

Measured memory_bytes: 17552
def main() -> None:
    N, M = map(int, input().split())
    left, right = 1, N
    for _ in range(M):
        l, r = map(int, input().split())
        left = max(l, left)
        right = min(r, right)
    print(max(0, right - left + 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) cout << abs(a - b) / 2;
    else {
        ll x = a, y = b, z = 0;
        x -= a - 1; y -= a - 1; z += a - 1;
        y--; z++;
        z += (y - x) / 2;
        ll x2 = a, y2 = b, z2 = 0;
        x2 += n - b; y2 += n - b; z2 += n - b;
        x2++; z2++;
        z2 += (y2 - x2) / 2;
        cout << min(z, z2);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
int main (){
    long double a,b,x;
    cin >> a >> b >> x;
    long double c;
    if(x<a*a*b/2){
//        c=atan2((2*x)/(a*b),b);
        c=atan2l(b,(2*x)/(a*b));
    }
    else{
        c=atan2l((2*(a*a*b-x))/(a*a),a);
//        c=atan2l(a,(2*(a*a*b-x))/(a*a));
    }
    c= c/M_PI*180.0;
    cout <<std::fixed<<std::setprecision(10)<< c << "\n";

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func PrntChes(H, W int) {

	for i := 0; i < H; i++ {
			
			switch i % 2 {
				case 0:
					StartBlack(W)
				case 1:
					StartWhite(W)
				default :
			}
	}

	
}

func StartBlack(W int) {
	for i := 0; i < W; i++ {
		switch i % 2 {
			case 0:
				fmt.Print("#")
			case 1:
				fmt.Print(".")
			default :
		}
	}

	fmt.Println()
}

func StartWhite(W int) {
	for i := 0; i < W; i++ {
		switch i % 2 {
			case 0:
				fmt.Print(".")
			case 1:
				fmt.Print("#")
			default :
		}
	}

	fmt.Println()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	
		for {
			H := nextInt()
			W := nextInt()
				if H == 0 && W == 0 {
					break
				} else {
					PrntChes(H, W)
					fmt.Println()
				}
		}
	
}


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

float noudo(int aquvo, int salo){
    if(aquvo + salo == 0) return 0;
    return (float)salo * 100 / (float)(salo + aquvo);
}

int main(){
    int a, b, c, d, e, f;
    float max_percent;
    cin >> a >> b >> c >> d >> e >> f;
    max_percent = noudo(100,e);
    // cout << max_percent << endl;;
    int max_aq = 0, max_salo = -1;
    for(int i = 0;100 * a * i<=f;i++){
        for(int j = 0;100 * a * i + 100 * b * j <= f;j++){
            for(int k = 0; 100 * (a * i + b * j) + c * k <= f;k++){
                for(int l = 0; 100 * (a * i + b  * j) + c * k + d * l <= f;l++){
                    float temp = noudo(100 * (a * i + b  * j),c * k + d * l);
                    if (temp <= max_percent && temp >= noudo(max_aq,((max_salo == -1) ? 0 : max_salo) )){
                        max_aq = 100 * (a * i + b  * j);
                        max_salo = c * k + d * l;
                        // cout << i << j << k << l << endl;
                    }
                }
            }
        }
    }
    cout << max_aq + max_salo << " " << max_salo << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int wi,ans[10]={0},cou=0;
while(cin>>wi){
        cou=0;
    for(int i=512;i>0;i=i/2){
        if(wi>=i){
            ans[cou]=i;
            wi-=i;
            cou++;
        }
    }
    cout<<ans[cou-1];
    for(int i=cou-2;i>=0;i--){
        cout<<" "<<ans[i];
    }
    cout<<endl;
}
return 0;
}

Measured memory_bytes: 1160
from collections import defaultdict

N = int(input())
d = defaultdict(int)
A = list(map(int, input().split()))
for a in A:
    d[a] += 1
Q = int(input())
ans = 0
for k, v in d.items():
    ans += k * v
for _ in range(Q):
    B, C = map(int, input().split())
    d[C] += d[B]
    ans -= B * d[B]
    ans += C * d[B]
    del d[B]
    print(ans)

Measured memory_bytes: 24144
#include <bits/stdc++.h>
using namespace std;
 
 
long long dp[1<<17] = {0};
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, W; cin >> n >> W;
  fill(dp + 1, dp + W + 1, -(1ll<<60));
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int w, v; cin >> w >> v;
    for (int j = W; j >= w; --j) {
      dp[j] = max(dp[j], dp[j - w] + v);
    }
  }
  cout << *max_element(dp, dp + W + 1) << '\n';
}


Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string S; cin >> S;
  int ans = 100000000;
  rep(i, S.size() - 2) {
    int a = stoi(S.substr(i, 3));
    if (ans > abs(a - 753)) {
      ans = abs(a - 753);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define f0(i,a,b) for(int i= a; i<= b; ++i)
#define f1(i,a,b) for(int i= a; i>= b; --i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define X first
#define Y second
using namespace std;
const long long base=1e9+7;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
const long long MAX_N = 1111001;

void Solves() {
   string s;
   cin >> s;
   int id = 1;
   int ans = 0;
   for(int i = 0; i < s.length() ;i++) {
        if(id == 1) {
            ans ++;
            id = 0;
        }
        else if(s[i] == s[i - 1]) {
            if(i + 1 < s.length()) {
                ans ++;
                i++;
                id = 1;
            }
        }
        else {
            ans ++;
            id = 0;
        }

   }
   cout << ans;

}

int main() {
     Solves();
     return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n] ;
    for(int i=0;i<n;i++) cin>>a[i];
       sort(a,a+n);
    int sumAlic=0;
    int sumBob=0;
    for(int i=0;i<n;i++) {
        if(i%2==0) sumAlic +=a[i];
        else sumBob +=a[i];
    }

    cout << abs(sumAlic-sumBob) ;
    return 0;
}


Measured memory_bytes: 256
def main():
    num = int(input())
    ans = num

    for i in range(num + 1):
        cc = 0
        t = i
        while t > 0:
            cc += t % 6
            t //= 6
        t = num - i
        while t > 0:
            cc += t % 9
            t //= 9
        if ans > cc:
            ans = cc

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll A,B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << "\n";
    }else if(A >= 6){
        cout << B/2 << "\n";
    }else{
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 3588
import java.util.*;

public class Main
 {
	public static void main (String[] args)
	 {
	    Scanner in = new Scanner(System.in);
	    int K,X;
	    K = in.nextInt();
	    X = in.nextInt();
	    int start = X-K+1>=-1000000?X-K+1:-1000000;
	    int end = X+K-1<=1000000?X+K-1:1000000;
	    for(int i=start;i<=end;i++) {
	    	System.out.print(i+" ");
	    }

	    
	 }
	
	 

}



Measured memory_bytes: 22868
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll sum;
    if(A > B) sum = 0;
    else if(N == 1 and A == B) sum = 1;
    else if(N == 1 and A != B) sum = 0;
    else sum = A + B * (N - 1) - (A * (N - 1) + B) + 1;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int w, h, x, y;
    scanf("%d %d %d %d", &w, &h, &x, &y);
    double max = (double)w * (double)h / 2.0;
    int multi = 0;
    if(w - x == x && h - y == y) multi = 1;
    printf("%.10lf %d\n", max, multi);
}

Measured memory_bytes: 128
H, W = map(int, input().split())
data = [input() for i in range(H)]

for h in range(H):
    for w in range(W):
        if data[h][w] == '#':
            if h - 1 >= 0:
                if data[h-1][w] == '#':
                    continue
            if w - 1 >= 0:
                if data[h][w-1] == '#':
                    continue
            if h + 1 <= H - 1:
                if data[h+1][w] == '#':
                    continue
            if w + 1 <= W - 1:
                if data[h][w+1] == '#':
                    continue
            print('No')
            exit()
print('Yes')




Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    int i;
    int n, k;
    scanf("%d", &n);

    char str[n];
    scanf("%s", str);
    scanf("%d", &k);
    
    for(i = 0;i < n; i++)
    {
        if(str[i] != str[k-1])
            str[i] = '*';
    }
    
    printf("%s\n", str);
    
    return 0;
}


Measured memory_bytes: 128
S=input()
N=len(S)+1
L=[0]*N
R=[0]*N
ans=[0]*N
for i in range(1,N):
    if S[i-1]=='<':
        L[i]=L[i-1]+1
    if S[N-i-1]=='>':
        R[N-i-1]=R[N-i]+1
for i in range(N):
    ans[i]=max(L[i], R[i])
print(sum(ans))

Measured memory_bytes: 84304
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]

print(Ans)

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

int main() {
    int K,N;
	cin >> K >> N;
	int a0=0,ap,a;
	int max_dist=0;
	cin >> a0;
	ap=a0;
	for(int i=1;i<N;i++){
		cin >> a;
		if(a-ap>max_dist){
			max_dist=a-ap;
		}
		ap=a;
	}
	
	if(K-(a-a0)>max_dist){
		max_dist = K-(a-a0);
	}

	cout << K - max_dist << endl;
    return 0;
}


Measured memory_bytes: 256
/* ex5_3
   moka223711 */

#include <stdio.h>
#define ROW 101
#define COL 101

int main(void){
    int row, col, i, j, br[ROW]={0}, bc[COL]={0}, id;
    char sq[ROW][COL];
    scanf("%d %d", &row, &col);
    
    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &sq[i][j]);
            if(sq[i][j]=='#'){
                br[i] = 1;
                bc[j] = 1;
            }
        }
    }
    
    for(i = 0; i < row; i++){
        if(br[i] == 0)
            continue;
        for(j = 0; j < col; j++){
            if(bc[j] == 0)
                continue;
            printf("%c", sq[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;
const int N = 1e5 + 5;

int n, tot = 0, r, c;
pii p[N];
bool ans = 1;

inline bool on_edge(int x, int y) {
  if (x == 0 || x == r || y == 0 || y == c) return true;
  return false;
}

inline int GetID(int x, int y) {
  if (x == 0) return r + c + r + c - y;
  if (x == r) return r + y;
  if (y == 0) return x;
  return r + c + r - x;
}

inline void solve() {
  sort(p + 1, p + tot + 1);
  priority_queue <int, vector <int>, greater <int> > Q;
  for (int i = 1; i <= tot && ans; i ++) {
    while (!Q.empty() && Q.top() <= p[i].first) Q.pop();
    if (!Q.empty() && Q.top() < p[i].second) ans = 0;
    Q.push(p[i].second);
  }
}

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d", &r, &c, &n);
  for (int i = 1, a, b; i <= n; i ++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if(!on_edge(x1, y1) || !on_edge(x2, y2)) continue;
    a = GetID(x1, y1); b = GetID(x2, y2);
    p[++ tot] = mp(min(a, b), max(a, b));
  }
  solve();
  // for (int i = 1, a, b; i <= tot; i ++) {
  //   a = (p[i].first + r + c) % (r + r + c + c);
  //   b = (p[i].second + r + c) % (r + r + c + c);
  //   p[i] = mp(min(a, b), max(a, b));
  // }
  // solve();
  printf("%s\n", ans ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm> 
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left";
	if(a+b<c+d)cout<<"Right";
	if(a+b==c+d) cout<<"Balanced";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int selectionSort(int A[], int N)
{
	int i, j, t, sw = 0, mini;
	rep(i, N - 1)
	{
		mini = i;
		for (j=i; j<N; j++)
		{
			if (A[j] < A[mini]) mini = j;
		}
		t = A[i]; A[i] = A[mini]; A[mini] = t;
		if (i != mini) sw++;
	}
	return sw;
}


int main()
{
	int A[100], N, i, sw;
	
	scanf("%d", &N);
	rep(i, N) scanf("%d", &A[i]);
	
	sw = selectionSort(A, N);
	
	rep(i, N)
	{
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

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

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  rep(i, 5){
    ll a; cin >> a;
    if (a == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N, T; 
cin >> N >> T; 
int cost = 10000; 
for(int i = 0; i < N; i++){
int c, t; 
cin >> c >> t; 
if(t <= T && c <= cost){
cost = c; 
}
}
if(cost == 10000){
cout << "TLE" << endl; 
}
else cout << cost << endl; 
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	m := make(map[int]int, 100000)
	sum := 0
	for i := 0; i < N; i++ {
		tmp := nextInt()
		sum += tmp
		if _, ok := m[tmp]; ok {
			m[tmp]++
		} else {
			m[tmp] = 1
		}
	}

	Q := nextInt()
	for i := 0; i < Q; i++ {
		b, c := nextInt(), nextInt()

		sum = sum - b*m[b] + c*m[b]
		fmt.Println(sum)
		m[c] += m[b]
		m[b] = 0
	}

}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int X;
	cin >> X;
	int Y = X % 100;
	int T = X / 100;
	bool ans = false;
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 50; j++)
		{
			for (int k = 0; k < 34; k++)
			{
				for (int l = 0; l < 25; l++)
				{
					for (int m = 0; m < 20; m++)
					{
						int Z = 1*i + 2*j + 3*k + 4*l + 5* m;
						if (Z == Y && i+j+k+l+m <= T)
							ans = true;
					}
				}
			}
		}
	}
	cout << (ans ? 1 : 0) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

double cc[3];
int main()
{
	ll d,n,m;
cout.setf(ios::fixed);
cout.precision(12);
	double ans=0;
	
	cin>>n>>m>>d;
	if(d==0)
	{
		ans=(double)(m-1)/(double)n;
	}else{
		if(2*d<n)
		{
			cc[0]=0;
			cc[1]=2*d;
			cc[2]=n-2*d;
		}else if(2*d==n){
			cc[0]=0;
			cc[1]=n;
			cc[2]=0;
		}else{
			cc[0]=(1+d)-(n-d+1);
			cc[2]=0;
			cc[1]=n-cc[0];
		}
		double pp=((double)cc[1]+(double)cc[2]*2)/(double)pow(n,2);
		ans=pp*(double)(m-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int main() {
  int s,f;
  cin >> s;
  f=s;
  map<int,int> mp;
  mp[f]++;
  for(int i=1; i<1000001; i++) {
    if(f%2==0) {
      f/=2;
      mp[f]++;
      if(mp[f]==2) {
        cout << i+1 << endl;
        return 0;
      }
    }
    else {
      f=f*3+1;
      mp[f]++;
      if(mp[f]==2) {
        cout << i+1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N,i;
    int h[100010];
    int s[100010]={};
    cin >> N;
    
    for(i=1;i<=N;i++){
        cin >> h[i];
    }
    s[1]=0,s[2]=abs(h[1]-h[2]);
    for(i=3;i<=N;i++){
        s[i]=min(s[i-1]+abs(h[i]-h[i-1]),s[i-2]+abs(h[i]-h[i-2]));
    }
    
    cout << s[N] << endl;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long N, K;
vector<long long> a, b, c;
long long A, B, C;
long long count(long long x) {
    if (x < 0) {
        x = -x;
        long long res = 0;
        for (int i = 0; i < C; i++) {
            if (x % c[i] == 0) {
                res += a.end() - lower_bound(a.begin(), a.end(), x/c[i]);
            }
            else {
                res += a.end() - lower_bound(a.begin(), a.end(), x/c[i]+1);
            }
        }
        return res;
    }
    else {
        long long res = (A*C)+(B*(A+C)+B*(B-1)/2);
        for (int i = 0; i < A; i++) {
            res += upper_bound(a.begin()+i+1, a.end(), x/a[i]) - (a.begin()+i+1);
        }
        for (int i = 0; i < C; i++) {
            res += upper_bound(c.begin()+i+1, c.end(), x/c[i]) - (c.begin()+i+1);
        }
        return res;
    }
}
int main () {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x > 0) {
            a.push_back(x);
        }
        else if (x == 0) {
            b.push_back(x);
        }
        else {
            c.push_back(-x);
        }
    }
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    A = a.size(), B = b.size(), C = c.size();
    long long low = -1'000'000'000'000'000'001, high = 1'000'000'000'000'000'001;
    while (high - low > 1) {
        long long mid = (high + low) / 2;
        if (count(mid) < K) {
            low = mid;
        }
        else {
            high = mid;
        }
    }
    cout << high << endl;
}

Measured memory_bytes: 2548
// std input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),*  )) => {
        ( $(read_value!($iter, $t)),*  )
    };
    ($iter:expr, [ $t:tt ; $len:expr  ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    input!{
        n: u64,
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        if (      1 <= i && i <=       9) ||
           (    100 <= i && i <=     999) ||
           (  10000 <= i && i <=   99999) ||
           (1000000 <= i && i <= 9999999) {
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))
checklist = []
for i in range(N):
    cl = [i, a[i] - 1]
    cl.sort()
    checklist.append(cl)
cnt = 0
checklist.sort()
for i in range(1, N):
    if checklist[i] == checklist[i - 1]:
        cnt += 1
print(cnt)


Measured memory_bytes: 23804
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	int n = s.size();
	if (n == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	string t = "";
	rep(i, n)
	{
		if (s[i] != 'x')t += s[i];
	}
	int m = t.size();
	rep(i, m / 2)
	{
		if (t[i] != t[m - 1 - i])
		{
			cout << -1 << endl;
			return 0;
		}
	}
	int l = 0, r = n - 1;
	int res = 0;
	while (l < r)
	{
		if (s[l] == s[r])++l, --r;
		else if (s[l] == 'x')++l, ++res;
		else if (s[r] == 'x')--r, ++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
s = input()
while s:
    if s[:11] == "dreameraser":
        s = s[11:]
    elif s[:10] == "dreamerase":
        s = s[10:]
    elif s[:7] == "dreamer":
        s = s[7:]
    elif s[:6] == "eraser":
        s = s[6:]
    elif s[:5] == "dream":
        s = s[5:]
    elif s[:5] == "erase":
        s = s[5:]
    else:
        print("NO")
        quit()
print("YES")
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 134760
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void)
{
	double N, T, A;

	cin >> N >> T >> A;

	int32_t ans = 0;
	double ave = 100000 * 0.006;
	for(uint32_t i = 0; i < N; ++i)
	{
		double Hn;
		cin >> Hn;
		double temp = T - Hn * 0.006;
		double nAve = fabs(max(temp, A) - min(temp, A));
		if(nAve < ave)
		{
			ave = nAve;
			ans = i + 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        //最大値を格納する変数ans
        long ans = a * c;
        if(a * d > ans){
            ans = a * d;
        }
        if(b * c > ans){
            ans = b * c;
        }
        if(b * d > ans){
            ans = b * d;
        }
        //ansを出力する
        System.out.println(ans);
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int fib[45]={1,1};
    int n;
    cin>>n;
    for(int i=2; i<=n; i++) fib[i]=fib[i-1]+fib[i-2];
    cout<<fib[n]<<'\n';
    return 0;
}

Measured memory_bytes: 1196
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    ll n, m, r;
    vector<ll> mati;
    cin >> n >> m >> r;
    mati.resize(r);
    rep(i,r){
        ll in;
        cin >> in;
        mati[i] = in-1;
    }
    ll d[201][201];
    rep(i,201){
        rep(j,201){
            d[i][j] = LINF;
        }
    }
    rep(i,m){
        ll a,b,c;
        cin >> a >> b >> c;
        d[a-1][b-1] = c;
        d[b-1][a-1] = c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    sort(all(mati));
    ll ans=LINF;
    do {
        ll dis=0;
        rep(i,r){
            if(i==0) continue;
            dis += d[mati[i]][mati[i-1]];
        }
        ans = min(ans, dis);
    }while(next_permutation(all(mati)));
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s;
    getline(cin, s);
    int T = atoi(s.c_str());
    while (T--) {
        getline(cin, s);
        if (s.size() && s[s.size()-1] == '\r') s.resize(s.size()-1);
        sort(s.begin(), s.end());
        const int a = atoi(s.c_str());
        reverse(s.begin(), s.end());
        const int b = atoi(s.c_str());
        printf("%d\n", b-a);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  string w;
  cin >> w;
  bool ev=true;
  for (int i=0;i<26;i++){
    int count =0;
    for (int j=0;j<w.size();j++){
      if(w[j]==char('a'+i)){
        count++;
      }
    }
    if(count%2!=0){
      ev=false;
    }
  }
  if(ev){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    CNT = Counter(A+B)
    num = CNT.most_common()[0][1]
    if num > N:
        print("No")
        return 

    j, pre = 0, -1
    for i in range(N):
        if A[i] != pre:
            j = 0
        if A[i] == B[i]:
            while j < N:
                if A[i] != B[j] and A[j] != B[i]:
                    B[i], B[j] = B[j], B[i]
                    break
                j += 1
        pre = A[i]

    print('Yes')
    print(*B)


if __name__ == "__main__":
    resolve()

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

using namespace std;


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

class IN{
public:
  char c;
  int a;
  IN(char c, int a):c(c),a(a){}
};

class UF{
public:
  vector<int> per;
  void init(int n){
    per = vector<int>(n+1);
    rep(i,per.size())per[i]=i;

  }
  int find(int a){
    if(per[a]==a)return a;
    return per[a] = find(per[a]);
  }
  void uni(int a, int b){

    a = find(a);
    b = find(b);


    if(a==b)return;
    per[b] = a;
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  void print(){
    reps(i,1,per.size())printf("%d ",per[i]);puts("");
  }
  void fprint(){
    reps(i,1,per.size())printf("%d ",find(i));puts("");
  }
};

int n,m;
vector<int> tree;
vector<IN> in;

bool input(){
  if(!(cin>>n>>m))return false;
  if(n==0)return false;
  tree = vector<int>(n+1);
  tree[1] = -1;

  rep(i,n-1){
    cin>>tree[i+2];
  }
  in.clear();

  vector<int> check(n+1,0);
  check[1]=1;
  in.push_back(IN('M',1));

  rep(i,m){
    char c;
    int a;
    cin>>c>>a;
    if(c=='M'){
      if(check[a]==1)continue;
      check[a]=1;
    }
    in.push_back(IN(c,a));
    //rep(i,check.size())printf(" ==%d ",check[i]);puts("");
  }
  return true;

}


UF uf;

long long solve(){
  vector<IN> rev = in;
  reverse(rev.begin(),rev.end());
  uf.init(n);
  vector<int> check(n+1,0);
  rep(i,in.size()){
    if(in[i].c=='M'){
      check[in[i].a]=1;
    }
    //printf("hoooo %c %d\n",in[i].c, in[i].a);
  }

  reps(i,1,n+1){
    //printf("uniiii %d %d\n",tree[i],i);
    if(check[i]==0)uf.uni(tree[i], i);
    if(check[i]==1)uf.per[i]=i;
  }
  
  long long ret = 0;
  rep(i,rev.size()){

    if(rev[i].c=='Q'){
      int t = uf.find(rev[i].a);
      ret += t;
      //printf("%d %d\n",i,t);
    }else{
      //printf("  ");uf.fprint();
      uf.uni(tree[rev[i].a], rev[i].a);
    }
    //printf("  ");uf.fprint();
  }
  return ret;
}

int main(){
  while(input())cout<<solve()<<endl;
}

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

int main(int argc, char* argv[]) {
  string s;
  cin >> s;
  long long sum = 0, lb = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') {
      sum += lb;
    } else if (s[i] == 'B') {
      lb++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
  /* your code */
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
  /*

   your code


  */

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if(a==b){
    for(int i=0;i<a;i++){
      cout << a;
    }
  }else {
    for(int i=0;i<max(a,b);i++){
      cout << min(a,b);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    set<string> s;
    ll n;
    cin>>n;
    bool j=true;
    string t;
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        if(i!=0){
            if(t[t.size()-1]!=str[0]){j=false;}
        }
        t=str;
        s.insert(str);
    }
    if(s.size()!=n){j=false;}
    cout<<(j?"Yes":"No")<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
    register int n,l,r,x,ans=0;
	scanf("%d%d%d",&n,&l,&r);
	while(n--)
	{
		scanf("%d",&x);
		if(x<l||x>=r)  ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#Reference : http://qiita.com/lethe2211/items/6cbade2bc547649bc040
#Reference : http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_D
n = input()

R = []
for i in range(n):
    R.append(input())

min_v = R[0]
max_v = -pow(10, 9)
for i in range(1, n):
    temp = R[i] - min_v
    if (temp >= max_v):
        max_v = temp
    temp = R[i]
    if (min_v >= temp):
        min_v = temp
print max_v

    

Measured memory_bytes: 18932
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

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

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll a,b; cin >> a >> b;
    if(a%2 != 0) {
        if(b%2 == 0) {
            if((b-a+1)%4 == 0){
                cout << (1 ^ a ^ b) << endl;
            }
            else
                cout << (a ^ b) << endl;
        } else {
            if((b-a)%4==0)
                cout << a << endl;
            else
                cout << (1 ^ a) << endl;
        }
    } else {
        if(b%2 == 0) {
            if((b-a)%4 == 0)
                cout << b << endl;
            else
                cout << (1 ^ b) << endl;
        } else {
            if((b-a+1)%4==0)
                cout << 0 << endl;
            else
                cout << 1 << endl;
        }
    }
}


Measured memory_bytes: 256
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var first = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (first[0] < first[1])
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(10);
            }
            
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC129.B();
        //    temp.Run();
        //}

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
    //var N = int.Parse((K[0]));
    //var M = int.Parse((K[1]));
    //var firstLine = Console.ReadLine().Split(' ').Select(int.Parse);
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n, m;
    cin >> n >> m;
    char a[n][m];
    ll col[n][m]; mem(col, 0);
    rep(i, n) rep(j, m)
    {
        cin >> a[i][j]; if(a[i][j] == '#') col[i][j] = 1;
    }
    rep(i, n)
    {
        rep(j, m)
        {
            if(a[i][j] == '#')
            {
                if(i+1 < n && a[i+1][j] == '#') col[i+1][j] = col[i][j] = 0;
                if(j+1 < m && a[i][j+1] == '#') col[i][j+1] = col[i][j] = 0;
            }
        }
    }
    rep(i, n)
    rep(j, m)
    if(col[i][j]) ANS("No");
    ANS("Yes");
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;

class modint_t {
public:
    modint_t() = default;
    modint_t(int64_t value):value(value % MOD){}

    bool operator<(const modint_t rhs) const { return value < rhs.value; }
    bool operator<=(const modint_t rhs) const { return value <= rhs.value; }
    bool operator>(const modint_t rhs) const { return value > rhs.value; }
    bool operator>=(const modint_t rhs) const { return value >= rhs.value; }

    modint_t operator+(const modint_t rhs) const { return modint_t(value + rhs.value); }
    modint_t operator+=(const modint_t rhs) { return value = (value + rhs.value) % MOD; }
    modint_t operator-(const modint_t rhs) const { return modint_t(MOD + value - rhs.value); }
    modint_t operator-=(const modint_t rhs) { return value = (MOD + value - rhs.value) % MOD; }

    modint_t operator*(const modint_t rhs) const { return modint_t(value * rhs.value); }
    modint_t operator*=(const modint_t rhs) { return value = value * rhs.value % MOD; }
    modint_t operator/(const modint_t rhs) const { return *this * rhs.invert(); }
    modint_t operator/=(const modint_t rhs) { return *this *= rhs.invert(); }

    modint_t square() const { return *this * *this; }
    modint_t power(int64_t y) const
    {
        if(y == 0) return 1;
        else if(y == 1) return *this;
        else if(y % 2 == 0) return this->power(y/2).square();
        else return *this * this->power(y-1);
    }

    modint_t invert() const
    {
        return power(MOD-2);
    }

    operator int64_t() const
    {
        return value;
    }
private:
    static const int MOD = 1000000007;
    int64_t value = 0;
};

int main()
{
    int n;
    cin >> n;
    vector<int64_t> counts(60);
    for(int i = 0; i < n; ++i){
        uint64_t a;
        cin >> a;
        for(int d = 0; d < 60; ++d){
            counts[d] += (a >> d) & 1;
        }
    }
    modint_t sum = 0;
    for(int64_t d = 0; d < 60; ++d){
        modint_t s = counts[d];
        s *= n - counts[d];
        s *= (1L << d);
        sum += s;
    }
    cout << (int64_t)sum << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,A,B,C,D;
string S;

int main(){
  cin>>N>>A>>B>>C>>D;
  cin>>S;

  bool ng=false;
  int rock=0;
  for(int i=A;i<=C;i++){
    if(S[i-1]=='#') rock++;
    else rock=0;

    if(rock>=2) ng=true;
  }
  rock=0;
  for(int i=B;i<=D;i++){
    if(S[i-1]=='#') rock++;
    else rock=0;

    if(rock>=2) ng=true;
  }

  if(ng){
    cout<<"No"<<endl;
    return 0;
  }

  if(C<D){
    cout<<"Yes"<<endl;
    return 0;
  }

  for(int i=B;i<=D;i++){
    bool ng=false;
    if(S[i-1]=='#') continue;

    /*if(i-3>=0&&(S[i-3]!='#'||S[i-2]!='#')) ok=true;
    if(i-2>=0&&i<N&&(S[i-2]!='#'||S[i]!='#')) ok=true;
    if(i+1<N&&(S[i]!='#'||S[i+1]!='#')) ok=true;*/

    if(i-2>=0&&S[i-2]=='#') ng=true;
    if(i<N&&S[i]=='#') ng=true;

    if(!ng){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;

  return 0;
}


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

int n;
pair<int, int> A[100000], B[100000];
int num = 0;

void solve(){
    // secondを基準にして，A, Bを降順にsort
    sort(
        A,
        A + 100000);
    sort(
        B,
        B + 100000);

    int a = 0;
    int b = 0;
    if (A[a].second == B[b].second){
        num = min(A[a + 1].first + B[b].first, A[a].first + B[b + 1].first);
    }else{
        num = A[a].first + B[b].first;
    }
}

int main(){
    cin >> n;
    // A, Bの初期化
    for (int i = 0; i < 100000; i++){
        A[i].second = 0;
        A[i].first = 0;
        B[i].second = 0;
        B[i].first = 0;
    }
    for (int i = 0; i < n; i++){
        int element;
        cin >> element;
        if (i % 2 == 0){
            A[element].second = element;
            A[element].first -= 1;
        }
        else{
            B[element].second = element;
            B[element].first -= 1;
        }
    }
    solve();
    cout << n + num << endl;
    return 0;
}

Measured memory_bytes: 1792