akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
//using System.Collections.Generic;

class Test
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            int[] query = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] B = new int[query[1] - query[0]];
            Array.Copy(A, query[0], B, 0, query[1] - query[0]);
            int c = 0;
            for (int j = 0; j < B.Length; j++)
            {
                if (B[j] == query[2]) c++;
            }
            Console.WriteLine(c++);
        }
    }
}




Measured memory_bytes: 20312
/*#include<stdio.h>
int main(){
	float a,b,c,d,e,f,x,y;
	//while(scanf_s("%f",&a)!=EOF){
	while(scanf_s("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF){
	y=(c*d-a*f)/(b*d-a*e);
	x=(c*e-b*f)/(a*e-b*d);
	printf("%f %f\n",x,y);
	}
	return 0;
}
*/
#include<stdio.h>
#include<math.h>
int main(void){
    double a,b,c,d,e,f,A,x,y,X,Y,Z;
 
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
 
 
    Y=a*e-b*d,Z=f*a-c*d;
    y=Z/Y;
 
    x=(c-b*y)/a;
 
   printf("%.3lf %.3lf\n",x,y);
    }
 
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll N;
    string S;
    cin >> N;
    cin >> S;
    stack<char> st;
    rep(i,N){
        if(S[i] == '('){
            st.push(S[i]);
        }else{
            if(!st.empty()){
                if(st.top() == '('){
                    st.pop();
                }else{
                    st.push(')');
                }
            }else{
                st.push(S[i]);
            }
        }
    }
    while(!st.empty()){
        char c = st.top();
        st.pop();
        if(c == '('){
            S += ')';
        }else{
            S = '(' + S;
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define MAX 1000000
#define LMT 1000
unsigned flag[MAX>>6];
int primes[6000000];//5761455
#define ifc(n) (flag[n>>6]&(1<<((n>>1)&31)))
#define isc(n) (flag[n>>6]|=(1<<((n>>1)&31)))

int sieve()
{
    unsigned i, j, k;
    for(i=3; i<LMT; i+=2)
        if(!ifc(i))
            for(j=i*i, k=i<<1; j<MAX; j+=k)
                isc(j);
    return 0;
}

int main()
{
    sieve();
    unsigned int i,L;
    int k=1, count;
    primes[0]=2;
    while(scanf("%d", &L)==1)
    {
        count=1;
        for( i=3; i<=L; i+=2)
        {
            if(ifc(i)==0)
                count++;
        }
        if(L>1)
            printf("%d\n", count);
        else printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,ans,a[N],b[N],c[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read();
	for(int i=1;i<n;i++)c[i]=read();
	for(int i=2;i<=n;i++)
		if(a[i-1]+1==a[i])ans+=c[a[i-1]];
	for(int i=1;i<=n;i++)ans+=b[a[i]];
	cout<<ans;
}

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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

bool chkmin(int &x,int y){return x>y?x=y,1:0;}
bool chkmax(int &x,int y){return x<y?x=y,1:0;}

ll readint(){
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

ll n,x;

int main(){
	n=readint(); x=readint();
	ll a=x,b=n-x,ans=n;
	while(a!=0){
		if(a<b) swap(a,b);
		ans+=2*b*(a/b);
		a%=b;
	}
	cout<<ans-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,W;
    cin>>N>>W;
    int arrW[N+1], arrV[N+1];
    long long dp[W+1];
    for(int i=1; i<=N; i++){
        cin>>arrW[i]>>arrV[i];
    }
    for(int i=1;i<=W;i++)
        dp[i]  = INT_MIN;
    dp[0] = 0;
    long long maxVal = INT_MIN;
    for(int i=1;i<=N;i++){
        for(int j=W; j>=arrW[i];j--){
            if(dp[j-arrW[i]] != INT_MIN)
                dp[j] = max(dp[j], dp[j-arrW[i]]+arrV[i]);
            maxVal = max(maxVal, dp[j]);
        }
    }
    cout<<maxVal;
    return 0;
}

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

int main(){
  char x,y;
  cin >> x >> y;
  if(x<y){
    cout << "<" << endl;
  }else if(x==y){
    cout << "=" << endl;
  }else{
    cout << ">" << endl;
  }
    
  return 0;
}

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

using namespace std;

#define pii pair<int,int> 
#define F first 
#define S second 
#define int long long
typedef long long ll;

const int maxn = 3e5+10;
const int mod = 1e9+7;
//const int inf = 2e18+10;

int n, m, k;
int cnt[26];

signed main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    string s; cin>> s; 
    for(auto c : s) cnt[c-'a']++;
    ll ans = 1;
    for(int i = 0; i < 26; i++)
        for(int j = i+1; j < 26; j++)   
            ans += cnt[i] * cnt[j];
    cout<< ans;
}


Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll a;
cin>>a;
ll b;
cin>>b;
if(a>12){
    cout<<b<<endl;
}else if(a>5){
    cout<<b/2<<endl;
}else{
    cout<<0<<endl;
}
}









Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int[] a = new int[h+1];
        for(int i = 1; i <= h; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        buildMaxHeap(a);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 1; i <= h; i++){
            sb.append(" ").append(a[i]);
        }
        System.out.println(sb);
    }
    
    static void maxHeapify(int[] a, int i){
        
        int h = a.length-1;
        int l = i*2;
        int r = i*2+1;
        int largest;
        
        if(l <= h && a[l] > a[i]){
            largest = l;
        }else{
            largest = i;
        }
        if(r <= h && a[r] > a[largest]){
            largest = r;
        }
        
        if(largest != i){
            int tmp = a[i];
            a[i] = a[largest];
            a[largest] = tmp;
            maxHeapify(a, largest);
        }
    }
    
    static void buildMaxHeap(int[] a){
        
        int h = a.length-1;
        for(int i = h/2; i >= 1; i--){
            maxHeapify(a, i);
        }
    }
}


Measured memory_bytes: 90468
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

N = int(sys.stdin.readline())

A = sys.stdin.readline().split(' ')

A = [int(x) for x in A]

A.insert(0, 0)
A.append(0)

total = 0

for i in range(N + 1):
	total += abs(A[i] - A[i+1])

for i in range(1, N + 1):
	print(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))


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

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

  int ans = 0;
  ans += N * (N - 1) / 2;
  ans += M * (M - 1) / 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll poc(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m,x;cin>>n>>m>>x;
    ll ans=inf;
    ll a[n][m];
    ll c[n];
    rep(i,0,n){
        cin>>c[i];
        rep(j,0,m)cin>>a[i][j];
    }
    rep(i,0,1<<n){
        ll cnt[m];
        fill(cnt,cnt+m,0);
        ll sum=0;
        ll u=i;
        rep(j,0,n){
            if(u%2){
                sum+=c[j];
                rep(k,0,m)cnt[k]+=a[j][k];
            }
            u/=2;
        }
        bool bo=false;
        rep(j,0,m){
            if(cnt[j]<x){
                bo=true;
                break;
            }
        }
        if(!bo)Min(ans,sum);
    }
    if(ans==inf)ans=-1;
    cout<<ans<<endl;
}




