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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, q, l, r;
  string s;
  cin >> n >> q >> s;
  vecll a(n-1, 0);

  forll(i, 0, n-1){
	if (s[i] == 'A' && s[i+1] == 'C')
	  a[i] = 1;
  }
  forll(i, 1, n-1)
	a[i] = a[i - 1] + a[i];
  
  forll (i, 0, q){
	cin >> l >> r;
	if (l == 1)
	  cout << a[r-2] << endl;
	else
	  cout << a[r-2] - a[l-2] << endl;
  }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int main(){
    int a,b;
    scanf("%d%d", &a, &b);
    if(a < b) printf("a < b\n");
    else if(a > b) printf("a > b\n");
    else printf("a == b\n");
    
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int s;
    cin>>s;
    if(s==1){
        cout<<"Hello World"<<endl;
        return 0;
    }
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 384
import numpy as np
n=int(input())
l=list(map(int,input().split()))

arr=np.sort(np.array(l))
med=np.median(arr)

med_max=int(np.median(np.delete(arr,0)))
med_min=int(np.median(np.delete(arr,n-1)))


p=(n+1)//2
for i in range(n):
    if l[i]<=arr[p-1]:
        print(med_max)
    else:
        print(med_min)

Measured memory_bytes: 34176
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def check(x, N, M, V, P, A):
    if (N - x) <= P:
        return True

    if V <= x + P:
        return (A[x] + M) >= A[N-P]

    x_score = A[x] + M
    total_v = (V - x - P) * M
    show('x =', x, 'A[x] =', A[x], 'x_score =', x_score, 'total_v =', total_v)

    if A[N-P] > x_score:
        return False

    for i in range(x+1, N-P+1):
        show('i = ', i, 'A[i] =', A[i], 'total_v =', total_v,
             '(x_score - A[i]) =', (x_score - A[i]))
        total_v -= min(M, (x_score - A[i]))

    show('total_v =', total_v)
    if total_v <= 0:
        return True
    else:
        return False


def check_(x, N, M, V, P, A):
    if (N-x) <= P:
        return True
    if(V <= x+P):
        return(A[x]+M >= A[N-P])

    x_score = A[x]+M
    total_v = (V-x-P)*M

    if(A[N-P] > x_score):
        return False

    for i in range(x+1, N-P+1):
        total_v -= min(M, (x_score - A[i]))
    if total_v <= 0:
        return True
    else:
        return False


def main():
    N, M, V, P = MI()
    A = LI()
    A.sort()

    if(check(0, N, M, V, P, A)):
        print(N)
        return

    isOK = N-1
    isNG = 0
    while(isOK-isNG > 1):
        middle = (isOK+isNG)//2
        if(check(middle, N, M, V, P, A)):
            isOK = middle
        else:
            isNG = middle
    print(N-isOK)
    return
    # A = sorted(A)
    # show('N =', N, 'M =', M, 'V =', V, 'P =', P)
    # show(A)

    # l = 0
    # r = N - 1
    # while r-l > 1:
    #     mid = (l+r) // 2
    #     # print('brefore l =', l, 'mid =', mid, 'r =', r, 'A[mid] =', A[mid])
    #     if check_(mid, N, M, V, P, A):
    #         r = mid
    #     else:
    #         l = mid
    #     # print('after l =', l, 'mid =', mid, 'r =', r, 'A[mid] =', A[mid])
    # print(N - r)


if __name__ == '__main__':
    main()


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

void Main() {
    // input
    u_int32_t H, A;
    cin >> H >> A;


    // process
    u_int32_t count = 0;
    count = H / A;
    if (H % A != 0) {
        count++;
    }

    // output
    cout << count << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define ll long long

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

    int n, m;
    cin >> n >> m;
    unordered_map<int, int> umap;

    for (int i = 0; i < n; ++i){
        int k;
        cin >> k;
        for (int i = 0; i < k; ++i){
            int x;
            cin >> x;
            umap[x]++;
        }
    }

    int count = 0;
    for (auto x:umap){
        if (x.second == n)count++;
    }
    cout << count << endl;



    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    ArrayList<Integer> ar = new ArrayList<>();
    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0)
        ar.add(i);
    }
    System.out.println(ar.get(ar.size() - K));
  }
}

Measured memory_bytes: 23252
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define PRINT
#define LCERR
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:
    vector<int> exception_handling(vector<int>& nums) {
        int max1 = numeric_limits<int>::min();
        int max2 = numeric_limits<int>::min();
        for (size_t i = 0; i < nums.size(); ++i) {
            if (nums[i] >= max1) {
                max2 = max1;
                max1 = nums[i];
            } else if (nums[i] > max2) {
                max2 = nums[i];
            }
        }
        vector<int> result;
        for (size_t i = 0; i < nums.size(); ++i) {
            if (nums[i] == max1) {
                result.emplace_back(max2);
            } else {
                result.emplace_back(max1);
            }
        }
        return result;
    }
};

