akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define M 1000000000
void printprecise(double l,ll precision)
{
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l;
}

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

void initialize(ll ar[],ll n)
{
	for(ll x=0;x<n;x++)
		ar[x] = x;
}

void printarray(ll ar[],ll n)
{
	for(ll x=0;x<n;x++)
		cout<<ar[x]<<" ";
	cout<<endl;
}

void printvector(vector <char> v)
{
	for(ll x=0;x<v.size();x++)
	{
		cout<<v[x]<<" ";
	}
	cout<<endl;
}

ll root(ll i,ll ar[])
{
	while(ar[i]!=i)
	{
		ar[i] = ar[ar[i]];
		i = ar[i];
	}
	return i;
}

void unione(ll a,ll b,ll ar[])
{
	ll p = root(a,ar);
	ll q = root(b,ar);
	ar[p] = ar[q];
}

ll bfs(ll n,ll vis[],vector <ll> v[],ll level[])
{
	list <ll> g;
	g.pb(n);
	vis[n]=1;
	level[n]=1;
	while(!g.empty())
	{
		ll a = g.front();
		g.pop_front();
		for(ll x=0;x<v[a].size();x++)
		{
			if(vis[v[a][x]]==1 && v[a][x] != a) 
			{
				return level[a]-level[v[a][x]]+1;
			}
			else
			{
				g.pb(v[a][x]);
				vis[v[a][x]]=1;
				level[v[a][x]] = level[a]+1;
			}
		}
	}
	return 10000000;
}


int main()
{


	ll n;
	cin>>n;
	ll ar[n+1];
	for(ll x=1;x<=n;x++)
	{
		cin>>ar[x];
	}

	ll dp[n+1]={0};
	dp[1] = 0;
	dp[2] = abs(ar[2]-ar[1]);
	for(ll x=3;x<=n;x++)
	{
		dp[x] = min(dp[x-1]+abs(ar[x]-ar[x-1]),dp[x-2]+abs(ar[x]-ar[x-2]));
	}
	cout<<dp[n];
}

	 	

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

vector <int> pi;

void getpi(string b){
	pi.clear();
    pi.resize(b.length());
    int j = 0;
    for (int i = 1; i < b.length(); i++){
        while (j > 0 && b[i] != b[j])    
            j = pi[j - 1];       
        if (b[i] == b[j])
            pi[i] = ++j;        
    }
}

bool kmp(string a,string b){
    int j = 0;
    getpi(b);
    for (int i = 0; i < a.length(); i++){
        while (j > 0 && a[i] != b[j])    
            j = pi[j - 1];     
        if (a[i] == b[j]){        
            if (j == b.length() - 1){    
            	return true;
               // res.push_back(i - b.length() + 1);
                j = pi[j];    
            }
            else
                j++;  
        }
    }
    return false;
}



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

	string s;
	int n;

	cin >> n;
	cin >> s;

	int lo = 0;
	int hi = n;

	while(lo+1<hi)
	{
		int mid = (lo + hi)/2;
		bool ok = false;

		for(int i=0;i<n;i++)
		{
			if(i+mid >= n)
			{
				break;
			}
			string s1 = s.substr(i,mid);
			string s2 = s.substr(i+mid);	
			if(s1.length() > s2.length())
			{
				continue;
			}
			//cout << s1 << ' ' << s2 << '\n';
			if(kmp(s2,s1))
			{
				//cout << s1 << ' ' << s2 << '\n';
				ok = true;
				break;
			}
		}

		if(ok)
		{
			lo = mid;
		}
		else
		{
			hi = mid;
		}
	}

	cout << lo << '\n';
	return 0;	
}

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

