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

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

    boolean tmp = true;

    while(tmp){
      int n = sc.nextInt();
      int x = sc.nextInt();
      int ans = 0;

      if(n == 0 && x == 0){
        tmp = false;
        break;
      }

      for(int i = 1; i < n; i++){
        for(int j = i + 1; j < n + 1; j++){
          if(x - i - j > j && x - i - j < n + 1){
            ans += 1;
          }
        }
      }

      System.out.println(ans);
    }
  }
}



Measured memory_bytes: 26344
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt(), M = scan.nextInt();

        Map<Integer, Integer> res = new HashMap<>();
        for (int i=1; i<=N; i++){
            res.put(i, 0);
        }

        int tmpa = 0, tmpb =0;
        for (int i=0; i<M; i++){
            tmpa = scan.nextInt();
            tmpb = scan.nextInt();
            res.put(tmpa, res.get(tmpa)+1);
            res.put(tmpb, res.get(tmpb)+1);
        }

        res.forEach((integer, integer2) -> System.out.println(integer2));
    }
}


Measured memory_bytes: 27092
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 1;

		int maxMount = sc.nextInt();
		for(int i=0; i<N-1; i++){
			int currentMount = sc.nextInt();
			if(maxMount <= currentMount){
				ans++;
				maxMount = currentMount;
			}
		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 23892
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

#define MAX (10^5)

int main(void) {
  int N = 0;
  //int A[MAX] = {0};
  cin >> N;

  vector<int> A(N);
  vector<int> X(N);

  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  int a[2];
  for(int j = 0; j < 1; j++) {
    int sum = 0;
    for(int i = j; i < j + N; i+=2) {
      //sum += A[i%N];
      sum += A.at(i%N);
    }
    for(int i = j+1; i < j + N; i+=2) {
      //sum -= A[i%N];
      sum -= A.at(i%N);
    }
    X[j] = sum;
  }
  for(int j = 0; j < N - 1;j++) {
    X[j+1] = 2 * A[j] - X[j]; 
  }
  for(int j = 0; j < N; j++) {
    cout << X[j] << " ";
  }
  
  cout << endl;
  
  return 0; 
}

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

using namespace std;
typedef long long ll;
int main()
{
          ll a,b;
          cin>>a>>b;
          for(ll i=0;i<max(a,b);i++)
                    if(abs(a-i)==abs(b-i)){
                    cout<<i<<endl;return 0;}
                    cout<<"IMPOSSIBLE"<<endl;


}


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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }

    ll cnt = 0;

    for(int i=0;i<n;++i) {
      for(int j=0;j<n;++j) {
        if(i != j && a[i] > a[j]) {
          if(i < j) {
            cnt += k * (k + 1) / 2;
            cnt %= MOD;
          } else if(i > j) {
            cnt += k * (k - 1) / 2;
            cnt %= MOD;
          }
        }
      }
    }
    cout << cnt << endl;
}

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

using namespace::std;

const int MAXW = 1e5 + 1;
long long DP[2][MAXW];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int N,W;
	cin >> N >> W;
	
	bool flag = true;
	for(int i = 1;i <= N;i++){
		int w,v;
		cin >> w >> v;

		for(int j = 0;j <= W;j++)
			DP[flag][j] = DP[!flag][j];

		for(int j = 0;j + w <= W;j++){
				DP[flag][j + w] = max(DP[!flag][j + w],DP[!flag][j] + v);
		}
		flag = !flag;
	}

//	for(int i = 1;i <= N;i++)
//		cerr << i << ' ' << DP[!flag][i] << '\n';

	cout << *max_element(DP[!flag],DP[!flag] + W + 1) << '\n';

	return 0;
}


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