int solve() {
    Solution solution;
    // handle IO here
    int N;
    cin >> N;
    vector<int> nums(N);
    for (int i = 0; i < N; ++i) {
        cin >> nums[i];
    }
    auto result = solution.exception_handling(nums);
    for (auto n : result) {
        cout << n << endl;
    }
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll K, N; cin >> K >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  ll result = K;
  rep(i,N-1) result = min(result,K-(A[i+1]-A[i]));
  result = min(result,K-(A[0]+K-A[N-1]));
  cout << result << endl;
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    auto getPositions = [&]() {
        vector<int> res;
        for (int i = 0; i < n && res.size() < k;) {
            if (s[i] == 'o') {
                res.push_back(i);
                i += c + 1;
            } else {
                ++i;
            }
        }
        return res;
    };

    vector<int> l, r;
    l = getPositions();
    reverse(s.begin(), s.end()); // 右から詰めるために
    r = getPositions();
    rep(i, k) r[i] = n - 1 - r[i]; // 左からの位置で表す
    reverse(s.begin(), s.end()); // 元に戻す

    vector<int> lastL(n + 1, -1); // 番兵を入れている
    rep(i, k) lastL[l[i] + 1] = i;
    rep(i, n)
    {
        if (lastL[i + 1] == -1)
            lastL[i + 1] = lastL[i];
    }
    vector<int> lastR(n + 1, -1);
    rep(i, k) lastR[r[i]] = i;
    for (int i = n - 1; i >= 0; i--) {
        if (lastR[i] == -1)
            lastR[i] = lastR[i + 1];
    }

    rep(i, n) // i番目を使っちゃダメ
    {
        if (s[i] == 'x')
            continue;
        int li = lastL[i];
        int ri = lastR[i + 1];
        int cnt = 0;
        if (li != -1)
            cnt += li + 1;
        if (ri != -1)
            cnt += ri + 1;
        if (li != -1 && ri != -1 && r[ri] - l[li] <= c) {
            --cnt;
        }
        if (cnt >= k)
            continue;
        printf("%d\n", i + 1);
    }
    return 0;
}

Measured memory_bytes: 6556
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if(b.equals ("A")) {
			System.out.println('T');
		} else if(b.equals("C")) {
			System.out.println("G");
		} else if(b.equals("T")) {
			System.out.println("A");
		} else {
			System.out.println("C");
		}
	}
}

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

typedef long long ll;

int k, x;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> k >> x;
    int l = x - k + 1;
    int r = x + k - 1;
    for (int i = l; i <= r; ++i) {
        cout << i << ' ';
    }
    cout << endl;

    return 0;
}



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

const int MAXN = 1e5 + 10;
const int INF = 2*1e9;

int dp[MAXN],N,K,h[MAXN];

int main(){

	scanf("%d",&N);
	K = 2;
	for(int i = 1;i<=N;i++){
		scanf("%d",&h[i]);
	}

	for(int i = 2;i<=N;i++){
		dp[i] = INF;
		for(int j = i-1;j>=max(i - K,1);j--){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]) );
		}
	}

	printf("%d\n",dp[N]);

	return 0;

}

Measured memory_bytes: 1024
import scala.io.StdIn._

object Main extends App {
  val s = readLine()
  val len = s.length

  var min = len

  for (i <- 1 until len) {
    if (s(i - 1) != s(i)) {
      min = math.min(min, math.max(i, len - i))
    }
  }

  println(min)
}


Measured memory_bytes: 29036
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <climits>

using namespace std;
struct Koma {
	int x1, y1, x2, y2;
};

vector<Koma> page;

vector<int> recur(const vector<int> &remains){
	vector<int> result;
	if(remains.size() <= 1){ return remains; }
	int first = remains[0];
//	cerr << "> " << first << endl;
	for(int i = 1; i < remains.size(); ++i){
		if(page[remains[i]].x1 < page[first].x1){
			first = remains[i];
		}else if(page[remains[i]].x1 == page[first].x1 && page[remains[i]].y1 < page[first].y1){
			first = remains[i];
		}
	}
	result.push_back(first);
	int x = INT_MAX;
	for(int i = 0; i < remains.size(); ++i){
		if(remains[i] == first){ continue; }
		if(page[remains[i]].x1 > page[first].x2){ continue; }
		if(page[remains[i]].y1 < page[first].y2 && page[first].y2 < page[remains[i]].y2){
			x = min(x, page[remains[i]].x1);
		}
	}
//	cerr << "x: " << x << " | " << first << endl;
	vector<int> a, b;
	for(int i = 0; i < remains.size(); ++i){
		if(remains[i] == first){ continue; }
		if(page[remains[i]].x2 > x){ b.push_back(remains[i]); continue; }
		if(page[remains[i]].y2 > page[first].y2){ b.push_back(remains[i]); continue; }
		a.push_back(remains[i]);
	}
//	cerr << ">>> ";
//	for(int i = 0; i < a.size(); ++i){ cerr << a[i] << " "; }
//	cerr << endl;
//	cerr << "<<< ";
//	for(int i = 0; i < b.size(); ++i){ cerr << b[i] << " "; }
//	cerr << endl;
	vector<int> ar = recur(a), br = recur(b);
	copy(ar.begin(), ar.end(), back_inserter(result));
	copy(br.begin(), br.end(), back_inserter(result));
	return result;
}