int main() {
  int H, W;
 cin >> H >> W;
  vector<string> s(H);
  for (int i = 0; i < H; i++) cin >> s.at(i);
    
  vector<string> s2(H + 2);//最初は何も入ってない状態ってことを書く必要は無いと信じている
 for (int i = 0; i < W + 2; i++){
  s2.at(0) = "." + s2.at(0);
    s2.at(H + 1) = "." + s2.at(H + 1);
 }
  for (int i = 1; i < H + 1; i++) s2.at(i) = "." + s.at(i - 1) + ".";
  
  vector<int> x = { -1, -1, -1, 0, 0, 1, 1, 1 };
  vector<int> y = { -1, 0, 1, -1, 1, -1, 0, 1 };
  
  int count = 0;
  
 
  
  
  
 
  for (int i = 1; i < H + 1; i++){
    for (int j = 1; j < W + 1; j++){
      if (s2.at(i).at(j) == '.'){
        for (int k = 0; k < 8; k++){
          if (s2.at(i + x.at(k)).at(j + y.at(k)) == '#'){
            count++;
          }
        }
        s.at(i -1).at(j -1) = '0' + count;//intだけど大丈夫？
        count = 0;
      }
    }
  }
    for (int i = 0; i < H; i++) cout << s.at(i) << endl;
 // cout << ans << endl;
  return 0;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i,n,ave,ans;
    cin >> n;
    vector<int> d(n);
    for(i=0;i<n;i++){
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    ave = n/2;
    if(d.at(ave-1)==d.at(ave)){
            cout << 0 << endl;
    }
    else{
            ans = d.at(ave)-d.at(ave-1);
            cout << ans << endl;
    }

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

string res(int n) {
    if(n == 0) return "pairwise coprime";
    else if(n == 1) return "setwise coprime";
    else return "not coprime";
}

const int M = 1e6 + 5;

int main() {
    int N; cin >> N;
    vector<int64_t> A(N);
    for(auto &e : A) cin >> e;

    int64_t G = 0;
    rep(i, N) G = gcd(G, A[i]);
    if(G != 1) {
        cout << res(2) << '\n';
        return 0;
    }

    vector<int> smallestDivisor(M);
    smallestDivisor[1] = 1;
    for(int i = M - 1; i >= 2; --i) {
        for(int j = i; j < M; j += i) {
            smallestDivisor[j] = i;
        }
    }

    map<int64_t, int> prime;

    for(auto a : A) {
        int x = a;
        while(smallestDivisor[x] != 1) {
            if(prime[smallestDivisor[x]]) {
                cout << res(1) << '\n';
                return 0;
            }
            x = x / smallestDivisor[x];
        }
        x = a;
        while(smallestDivisor[x] != 1) {
            prime[smallestDivisor[x]]++;
            x = x / smallestDivisor[x];
        }
    }

    cout << res(0) << '\n';
    return 0;
}


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

int main(){
  int n,q;
  string s;
  cin >> n >> q >> s;
  int l[q],r[q];
  for(int i=0;i<q;i++){
    cin >> l[i] >> r[i];
  }
  int a[n];
  a[n-1]=0;
  for(int i=0;i<n-1;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='C'){
      a[i]=1;
    }
    else{
      a[i]=0;
    }
  }
  int b[n];
  b[0]=a[0];
  for(int i=1;i<n;i++){
    b[i]=b[i-1]+a[i];
  }
  for(int i=0;i<q;i++){
    if(l[i]!=1){
      cout << b[r[i]-2]-b[l[i]-2] << endl;
    }
    else{
      cout << b[r[i]-2] << endl;
    }
  }
}
  

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    int ans;
    double v;
    while (scanf("%lf",&v)!=EOF) {
        double t=v/9.8;
        double y=t*t*4.9;
        //int n=int(floor((y+5.0)/5.0));
        int tmp;
        for (int j=0;;j++) {
            if ((j*5-5)*1.0>=y) {
                tmp=j;
                break;
            }
        }
        printf("%d\n",tmp);
    }
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a; cin >> n;
	int test[101] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a;
		test[h] = a;
	}
	int b = 0;
	for (int h = 1; h < n; h++) {
		if (test[h - 1] == test[h]) {
			 b++;
			 h++;
		}
	}
	cout << b << endl;
	cin >> n;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var all int
	fmt.Scanf("%d", &all)

	takoyaki := make([]int, all)
	for i := 0; i < all; i++ {
		fmt.Scanf("%d", &takoyaki[i])
	}

	result := 0
	for i, baseT := range takoyaki {
		for j, t := range takoyaki {
			if i >= j {
				continue
			}

			product := baseT * t
			result = result + product
		}
	}

	fmt.Printf("%d", result)
}


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