Measured memory_bytes: 3660
n = int(input())

for p in range(1, 3500 + 1):
    for q in range(1, 3500 + 1):
        if (4*p*q - n*q - n*p) == 0:
            continue
        r = n*p*q / (4*p*q - n*q - n*p)
        if int(r) == r and 1 <= r <= 3500:
            print(p, q, int(r))
            exit()
print(-1)

Measured memory_bytes: 40940
#include <bits/stdc++.h>
 
using namespace std;
 
struct st {
	double x, y;
	char d;
	st() {}
	st(double a, double b, char c) {
		x = a, y = b, d = c;
	}
}take[(int)1e5+5];
 
int n;
 
double f(double t) {
	double x_max = -1e10, x_min = 1e10, y_max = -1e10, y_min = 1e10;
	for(int i=0; i<n; i++) {
		double x = take[i].x, y = take[i].y;
		if(take[i].d == 'R') {
			x += t;	
		}
		else if(take[i].d == 'L') {
			x -= t;
		}
		else if(take[i].d == 'U') {
			y += t;
		}
		else if(take[i].d == 'D') {
			y -= t;
		}
		x_max = max(x_max, x);
		x_min = min(x_min, x);
		y_max = max(y_max, y);
		y_min = min(y_min, y);
	}
	return (x_max - x_min) * (y_max - y_min);
}
 
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i=0; i<n; i++) {
		double x, y;
		char d;
		cin >> x >> y >> d;
		take[i] = st(x, y, d);
	}
	double l, r, m1, m2;
	l = 0, r = 1e12;
	for(int i=0; i<300; i++){
		m1 = l + (r - l) / 3.0;
		m2 = l + 2.0 * (r - l) / 3.0;
		if (f(m1) < f(m2)){
			r = m2;
		}
		else{
			l = m1;
		}
	}
	cout << fixed;
	cout << f(l) << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int sz = n;
    int a[sz+1],b[sz+1],c[sz];
    for(int i=1;i<=n;++i) cin >> a[i];
    for(int i=1;i<=n;++i) cin >> b[i];
    for(int i=1;i<=n-1;++i) cin >> c[i];
    long sum=0;
    for(int i=1;i<=n;++i){
        sum += b[a[i]];
        if(i<n && a[i]+1==a[i+1]) sum += c[a[i]];
    }
    cout << sum << endl;
    return 0;
}

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

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

Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

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

    int N = scanner.nextInt();
    Map<String, Integer> freq = new HashMap<>();
    for (int i = 0; i < N; i++) {
      String S = scanner.next();
      freq.put(S, freq.getOrDefault(S, 0) + 1);
    }
    int max = freq.values().stream().max(Integer::compareTo).get();
    for (String s : freq.entrySet().stream().filter(e -> e.getValue() == max).map(Map.Entry::getKey).sorted().collect(Collectors.toList())) {
      System.out.println(s);
    }
  }
}