public class Main {
	String S;
	char[] c;
	int N;
	public long dfs(int n,String s){

		if(n == N){
			String ss = s.replace("+", " ");
			String[] nums = ss.split(" ");
			long sum = 0;
			for(int i = 0;i < nums.length;i++){
				sum += Long.parseLong(nums[i]);
			}
			return sum;
		}

		long ret = 0;

		ret += dfs(n + 1,s + c[n]);
		if(n != 0)ret += dfs(n + 1,s + "+" + c[n]);
		return ret;

	}
	public void solve() {
		S = next();
		c = S.toCharArray();
		N = S.length();
		out.println(dfs(0,""));
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

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

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

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

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

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

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

signed
main(){
		ll N, M;
		cin >> N >> M;
		vector<bool> ok(N+2, true);
		for(int i=0;i<M;i++)
		{
				int a;
				cin >> a;
				ok[a] = false;
		}
		vector<ll> dp(N+2,0);
		dp[0] = 1;
		if(ok[1]==true) dp[1] = 1;
		else dp[1] = 0;

		for(int i=2;i<=N;i++)
		{
				if(ok[i]){
						if(ok[i-1] && ok[i-2]){
								dp[i] = dp[i-1] + dp[i-2];
						}else if(ok[i-1]){
								dp[i] = dp[i-1];
						}else if(ok[i-2]){
								dp[i] = dp[i-2];
						}else{
								dp[i] = 0;
						}
				}else{
						dp[i] = 0;
				}
				dp[i] %= MOD;
		}
		cout << dp[N] << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vn(n);
  for (int i = 0; i < n; i++) {
    cin >> vn.at(i);
  }
  int m;
  cin >> m;
  vector<int> vm(m);
  for (int i = 0; i < m; i++) {
    cin >> vm.at(i);
  }
  if (vn >= vm) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}



Measured memory_bytes: 3104
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<string> s(3); cin >> s;
  ll ans = 0;
  rep(i, n) {
    map<char, ll> c;
    rep(j, 3) c[s[j][i]]++;
    ll mx = 0;
    each(p, c) chmax(mx, p.second);
    ans += 3 - mx;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
/*int main(void){
    rep(i,5){
        int a;
        cin>>a;
    if(a==0) cout<<i+1<<endl;
    }
    return 0;
}*/
//////////////////
//  B
int main(void){
    int x,y;
    cin>>x>>y;
    string ret="No";

    for(int i=0;i<=x;i++){
        if(i*4+(x-i)*2==y){
            ret="Yes";
            break;
        }

    }
    cout<<ret<<endl;

    return 0;
}
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
n = int(input())
a = [list(input().rstrip()) for i in range(n)]
ans = 0
for k in range(n):
    for i in range(n):
        for j in range(i+1,n):
            if a[(i+k)%n][j] != a[(j+k)%n][i]:
                break
        else:
            continue
        break
    else:
        ans += n
print(ans)

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

 void selectionSort(int a[], int n){
    int cnt=0;
    for(int i=0; i<n; i++){
        int minj = i;
        for(int j=i; j<n; j++){
            if(a[j]<a[minj]){
                minj = j;
            }
        }
        if(i!=minj) cnt++;
        swap(a[i],a[minj]);
    }
    for(int i=0; i<n; i++){
        cout<<a[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
}

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    selectionSort(a,n);
    return 0;
}


Measured memory_bytes: 3100
def main():
    MOD = 10**9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    b = [v for v in a]
    for i in range(1, n):
        b[i] += b[i-1]
        b[i] %= MOD
    ans = 0
    for i in range(n-1):
        ans += a[i] * ((b[n-1] - b[i])%MOD)
        ans %= MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 31676
#include <stdio.h>


int main(int argc, char *argv[]) {

	int a = 0, b = 0;
	
	(void)fscanf(stdin, "%d %d", &a, &b);
	
	if(a > b) {
		printf("a > b\n");
	}else if(a < b) {
		printf("a < b\n");
	}else if(a == b) {
		printf("a == b\n");
	}

	return 0;

}

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

int main() {
	string S;
	cin >> S;
	int res = 0;
	for (int i = 0; i < S.length()-1; i++) {
		if (S[i + 1] != S[i]) {
			res++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  cin >> N;
  printf("ABC%03d\n",N);
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<stdio.h>

static int N = 100;

int min(int, int);

int min(int x, int y){
  if(x >= y) return y;
  else return x;
}

int main(){
  int n, p[N+1], m[N+1][N+1];
  int i, j, l, k;

  scanf("%d", &n);
  for(i=1; i<=n; i++){
    scanf("%d%d", &p[i-1], &p[i]);
  }

  for(i=1; i<=n; i++) m[i][i] = 0;
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
    j = i+l-1;
    m[i][j] = 100000000;
    for(k=i; k<=j-1; k++){
      m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
    }
    }
  }

  printf("%d\n", m[1][n]);

  return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed <<setprecision(10) << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  return 0;
}



Measured memory_bytes: 3276
a,b = (int(i) for i in input().split())
ans = 0
if a % 2 == 0:
  temp = (b - a + 1) % 4 
  for i in range(b-temp+1,b+1):
    ans ^= i
else:
  temp = (b - a) % 4 
  ans ^= a
  for i in range(b-temp+1,b+1):
    ans ^= i
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,j,N,Y;
  bool flag = false;
  cin >> N >> Y;
 
  for(i = 0; i <= N; i++){
    for(j = 0; j <= N - i; j++){
		int tmp = 10000*i + 5000*j + 1000*(N-i-j);
      	if(tmp == Y){
           flag = true;
           cout << i << " "<< j << " " << (N-i-j) << endl;
           break;
        }
    }
    if(flag == true){break;}
  }
  if(flag == false){cout << "-1 -1 -1" << endl;}

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n, k;
	long double sum = 0;
	scanf("%d %d", &n, &k);
	
	for (int i = 1; i <= n; i++)
	{
		int temp = i;
		int cnt = 0;
		while (temp < k)
		{
			temp *= 2;
			cnt++;
		}
		long double p = 1;
		while (cnt--)
			p *= 0.5;
		sum += (1 / (long double)n) * p;
	}
	cout.precision(13);
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) cin >> A[i];

	sort(A, A+N);

	int cnt = 0, e = -1, W = 0, H = 0;

	for (int i = 0; i < N; i++) {
		if (e == A[i]) cnt++;

		if (e != A[i] || i == N-1) {
			if (cnt >= 4) {
				W = e;
				H = e;
			} else if (cnt >= 2) {
				if (e > W) {
					H = W;
					W = e;
				} else if (e > H) {
					H = e;
				}
			}
			e = A[i];
			cnt = 1;
		}
	}

	cout << (ll)W * (ll)H << endl;
    return 0;
}


Measured memory_bytes: 640
a = map(int, raw_input().split())
n = input() * 4
v = [1, 2, 4, 8]

for i in xrange(4):
    t = a[i]
    for j in xrange(i + 1, 4):
        t *= 2
        a[j] = min(a[j], t)

ans = 0

for i in xrange(3, -1, -1):
    ans += (n / v[i]) * a[i]
    n %= v[i]

print ans


Measured memory_bytes: 2692
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

count = 0
from itertools import product
for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            abc = len(set([a,b,c]))
            t = gcd(a, b, c)
            count += t if abc == 1 else t * 3 if abc == 2 else t * 6

print(count)

Measured memory_bytes: 9628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def integer_factorization(n):
    prime_count = collections.Counter()
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n //= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    return prime_count

prime = [True] * (10**6 + 2)
prime[1] = False
max_range = int(math.sqrt(10**6)) + 1

for i in range(2, 10**6 + 1):
    if not prime[i]:
        continue
    if prime[i]:
        num = i + i
        while num < max_range:
            prime[num] = False
            num += i

def main():
    gcd = fractions.gcd
    A, B = LI()
    m = gcd(A, B)
    cnt = 1
    cnt += len(integer_factorization(m))
    # for i in range(2, int(math.sqrt(m)) + 1):
    #     if m % i != 0:
    #         continue
    #     if prime[i]:
    #         cnt += 1
    print(cnt)
main()



Measured memory_bytes: 13508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <climits>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)

signed main()
{
	int N; cin >> N;
	int ans = 0;
	rep1(i, N-1) ans += i;
	cout << ans << endl;
}


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



using namespace std;

int main(){
  long int n,k;
  cin>>n>>k;
  
  long int min=abs(n-k),tmp;
  while(true){
    
    if(min>=k){
      min=min%k;
    }else{
      if(min<=k/2){
        break;
      }else{
        min=k%min;
        break;
      }
    }
    
  }
  
  cout<<min;
  
  
  return 0;
}

Measured memory_bytes: 256
import collections


class RollingHashSingle:
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod

        self.hash = [0]
        self.power = [1]
        for c in s:
            self.hash.append((self.hash[-1] * base + ord(c)) % mod)
            self.power.append(self.power[-1] * base % mod)

    def get(self, left, right):
        h = self.hash[right] - self.hash[left] * self.power[right - left]
        return (h + self.mod) % self.mod


class RollingHash:
    def __init__(self,
                 s,
                 base=(10**4 + 7, 10**4 + 9),
                 mod=(10**9 + 7, 10**9 + 9)):
        if isinstance(base, int):
            assert isinstance(mod, int)
            self.base = (base, )
            self.mod = (mod, )
        elif isinstance(base, tuple):
            assert isinstance(mod, tuple)
            assert len(base) == len(mod)
            self.base = base
            self.mod = mod
        else:
            raise ValueError()

        self._rh = [
            RollingHashSingle(s, base, mod)
            for base, mod in zip(self.base, self.mod)
        ]

    def get(self, left, right):
        return tuple(rh.get(left, right) for rh in self._rh)


n = int(input())
s = input().rstrip()
rh = RollingHash(s)


def check(diff):
    d = collections.defaultdict(list)
    for i in range(n - diff + 1):
        h = rh.get(i, i + diff)
        d[h].append(i)
    for l in d.values():
        if max(l) - min(l) >= diff:
            return True
    return False


lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
    mid = (lo + hi) // 2
    if check(mid):
        lo = mid
    else:
        hi = mid
print(lo)

Measured memory_bytes: 53084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	if (((b - 1) % (a - 1))>0)cout << 1 + (b - 1) / (a - 1) << endl;
	else cout <<(b - 1) / (a - 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,count,i,j,num;
  count=0;
  scanf("%d",&N);
  for(i=1;i<N;i++){
    for(j=1;j<i+1;j++){
      if(i%j==0 && i/j==j) count++;
      else if(i%j==0) count=count+2;
      if(i/j<=j+1) break;
    }
  }
  printf("%d",count);
  return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	vector<int> ans = { 1, 2, 3 };

	for (auto& e : ans)
	{
		if (e != A && e != B) {
			cout << e << endl;
		}
	}
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int n = 0; n < N; n++) {
        cin >> A[n];
        A[n]--;
    }

    vector<int> B(N);
    for (int n = 0; n < N; n++) {
        cin >> B[n];
    }

    vector<int> C(N - 1);
    for (int n = 0; n < N - 1; n++) {
        cin >> C[n];
    }

    int ans = 0;
    for (int n = 0; n < N; n++) {
        ans += B[A[n]];
        if (n > 0) {
            if (A[n - 1] + 1 == A[n]) {
                ans += C[A[n - 1]];
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
lb = list(map(int,input().split()))
la = [0] * N

la[0] = lb[0]
for i in range(N-2):
    if lb[i] > lb[i + 1]:
        la[i + 1] = lb[i + 1]
    else:
        la[i + 1] = lb[i]
la[N-1] = lb[N-2]

print(sum(la))

Measured memory_bytes: 3064
#include <iostream>

long sum = 0;

int addr(int a, int b, int cin)	//return cout
{
  if (a <= cin){
    sum += a;
    return b;
  }
  else if (a <= cin+b){
    sum += a;
    return cin + b - a;
  }
  else{
    sum += cin + b;
    return 0;
  }
}
 
int main() 
{
  int n;
  std::cin >> n;
  int a[n+1], b[n+1];
  for (int i = 0; i < n+1; i++) std::cin >> a[i];
  for (int i = 0; i < n; i++) std::cin >> b[i];
  b[n] = 0;
  
  int cin = 0;
  for (int i = 0; i < n+1; i++) cin = addr(a[i], b[i], cin);
  
  std::cout << sum;
  return 0;
}
  


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;

vi g[maxn];
int dep[maxn];

void dfs(int v, int p, int d) {
	dep[v] = d; 
	for (int to : g[v]) {
		if (to != p) {
			dfs(to, v, d + 1);
		}
	}
}

bool win[maxn];

int main() {
	int N; cin >> N;
	rep(i, N-1) {
		int a, b;
		cin >> a >> b; --a; --b;
		g[a].pb(b); g[b].pb(a);
	}

	dfs(0, -1, 0);
	int r = -1;

	rep(i, N) {
		if (r == -1 || dep[r] < dep[i]) {
			r = i;
		}
	}

	dfs(r, -1, 0);
	int dia = *max_element(dep, dep + N);
	//dump(dia);

	win[0] = true;
	for (int i = 1; i < maxn; ++i) {
		win[i] = (!win[i-1]);
		if (i >= 2) {
			win[i] |= (!win[i-2]);
		}
	}

	puts(win[dia] ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 21504
#21 D - Banned K AC TLE(hint)
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)
#先に組み合わせの個数を計算しておく
combinations = {}
for j in cnt.keys():
    if cnt[j] >= 2:
        comb = (cnt[j]*(cnt[j]-1))//2
        combinations[j] = comb      

#あるボールを選ばないとき、組み合わせの総数は
#(全組み合わせ数) - (選ばないボールと同じボールの数 - 1)
tot = sum(combinations.values())
ans = []
for i in A:
    a = tot - (cnt[i] - 1)
    ans.append(a)
    
for k in ans:
    print(k)

Measured memory_bytes: 131532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<ll> p(A), q(B), r(C);
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    sort(ALL(p), greater<ll>());
    sort(ALL(q), greater<ll>());

    rep(i, X) r.pb(p[i]);
    rep(i, Y) r.pb(q[i]);
    sort(ALL(r), greater<ll>());

    ll ans = 0;
    rep(i, X + Y) { ans += r[i]; }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7808
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

l = input()
mod = 10**9+7
from collections import deque
l = deque(l)

def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod



if "0" not in l:
    print(pow(3,len(l),mod))
else:
    ans = llo(l)
    print(ans)


Measured memory_bytes: 88524
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 1e5 + 20;
int n, a[N], num, cnt;

inline void no ()
{
	cout << "No\n";
	exit(0);
}

inline void yes ()
{
	cout << "Yes\n";
	exit(0);
}

void check_n ()
{
	bool fl = 1;
	for (int i = 0; i < n; i++)
		fl &= (a[i] == n - 1);

	if (fl) yes();
}

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

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

	check_n();

	for (int i = 0; i < n; i++)
		num = max(num, a[i]);

	if (num >= n) no();

	for (int i = 0; i < n; i++)
		if (num - a[i] > 1) no();

	for (int i = 0; i < n; i++)
		cnt += (a[i] == num - 1);

	if (cnt >= num || (n - cnt) < 2 * (num - cnt)) no();

	yes();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n;
	ll a[200000];
	cin >> n;
	REP(i, n) cin >> a[i];

	ll sum[200010], mem = 0;
	sum[0] = 0;
	REP(i, n){
		mem += a[i];
		sum[i+1] = mem;
	}

	sort(sum, sum+n+1);

	ll ans = 0, cnt = 0;
	REP(i, n){
		cnt++;
		if(sum[i+1] != sum[i]){
			if(cnt >= 2) ans += nCr(cnt, 2LL);
			cnt = 0; 
		}
	}
	cnt++;
	if(cnt >= 2) ans += nCr(cnt, 2LL);

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define pb push_back
typedef long long ll;
typedef long double ld;

using namespace std;

signed main(){
    int a , b;
    cin >> a >> b;
    if(a <= 5)
        cout << 0;
    else if(a >= 6 && a <=12)
        cout << b/2;
    else
        cout << b;
    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

con_sum_A = [0]*(N+1)
con_sum_B = [0]*(M+1)
for i in range(1, N+1):
    con_sum_A[i] = con_sum_A[i-1] + A[i-1]

for i in range(1, M+1):
    con_sum_B[i] = con_sum_B[i-1] + B[i-1]

ans = 0
j = M
for i in range(N+1):
    time = con_sum_A[i]
    if time > K:
        break
    while time + con_sum_B[j] > K:
        j -= 1
    
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47428
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;
int V, E, r;
struct edge{int to, cost; };

typedef pair<int, int> P; //firstは最短距離, secondは頂点の番号
vector<vector<edge> > G(100010);
int d[100010];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    for(int i=0; i<V; ++i) d[i]=1e9+7;
    d[s]=0;
    que.push(P(0, s));
    
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i=0; i<(int)G[v].size(); ++i){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] +e.cost;
                que.push(P(d[e.to], e.to));
            }
        }  
    }
}
int main(){
    cin >> V >> E >> r;
    for(int i=0; i<E; ++i){
        edge da;
        int s, t, d; cin >> s >> t >> d;
        da.to = t; da.cost = d;
        G[s].push_back(da);
    }
    dijkstra(r);
    for(int i=0; i<V; ++i){
        if(d[i]!=1e9+7) cout << d[i] << endl;
        else cout << "INF" << endl;
    }
    return 0;
}




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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    double d, t, s;
    read(d, t, s);
    
    double t1 = d / s;
    
    print(t1 <= t ? "Yes" : "No");
    
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



Measured memory_bytes: 3716
import Data.List (tails)

main :: IO ()
main = do
  let
    diff :: String -> String -> Int
    diff s t = length . filter not $ zipWith (==) s t
  s <- getLine :: IO String
  let
    l = length s :: Int
  t <- getLine :: IO String
  let
    m = length t :: Int
  print . minimum . map (diff t) . take (l - m + 1) . tails $ s


Measured memory_bytes: 3948
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair < llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int cnt = 1;
	int ans = 0;
	rep(i, s.size() - 1) {
		if (s[i] != s[i + 1]) {
			cnt++;
		}
		else {
			ans++;
		}
	}
	if (cnt - k * 2 <= 1) {
		cout << n - 1 << endl;
	}
	else {
		ans += 2 * k;
		cout << ans << endl;
	}
	return 0;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int x, y, z;
int ans, tmp, cnt, idx, mx = -inf, mn = inf;
string s, t;
int a[N], b[N];
vi adj[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
int q = 1;
// cin >> q;
while (q--){
    cin >> x >> y >> z;
    if (x == y && x != z) cout << "Yes";
    else if (x == z && y != z) cout << "Yes";
    else if (z == y && x != z) cout << "Yes";
    else cout << "No";
}
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
#define inf INT64_MAX
int32_t main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    if(x == 0) outline(1)
    else outline(0)
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

int main()
{
    int A, B;
    cin >> A >> B;
    vector<int> valueA(2, 0), valueB(2, 0); // [0]: min, [1]: max

    valueA[0] = static_cast<int>(ceil(A * 100.0 / 8.0));
    valueA[1] = valueA[0];
    while(static_cast<int>(valueA[1] * 0.08) == A) {
        ++valueA[1];
    }
    --valueA[1];

    valueB[0] = static_cast<int>(ceil(B * 10.0));
    valueB[1] = valueB[0];
    while(static_cast<int>(valueB[1] * 0.1) == B) {
        ++valueB[1];
    }
    --valueB[1];

    if ((valueA[0] > valueB[1]) || (valueB[0] > valueA[1])) {
        cout << -1 << endl;
        return 0;
    }
    int ans = max(valueA[0], valueB[0]);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

vector<vector<int>> G;
vector<int> A;
vector<int> ans;
vector<stack<int>> L;
int N;
void dfs(int cur = 0, int par = -1) {
    bool update = false;
    int pos = -1;
    int l = -1, r = N - 1; // ng, ok
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(L[mid].top() >= A[cur]) {
            r = mid;
        }
        else l = mid;
    }
    if(L[r].top() > A[cur]) {
        update = true;
        pos = r;
        L[r].push(A[cur]);
    }
    
    l = 0; r = N; // ok, ng
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(L[mid].top() == inf) {
            r = mid;
        }
        else l = mid;
    }
    ans[cur] = l + 1;
    for(int v: G[cur]) {
        if(v != par) {
            dfs(v, cur);
        }
    }
    if(update) {
        L[pos].pop();
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    cin >> N;
    G.resize(N);
    A.resize(N);
    rep(i, N) cin >> A[i];
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    ans.resize(N);
    L.resize(N);
    rep(i, N) L[i].push(inf);
    dfs();
    rep(i, N) {
        output(ans[i]);
    }

    
    return 0;
}


Measured memory_bytes: 164156
#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
typedef long long ll;
#define equ(a,b) ((fabs((a)-(b)))<(eps))
#define more(a,b) (((a)-(b))>(eps))
#define less(a,b) (((a)-(b))<(-eps))
#define inf 0x3f3f3f3f
struct pp{
    ll b,c;
}x[100005];
int main(){
    ios::sync_with_stdio(false);
    ll s=0;
    ll n,a[100005],q,vis[100005]={0};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        vis[a[i]]++;
        s+=a[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>x[i].b>>x[i].c;
        s+=vis[x[i].b]*(x[i].c-x[i].b);
        cout<<s<<"\n";
        vis[x[i].c]+=vis[x[i].b];
        vis[x[i].b]=0;
    }
    return 0;
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main() {
	int n,m,a,b;
	cin>>n>>m;
	vector<int>g[n+1];
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int>vis(n+1,-1);
	if(g[1].size()==0)
	{
		cout<<"No";
		return 0;
	}
	queue<pair<int,int>>q;
	q.push({1,0});
	while(!q.empty())
	{
		auto p=q.front();
		q.pop();
		
		int x=p.first;
		int par=p.second;
		//cout<<x<<"\n";
		if(vis[x]!=-1)
		continue;
		
		vis[x]=par;
		for(auto u:g[x])
		{
			if(vis[u]==-1)
			q.push({u,x});
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(vis[i]==-1)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<"\n";
	for(int i=2;i<=n;i++)
	{
		cout<<vis[i]<<"\n";
	}
	
	
	

	
	return 0;
}


Measured memory_bytes: 10812