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

int main(void) {
    string S;
    long long K;
    cin >> S >> K;
    long long length = S.length();
    long long count = 0, same = 1;
    if (S[0] != S[length - 1]) {
        for (int i = 1; i < length; i++) {
            if (S[i] != S[i - 1]) {
                count += same / 2;
                same = 1;
            } else {
                ++same;
            }
        }
        count += same / 2;
        count *= K;
    } else {
        long long first, last;
        for (first = 0; first < length; ++first) {
            if (S[first] != S[0]) {
                break;
            }
        }
        for (last = length - 1; last > first; --last) {
            if (S[last] != S[length - 1]) {
                break;
            }
        }
        if (first == length) {
            count = length * K / 2;
        } else {
            for (int i = first; i <= last; i++) {
                if (S[i] != S[i - 1]) {
                    count += same / 2;
                    same = 1;
                } else {
                    ++same;
                }
            }
            count += same / 2;
            count *= K;
            count += ((first + (length - last - 1)) / 2) * (K - 1);
            count += (first) / 2;
            count += (length - last - 1) / 2;
        }
    }
    printf("%lld\n", count);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0,ans=0;
string s, t;


int main()
{
	cin >> n; int cnt = 1, min = 0;
	cin >> min;
	rep(i,n-1)
	{
		cin >> a;
		if (min > a)
		{
			cnt++; min = a;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
 
  int N;
  int A;
  cin >> N >> A;
  
  if (N % 500 == 0){
    cout << "Yes" << endl;
  }else if (N % 500 != 0 && A > N % 500){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}

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

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	
	int sum = max(a,b);
	if(a>b) a--;
	else b--;
	
	sum += max(a,b);
	
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Array.IArray

main = do
  n <- readLn
  slist <- map read.words<$>getLine
  q <- getLine
  ts <- map read.words<$>getLine
  let ss = listArray (1,n) slist :: Array Int Int
  print.length.filter (binSearch ss) $ ts

binSearch arr x = bins' st en arr x
  where (st,en) = bounds arr

bins' l r arr x 
  | abs (l-r) <= 1          = x `elem` [arr!l,arr!r]
  | arr!m `compare` x == LT = bins' m r arr x
  | arr!m `compare` x == GT = bins' l m arr x
  | arr!m `compare` x == EQ = True
  where m = (l+r) `div` 2

Measured memory_bytes: 108448
#include<stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int a;
	scanf("%d",&a);
	int i;
	int min = a;
	int max = a;
	long sum = a;
	for(i = 1;i < n;i++){
		scanf("%d",&a);
		if(a <min){
			min = a;
		}
		if(a > max){
			max = a;
		}
		sum+=a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
n=int(input())
t,a=[int(s)for s in input().split()]
h=[int(s) for s in input().split()]

temp=[]
for x in h:
    temp.append(t-0.006*x)
mi=114514
p=0
for i in range(len(temp)):
    dif=abs(temp[i]-a)
    if dif<mi:
        mi=dif
        p=i
print(p+1)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int table[11][100000];

inline int solve(vector<int> &in){
  int n=in.size();
  rep(i,n)rep(j,11)table[j][i]=0;
  if (in[0]!=0 )table[in[0]][0]=1;
  //((a+b*10+...+x*10^y)*10mod11 +zmod11)==
  //(z+a*10+b*100+...+x*10^(y+1))mod11
  REP(i,1,n){
    rep(j,11){
      table[(j*10+in[i])%11][i]+=table[j][i-1];
    }
    if (in[i]!=0)table[in[i]][i]++;
  }
  
  int ret=0;
  rep(i,n)ret+=table[0][i];
  return ret;
}

main(){
  string a;
  while(cin>>a && a!="0"){
    vector<int> in;
    rep(i,a.size())in.push_back(a[i]-'0');
    cout << solve(in)<<endl;
  }
}

Measured memory_bytes: 5032
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;

  ll taka = 0;
  ll aoki = 0;
  rep(i, N) {
    ll t, a;
    cin >> t >> a;
    if (i == 0) {
      taka = t;
      aoki = a;
      continue;
    }

    if (taka <= t && aoki <= a) {
      taka = t;
      aoki = a;
      continue;
    }

    ll bai_taka = (taka + (t - 1)) / t;
    ll bai_aoki = (aoki + (a - 1)) / a;
    ll bai_max = max(bai_taka, bai_aoki);
    taka = t * bai_max;
    aoki = a * bai_max;
  }

  ll ans = taka + aoki;
  ANS;
  return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

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

  dfs("", 'a', N);
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 1536
//00
#include<iostream>

using namespace std;

#define S(X) ((X)*(X))

int main(){
  int cn[(1<<15)+1]={};
  for(int a=0;S(a)<=1<<15;a++){
    for(int b=a;S(a)+S(b)<=1<<15;b++){
      for(int c=b;S(a)+S(b)+S(c)<=1<<15;c++){
	for(int d=c;S(a)+S(b)+S(c)+S(d)<=1<<15;d++){
	  cn[S(a)+S(b)+S(c)+S(d)]++;
	}
      }
    }
  }
  for(int n;cin>>n,n;){
    cout<<cn[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str,command,p;
    int n;
    int a,b;

    cin >> str;
    cin >> n;

    while(n>0){
        cin >> command;
        cin >> a >> b;
        if (command=="replace"){
            cin >> p;
            str.replace(a,b-a+1,p);
        }
        else if(command=="reverse"){
            char temp;
            while(b>a){
                temp = str[a];
                str[a] = str[b];
                str[b] = temp;
                a++;
                b--;
            }
        }
        else if(command=="print"){
            cout << str.substr(a,b-a+1) << endl;
        }
        n--;
    }

    return 0;
}



Measured memory_bytes: 3200
/*
[agc027] D - Modulo Matrix
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 500;
const int MAX_PRIME = 10000;

ll gcd(ll a, ll b) {
    while (b > 0) {
        swap(a %= b, b);
    }
    return a;
}

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

int N;
vector<int> primes;

void eratos() {
    vector<bool> is_prime(MAX_PRIME, true);
    for (int i = 2; i < MAX_PRIME; i++) {
        if (!is_prime[i]) {
            continue;
        }
        primes.push_back(i);
        for (int j = 2 * i; j < MAX_PRIME; j += i) {
            is_prime[j] = false;
        }
    }
}

void solve(vector<vector<ll>>& ans) {
    eratos();

    ans.resize(MAX_N);
    for (int i = 0; i < MAX_N; i++) {
        ans[i].resize(MAX_N);
    }

    for (int i = 0; i < MAX_N; i++) {
        for (int j = (i % 2); j < MAX_N; j += 2) {
            int p = (i + j) / 2;
            int q = (i - j + MAX_N) / 2;
            ans[i][j] =
                primes[((p % 2 == 0) ? (p / 2) : (MAX_N - 1 - p / 2))] *
                primes[((q % 2 == 0) ? (q / 2) : (MAX_N - 1 - q / 2)) + MAX_N];
        }
    }

    int di[4] = {0, 1, 0, -1};
    int dj[4] = {-1, 0, 1, 0};
    for (int i = 0; i < MAX_N; i++) {
        for (int j = 1 - (i % 2); j < MAX_N; j += 2) {
            ans[i][j] = 1;
            for (int k = 0; k < 4; k++) {
                if (0 <= i + di[k] && i + di[k] < MAX_N && 0 <= j + dj[k] &&
                    j + dj[k] < MAX_N) {
                    ans[i][j] = lcm(ans[i][j], ans[i + di[k]][j + dj[k]]);
                }
            }
            ans[i][j]++;
        }
    }
}

int main() {
    cin >> N;

    vector<vector<ll>> ans;
    solve(ans);

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

    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>

int main(void){

   double f;
   int a,b,d,r;
   
   scanf("%d %d",&a,&b);
   
   d=a/b;
   r=a%b;
   f=(double)a/(double)b;
   
   printf("%d %d %f\n",d,r,f);
   
   return 0;
}
   
   

Measured memory_bytes: 636
#python3
from operator import itemgetter 
from itertools import accumulate
def main():
    n = int(input())
    d = []
    for _ in range(n):
        x, y = map(int, input().split())
        d.append((x, y))
    d.sort(key=itemgetter(1))
    acc = 0
    f = True
    for i in range(n):
        acc = acc+d[i][0] 
        if acc > d[i][1]:
            f = False
    if f:
        print('Yes')
    else:
        print('No')
main()


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

int N,K,A[50],S,T;
ll res;
map<pair<int,pair<int,int>>,ll>mp;

int main(){
	cin>>N>>K>>S>>T;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N;i++){
		if((A[i]&S)==S&&(A[i]|T)==T){
			queue<pair<pair<int,pair<int,int>>,ll>>q;
			for(auto p:mp){
				if(p.first.first==K)continue;
				q.push({{p.first.first+1,{p.first.second.first&A[i],p.first.second.second|A[i]}},p.second});
			}
			while(!q.empty()){
				mp[q.front().first]+=q.front().second;
				q.pop();
			}
			mp[{1,{A[i],A[i]}}]++;
		}
	}
	for(int i=1;i<=K;i++)res+=mp[{i,{S,T}}];
	cout<<res<<endl;
}


Measured memory_bytes: 208700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

using namespace std;

int main(void){
	unsigned long long int x, y, n = 0;

	cin >> x >> y;

	while (1){
		n++;
		if (x * 2 > y){
			break;
		}
		x *= 2;
	}

	cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

// int n,m;
// int h[100001];
// int a[100001];
// int b[100001];
// bool flag = 0;
// int counter = 0;

// vector<int> seen(100001);
bool seen[100001];
// vector<vector<int>> way(100001);

// void func(int i){

//   seen[i] = 1;

//   for(auto j : way[i]){
//     if(seen[j]) continue;
//     if(h[j] > h[i]) flag = 1;
//     func(j);
//   }

//   return;
// }

int main(){

  int n,m;
  int h[100001];

  vector<vector<int>> way(100001);
  // vector<vector<int>> way;

  cin >> n >> m;

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

  for(int i = 0; i < m; i++){
    int x,y;
    cin >> x >> y;
    way[x - 1].push_back(y - 1);
    way[y - 1].push_back(x - 1);
  }

  // printf("---------------\r\n");

  // for(int i = 0; i < n; i++){
  //   cout << h[i] << ",";
  // }
  // cout << endl;

  // for(int i = 0; i < n; i++){
  //   cout << way[i].size() << ",";
  //   for(int j = 0; j < way[i].size(); j++){
  //     cout << way[i][j];
  //   }
  //   cout << endl;
  // }

  // for(int i = 0; i < n; i++){
  //   flag = 0;
  //   for(int j = 0; j < n; j++){
  //     seen[j] = 0;
  //   }
  //   func(i);
  //   if(flag == 0) counter ++;
  // }

  bool flag = 0;
  int counter = 0;
  for(int i = 0; i < n; i++){
    // hill i について
    flag = 0;
    if(way[i].size() == 0){
      counter ++;
      // continue;
    }else{
      for(int j = 0; j < way[i].size(); j++){
        if(h[way[i][j]] >= h[i]) flag = 1;
      }
      if(flag == 0) counter ++;
    }
    // for(auto j : way[i]){
    //   if(h[j] > h[i]) flag = 1;
    // }
    
  }
 
  cout << counter << endl;


  return 0;
}

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

int main() {
  int n, k, sum = 0;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  std::sort(p.begin(), p.end());
  for (int i = 0; i < k; i++) {
    sum += p.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int N, M; cin >> N >> M;
	int D[1002], C[1002];
	for (int i = 1; i <= N; i++) cin >> D[i];
	for (int i = 1; i <= M; i++) cin >> C[i];

	static int dp[1002][1002];

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

	for (int i = 0; i < N; i++)dp[i + 1][i + 1] = dp[i][i] + D[i + 1] * C[i + 1];

	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= M; j++) {
			dp[i][j] = min(
				dp[i][j - 1], //??????
				dp[i - 1][j - 1] + D[i] * C[j]);
			//cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	cout << dp[N][M] << endl;
	return 0;
}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll num;
    cin>>num;
    while(num)
    {
        if(num%10==7)
        {
            cout<<"Yes";
            return;
        }
        num/=10;
    }
    cout<<"No";
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3552
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int c = sc.nextInt();
			if(n == 0 && c == 0) break;
			int[][] a = new int[n][16];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < 16; j++) {
					a[i][j] = sc.nextInt();
				}
			}
			int[][] b = new int[c][16];
			for(int i = 0; i < c; i++) {
				for(int j = 0; j < 16; j++) {
					b[i][j] = sc.nextInt();
				}
			}
			int[] ax = new int[n];
			int[] bx = new int[c];
			for(int i = 0; i < n; i++) {
				int tmp = 0;
				for(int j = 0; j < 16; j++) {
					tmp |= a[i][j] << (15 - j);
				}
				ax[i] = tmp;
			}
			for(int i = 0; i < c; i++) {
				int tmp = 0;
				for(int j = 0; j < 16; j++) {
					tmp |= b[i][j] << (15 - j);
				}
				bx[i] = tmp;
			}
			
			
			int[][] dp = new int[n+1][1 << 16];
			for(int i = 0; i < n+1; i++) {
				Arrays.fill(dp[i], -1);
			}
			dp[0][0] = 0;
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < 1 << 16; j++) {
					if(dp[i][j] == -1) continue;
					int to = j | ax[i];
					for(int k = 0; k < c; k++) {
						int cx = to & bx[k];
						int dx = ~cx & to;
						int ret = Integer.bitCount(cx);
						dp[i+1][dx] = Math.max(dp[i+1][dx], dp[i][j] + ret);
					}
				}
			}
			int max = 0;
			for(int i = 0; i < 1<<16; i++) {
				max = Math.max(dp[n][i], max); 
			}
			
			System.out.println(max);
		}
		
	}
	
}

Measured memory_bytes: 63512
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {

	
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
//		int n = s.nextInt();
//		
//		int a[] = new int[n];
//		for(int i=0;i<n;i++)
//			a[i] = s.nextInt();
		
		int n = s.nextInt();
		Pair3 a[] = new Pair3[n];
		
		for(int i=0;i<n;i++) {
			a[i] = new Pair3(s.next(),s.nextInt());
		}
		String k = s.next();
		int sum=0,flag=0;
		for(Pair3 i:a) {
			if(flag==1) {
				sum+=i.ctr;
			}
			if(i.num.compareTo(k)==0) {
				flag=1;
			}
		}
		System.out.println(sum);
		
		
	}
}
class Pair3 {

	String num;
	int ctr;
	Pair3(String a,int b){
		num=a;
		ctr=b;
	}
	
	
}



Measured memory_bytes: 23124
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for (ll &e : A) cin >> e;
    sort(ALL(A));
    A.erase(unique(ALL(A)), A.end());
    cout << (A.size() == N ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn = 205;
int a[maxn];
int main() {
    int n;cin  >> n;
    for (int i = 1; i <= n - 1; ++i) {
        cin >> a[i];
    }
    a[0] = a[n] = INT_MAX;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += min(a[i], a[i - 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
f = list(map(int, input().split()))
q = int(input())
for i in range(q):
    a = list(map(int, input().split()))
    if a in [[f[0], f[1]], [f[1], f[5]], [f[5], f[4]], [f[4], f[0]]]:
        print(f[2])
    elif a in [[f[0], f[2]], [f[2], f[5]], [f[5], f[3]], [f[3], f[0]]]:
        print(f[4])
    elif a in [[f[0], f[4]], [f[4], f[5]], [f[5], f[1]], [f[1], f[0]]]:
        print(f[3])
    elif a in [[f[0], f[3]], [f[3], f[5]], [f[5], f[2]], [f[2], f[0]]]:
        print(f[1])
    elif a in [[f[1], f[2]], [f[2], f[4]], [f[4], f[3]], [f[3], f[1]]]:
        print(f[0])
    elif a in [[f[1], f[3]], [f[3], f[4]], [f[4], f[2]], [f[2], f[1]]]:
        print(f[5])


Measured memory_bytes: 5612
def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    
    rdp_shift = [N + 1] * K  # rdp_shift[j] = (右からi個を使って部分和jを作れるような最初のi)
    rdp_shift[0] = 0
    rdp = [0] * K  # rdp[i][j] = (a(-1),...,a(-i)の部分和でjを作れるか)
    rdp[0] = 1
    for i in range(N):
        rdp2 = [0] * K
        for j in range(K):
            if rdp[j] == 1:
                rdp2[j] = 1
            elif (j >= A[-i] and rdp[j - A[-i]] == 1):
                # print(j - A[i])
                rdp2[j] = 1
                rdp_shift[j] = i
                # print(rdp_shift)
        rdp = rdp2
    # print(rdp_shift)
    ldp = [0] * K  # ldp[i][j] = (a1,...,aiの部分和でjを作れるか)
    ldp[0] = 1
    S = [0] * (K + 1)
    ans = 0
    for i in range(1, N + 1):
        # ここで一つ一つチェックしている！！
        # A[i]が不要かチェック
        for j in range(K):
            S[j + 1] = S[j]
            # print(N - i, rdp_shift[j])
            if rdp_shift[j] <= N - i:
                S[j + 1] += 1
        no_need = True
        for lval in range(K):
            if ldp[lval] == 0:
                continue
            # print(K - A[i] - lval)
            rval = S[K - lval] - S[max(0, K - A[i] - lval)]
            # print(S, K - lval, K - A[i] - lval, rval)
            if rval > 0:
                no_need = False
                break
        if no_need:
            ans += 1

        # ldp[i][:]の計算
        ldp2 = [0] * K
        for j in range(K):
            if ldp[j] == 1 or (j >= A[i] and ldp[j - A[i]] == 1):
                ldp2[j] = 1
        ldp = ldp2
    print(ans)
    # print(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74272
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int md = 1e9 + 7;
const int maxn = 2e5 + 5;
LL fact[maxn], inv[maxn];

LL quick_pow(LL a, LL k){
    LL ans = 1;
    while(k){
        if(k & 1) ans = ans * a % md;
        a = a * a % md;
        k >>= 1;
    }
    return ans;
}

void init(){
    fact[0] = inv[0] = 1;
    for(int i = 1; i < maxn; i++){
        fact[i] = fact[i - 1] * i % md;
        inv[i] = inv[i - 1] * quick_pow(i, md - 2) % md;
    }
}

LL C(int n, int m){
    return fact[n] * inv[m] % md * inv[n - m] % md;
}

LL path(int x1, int y1, int x2, int y2){
    return C(x2 + y2 - x1 - y1, x2 - x1);
}

int main(){
    init();
    int H, W, A, B;
    scanf("%d%d%d%d", &H, &W, &A, &B);
    LL ans = 0;
    for(int i = 1; i < H - A; i++){
        if(B + 2 <= W){
            ans += path(1, 1, i, B + 1) * path(i, B + 2, H, W) % md;
            ans %= md;
        }
    }
    if(B + 1 <= W && A){
        ans += path(1, 1, H - A, B + 1) * path(H - A + 1, B + 1, H, W) % md;
        ans %= md;
    }
    if(B + 2 <= W){
        ans += path(1, 1, H - A, B + 1) * path(H - A, B + 2, H, W) % md;
        ans %= md;
    }
    printf("%lld\n", ans);
    return 0;
}
/*
2 3 1 1
*/


Measured memory_bytes: 3328
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
 
C_A1 = Counter([i + A[i] for i in range(N)])
C_A2 = Counter([i - A[i] for i in range(N)])

count = sum([C_A1[i]*C_A2[i] for i in range(N)])

print(count)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0;i<N;i++) cin >> a[i];
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int tmp = 0;
  int cnt = 0;
  
  for (int i=0; i<N; i++){
    if (tmp != a[i])
      cnt++;
    tmp = a[i];
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include<algorithm>
#include<math.h>
 
using namespace std;
 
int main() {
	int N, K;
	cin >> N >> K;
	if (K >= N)cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;

ll Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];

  REP(i, h) {
    ll cur = 0;
    REP(j, w) {
      if (s[i][j] == '#')
        cur = 0;
      else
        ++cur;
      Left[i][j] = cur;
    }
  }
  REP(i, h) {
    ll cur = 0;
    REPR(j, w - 1) {
      if (s[i][j] == '#')
        cur = 0;
      else
        ++cur;
      Right[i][j] = cur;
    }
  }
  REP(j, w) {
    ll cur = 0;
    REP(i, h) {
      if (s[i][j] == '#')
        cur = 0;
      else
        ++cur;
      Up[i][j] = cur;
    }
  }
  REP(j, w) {
    ll cur = 0;
    REPR(i, h - 1) {
      if (s[i][j] == '#')
        cur = 0;
      else
        ++cur;
      Down[i][j] = cur;
    }
  }
  ll ans = 0;
  REP(i, h) {
    REP(j, w) {
      if (s[i][j] == '#') continue;
      ans = max(ans, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 141568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCraneAndTurtle solver = new BCraneAndTurtle();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCraneAndTurtle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt(), y = in.nextInt();

            int min = x * 2, max = 4 * x;

            if (min <= y && y <= max && y % 2 == 0) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 25560
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;
const int MOD=1e9+7;

int n;
int a[N];
map<int, int> m;

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

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	int diff=n-1;
	while(diff>0)
	{
		if(m[diff]!=2)
		{
			cout<<"0";
			return 0;
		}
		diff-=2;
	}
	if(n%2)
	{
		if(m[0]!=1)
		{
			cout<<"0";
			return 0;
		}
	}
	int ans=pow(2LL, n/2, MOD);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
import Control.Applicative
import Control.Monad

data Dice = Dice {td::(Int,Int),ns::(Int,Int),ew::(Int,Int)} deriving Show
main = do
  d <- (fromList . map read . words) <$> getLine
  n <- read <$> getLine    
  v <- replicateM n ((map read . words) <$> getLine)
  mapM_ (putStrLn . show . solve d) v
  
solve :: Dice -> [Int] -> Int
solve d [t,s] 
  | snd(ns d)  ==s  && (fst (td d))==t  = fst(ew(d))
  | snd(ns d)  ==s = solve (opE d) [t,s] 
  | fst(ew d)  ==s = solve (opS(opW d)) [t,s] 
  | snd(ew d)  ==s = solve (opS(opE d)) [t,s] 
  | otherwise      = solve (opS d) [t,s]
  
fromList :: [Int] -> Dice
fromList [x1,x2,x3,x4,x5,x6] = Dice {td=(x1,x6),ns=(x5,x2),ew=(x3,x4)}
  
trans :: [Char] -> Dice -> Dice
trans [] x = x
trans (x:xs) d = case x of 
  'E' -> trans xs (opE d)
  'W' -> trans xs (opW d)
  'N' -> trans xs (opN d)
  'S' -> trans xs (opS d)

chg :: (Int,Int) -> (Int,Int)
chg (a,b) = (b,a)

opE :: Dice -> Dice
opE d = Dice (chg(ew d)) (ns d) (td d)
opW :: Dice -> Dice
opW d = Dice (ew d) (ns d) (chg(td d))

opN :: Dice -> Dice
opN d = Dice (chg(ns d)) (td d) (ew d)

opS :: Dice -> Dice
opS d = Dice (ns d) (chg(td d)) (ew d)

Measured memory_bytes: 3984
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int A[101];
        rep(i, n){
            cin >> A[i];
        }
        int ans = 0;
        bool flag = true;
        while(flag){
            flag = false;
            for(int j = n - 1; j > 0; j--){
                if(A[j] < A[j - 1]){
                    int num = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = num;
                    ans++;
                    flag = 1;
                }
            }
        }
        rep(i, n){
            if(!i) cout << A[i];
            else cout << ' ' << A[i];
        }
        cout << endl << ans << endl;
    }
}

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


int main(){
  int n,i,k,max,maxid,smax;
  cin >> n;
  vector<int> a(n);
  priority_queue<int> que;
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  max=a[0];
  maxid=0;
  smax=a[0];
  for(i=0;i<n;i++){
    if(max<a[i+1]){
      max=a[i+1];
      maxid=i+1;
    }
  }
  for(i=0;i<n;i++){
    que.push(a[i]);
  }
  que.pop();
  smax=que.top();
  for(i=0;i<n;i++){
    if(i==maxid){
      cout << smax << endl;
    }else{
      cout << max <<endl;
    }
  }
  return 0;
}

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

int main(){
  int N,K,count=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int H;
    cin >> H;
    if(H>=K){
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 305
using namespace std;
int n,m;
int per[N][N],now[N];
int sta[N];
bool test(int v){
	queue<int> th[N];
	memset(sta,0,sizeof(sta));
	for(int i=1;i<=n;i++) now[i]=1;
	for(int i=1;i<=n;i++) th[per[i][now[i]]].push(i);
	while(1){
		int mx=0,chs;
		for(int i=1;i<=m;i++) if(sta[i]!=1&&th[i].size()>mx) mx=th[i].size(),chs=i;
		if(mx<=v) return true;
		sta[chs]=1;
		while(!th[chs].empty()){
			int id=th[chs].front();th[chs].pop();
			while(now[id]+1<=m&&sta[per[id][now[id]]]==1) now[id]++;
			if(sta[per[id][now[id]]]==1) return false;
			th[per[id][now[id]]].push(id);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1,t;j<=m;j++)
			scanf("%d",&per[i][j]);
	int l=0,r=n;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(test(mid)) r=mid;
		else l=mid;
	}
	cout<<r<<endl;
	return 0;
} 

Measured memory_bytes: 864
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N;
	cin>>N;
	vector<ll> a(N);
	rep(i,N){
		cin>>a[i];
	}
	ll mx = -1e18;
	vector<int> ag;
	rep(t,2){
		vector<int> v;
		ll sm = 0;
		for(int i=t;i<N;i+=2){
			if(a[i]>=0){
				sm += a[i];
				v.pb(i);
			}
		}
		if(!v.empty() && mx<sm){
			mx = sm;
			ag = v;
		}
	}
	if(ag.empty()){
		int x = 0;
		rep(i,N) if(mx<a[i]){
			mx = a[i];
			x = i;
		}
		ag = {x};
	}
	cout<<mx<<endl;
	vector<int> op;
	int L = ag.front(), R = ag.back();
	rep(i,N-1-R) op.pb(N-1-i);
	rep(i,L) op.pb(0);
	for(int i=L+2;i<=R;i+=2){
		if(a[i]>=0) op.pb(1);
		else op.pb(2);
	}
	cout<<op.size()<<endl;
	for(int x: op) cout<<x+1<<endl;
}

Measured memory_bytes: 256
def bubbleSort(a, N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                flag = 1
                count += 1
    return a, count

N = int(input())
a = list(map(int, input().split()))
ans, count = bubbleSort(a, N)
print(' '.join(map(str, a)))
print(count)



Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;
const int MAX_N = 200000;
ll s[MAX_N];

vector<int> divs(int n) {
  vector<int> res;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      res.push_back(i);
      if(i != 1 && i * i != n) {
        res.push_back(n / i);
      }
    }
  }
  return res;
}

int main(){
  cin >> N;
  REP(i, N) cin >> s[i];

  ll ans = 0;
  for(int c = 1; c < N - 1; c++) {
    ll dp[(N - 1) / c];
    dp[0] = 0;
    // cout << c << endl;
    REP(k, (N - 1) / c - 1) {
      ll a = N - 1 - (k + 1) * c;
      if(a <= c) break;
      if(a % c == 0 && a / c <= k + 1) break;
      dp[k + 1] = dp[k] + s[a] + s[(k + 1) * c];
      ans = max(ans, dp[k + 1]);

      // cout << dp[k + 1] << ",";
    }
    // cout << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+6;
const int MOD=998244353;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
bool check(ll n){
    if(n%2==0)  return false;
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(n%i==0)  cnt++;
    if(cnt==8)    return true;
    else    return false;
}
ll n;
int main(void){
    scanf("%lld",&n);
    ll ans=0;
    for(int i=1;i<=n;i++)
        if(check(i))    ans++;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

ans = "No"

for i in range(n):
	b = int(input())
	for j in range(3):
		for k in range(3):
			if a[j][k] == b:
				a[j][k] = -1

for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == -1:ans = "Yes"
	if a[0][i] == a[1][i] == a[2][i] == -1:ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == -1:ans = "Yes"
if a[0][2] == a[1][1] == a[0][2] == -1:ans = "Yes"
print(ans)


	


Measured memory_bytes: 3064
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define all(a) (a).begin(),(a).end()
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define N 100005
    #define fs first
    #define sc second
    using namespace std;

    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;
    


    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios;
  ll n,a,b,t,f=0;
cin>>n;
ll x=0,y=0,time=0;
for(int i=0;i<n;i++)
{
    cin>>t>>a>>b;
    ll dis=(abs(a-x)+abs(b-y));
   // cout<<dis<<endl;
    if(dis>t-time)
    f=1;
    else if(dis%2==0 && (t-time)%2==1)
        f=1;
    else if(dis%2==1 && (t-time)%2==0)
        f=1;
    time=t;
    x=a;y=b;
    //cout<<f<<endl;
}

if(f==0)
    cout<<"Yes";
else
    cout<<"No";



    return 0;


    }

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

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

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

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

struct QUERY {
  int l, r, index;
  QUERY(int i, int l, int r) {
    this->index = i;
    this->l = l;
    this->r = r;
  }
};

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

  vector<int> c(n);
  rep(i,n) cin >> c[i];

  vector<QUERY> qs;
  rep(i,q) {
    int l, r;
    cin >> l >> r;
    qs.push_back(QUERY(i,l,r));
  }

  sort(qs.begin(), qs.end(), [](QUERY a, QUERY b){ return a.r < b.r; });

  vector<int> pos(n+1,-1);
  BIT<int> bit(n+1);
  vector<int> ans(q);

  int nowr = 0;
  rep(i,q) {
    for (;nowr < qs[i].r; nowr++) {
      int col = c[nowr];
      if (pos[col] != -1) bit.add(pos[col],-1);
      pos[col] = nowr;
      bit.add(nowr,1);
    }
    ans[qs[i].index] = bit.sum(qs[i].l-1,qs[i].r);
  }

  rep(i,q) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 17352
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<abs(a[1]-a[0])+abs(a[2]-a[1]);

  return 0;
}


Measured memory_bytes: 256
while n = gets.to_i do
  if n == 0 then
    break
  end
  top = 1
  bottom = 6
  tate = [5, 2]
  yoko = [4, 3]
  sum = 1
  n.times do
    opt = gets.chomp

    if opt == "North" then
      tmp = top
      top = tate[1]
      tate[1] = bottom
      bottom = tate[0]
      tate[0] = tmp
    elsif opt == "East" then
      tmp = top
      top = yoko[0]
      yoko[0] = bottom
      bottom = yoko[1]
      yoko[1] = tmp
    elsif opt == "West" then
      tmp = top
      top = yoko[1]
      yoko[1] = bottom
      bottom = yoko[0]
      yoko[0] = tmp
    elsif opt == "South" then
      tmp = top
      top = tate[0]
      tate[0] = bottom
      bottom = tate[1]
      tate[1] = tmp
    elsif opt == "Right" then
      tmp = tate[0]
      tate[0] = yoko[0]
      yoko[0] = tate[1]
      tate[1] = yoko[1]
      yoko[1] = tmp
    elsif opt == "Left" then
      tmp = tate[0]
      tate[0] = yoko[1]
      yoko[1] = tate[1]
      tate[1] = yoko[0]
      yoko[0] = tmp
    end
    sum += top
  end
  puts sum
end

Measured memory_bytes: 6108
class UnionFind
  def initialize(n)
    @n = n
    @par = Array.new(@n)
    @chl = Hash.new{|h, k| h[k] = []}
    @par.map!.with_index{|x, i| @chl[i]; i}
  end
  def union(a, b)
    pa, pb = [@par[a], @par[b]]
    if pa < pb then
      absorb(a, b)
    elsif pa > pb then
      absorb(b, a)
    end
  end
  def each_group(&b)
    @chl.each{|k, v| b.call(k, v)}
  end
  
  private
  
  def absorb(pa, ch)
    par = @par[pa]
    chl = @par[ch]
    @chl[chl].each{|c|
      @chl[par] << c
      @par[c] = par
    }
    @chl.delete(chl)
    @chl[par] << chl
    @par[chl] = par
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
P = gets.chomp.split(" ").map(&:to_i)
U = UnionFind.new(N+1)
M.times{|i|
  x, y = gets.chomp.split(" ").map(&:to_i)
  U.union(x, y)
}

ans = 0
U.each_group{|k, v|
  v << k
  num = v.map{|pos| P[pos-1]}
  ans += (v & num).size
}

puts ans


Measured memory_bytes: 30972
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

max_cand = m//n

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


divs = make_divisors(m)
divs.sort()

from bisect import bisect_right

index = bisect_right(divs, max_cand)

print(divs[index-1])


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

int main() {
  int N; 
  cin >> N;
  int po = 1, pon = 1, Nco = N, Har = 0;
  while (pon < N){
    po++;
    pon *= 10;
  }
  for (int i = 0; i < po; i++){
    Har += Nco / pon;
    Nco %= pon;
    pon /= 10;
  }
  if (N % Har == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;    
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

ll mod=998244353;
ull pow_mod(ull x,ull y)
{
    x%=mod;
    return(
        y==0?1
        :y%2==0?pow_mod(x*x%mod,y/2)
        :x*pow_mod(x,y-1)
    )%mod;
}
int main()
{
    ll n=in();
    vector<ll>d(n),dcnt(n,0);
    for(ll i=0;i<n;++i){
        ++dcnt[d[i]=in()];
    }
    if(d[0]!=0||count(d.begin(),d.end(),0)!=1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;--n;
    for(ll i=1;n;++i){
        ans*=pow_mod(dcnt[i-1],dcnt[i]);ans%=mod;
        n-=dcnt[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(void)
{
    int H;
  	int A;
  	int count=0;
    // 整数の入力
    scanf("%d %d\n",&H,&A);
   	while(H>0){
    	H=H-A;
      	count++;
    }
      printf("%d\n",count);
  
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src_, int dst_, Weight weight_) :
		src(src_), dst(dst_), weight(weight_) { }
	Edge(int src_, int dst_) :
		src(src_), dst(dst_) {

	}
};
pair<bool, vector<Weight>> spfa(const int v_num, const vector<vector<Edge>>&es, const int start) {
	vector<Weight>diss(v_num, INT_MAX);
	queue<int>que;
	vector<bool>use(v_num);
	vector<int>count(v_num);
	que.emplace(start);
	diss[start] = 0;
	while (!que.empty()) {
		int src(que.front());
		que.pop();
		use[src] = false;
		for (auto e : es[src]) {
			const int d = e.dst;
			if (diss[src] + e.weight < diss[d]) {
				diss[d] = diss[src] + e.weight;
				if (!use[d]) {
					use[d] = true;
					count[d]++;
					if (count[d] >= v_num)return make_pair(false, vector<Weight>());
					que.emplace(d);
				}
			}
		}
	}
	return make_pair(true, diss);
}

int main() {
	int N, M; cin >> N >> M;
	vector<vector<Edge>>es(N);
	for (int i = 0; i < M; ++i) {
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		a--; b--;
		es[a].push_back(Edge(a, b, c));
		es[b].push_back(Edge(b, a, d));
	}
	int s, g, V, P;
	scanf("%d,%d,%d,%d", &s, &g, &V, &P);
	s--; g--;
	auto p1 = spfa(N, es, s);
	auto p2 = spfa(N, es, g);
	cout << V - P - p1.second[g] - p2.second[s] << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
//左から順に検索し、R->Lの並びで無いところは違う文字までの距離を算出
//その距離の偶奇で境界のどちらにとどまるかが決まる。
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string S;
cin>>S;
int N=S.length();
int member[N]={0};
int old_R=0;
int old_L=0;
int L_Pos=0;
for(int i=0;i<N;i++){
    if(S[i]=='R' && S[i+1]=='R'){
        if(old_R==i-1){
            L_Pos=old_L;
        }
        else{
            L_Pos=(int)S.find("L", i);
        }

        if((L_Pos-i)%2==0){
            member[L_Pos]+=1;
            }
        else{
            member[L_Pos-1]+=1;
        }
        old_R=i;
        old_L=L_Pos;
        // for(int j=i+2;j<N;j++){
        //     if(S[j]=='L'){
        //         if((j-i)%2==0){
        //             member[j]+=1;
        //         }
        //         else{
        //             member[j-1]+=1;
        //         }
        //         break;
        //     }
        // }
    }
    else if(S[i]=='L' && S[i-1]=='L'){
        if((i-old_R)%2==0){
                member[old_R]+=1;
        }
        else{
                member[old_R+1]+=1;
        }
    }
    else if(S[i]=='R' && S[i+1]=='L'){
        member[i]+=1;
        member[i+1]+=1;
        old_R=i;
    }
}

for(int i=0;i<N;i++){
    cout<<member[i]<<' ';
}
cout<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 1104