Measured memory_bytes: 85272
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

vector<int> res, tmp;
vector<vector<int>> bra;

void dfs(int par, int now);

int main(){
    int n, q;
    cin >> n >> q;
    rep(i, n){
        res.push_back(0);
        bra.push_back(tmp);
    }
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        bra[a-1].push_back(b-1);
        bra[b-1].push_back(a-1);
    }
    rep(i, q){
        int p, x;
        cin >> p >> x;
        res[p-1] += x;
    }

    dfs(-1, 0);

    rep(i, n){
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}

void dfs(int par, int now){
    int len = bra[now].size();
    if(par!=-1){
        res[now] += res[par];
    }
    if(len){
        rep(i, len){
            if(bra[now][i]!=par){
                dfs(now, bra[now][i]);
            }
        }
    }
    return;
}

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

int main(){
	int N=0;
	int dx=0,dy=0;
	int x=0,y=0,dis=0,ansdis=0;
	int trex=0,trey=0;

	cin >> N;
	for(int i=0;i<N;i++){
		while(1){
			cin >> dx >> dy;
			if(dx==0&&dy==0) break;
			x = x + dx;
			y = y + dy;
			dis = x*x+y*y;
			if(ansdis<=dis){
				if(ansdis==dis&&x<trex) break;
				trex = x;
				trey = y;
				ansdis = dis;
			}
		}
		cout << trex << " " << trey << endl;
		dx=0,dy=0,x=0,y=0,dis=0,trex=0,trey=0,ansdis=0;
	}
}

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

using namespace std;

#define MAX_SIZE 200000
const int INF = (1 << 31) - 1;

int seg[MAX_SIZE * 2 - 1], size = 1;