int main() {
    long double A, B, C;
    cin >> A >> B >> C;
    if(A + B- C +2*sqrt(A*B)<0.0000000000){
      cout << "Yes" << endl;
    }else{
  	  cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const WHITE: u32 = 0;
const GRAY: u32 = 1;
const BLACK: u32 = 2;
const INFINITY: u32 = 1000000;
const MAX: usize = 100;

fn prim(m: &mut Vec<Vec<u32>>, n: usize) -> u32 {
    let mut d: Vec<u32> = vec![0; MAX];
    let mut p: Vec<i32> = vec![0; MAX];
    let mut color: Vec<u32> = vec![0; MAX];
    for index in 0..n {
        d[index] = INFINITY;
        p[index] = -1;
        color[index] = WHITE;
    }

    d[0] = 0;

    loop {
        let mut minv = INFINITY;
        let mut u: i32 = -1;
        for index in 0..n {
            if minv > d[index] && color[index] != BLACK {
                u = index as i32;
                minv = d[index];
            }
        }
        if u == -1 {
            break;
        }
        color[u as usize] = BLACK;
        for v in 0..n {
            if color[v] != BLACK && m[u as usize][v] != INFINITY {
                if d[v] > m[u as usize][v] {
                    d[v] = m[u as usize][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    let mut sum = 0 as u32;
    for index in 0..n {
        if p[index] != -1 {
            sum += m[index][p[index] as usize]
        }
    }
    return sum;
}

fn main() {
    let n: usize = read();
    let mut m: Vec<Vec<u32>> = vec![vec![0; MAX]; MAX];
    for index_i in 0..n {
        for index_j in 0..n {
            let number: i32 = read();
            if number == -1 {
                m[index_i][index_j] = INFINITY;
            } else {
                m[index_i][index_j] = number as u32;
            }
        }
    }
    println!("{}", prim(&mut m, n));
}



Measured memory_bytes: 5044
fn func(input_str: &str) -> u32 {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut h_s: Vec<u32> = iter.take(n).map(|x| x.parse().unwrap()).collect();
    for i in 0..n {
        for j in (i + 1)..n {
            if h_s[i] > h_s[j] {
                h_s[j] = 0;
            }
        }
    }
    h_s.into_iter().filter(|x| *x > 0).collect::<Vec<_>>().len() as u32
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

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

	if (n/100 == 1)
		cout << 9;
	else if (n/100 == 9)
		cout << 1;
	else
		cout << n/100;

	if ((n%100)/10 == 1)
		cout << 9;
	else if ((n%100)/10 == 9)
		cout << 1;
	else
		cout << (n%100)/10;

	if((n%100)%10 == 1)
		cout << 9;
	else if ((n%100)%10 == 9)
		cout << 1;
	else
		cout << (n%100)%10;

	cout << "\n";
	
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double x[110];
double y[110];
double z[110];
double r[110];
double EPS=1e-9;
double ABS(double a){return max(a,-a);}
int main(){
	int a;
	while(scanf("%d",&a),a){
		double u,v,w;
		scanf("%lf%lf%lf",&u,&v,&w);
		for(int i=0;i<a;i++){
			scanf("%lf%lf%lf%lf",x+i,y+i,z+i,r+i);
		}
		double nx=0;
		double ny=0;
		double nz=0;
		int last=-1;
		while(1){
			int at=-1;
			double mt=999999999;
		
			for(int i=0;i<a;i++){
				if(last==i)continue;
				double A=u*u+v*v+w*w;
				double B=-2.0*(u*(x[i]-nx)+v*(y[i]-ny)+w*(z[i]-nz));
				double C=(x[i]-nx)*(x[i]-nx)+(y[i]-ny)*(y[i]-ny)+(z[i]-nz)*(z[i]-nz)-r[i]*r[i];
				if(B*B-4*A*C<EPS)continue;
				double t=(-B-sqrt(B*B-4*A*C))/2/A;
			//	printf("%f %f %f: %f\n",A,B,C,t);
				if(t<0)continue;
				if(mt>t){
					mt=t;at=i;
				}
			}
			if(!~at)break;
			last=at;
			double tx=nx+mt*u;
			double ty=ny+mt*v;
			double tz=nz+mt*w;
		//	printf("%f %f %f %f\n",mt,tx,ty,tz);
			double ns=((tx-x[at])*(-u)+(ty-y[at])*(-v)+(tz-z[at])*(-w));
			double td=sqrt((tx-x[at])*(tx-x[at])+(ty-y[at])*(ty-y[at])+(tz-z[at])*(tz-z[at]));
			ns/=td;
			double te=sqrt(u*u+v*v+w*w);
			ns/=te;
		//	printf("%f\n",ns);
			double ks=sqrt((tx-nx)*(tx-nx)+(ty-ny)*(ty-ny)+(tz-nz)*(tz-nz));
			double nu=tx+(tx-x[at])*ns/td*ks;
			double nv=ty+(ty-y[at])*ns/td*ks;
			double nw=tz+(tz-z[at])*ns/td*ks;
		//	printf("%f %f %f\n",nu,nv,nw);
			u=2*nu-nx-tx;
			v=2*nv-ny-ty;
			w=2*nw-nz-tz;
			nx=tx;
			ny=ty;
			nz=tz;
	//		printf("%f %f %f\n",u,v,w);
		}
		printf("%.12f %.12f %.12f\n",nx,ny,nz);
	}
}

Measured memory_bytes: 1096
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func makeFactorial(n int) int {
	result := 1
	for i := 2; i <= n; i++ {
		result *= i
	}
	return result
}

var patternNum = makeFactorial(8)
var patterns = make([][]int, 0, patternNum)

func remove(nums []int, i int) []int {
	result := make([]int, 0, len(nums)-1)
	result = append(result, nums[:i]...)
	result = append(result, nums[i+1:]...)
	return result
}

func permute(pat, nums []int) {
	if len(nums) == 0 {
		dst := make([]int, len(pat))
		copy(dst, pat)
		patterns = append(patterns, dst)
		return
	}

	for i := 0; i < len(nums); i++ {
		permute(append(pat, nums[i]), remove(nums, i))
	}
}

func calcRank(nums []int, patterns [][]int) int {
	result := 0
	for i := 0; i < len(patterns); i++ {
		if reflect.DeepEqual(patterns[i], nums) {
			result = i
			break
		}
	}
	return result
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	n, _ := strconv.Atoi(input())
	p := make([]int, n)
	q := make([]int, n)
	for i := 0; i < n; i++ {
		p[i], _ = strconv.Atoi(input())
	}
	for i := 0; i < n; i++ {
		q[i], _ = strconv.Atoi(input())
	}

	nums := make([]int, n)
	for i := 1; i <= n; i++ {
		nums[i-1] = i
	}
	permute([]int{}, nums)

	pRank := calcRank(p, patterns)
	qRank := calcRank(q, patterns)
	fmt.Println(abs(pRank - qRank))
}


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

int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int p[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    long long int s = 0;
    long long int i = 0;
    while(i < k)
    {
        s += p[i];
        i++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int n = s.length();
  vector<bool> vec(26, false);
  rep(i, n){
    vec[s[i]-'a'] = true;
  }
  int smallest = 10000;
  rep(i, 26){
    if(!vec[i]) continue;
    string sc = s;
    for(int j=0; j<=n/2; j++){
      bool allSame = true;
      rep(k, n-j){
        if(sc[k] != 'a'+i) allSame = false; 
      }
      if(allSame){
        smallest = min(smallest, j);
        break;
      }
      rep(k, n-j-1){
        if(sc[k] == 'a'+i || sc[k+1] == 'a'+i) sc[k] = 'a'+i;
      }
    }
  }
  cout << smallest << endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N; cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i += 2) {
		int div = 0;
		REP(j, 1, i+1) if (i % j == 0) div++;
		if (div == 8) ans++;
	}
	cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int a[100000];

int main(){
	int n, m; cin >> n >> m;
	int ans = 0;
	rep(i, m) cin >> a[i];
	rep(i, m - 1) ans = max(ans, (a[i + 1] - a[i]) / 2);
	ans = max(ans, a[0] - 1);
	ans = max(ans, n - a[m - 1]);
	cout << ans << endl;
	return 0;
}

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

int main() {
	int num[3], five = 0, seven = 0;
  cin >> num[0] >> num[1] >> num[2];

  for (int i = 0; i < 3; i++) {
    if (num[i] == 5) {
      five++;
    }
    else if (num[i] == 7) {
      seven++;
    }
  }
  if (five == 2 && seven == 1) {
    cout << "YES";
  }
  else {
    cout << "NO";
  }
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, h, w = map(int, input().split())
    ans = 0
    for _ in range(n):
        a, b = map(int, input().split())
        ans += a >= h and b >= w
    print(ans)
resolve()

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  for(auto c:S) {
    if(c=='7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3592
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ 
  int p,l,r;
};

struct Node T[MAX]; 

int depth(int u){
  if(T[u].p==NIL)return 0;
  else{
    return 1+depth(T[u].p);
  }
}

int degree(int u){
  if(T[u].l!=NIL && T[u].r!=NIL)return 2;
  else if(T[u].l!=NIL || T[u].r!=NIL)return 1;
  else return 0;
}

int sibling(int p,int u){
  if(p==NIL)return NIL;
  else if(T[p].l==u)return T[p].r;
  else return T[p].l;
}

int height(int u){
  int l_h=0,r_h=0;

  if(u==NIL)return 0;
  
  
    if(T[u].l!=NIL) l_h=height(T[u].l)+1;
    if(T[u].r!=NIL) r_h=height(T[u].r)+1;

    if(l_h>r_h)return l_h;
    else return r_h;
  }


void print(int u){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,sibling(T[u].p,u),degree(u),depth(u),height(u));

  if(T[u].p==NIL)printf("root\n");
  else if(T[u].l==NIL && T[u].r==NIL)printf("leaf\n");
  else printf("internal node\n");
}

main(){
  int n,i,id,c1,c2;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&c1,&c2);

    T[c1].p=id;
    T[c2].p=id;
    T[id].l=c1;
    T[id].r=c2;
  }
  
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

Measured memory_bytes: 612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int cnt = 0;
        HashSet<Integer> set = new HashSet<Integer>();
        for (int i=0;i<N;i++) {
            int A = Integer.parseInt(sc.next());
            if (set.contains(A)) {
                cnt++;
            }
            set.add(A);
        }
        System.out.println(cnt%2==0?set.size():set.size()-1);
    }
}

Measured memory_bytes: 48768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[112345];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	reverse(a, a+n);
	FOR(i, 1, n){
		if(a[i] - a[i-1] > 1){
			printf("No\n");
			return 0;
		} else if(a[i] - a[i-1] == 1){
			a[i]--;
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 640
n,m = map(int,input().split())
record = [[0,0] for _ in range(n)]
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        record[p-1][1] = 1
    else:
        # 既に正解してる奴にはwaを加算しない
        if record[p-1][1] == 0:
            record[p-1][0] += 1

ac = 0
pe = 0
for i in range(n):
    if record[i][1] == 1:
        ac += 1
        pe += record[i][0]
print(ac, pe)


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF       numeric_limits<int>::max()
#define NINF      numeric_limits<int>::min()
#define MOD       1000000007

using namespace std;
using Int    = long long;
using Edge   = vector<vector<pair<int, Int>>>; // src   -> dst, weight
using Vertex = vector<pair<Int, bool>>;        // index -> cost, visited

bool graph_dfs(int         vertex_index,
               const Edge& edge,
               Vertex&     vertex) {

    bool ret = true;
    REP(i, edge[vertex_index].size()) {
        int dst    = edge[vertex_index][i].first;
        int weight = edge[vertex_index][i].second;
        int cost   = vertex[vertex_index].first + weight;

        if(!vertex[dst].second) {
            vertex[dst] = make_pair(cost, true);

            ret = graph_dfs(dst, edge, vertex);
            if(!ret) {
                break;
            }
        }
        else if(vertex[dst].first != cost) {
            return false;
        }
    }

    return ret;
}

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

    int N, M;
    std::cin >> N >> M;

    Edge   edge(N);
    Vertex vertex(N, make_pair(0, false));

    REP(i, M) {
        int l, r, d;
        std::cin >> l >> r >> d;
        edge[l - 1].emplace_back(r - 1,  d);
        edge[r - 1].emplace_back(l - 1, -d);
    }

    string ans = "Yes";
    REP(i, edge.size()) {
        if(edge[i].size() == 0 || vertex[i].second) {
            continue;
        }

        vertex[i].second = true;
        if(!graph_dfs(i, edge, vertex)) {
            ans = "No";
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 17280
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    Map<Integer,Integer> count = new HashMap<Integer,Integer>();
    for(int i = 1; i <= n; i++){
      count.put(i,0);
    }
    for(int i = 0; i < m; i++){
      int a = sc.nextInt();
      int b = sc.nextInt();
      int temp = count.get(a) + 1;
      count.put(a,temp);
      temp = count.get(b) + 1;
      count.put(b,temp);
    }
    for(int i = 1; i <= n; i++){
      System.out.println(count.get(i));
    }
  }
}

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

string LCS(string s, string t){
    int r=s.size(), c=t.size();
    vector<vector<int>> vec(r+1, vector<int>(c+1));
    for(int i=0; i<=r; i++){
        for(int j=0; j<=c; j++){
            if(i==0 || j==0) vec[i][j]=0;
            else if(s[i-1]==t[j-1]) vec[i][j]=vec[i-1][j-1]+1;
            else {
                vec[i][j] = max(vec[i-1][j], vec[i][j-1]);
            }
        }
    }
    string str="";
    while(r>=0 && c>=0){
        if(vec[r][c]==vec[r][c-1]) c--;
        else if(vec[r][c]==vec[r-1][c]) r--;
        else if(vec[r][c]-1 == vec[r-1][c-1]){
            str+=s[r-1];
            r--; 
            c--;
        }
    }
    reverse(str.begin(), str.end());
    return str;
}

int main(){
  string s,t;
  cin>>s>>t;
  cout<<LCS(s, t);
  return 0;
}

Measured memory_bytes: 38480
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        
        if(n==m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int ans1[1048576];
int ans2[1048576];
std::vector<int> num4;
std::vector<int> numodd4;

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

  // step 1
  for(int i = 1; ; ++i) {
    int t = i * (i + 1) * (i + 2) / 6;
    if( t >= 1048576 ) break;
    num4.push_back(t);
    if( t % 2 == 1 ) numodd4.push_back(t);
  }
  std::sort(std::begin(num4), std::end(num4));
  std::sort(std::begin(numodd4), std::end(numodd4));
  num4.erase(std::unique(std::begin(num4), std::end(num4)), std::end(num4));
  numodd4.erase(std::unique(std::begin(numodd4), std::end(numodd4)), std::end(numodd4));

  // step 2
  for(int i = 1; i < 1048576; ++i) {
    int min = 1048576;
    for(int dx : num4) {
      int previ = i - dx;
      if( previ < 0 ) break;
      min = std::min(min, ans1[previ] + 1);
    }
    ans1[i] = min;
  }

  // step 3
  ans2[0] = 0;
  for(int i = 1; i < 1048576; ++i) {
    int min = 1048576;
    for(int dx : numodd4) {
      int previ = i - dx;
      if( previ < 0 ) break;
      min = std::min(min, ans2[previ] + 1);
    }
    ans2[i] = min;
  }
  
  // step 4
  for(;;) {
    int N;
    scanf("%d", &N);
    if( N == 0 ) break;
    printf("%d %d\n", ans1[N], ans2[N]);
  }
  
  return 0;
}

Measured memory_bytes: 11344
import itertools

n = int(input())
digits = [3, 5, 7]

def count(digits, n):
	A = []
	p = 3
	while True:
		for tup in itertools.product(digits, repeat=p):
			a = int(''.join(list(map(str, tup))))
			if a > n:
				break
			A.append(a)
		else:
			p += 1
			continue
		break
	return A

lst = count(digits, n)

cnt = 0
for v in lst:
	if all(str(v).count(c) > 0 for c in '753'):
		cnt += 1

print(cnt)


Measured memory_bytes: 45020
#!/bin/ruby

class UnionFindTree
  def initialize(size)
    @array = Array.new(size) { |i| i }
  end

  def union(x, y)
    @array[root(x)] = root(y)
  end

  def print_same(x, y)
    puts same?(x, y) ? 1 : 0
  end

  def same?(x, y)
    root(x) == root(y)
  end

  def root(n)
    @array[n] == n ? n : root(@array[n])
  end
end

n, q = gets.split.map(&:to_i)
tree = UnionFindTree.new(n)
q.times do
  com, x, y = gets.split.map(&:to_i)
  com == 0 ? tree.union(x, y) : tree.print_same(x, y)
end


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

using namespace std;

int n,i,j,st,ed,now;
char s[105];

int main(){
	scanf("%d", &n);
	scanf("%s", s);
	
	for(i = 0; i < n; i++){
		if(s[i] == '(')
		now++;
		else{
			if(now == 0)
			st++;
			else
			now--;
		}
	}
	
	ed = now;
	
	for(i = 0; i < st; i++)
	printf("(");
	printf("%s", s);
	for(i = 0; i < ed; i++)
	printf(")");
	printf("\n");
}


Measured memory_bytes: 256
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second                                                                                                                                                                                                                                                                                                                
#define f first
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000
#define mod 1000000007
#define inf 1000000000000000000
#define mI2 500000004
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string ans;
    for(ll i=0;i<n;i++){
        ans.pb(s[i]);
        ans.pb(t[i]);
    }
    cout<<ans;
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

type TPoint struct {
	T int
	X int
	Y int
}

func main() {
	var n int
	var steps []TPoint
	var match bool = true

	steps = append(steps, TPoint{T: 0, X: 0, Y: 0})

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		steps = append(steps, TPoint{T: t, X: x, Y: y})
	}

	for i := 0; i < n; i++ {
		dt := steps[i+1].T - steps[i].T
		dist := abs(steps[i+1].X - steps[i].X) + abs(steps[i+1].Y - steps[i].Y)
		if dt < dist {
			match = false
		}
		if dist%2 != dt%2 {
			match = false
		}
	}

	if match {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int A, B; cin >> A >> B;
  int sum = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i);
    //cout << s;
    int c = 0;
    for (int j = 0; j < s.length()/2; j++)
      c += (s[j] == s[s.length()-1-j]);
    //cout << " " << c << endl;
    sum += (c == s.length()/2);
  }
  cout << sum << endl;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string n = sc.Next();

        bool ok = false;

        for (int i = 0; i <= 9; i++)
        {
            if (n.Contains(i + "" + i + "" + i))
            {
                ok = true;
            }
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;




int main() {
int sx,sy,tx,ty;
cin>>sx>>sy>>tx>>ty;
string S="";
rep(i,ty-sy){
  S+='U';
}
rep(i,tx-sx){
  S+='R';
}
rep(i,ty-sy){
  S+='D';
}
rep(i,tx-sx){
  S+='L';
}
S+='L';
rep(i,ty-sy+1){
  S+='U';
}
rep(i,tx-sx+1){
  S+='R';
}
S+='D';
S+='R';
rep(i,ty-sy+1){
  S+='D';
}
rep(i,tx-sx+1){
  S+='L';
}
S+='U';
cout<<S<<endl;
return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define NMAX 3005
using namespace std;
int n;
long long a[NMAX],d[NMAX][NMAX];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        d[i][i]=a[i];
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=n-i+1;j++)
        {
            d[j][j+i-1]=max(a[j]-d[j+1][j+i-1],a[j+i-1]-d[j][j+i-2]);
        }
    }
    cout<<d[1][n];
    return 0;
}


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

int main() {
    int m, d;
    cin >> m >> d;
    int cnt = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < d; j++){
            int d_1 = 0, d_10 = 0;
            if((j+1) % 10 >= 2){
                d_1 = (j+1) % 10;
            }
            if((j+1) / 10 >= 2){
                d_10 = (j+1) / 10;
            }
            if( i+1 == d_1 * d_10){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}
    

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

signed main(){
       int n;
       string a,b,c;
       cin >>n >>a>> b>>c;
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            if(b[i]!=c[i])ans+=1;
        }else{
            if(b[i]==c[i])ans+=1;
            else{
                if(a[i]==c[i])ans+=1;
                else ans+=2;
            }
        }
    }    
    cout << ans;
    return 0;
}

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

int main()
{
  int t,n;
  cin>>t;
  double d=0.0,dd=0.0;
  while(t--)
  {
    cin>>n;
    d=d+1/(double)n;
  }
  dd=1/d;
  cout<<dd<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int h,w;
    char c[1000][1000];
    cin>>h>>w;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>c[i][j];
    for(int i=0;i<h;i++) for(int l=0;l<2;l++){ for(int j=0;j<w;j++) cout<<c[i][j]; cout<<endl;} 
    return 0;
}

Measured memory_bytes: 512
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long
void q1(){
	int n;	cin>>n;
	cout<<n*n*n;			
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;//cin>>t;
	t=1;
	while(t--)//
	q1();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int A,B,C;
	cin>>A>>B>>C;
	int ans;
	if(A==B)ans = C;
	else if (B==C)ans = A;
	else if (C==A) ans=B;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#

a, b = map(int, input().split())

print(a-(a > b))


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

using namespace std;

int main(){
    int N, M;

    cin >> N >> M;
    
    int comb = (N + M) * (N + M - 1) / 2;
    int odd_comb = N * M;
    cout << comb - odd_comb << endl;
    return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  string s;
  cin >> x >> s;
  if(x % 2 == 0) {
    REP(i, x / 2) {
      if(s[i] != s[i + x / 2]) {
        puts("No");
        return 0;
      }
    }
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


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

divisor = []
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divisor.append(i)
        if i != M // i:
            divisor.append(M // i)

print(max(filter(lambda x: x <= M // N, divisor)))


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

int main(){
    int a,b,c,x,y,X,Y,ans=INT_MAX;
    cin>>a>>b>>c>>x>>y;
    for(int i=0;i<=100000;i++){
        X=max(0,x-i);
        Y=max(0,y-i);
        int cost;
        cost=2*c*i+a*X+b*Y;

        ans=min(ans,cost);
        }
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().solve();
    }
    Scanner sc = new Scanner(System.in);
    Buil[] buil;

    void solve(){
	buil = new Buil[4];
	for(int i=0; i<4; i++)
	    buil[i] = new Buil();
	int n = sc.nextInt();
	while(n>0){
	    n--;
	    int t = sc.nextInt()-1;
	    //System.out.println(t);
	    buil[t].add();
	}
	buil[0].show();
	for(int i=1; i<buil.length; i++){
	    System.out.println("####################");
	    buil[i].show();
	}
    }
    
    class Buil{
	int[][] rooms;
	Buil(){
	    rooms = new int[3][10];
	}
	
	void add(){
	    int f = sc.nextInt();
	    int r = sc.nextInt();
	    int v = sc.nextInt();
	    rooms[f-1][r-1] += v;
	    //System.out.println(f+" "+r+" "+v);
	}

	void show(){
	    for(int i=0; i<3; i++){
		for(int j=0; j<10; j++){
		    System.out.print(" "+rooms[i][j]);
		}
		System.out.println();
	    }
	}
    }
}
	    

Measured memory_bytes: 21224
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		sc.close();

		long result = Arrays.stream(h).filter(he -> he >= k).count();
		System.out.println(result);
	}
}


Measured memory_bytes: 50616
loop {
	pc_num, student_num = gets.split.map &:to_i
	break if pc_num == 0

	event = (1..student_num).map { [] }

	r = gets.to_i
	r.times{
		t, n, m, s = gets.split.map &:to_i
		event[m-1] << [t, 2*s-1]
	}

	q = gets.to_i
	q.times{
		ts, te, m = gets.split.map &:to_i
		queue = event[m-1].dup

		i = queue.index{|t, s| ts < t} || queue.size
		queue.insert(i, [ts, 0])

		i = queue.index{|t, s| te < t} || queue.size
		queue.insert(i, [te, 0])

		c = 0
		sum = 0
		prev_t = 0
		check = false
		queue.each{|t, s|
			if check && c > 0
				sum += t - prev_t
			end
			check = !check if s == 0
			c += s
			prev_t = t
		}
		p sum
	}
}

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

int main(void){
	int  a,b,n;
	cin >> a >> b >> n;
	int s[n], f[n];
	for(int i = 0; i  < n; i++){
		cin >> s[i] >> f[i];
	}
	int k = 0;
	sort(s, s+n);
	sort(f, f+n);

	for(int i = 0, j = 1; j < n; i++, j++){
		if(a >= f[i] && b <= s[j])k = 1;
	}
	if(a >= f[n-1]) k = 1;
	if(b <= s[0]) k = 1;
	if(k == 1) cout << 0;
	else cout << 1;
	cout << endl;
	return 0;
}


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

comulative_sum=[0*i for i in range(N+1)]
for i in range(1,N+1):
    comulative_sum[i] = comulative_sum[i-1]+A[i-1]
minimum=pow(10,18)
for i in range(1,N):
    minimum=min(abs(comulative_sum[i]-(comulative_sum[N]-comulative_sum[i])), minimum)
print(minimum)


Measured memory_bytes: 24832
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
long long modpow(long long a, long long n) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
         if (n & 1) res = res * a % MOD;
         a= a * a % MOD;//次の準備
         n >>= 1;
      }
 return res;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll x;cin>>x;
    ll s=0;
    for(int i=1;i<100000;i++){
        s+=i;
        if(s>=x){
            cout<<i<<endl;
            return 0;
        }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(3,0);
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(tmp%4==0)a.at(0)++;
    else if(tmp%2==0)a.at(1)++;
    else a.at(2)++;
  }
  bool ans=false;
  if(a.at(1)==1)a.at(2)++;
  if(a.at(1)==0||a.at(1)==1){
    if(a.at(0)+1>=a.at(2)){
      cout <<"Yes"<<endl;
      return 0;
    }
    else{
      cout <<"No"<<endl;
      return 0;
    }
  }
  else{
    if(a.at(0)>=a.at(2)){
      cout <<"Yes"<<endl;
      return 0;
    }
  }
  cout <<"No"<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int MM=1e5+5;
const int NN=3e5+5;

int n,m,ans;

struct SS{
	int l,r,len;
	bool operator < (const SS &x) const{
		return x.len>len;
	}
}a[NN];

struct Node{
	int ls,rs,sum,lz;
}t[MM*4];

int pos=1,cnt=1;

void pushup(int x){
	if(!t[x].ls) t[x].ls=++cnt; if(!t[x].rs) t[x].rs=++cnt;
	t[x].sum=t[t[x].ls].sum+t[t[x].rs].sum;
}

void pushdown(int x,int l,int r){
	if(!t[x].ls) t[x].ls=++cnt; if(!t[x].rs) t[x].rs=++cnt; 
	int mid=(l+r)>>1;  t[t[x].ls].sum+=(mid-l+1)*t[x].lz; t[t[x].rs].sum+=(r-mid)*t[x].lz;
	t[t[x].ls].lz+=t[x].lz; t[t[x].rs].lz+=t[x].lz; t[x].lz=0;
}

void modify(int x,int l,int r,int a,int b){
	if(l==a && r==b) {t[x].sum+=r-l+1; t[x].lz++; return ;} pushdown(x,l,r); int mid=(l+r)>>1;
	if(b<=mid) modify(t[x].ls,l,mid,a,b);
	else if(a>mid) modify(t[x].rs,mid+1,r,a,b);
	else {modify(t[x].ls,l,mid,a,mid); modify(t[x].rs,mid+1,r,mid+1,b); pushup(x);}
}

int query(int x,int l,int r,int a,int b){
	if(l==a && r==b) return t[x].sum; int mid=(l+r)>>1; pushdown(x,l,r);
	if(b<=mid) return query(t[x].ls,l,mid,a,b);
	else if(a>mid) return query(t[x].rs,mid+1,r,a,b);
	else return query(t[x].ls,l,mid,a,mid)+query(t[x].rs,mid+1,r,mid+1,b); 
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {scanf("%d%d",&a[i].l,&a[i].r); a[i].len=a[i].r-a[i].l+1;}
	sort(a+1,a+1+n);
	for(int i=1;i<=m;i++){
		while(a[pos].len<i && pos<=n) {modify(1,1,m,a[pos].l,a[pos].r); pos++;} ans=n-pos+1;
		for(int j=1;j*i<=m;j++) ans+=query(1,1,m,i*j,i*j); 
		printf("%d\n",ans);
	} 
	return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG




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

  bool ans = true;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));

  for(ll i=0; i <N; i++){
    ll tmp;
    cin >> tmp;
    if(tmp % 2 ==0){
      if(tmp % 3 ==0 || tmp % 5 ==0){
        continue;
      }else{
        cout << "DENIED" << endl;
        return 0;
      }
    }else{
      continue;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


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


ones = [0] * (len(bin(K)) - 2)
for a in A:
    for i in range(len(ones)):
        if (1 << i) & a:
            ones[i] += 1

best_bits = [1 if x * 2 < N else 0 for x in ones]
best_k = sum(2 ** i * b for i, b in enumerate(best_bits))
if K < best_k:
    better = 0
    for i in range(len(ones) - 1, -1, -1):
        if best_bits[i]:
            b = 1 << i
            if better + b <= K:
                better += b
    best_k = better

answer = 0
for a in A:
    answer += a ^ best_k
print(answer)

Measured memory_bytes: 69264