int main(){
	bool first = true;
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		if(!first){ cout << endl; }
		first = false;
		page.clear();
		vector<int> task;
		for(int i = 0; i < n; ++i){
			Koma koma;
			cin >> koma.x1 >> koma.y1 >> koma.x2 >> koma.y2;
			if(koma.x1 > koma.x2){ swap(koma.x1, koma.x2); }
			if(koma.y1 > koma.y2){ swap(koma.y1, koma.y2); }
			page.push_back(koma);
			task.push_back(i);
		}
		vector<int> result = recur(task);
		for(int i = 0; i < n; ++i){
			task[result[i]] = i;
		}
		for(int i = 0; i < n; ++i){
			cout << task[i] + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long a,b,n,x,ans,t;
int main(){
    cin>>n>>x;
    cin>>a;
    if(a>x) ans+=a-x,a=x;
    for(int i=2;i<=n;i++)
    {
    	cin>>b;
    	if(a+b>x)t=a+b-x,ans+=t,
    	b=b-t;
    	a=b;
    	
    }
    cout<<ans;

	return 0;
}


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


int a[4];
int b[4];

int main()
{
    int n,m;
    while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]))
    {
        scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
        int i;
        n=m=0;
        for(i=0;i<4;i++)
        {
            for(int j=0;j<4;j++)
            {
                if(a[i] == b[j] && i==j)
                {
                    n++;
                }
                if(a[i] == b[j] && i!=j)
                {
                    m++;
                }
            }
        }
        cout<<n<<" "<<m<<endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  bool k = false;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 != 0)
      k = true;
  }

  int c = 0;
  while (!k) {
    bool t = true;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
      }
      else {
        t = false;
        break;
      }
    }
    if (t) {
      c++;
    }
    else {
      break;
    }
  }
  cout << c << endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int counter_5, counter_7;
    counter_5 = 0;
    counter_7 = 0;
    if(a == 5)++counter_5;
    else if(a == 7)++counter_7;
    if(b == 5)++counter_5;
    else if(b == 7)++counter_7;
  if(c == 5)++counter_5;
    else if(c == 7)++counter_7;
  
  if((counter_5 == 2)&&(counter_7 == 1))cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin>>n;
    n %= 10;
    if (n == 3)
    	cout<<"bon"<<endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8)
		cout<<"pon"<<endl;
	else
		cout<<"hon"<<endl;

    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        string[] s = Console.ReadLine().Split(' ');

		for (int i = 0; i < n; i++)
		{
            a[i] = int.Parse(s[i]);
        }

        int sum = 0;
        bool flag = true;

        while (flag)
        {
            flag = false;

            for (int i = n - 1; i >= 1; i--)
            {
                if(a[i] < a[i-1])
                {
                    int tmp = a[i - 1];
                    a[i - 1] = a[i];
                    a[i] = tmp;
                    sum++;
                    flag = true;
                }
            }
        }

        for (int i = 0; i < n - 1; i++)
        {
            Console.Write("{0} ", a[i]);
        }

        Console.WriteLine(a[n - 1]);
        Console.WriteLine(sum);


    }
}

Measured memory_bytes: 9232
#include<bits/stdc++.h>
#define inf 1000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int main()
{
    string str;
    cin>>str;
    if(str[2]==str[3] && str[4]==str[5]){
        printf("Yes");
    }
    else
        printf("No");

}


Measured memory_bytes: 256
h,w=map(int,input().split())

if h%3==0:
    d=0
elif w%3==0:
    d=0
else:
    if h>=w:
        h,w=w,h
    d1=h
    d2min=h*w
    for ww in range(1,w):
        h1=h//2
        h2=h-h1
        d2=max(ww*h,(w-ww)*h2)-min(ww*h,(w-ww)*h1)
#        print(d2,max(ww*h,(w-ww)*h2),min(ww*h,(w-ww)*h1))
        d2min=min(d2,d2min)

    for hh in range(1,h):
        w1=w//2
        w2=w-w1
        d2=max(hh*w,(h-hh)*w2)-min(hh*w,(h-hh)*w1)