int find(int sl, int sr, int s, int l, int r) {
    if (r <= sl || sr <= l) {
        return INF;
    }
    if (sl <= l && r <= sr) {
        return seg[s];
    }
    else {
        int vl = find(sl, sr, s * 2 + 1, l, (l + r) / 2);
        int vr = find(sl, sr, s * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

void update(int s, int v) {
    s += size - 1;
    seg[s] = v;
    while (s > 0) {
        s = (s - 1) / 2;
        seg[s] = min(seg[s * 2 + 1], seg[s * 2 + 2]);
    }
}

int main() {
    int n, q, com, x, y;
    cin >> n >> q;
    while (size < n) {
        size *= 2;
    }
    
    fill_n(seg, 2 * size - 1, INF);
    
    while (q--) {
        cin >> com >> x >> y;
        if (com) {
            cout << find(x, y + 1, 0, 0, size) << endl;
        }
        else {
            update(x, y);
        }
    }

    return 0;
}

Measured memory_bytes: 2184
#include<iostream>
#include<cstdio>
using namespace std;
long long f[10000000];
int main()
{
	int i,n;
	for(i=1;i<=1000000;i++)
	{
		if(i%3==0||i%5==0)
			f[i] = f[i-1];
		else
			f[i] = f[i-1] + i;
	}
	cin>>n;
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 11384
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int x,i;
  vector<int>w,k;
  for(i=0;i<10;i++)scanf("%d",&x),w.push_back(x);
  for(i=0;i<10;i++)scanf("%d",&x),k.push_back(x);
  sort(w.begin(),w.end());
  sort(k.begin(),k.end());
  printf("%d %d\n",w[7]+w[8]+w[9],k[7]+k[8]+k[9]);
}

Measured memory_bytes: 1048
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
string S;

bool ch(ll X) {
	//cout << X << endl;

	ll N = S.size();
	ll l = 0;
	ll r = X;
	ll p = 0;

	for (ll i = N - 1; i >= 0; i--) {
		if (S[i] == '0') { l++; r++; }
		if (S[i] == '1') { l--; r--; }
		if (S[i] == '?') { l--; r++; }
		if (l < 0) { l += 1 + p; }
		if (r > X) { r -= 1 + p; }

		if (l > r) { return false; }
		if (l == r) { p = 1; }
		
		//cout << l << " " << r << " " << p << endl;

	}

	return true;
}

int main() {
	cin >> S;
	ch(1);
	//return 0;

	ll r = 1e7;
	ll l = 0;
	while (r - l > 1) {
		ll m = (r + l) / 2;
		bool b = ch(m);
		if (b) { r = m; }
		else { l = m; }
	}

	cout << r << endl;

}


Measured memory_bytes: 5312
import java.util.*;
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[] = new int[n+k-1];
    int dp[] = new int[n+k-1];
    h[0]=sc.nextInt();
    for(int i=1;i<k;i++){
      h[i]=h[0];
    }
    for(int i=k;i<n+k-1;i++){
      h[i]=sc.nextInt();
    }
    for(int i=0;i<k;i++){
      dp[i]=0;
    }
    for(int i=k;i<n+k-1;i++){
      int tmp=1000000000;
      for(int j=1;j<=k;j++){
         tmp = Math.min(tmp,dp[i-j]+Math.abs(h[i]-h[i-j])); 
//        System.out.println(tmp);
      }
      dp[i]=tmp;
    }  

    System.out.println(dp[n+k-2]);
  }

  

  
}

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

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

  string s;

  cin >> s;

  rep(i,s.size()){
    s.at(i) += n;
    if((int)s.at(i)>90){
      s.at(i) -= 26;
    }
  }

  cout << s;

  // cout << (int)'A';
  // cout << endl << (int)'Z';
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	REPO(i, 51000) {
		if (i * 108 / 100 == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] r = new int[n + 1];
			r[2] = 1;
			if (n > 900000) {
				r[900000] = 12478098;
				IntStream.rangeClosed(900001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 800000) {
				r[800000] = 10997400;
				IntStream.rangeClosed(800001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 700000) {
				r[700000] = 9529244;
				IntStream.rangeClosed(700001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 600000) {
				r[600000] = 8075420;
				IntStream.rangeClosed(600001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 500000) {
				r[500000] = 6638407;
				IntStream.rangeClosed(500001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 400000) {
				r[400000] = 5221424;
				IntStream.rangeClosed(400001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 300000) {
				r[300000] = 3829761;
				IntStream.rangeClosed(300001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 200000) {
				r[200000] = 2472071;
				IntStream.rangeClosed(200001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else if (n > 100000) {
				r[100000] = 1166714;
				IntStream.rangeClosed(100001, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			} else {
				IntStream.rangeClosed(3, n).forEach(i -> r[i] = r[i - 1] + getFactorNumbers(i - 1));
			}
			System.out.println(r[n]);
		}
	}

	private static int getFactorNumbers(int n) {
		int result = 0;
		for (int i = 1; i * i <= n; i++) {
			if (0 == (n % i)) {
				result += (i == (n / i)) ? 1 : 2;
			}
		}
		return result;
	}
}


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

using namespace std;
using namespace atcoder;

int main() {
  int T;
  cin>>T;
  for(int i=0;i<T;i++){
    long long n,m,a,b;
    cin>>n>>m>>a>>b;
    long long ans=floor_sum(n,m,a,b);
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
 /* AtCoder Beginner Contest 107 (๑•﹏•๑｀) */

int main(){
    int H,W; SCD2(H,W);
    static char grid[102][102] = {};

    FORq(i,1,H){
        FORq(j,1,W){
            cin >> grid[i][j];
        }
        getchar();
    }

    set<int> yoko;
    set<int> tate;

    FORq(i,1,H){
        bool flg = true;
        FORq(j,1,W){
            if (grid[i][j] == '#') flg = false;
        }
        if (flg) yoko.insert(i);
    }

    FORq(j,1,W){
        bool flg = true;
        FORq(i,1,H){
            if (grid[i][j] == '#') flg = false;
        }
        if (flg) tate.insert(j);
    }

    FORq(i,1,H){
        bool iflg = true;
        FORq(j,1,W){
            if (SIN(i,yoko)){
                iflg = false;
                break;
            }
            if (SIN(j,tate)) continue;
            cout << grid[i][j];
        }
        if (iflg) cout << "\n";
    }
    cout << "\n";
}

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

int main(void){
    int i, n, a[101]={0}, r[10]={0}, cnt=0, cnt8=0, max=0,min=0;
    //r1=0,r2=0,r3=0,r4=0,r5=0,r6=0,r7=0,r8=0,r9=0,;
    
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf(" %d", &a[i]);
    }

    for(i=0;i<n;i++){
        
        if(a[i]<=399){
            r[0]=1;
        }else if(a[i]<=799){
            r[1]=1;
        }else if(a[i]<=1199){
            r[2]=1;
        }else if(a[i]<=1599){
            r[3]=1;
        }else if(a[i]<=1999){
            r[4]=1;
        }else if(a[i]<=2399){
            r[5]=1;
        }else if(a[i]<=2799){
            r[6]=1;
        }else if(a[i]<=3199){
            r[7]=1;
        }else if(a[i]>=3200){
            r[8]=1;
            cnt8++;
        }
        
    }
    
    for(i=0;i<8;i++){
        if(r[i]==1)cnt++;
    }
    min=cnt;
    //if(r[8]==1 && cnt<=8 ){
    if(r[8]==1){
        //max=cnt+2;
        max=cnt+cnt8;
        //max=8;
        //min=cnt
    //}else if(r[8]==1 && cnt<=7 ){
        //max=cnt+1;
      //  max=cnt+cnt8;
        //min=cnt;
    }else{
        max=cnt;
        //min=cnt;
    }
    
    if(min==0) min=1;
    //if(max>=8) max=8;
    
    if(n<=1){
        min=1;
        max=1;
    }
    printf("%d %d\n",min, max);
    
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class DoubleFactorial {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();

            if (n % 2 == 1) {
                out.println(0);
                return;
            }

            long result = 0;
            int s = 1;
            n /= 2;
            while (true) {
                long num = n / (long) Math.pow(5, s);
                s++;
                result += num;
                if (num == 0) {
                    break;
                }
            }
            out.println(result);

        }

    }
}



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

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define endl '\n'

struct __init {
    __init() {
        cin.tie(nullptr);
        std::iostream::sync_with_stdio(false);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        std::mt19937 rand(300);
    }

    ~__init() {
        #ifdef SEREZHKA
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC << endl;
        #endif
    }
} init;

const ll inf = (ll) 1e9 + 7ll;
const int maxn = (int) 1e6 + 17;

int n;
ll a[maxn];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    ll cost = abs(a[0]) + abs(a[n - 1]);

    forn (i, n - 1)
        cost += abs(a[i] - a[i + 1]);

    cout << cost - abs(a[0]) - abs(a[0] - a[1]) + abs(a[1]) << endl;

    for (int i = 1; i < n - 1; ++i)
        cout << cost - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << endl;

    cout << cost - abs(a[n - 1]) - abs(a[n - 2] - a[n - 1]) + abs(a[n - 2]) << endl;
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                  \
  ifstream in("atcoder-problems/sumitb2019_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int X;
  cin >> X;

  int l = X % 100;
  int g = X / 100;
  int cnt = 0;
  while (l > 0) {
    for (int i = 5; i > 0; i--) {
      if (l >= i) {
        l -= i;
        cnt++;
        break;
      }
    }
  }
  cout << (cnt <= g ? 1 : 0) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

                
def resolve():
    a=list(input())
    A=["+","-"]
    temp=""
    for i in A:
        for j in A:
            for k in A:
                temp=a[0]+i+a[1]+j+a[2]+k+a[3]
                if eval(temp)==7:
                    print(temp+"=7")
                    return
        #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1222"""
        output = """1+2+2+2=7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """0290"""
        output = """0-2+9+0=7"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3242"""
        output = """3+2+4-2=7"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Measured memory_bytes: 7436
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> x(n), y(n);
  vector<int> xary, yary;
  rep(i, n){
    cin >> x[i] >> y[i];
    xary.push_back(x[i]); 
    yary.push_back(y[i]);
  }
  sort(begin(xary), end(xary));
  sort(begin(yary), end(yary));
  
  ll ans = 1LL * (xary[n-1] -xary[0])*(yary[n-1]-yary[0]);
  rep(xi, n){
    rep_s(xj, xi+1, n){
      rep(yi, n){
        rep_s(yj, yi+1, n){
          int num = 0;
          ll lx = xary[xi], rx = xary[xj];
          ll by = yary[yi], uy = yary[yj];
		  
          rep(i, n){
            if (lx <= x[i] and x[i] <= rx and by<= y[i] and y[i] <= uy){
              num++;
            }
          }
          if (num >= k) ans = min(ans, 1LL * (rx - lx) * (uy - by));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    string res = "Yes";
    if (S.size() % 2 != 0) {
        res = "No";
    } else {
        for (int i = 0; i < N / 2; i++) {
            if (S[i] != S[i + (N / 2)]) {
                res = "No";
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

//26個の型を用意する(A～Zの分)
		int[] cnt = new int[26];

//入力待ち状態
		while (sc.hasNext()) {
//行単位で取り出す
			String S = sc.nextLine();
//全て小文字に変換
			S = S.toLowerCase();
//String型をchar型に変換
			char[] cs = S.toCharArray();

			for (int i = 0; i < cs.length; i++) {
//アスキーコードの割り当てを比べる
				if (cs[i] >= 'a' && cs[i] <= 'z') {
//アスキーコードの割り当てると対応した番号が得られる(数値として計算する)
					cnt[cs[i] - 'a']++;
				}
			}
		}
		for (int i = 0; i < 26; i++) {
//char型に戻して表示
			System.out.println((char) (i + 'a') + " : " + cnt[i]);
		}
	}
}


Measured memory_bytes: 26108
#include <iostream>
using namespace std;
int nya[100];
int main(){
  int a = 0;
  int n,k;cin>>n>>k;
  for(int i = 0; k > i; i++){
    int z;cin>>z;
    for(int j = 0; z > j; j++){
      int q;cin>>q;q--;
      nya[q]++;
    }
  }
  for(int i = 0; n > i; i++){
    if(!nya[i])a++;
  }
  cout << a << endl;
}
      

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <tuple>
using namespace std;

long long A, B, C;

int main() {
	cin >> A >> B >> C;
	cout << min(C, B / A) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 200005;
int n, a[mx], ans, m, s;

int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", a+i);
		if(a[i]>=m){
			s = m;
			m = a[i];
		}else if(a[i] > s) s = a[i];
	}
	rep(i,n) printf("%d\n",a[i]==m?s:m);
}

Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int x, y;
int g(int p) {return p>0 ? p:-p;}
int main() {
	cin>>x>>y;
	cout<<(x<y ? min(y-x, g(x+y)+1) : min(x-y+2, g(x+y)+1));
	return 0;
}

Measured memory_bytes: 256
from operator import sub

N = int(input())
data = list(map(int, input().split()))
step = N * (N+1) // 2
total = sum(data)
#print("-->", total, step)
if total % step:
  print("NO")
else:
  K = total // step
  #print("-->", total, step, K)
  datar = [data[i % N] for i in range(-1, N)] 
  delta = list(map(sub, datar[1:], datar))
  #print(*delta)
  #print("-->", *list(map(lambda x:(K-x) % N, delta)))
  #print("-->", *list(map(lambda x:(K-x) // N, delta)))
  if any(map(lambda x:(K-x) % N, delta)):
    print("NO")
  elif any(map(lambda x: K-x < 0, delta)): 
    print("NO")
  else:    
    ops = list(map(lambda x:(K-x) // N, delta))
    if sum(ops) == K:
      for i, v in enumerate(data[0:1]):
        vv = sum([ops[(i-k) % N] * (k+1) for k in range(N)])
        if v != vv:        
          print("NO")
          break
      else:    
        print("YES")
    else:
      print("NO")
    

Measured memory_bytes: 14540
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;

int ko[100010];
int main(){
	int n,m;cin>>n>>m;
	string ans="YES";
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		ko[a]++,ko[b]++;
	}
	for(int i=0;i<n;i++)
	{
		if(ko[i]%2==1)
		{
			ans="NO";
			break;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main(){
    ll N,W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i,N) cin >> w[i] >> v[i];
    ll w0 = w[0];
    vector<vector<ll> > dp(N + 1, vector<ll> (305));
    rep(i,N + 1){
        rep(j, 305){
            dp[i][j] = 0;
        }
    }
    for (ll i = 1; i <= N; i++){
        for (ll k = N; k >= 1; k--){
            for (ll j = 0; j <= 300; j++){
                dp[k][j + (w[i - 1] - w0)] = max(dp[k][j + (w[i - 1] - w0)], dp[k - 1][j] + v[i - 1]);
            }
        }
    }
    ll ans = 0;
    rep(i,N + 1){
        rep(j, 305){
            if (w0 * i + j <= W) ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3824
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

  ll N;cin>>N;
  vector<ll> vec(N-1);
  vector<ll> vecans(N);
  for(int i=0;i<N-1;i++){
    cin>>vec[i];
  }
  for(int i=0;i<N;i++){
    vecans[i]=0;
  }
  for(int i=0;i<N-1;i++){
    vecans[vec[i]-1]++;
  }

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



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

template<class T>
struct SegmentTree {

    int size;
    const T nullValue;
    const function<T(T, T)> annex;
    vector<T> data;

    SegmentTree ( int n, T defaultValue, const function<T(T, T)> f )
      : annex(f), nullValue(defaultValue) {
        for ( size = 1; size < n; size *= 2 );
        data.resize ( 2*size-1, defaultValue );
    }

    void update ( int pos, T value ) {
        pos += size-1;
        data[pos] = value;
        while ( pos > 0 ) {
            pos = ( pos - 1 ) / 2;
            data[pos] = annex ( data[pos*2+1], data[pos*2+2] );
        }
    }

    T add ( int pos, T value ) {
        update ( pos, value + data[pos+size-1] );
        return data[pos+size-1];
    }


    T get ( int begin, int end, int pos=0, int left=0, int right=-1 ) {
        if ( right == -1 ) right = size;

        if ( right <= begin || end <= left ) return nullValue;
        if ( begin <= left && right <= end ) return data[pos];

        int next = ( left + right ) / 2;
        return annex ( get ( begin, end, pos*2+1, left, next ), get ( begin, end, pos*2+2, next, right ) );
    }

    inline const T& operator [] ( int index ) const {
        return data[index+size-1];
    }

    inline T& operator [] ( int index ) {
        return data[index+size-1];
    }
};

// SegmentTree seg (n, 0, [](int a, int b) { return a+b }; );

signed main ( ) {

    int n;
    cin >> n;
    SegmentTree<int> seg(n, 0, [](int a, int b) { return max(a, b); });

    for ( int i = 0; i < n; i++ ) {
        int a;
        scanf("%d", &a);
        seg.update(i, a);
    }

    for ( int i = 0; i < n; i++ ) {
        int tmp = seg[i];
        seg.update(i, 0);
        printf("%d\n", seg.get(0, n));
        seg.update(i, tmp);
    }

    return 0;
}

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

int main(){
  double N,M,sum=0;
  cin >> N >> M;
  vector<double> A(N);
  for(int i=0;i<N;++i){
    cin >> A.at(i);
    sum += A.at(i);
  }
  double t = sum / (4*M);
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());

  bool b = 1;
  for(int i=0;i<M;++i){
    if(A.at(i)<t){
      b = 0;
    }
  }
  if(b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var max = ToInt32(input[0]);
        var num = ToInt32(input[1]);
        var result = 0;
        for(var i = 0; i <= max; i++)
        {
            if (i > num) break;
            for(var j = 0; j <=i; j++)
            {
                if (i + j > num) break;
                if (num - (i + j) > j) continue;
                var h = num-(i+j);
                if (i == j && j == h && h == i) result++;
                else if (i == j || j == h || h == i) result += 3;
                else result += 6;
            }
        }

        WriteLine(result);
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int A,B; cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	    cin>>a[i];
	int dp[n]={0};
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
	    int temp=INT_MAX;
	    for(int j=1;j<=k;j++)
	        {   if(i-j<0)
	                break;
	            temp=min(abs(a[i]-a[i-j])+dp[i-j],temp);
	        }
	       dp[i]=temp;
	    
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
	
int dp[3111][3111];
int S[3111][3111];

int sum(int i, int l, int r)
{
	l=max(l,0);
	if(l>r) return 0;
	if(l==0) return S[i][r];
	else return add(S[i][r],MOD-S[i][l-1]);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	dp[0][0]=1;
	S[0][0]=1;
	for(int i=1;i<n;i++)
	{
		char c=s[i-1];
		for(int j=0;j<=i;j++)
		{
			//choose j here
			if(c=='<')
			{
				dp[i][j]=sum(i-1,0,j-1);
			}
			else
			{
				dp[i][j]=sum(i-1,j,i-1);
			}
		}
		for(int j=0;j<=i;j++)
		{
			S[i][j]=dp[i][j];
			if(j>0) S[i][j]=add(S[i][j],S[i][j-1]);
		}
	}
	int ans=0;
	for(int i=0;i<n;i++) ans=add(ans,dp[n-1][i]);
	cout<<ans<<'\n';
}


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

#define YES(condition) if(condition){ cout << "YES" << endl; }else{ cout << "NO" << endl; }
#define Yes(condition) if(condition){ cout << "Yes" << endl; }else{ cout << "No" << endl; }

int main(){
    int N;
    cin >> N;
    int nums_not_have_2_count = 0;
    int nums_have_4_count = 0;
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        if(num % 4 == 0){
            nums_have_4_count++;
        }else if(num % 2 == 1){
            nums_not_have_2_count++;
        }
    }
    Yes(nums_have_4_count >= nums_not_have_2_count || (nums_have_4_count + 1 == nums_not_have_2_count && nums_have_4_count + nums_not_have_2_count == N));
}



Measured memory_bytes: 256