#        print(d2,max(ww*h,(w-ww)*h2),min(ww*h,(w-ww)*h1))
        d2min=min(d2,d2min)

    d=min(d1,d2min)
print(d)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 200005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
struct row
{
	int c,flag;
}r[MAXN];
int n,m;
int a[4][MAXN],t[2],c[MAXN];
inline void hult()
{
	printf("No\n");
	exit(0);
}
inline void op(int i)
{
	if(i<1)
	hult();
	swap(r[i],r[i+2]);
	r[i].flag^=1;
	r[i+1].flag^=1;
	r[i+2].flag^=1;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	a[1][i]=read();
	for(int i=1;i<=n;i++)
	a[2][i]=read();
	for(int i=1;i<=n;i++)
	a[3][i]=read();
	for(int i=1;i<=n;i++)
	{
		int b[3]={a[1][i],a[2][i],a[3][i]};
		sort(b,b+3);
		if(b[2]%3||b[1]!=b[2]-1||b[0]!=b[1]-1)
		hult();
		if(a[2][i]!=b[1])
		hult();
		r[i].c=b[2]/3;
		r[i].flag=b[2]==a[3][i];
		c[i]=r[i].c;
		if(abs(r[i].c-i)&1)
		hult();
		t[i&1]^=b[2]==a[1][i];
	}
    for(res i=1;i<=n;i++)
	{
        while(c[i]!=i)
		{
            t[i&1^1]^=1;
            swap(c[i],c[c[i]]);
        }
    }
    puts(t[0]||t[1]?"No":"Yes");
	return 0;
}

Measured memory_bytes: 3712
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;


int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    sort(a.rbegin(),a.rend());
    if(4*m*a[m-1]>=sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
} 

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


def bubbleSort(A,N):
    flag=1
    num=0
    i=0
    while flag:
        flag=0
        j=0
        for i in range(N-j-1):
            if A[i] > A[i+1]:
                tmp=A[i]
                A[i]=A[i+1]
                A[i+1]=tmp
                flag=1
                num += 1
        j += 1
    return A,num

(A,N)=bubbleSort(A,N)
print(*A)
print(N)






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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

/*
 * 縦も横も回分 <=> 180度回転しても同じ
 * abcdcba
 * efghgfe
 * abcdcba
 * こんな感じの対象な文字列になり、サイズ1,2,4のグループに分けられることがわかる
 */

int h, w, a[26], g1, g2, g4;
string s;
bool ok = true;

signed main() {
	cin >> h >> w;
	rep(i,h) {
		cin >> s;
		rep(j,w) a[s[j]-'a']++;
	}
	rep(i,26) g1 += a[i]%2, g2 += a[i]/2, g4 += a[i]/4;
	if ((h/2)*(w/2) && g4 != (h/2)*(w/2)) ok = false;
	if (g2 != (w*h)/2) ok = false;
	if (g1 != (w%2)*(h%2)) ok = false;
	if (ok) cout << "Yes" << ln;
	else cout << "No" << ln;
}

Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let mut s: Vec<Vec<char>> = vec![];
    let (h, w) = (line[0], line[1]);
    for i in 0..h{
        s.push(read_as_string().chars().collect::<Vec<char>>());
    }

    let mut ans: Vec<Vec<u64>> = vec![vec![0;w+2];h+2];

    for i in 0..h{
        for j in 0..w{
            if s[i][j] == '#'{
                ans[i+1][j+1] = 10;
                for hi in i..i+3{
                    for wi in j..j+3{
                        ans[hi][wi] += 1;
                    }
                }
            }
        }
    }


    for i in 1..h+1{
        for j in 1..w+1{
            if ans[i][j] >= 10{
                print!("#");
            }else{
                print!("{}", ans[i][j]);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll x,y;
ll solve(){
   ll ans=0;
   while(x<=y){
      ans++;
      x*=2;
   }

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

    cin>>x>>y;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    int pos = 0;
    if (x == W/2 and y == H/2){
        pos = 1;
    }

    double ans = W*H/2;

    cout << fixed << setprecision(15) << ans << " " ;
    cout << pos << endl;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
multiset<ll> s;
int main(){
    cin>>n;
    while(n--)cin>>a,s.insert(a);
    while(s.size()){
        a=*s.rbegin();
        s.erase(s.find(a));
        ll p=1;
        while(p<=a)p*=2;
        if(s.find(p-a)!=s.end())s.erase(s.find(p-a)),b++;
    }
    cout<<b<<'\n';
}

Measured memory_bytes: 12984
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int m,n;
int main(){
    cin>>m>>n;
    if(n==1)
        cout<<0<<endl;
    else
        cout<<m-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

int main() {
    int N; cin >> N;
    int H,W; cin >> H >> W;
    int cnt = 0;
    REP(i,N) {
        int a,b; 
        cin >> a >> b;
        if(a >= H && b >= W) cnt++;
    }
    cout << cnt << endl;
}

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

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

using ll = long long;

using namespace std;

struct UnionFind {
	vector<int> d;
	UnionFind(int n = 0) : d(n, -1) {}
	int find(int x) {
		if (d[x] < 0)return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};


const int MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;

	UnionFind uf(n);

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		uf.unite(--a, --b);
	}

	int ans = 0;
	rep(i, n) {
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
	return 0;
}






Measured memory_bytes: 3980
let () = Scanf.scanf "%s" @@ fun s ->
  let ary = Array.init (String.length s) @@
    fun i -> String.get s i in
  let () = Array.sort compare ary in
  let ans = if ary.(0) = ary.(1) && ary.(1) <> ary.(2) && ary.(2) = ary.(3) then "Yes" else "No" in
  Printf.printf "%s\n" ans

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

using namespace std;

int main() {
   string S;
   while (cin >> S) {
   while (S.size() >= 2 && S.back() == 'i' && S[S.size() - 2] == 'h') {
      S.pop_back();
      S.pop_back();
   }
   cout << ((S.empty() ? "Yes\n" : "No\n"));
   }
}


Measured memory_bytes: 256
import math

def is_prime(X):
    if X <= 1 :
        return False
    for k in range(2, int(math.sqrt(X)) + 1):
        if X % k == 0:
            return False
    return True

X = int(input())

p = X
while is_prime(p) == False:
    p += 1

print(p)

Measured memory_bytes: 2940
n,k = map(int,input().split())
P = list(map(int,input().split()))

P = [(v+1)/2 for v in P]

acum = [0]*(n+1)
for i in range(n):
  acum[i+1] = acum[i] + P[i]
  
total = [0]*(n-k+1)
for i in range(n-k+1):
  total[i] = acum[i+k]-acum[i]  
  
print(max(total))  

Measured memory_bytes: 24804
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, sum = 0;
	ll v[200020];
	cin >> n;
	v[0] = 0;
	for (int i = 0;i < n;i++) {
		ll a;
		cin >> a;
		sum += a;
		v[i + 1] = a + v[i];
	}
	ll maxx = 10000000000;
	for (int i = 1;i < n;i++) {
		maxx = min(abs(sum - v[i] - v[i]), maxx);
	}
	cout << maxx << endl;
}

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


int main(){
    ll n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<ll> ac(n);
    for(ll i = 0; i < n - 1; i++) if(s.substr(i, 2) == "AC") ac[i + 1] = 1;
    for(ll i = 0; i < n - 1; i++) ac[i + 1] += ac[i];
    for(ll i = 0; i < q; i++){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        cout << ac[b] - ac[a] << endl;
    }
}


Measured memory_bytes: 1792
Q, H, S, D = map(int, input().split())
N = int(input())
x = N % 2
y = N // 2
arr = [4*Q*x, 2*H*x, S*x]
arr1 = [8*Q*y, 4*H*y, 2*S*y, D*y]
#if N % 2 == 0:
#  arr.append(int(0.5*D*N))
#else:
#  arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
   
print(min(arr) + min(arr1))

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=b&&a>=c&&b>=c)
    {
        cout<<(a*10)+b+c;
    }
    else if(a>=b&&a>=c&&c>=b)
    {
        cout<<(a*10)+b+c;
    }
    else if(b>=a&&b>=c&&a>=c)
    {
        cout<<b*10+a+c;
    }
    else if(b>=a&&b>=c&&c>=a)
    {
        cout<<b*10+a+c;
    }
    else if(c>=b&&c>=a&&a>=b)
    {
        cout<<c*10+b+a;
    }
    else if(c>=b&&c>=a&&b>=a)
    {
        cout<<c*10+b+a;
    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ans;

signed main(){
	
	int a;
	string s;
	cin>>a>>s;
	if(a>=3200)cout<<s<<endl;
	else cout<<"red"<<endl;
	
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    int a, b;
    cin >> h >> w >> a >> b;
    cout << (h - a) * (w - b) << endl;
    return 0;
}


Measured memory_bytes: 256
/*
g++ -std=c++14 -o2 -Wall ABC.cpp -o .\ABC.out
.\ABC.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll a[200010];
ll b[200010];

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  int c;
  for (int i=0; i<n; ++i) {
    cin >> c;
    a[i+1]=a[i]+c;
  }
  for (int i=0; i<m; ++i) {
    cin >> c;
    b[i+1]=b[i]+c;
  }
  int ans=0;
  int jp=m;
  for (int i=0; i<=n; ++i) {
    if(a[i] > k) break;
      for (int j=jp; j>=0; --j) {
        if (a[i]+b[j]<=k) {
          ans=max(ans,i+j);
          jp=j;
          break;
        }
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6724
N, M = [int(_) for _ in input().split()]
INF = 10 ** 10
costs = [[INF] * 101 for _ in range(101)]

for i in range(N + 1):
    costs[i][i] = 0
paths = []
for i in range(M):
    a, b, c = [int(_) for _ in input().split()]
    costs[a][b] = c
    costs[b][a] = c
    paths.append((a, b, c))

for k in range(N + 1):
    for i in range(N + 1):
        for j in range(N + 1):
            costs[i][j] = min(costs[i][j], costs[i][k] + costs[j][k])
            costs[j][i] = costs[i][j]

for i in range(1, N + 1):
    paths2 = paths.copy()
    for p in paths:
        # 点i から 経路p をつかってp[1]への経路をもつかチェック
        if costs[i][p[0]] >= INF or costs[i][p[1]] >= INF: continue
        if costs[i][p[0]] + p[2] == costs[i][p[1]]:
            paths2.remove(p)
    paths = paths2
print(len(paths))

Measured memory_bytes: 3316
N=int(input())
A=list(map(int,input().split()))
B=[0]*(N+1)
for i in range(N):
  B[i+1]=B[i]+A[i]

dp=[[0]*(N+1) for i in range(N)]
#k:いくつのスライムを合体しているか
for k in range(2,N+1):
  #i:どこのスライムを起点に合体しているか
  for i in range(N-k+1):
    dp[i][k]=min(dp[i][j]+dp[i+j][k-j] for j in range(1,k))+B[i+k]-B[i]
print(dp[0][N])

Measured memory_bytes: 43612
#include<stdio.h>

int main(){
    int x;
    scanf("%d", &x);
    int f=0;
    for(int i=0; i<=1000; i++){
        int buf = x - 100*i;
        if(buf < 0){
            break;
        }
        if(buf <= 5*i){
            f=1;
            break;
        }
    }
    if(f){
        printf("1");
    }else{
        printf("0");
    }

    return 0;
}

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

using namespace std;

const int N = 4069;
const int M = 200010;
const int SHIFT = 2005;
const int MOD = 1e9 + 7;

int n, a[M], b[M], dp[N][N], fac[N << 1], inv[N << 1], dest[N][N];

int call (int x, int y) {
  if (x == N or y == N) return 0;
  if (~dp[x][y]) return dp[x][y];
  dp[x][y] = call(x + 1, y) + call(x, y + 1);
  if (dp[x][y] >= MOD) dp[x][y] -= MOD;
  dp[x][y] += dest[x][y];
  if (dp[x][y] >= MOD) dp[x][y] -= MOD;
  return dp[x][y];
}

int bigMod (int a, int e) {
  if (e == -1) e = MOD - 2;
  int ret = 1;
  while (e) {
    if (e & 1) ret = (long long) ret * a % MOD;
    a = (long long) a * a % MOD, e >>= 1;
  }
  return ret;
}

inline int comb (int x, int y) {
  return (long long) inv[x] * inv[y] % MOD * fac[x + y] % MOD;
}

int main() {
  fac[0] = 1;
  for (int i = 1; i < N << 1; ++i) {
    fac[i] = (long long) i * fac[i - 1] % MOD;
    inv[i] = bigMod(fac[i], -1);
  }
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", a + i, b + i);
    ++dest[SHIFT + a[i]][SHIFT + b[i]];
  }
  memset(dp, -1, sizeof dp);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += call(SHIFT - a[i], SHIFT - b[i]);
    if (ans >= MOD) ans -= MOD;
  }
  for (int i = 1; i <= n; ++i) {
    int cur = comb(a[i] << 1, b[i] << 1);
    ans -= cur; if (ans < 0) ans += MOD;
  }
  if (ans & 1) ans += MOD; ans >>= 1;
  cout << ans % MOD << '\n';
  return 0;
}



Measured memory_bytes: 93516
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t="";
	cin>>s;
	bool flag =0;
	if(s.length()<5)
		flag = 1;
	for(int i = 0;i<s.length(); i+=5)
	{
		t = s.substr(i,5);
		if(t=="dream")
		{
			if(i+5+1<s.length())
				if(s[i+5]=='e' && s[i+6]=='r')
				{
					if(i+7<s.length())
					{
						if(s[i+7]!='a')
							i+=2;
					}
					else
						i+=2;
				}

		}

		else if(t == "erase")
		{
			if(i+5<s.length())
				if(s[i+5]=='r')
					i++;
		}
		else
		{
			flag = 1;
			break;
		}
	}
	if(flag) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct LazySegTree{
    int n; vector<int> dat,lazy;
    //初期化
    LazySegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<int>(2*n-1,0);
        lazy=vector<int>(2*n-1,0);
    }

    void setLazy(int k, int v){
        lazy[k] = v;
        dat[k] = v;
    }

    void push(int k, int l, int r){
        if(lazy[k]!=0){
            setLazy(2*k+1,lazy[k]);
            setLazy(2*k+2,lazy[k]);
        }
        lazy[k]=0;
    }

    void fix(int k, int l, int r){
        dat[k] = dat[2*k+1]&dat[2*k+2];
    }

    ll merge(ll x, ll y){
        return x&y;
    }

    //内部的に投げられるクエリ
    void _update(int a, int b, ll x, int k, int l, int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            setLazy(k,x);
            return;
        }

        push(k,l,r);
        _update(a,b,x,2*k+1,l,(l+r)/2);
        _update(a,b,x,2*k+2,(l+r)/2,r);

        fix(k,l,r);
    }
    //[a,b)をxに更新
    void update(int a, int b, ll x){
        return _update(a,b,x,0,0,n);
    }

    //内部的に投げられるクエリ
    int _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return 1;
        if(a<=l && r<=b) return dat[k];

        push(k,l,r);
        int vl=_query(a,b,2*k+1,l,(l+r)/2);
        int vr=_query(a,b,2*k+2,(l+r)/2,r);
        return merge(vl,vr);
    }
    //[a,b)
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

const int N = 200000;
vector<int> C[N],Q[N];

int main(){
    int n,m,q;
    scanf(" %d %d %d", &n, &m, &q);

    vector<int> d(m),a(m),b(m);
    rep(i,m) scanf(" %d %d %d", &d[i], &a[i], &b[i]);

    vector<int> e(q),s(q),t(q);
    rep(i,q) scanf(" %d %d %d", &e[i], &s[i], &t[i]);

    vector<int> v;
    rep(i,m) v.pb(d[i]);
    rep(i,q) v.pb(e[i]);
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    rep(i,m){
        int idx = lower_bound(all(v), d[i])-v.begin();
        C[idx].pb(i);
    }
    rep(i,q){
        int idx = lower_bound(all(v), e[i])-v.begin();
        Q[idx].pb(i);
    }

    LazySegTree st(n+1);
    vector<bool> ans(q);
    rep(i,v.size()){
        for(const auto &ID:Q[i]) ans[ID] = st.query(s[ID], t[ID]);
        for(const auto &ID:C[i]) st.update(a[ID], b[ID], 1);
    }
    rep(i,q) printf("%s\n", (ans[i]?"Yes":"No"));
    return 0;
}



Measured memory_bytes: 23812
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
int tc;
const int N=3e5+5,M=3e5+5,MOD=1e9+7,OO=1e9;
int memo[3005][3005];
int n,T;
pair<int,int>a[3005];
int solve(int indx,int curr){
	if(curr>=T || indx==n)return 0;
	int &ret = memo[indx][curr];
	if(~ret)return ret;
	ret = max(solve(indx+1,curr+a[indx].first)+a[indx].second,solve(indx+1,curr));
	return ret;
}
int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 //	file();
 	
 	scanf("%d %d",&n,&T);
 	for(int i=0;i<n;i++)scanf("%d %d",&a[i].first,&a[i].second);
 	sort(a,a+n);
 	int ans = 0;
 	for(int i=0;i<10;i++){
 		memset(memo,-1,sizeof(memo));
 		ans = max(ans,solve(0,0));
 		random_shuffle(a,a+n);
 	}
 	printf("%d\n",ans);
}


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

using namespace std;

const int N = 2e3 + 5;

int e[N][N], ans[N];

int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			e[j][i] = e[i][j] = j - i;
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			e[i][j] = e[j][i] = min(e[i][x] + e[y][j] + 1, e[i][j]);
		}
	}
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			ans[e[i][j]]++;
	for (int i = 1; i < n; ++i)
		cout << ans[i] << endl;
	
	return  0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    std::cout << std::fixed << std::setprecision(10);
    int n; std::cin >> n;
    double ans;
    for(int i=0; i<n; i++)
    {
        double temp;
        std::cin >> temp;
        ans += 1/temp;
    }
    std::cout << 1/ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll l,r,min=inf;
	cin>>l>>r;
	if(r-l+1>=2019)
	{
		cout<<0<<endl;
	}
	else
	{
		for(ll i=l;i<=r;i++)
		{
			for(ll j=i+1;j<=r;j++)
			{
				if(min>(i*j)%2019)
					min=(i*j)%2019;
			}
		}
		cout<<min<<endl;
	}
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

int W=0;//	長方形の横の長さ
int H=0;//長方形の縦の長さ
int N=0;//範囲をとる個数

int x[100];
int y[100];
int a[100];//切る方向

int xs=0;
int xg=0;
int ys=0;
int yg=0;

int ans=0;

cin>>W>>H>>N;

int i=0;
int c=0;

int ok=0;

for(i=0;i<N;i++){
	cin>>x[i]>>y[i]>>a[i];
}

xg=W;
yg=H;

for(i=0;i<N;i++){
	if(a[i]==1){
		if(xs<x[i])xs=x[i];
	}
	if(a[i]==2){
		if(xg>x[i])xg=x[i];
	}
	if(a[i]==4){
		if(yg>y[i])yg=y[i];
	}			
	if(a[i]==3){
		if(ys<y[i])ys=y[i];
	}		
	
}
ok=1;
if(xg-xs<=0)ok=0;
if(yg-ys<=0)ok=0;

ans=(xg-xs)*(yg-ys);

if(ok==0){
	cout<<0;
}else{
	cout<<ans;
}




}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<>();
        
        
        for(int i=0; i<n; i++){
            String s = sc.next();
            set.add(s);
        }
        
        System.out.println(set.size());
    }
}

Measured memory_bytes: 78488
import java.util.*;
 
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int x = sc.nextInt();
   int grade = 0;
   
   if(x >= 400 && x <= 599){
    grade = 8;
   }else if(x >= 600 && x <= 799){
    grade = 7;
   }else if(x >= 800 && x <= 999){
    grade = 6;
   }else if(x >= 1000 && x <= 1199){
    grade = 5;
   }else if(x >= 1200 && x <= 1399){
    grade = 4;
   }else if(x >= 1400 && x <= 1599){
    grade =3;
   }else if(x >= 1600 && x <= 1799){
    grade = 2;
   }else if(x >= 1800 && x <= 1999){
   grade = 1;
   }
   
   System.out.println(grade);  
   
   
  }
 }

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


  
int main(){
  int n,m,answer;
  cin >> n >> m;
  if(n+1 >= m){
    answer = n;
    n--;
    if(n >= m)
      answer += n;
      else
        answer += m;
    
  }
  else
    answer = 2 * m - 1;
  cout << answer << endl;
      }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	int n, a, b, m = 0,pan=0;
	cin >> n;
	while (n--) {
		cin >> a >> b;
		if (a == b)m++;
		else m = 0;
		if (m >= 3)pan = 1;
	}
	if (pan)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
local msq = math.sqrt
local mfl, mce, mmi = math.floor, math.ceil, math.min
local mma = math.max

local function getsqrt(al, bl)
  local min, max = al, bl + 1LL
  local dst = al * bl
  while 1LL < max - min do
    local mid = (min + max) / 2
    if mid * mid <= dst then
      min = mid
    else
      max = mid
    end
  end
  return min
end

local q = io.read("*n")
for iq = 1, q do
  local a, b = io.read("*n", "*n")
  local c = 0LL
  if b < a then a, b = b, a end
  local al, bl = 0LL + a, 0LL + b
  local dst = al * bl
  local sql = getsqrt(al, bl)
  if sql * sql == dst then
    if sql == al then
      c = 2LL * (sql - 1LL)
    else
      c = 2LL * (sql - 1LL) - 1LL
    end
  elseif sql * (sql + 1LL) < dst then
    c = 2LL * sql - 1LL
  else
    c = 2LL * (sql - 1LL)
  end
  local str = tostring(c):gsub("LL", "")
  print(str)
end


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	u64 H, W, M;
	cin >> H >> W >> M;

	set<pair<u64, u64>> B;
	vector<u64> BH(H);
	vector<u64> BW(W);

	u64 max_h = 0;
	u64 max_w = 0;

	for(u64 i=0; i<M; i++) {
		u64 h, w;
		cin >> h >> w;
		h--; w--;
		B.insert(make_pair(h, w));
		BH[h]++; BW[w]++;
		max_h = max(max_h, BH[h]);
		max_w = max(max_w, BW[w]);
	}

	vector<pair<u64, u64>> hb_p;
	vector<pair<u64, u64>> wb_p;

	for(u64 i=0; i<H; i++) if(BH[i] == max_h) hb_p.push_back(make_pair(BH[i], i));
	for(u64 i=0; i<W; i++) if(BW[i] == max_w) wb_p.push_back(make_pair(BW[i], i));

	for(const auto& ph : hb_p) {
		for(const auto& pw : wb_p) {
			if(B.find(make_pair(ph.second, pw.second)) == B.end()) {
				cout << max_h + max_w << endl;
				return 0;
			}
		}
	}

	cout << max_h + max_w - 1 << endl;
	return 0;
}

Measured memory_bytes: 43620
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
num =  int(input())
print(K[num-1])

Measured memory_bytes: 3060
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    del ls[i][0]
Ls = []
for i in range(m):
    a = 0
    for j in range(n):
        a += ls[j].count(i+1)
    Ls.append(a)
print(Ls.count(n))

Measured memory_bytes: 3060