akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<functional>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;
typedef pair<int, int> P;
int N, M, K;
int G[3000][3000];
int S[3000];
int main()
{
	scanf("%d%d%d", &N, &M, &K);
	for (int i = 0; i < N; i++)S[i] = 1000000000;
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)G[i][j] = 1000000000;
	for (int i = 0; i < M; i++){
		int A, B, C;
		scanf("%d%d%d", &A, &B, &C);
		G[A - 1][B - 1] = C;
		G[B - 1][A - 1] = C;
	}
	priority_queue<P,vector<P>,greater<P> >que;
	for (int i = 0; i < K; i++){
		int A;
		scanf("%d", &A);
		que.push(make_pair(0, A-1));
	}
	while (!que.empty()){
		P p = que.top(); que.pop();
		if (p.first>S[p.second])continue;
		S[p.second] = p.first;
		for (int u = 0; u < N; u++){
				if (S[p.second] + G[p.second][u]<S[u]){
					que.push(make_pair(S[p.second] + G[p.second][u], u));
				}
		}
	}
	
	int ans = 0;
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			if(G[i][j]<=10000)ans = max(ans, (S[i] + S[j] + 1 + G[i][j]) / 2);
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

 
int main(){
    long long N,K;
    cin >> N >> K;
    N %= K;
    cout << min(N,abs(N-K)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n); rep (i, n) cin >> a[i];
    ll ans = 0;
    sort(all(a));
    reverse(all(a));
    rep (i, n) {
        if (i == 0) continue;
        eprintf("%d:%d\n", i, a[i/2]);
        ans += a[i / 2];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end(), greater<ll>());
    ll ok = P-1;

    auto solve = [&](ll a){
        ll cnt = 0;
        Rep (i, N) {
            if (A[a]+M < A[P-1]) return false;

            if (i < P-1 || a <= i) {
                cnt += M;
            } else {
                cnt += max((ll)0, A[a]+M-A[i]);
            }
        }
        if (cnt >= M*V) return true;
        else return false;
    };


    ll ng = N;
    while (abs(ok-ng) > 1) {
        ll mid = (ok+ng)/2;
        if (solve(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok+1 << endl;
}

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

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

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

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

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

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

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

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

		return true;
	}
};

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

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

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

int main() {
	int n, q;
	string s;
	cin >> n >> q;
	cin >> s;
	vpint rl(q);
	rep(i, q) {
		cin >> rl[i].first >> rl[i].second;
	}
	vint table(n, 0);
	rep(i, n - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			table[i + 1] = table[i] + 1;
		}
		else {
			table[i + 1] = table[i];
		}
	}
	vint ans(q, 0);
	rep(i, q) {
		ans[i] = table[rl[i].second - 1] - table[rl[i].first - 1];
	}
	rep(i, q) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>

#define mod 1000000007
struct yak{
		long long a;
		int c;
};

long long ka(long long x,long long a){
//		printf("%lld\n",a);
		if(a==1)return x;
		if(a%2==0){
				long long b;
				b=ka(x,a/2);
				return (b*b)%mod;
		}
		return (x*ka(x,a-1))%mod;
}

long long div(long long x,long long y){
		return (x*ka(y,mod-2))%mod;
}

long long ncm(long long n,long long m){
		long long r=1,i,rr=1,rrr=1;
		for(i=2;i<=n;i++)r=(r*i)%mod;
		for(i=2;i<=m;i++)rr=(i*rr)%mod;
		for(i=2;i<=n-m;i++)rrr=(rrr*i)%mod;
		return (div(div(r,rr),rrr))%mod;
}
int main(){
		int n,i,c=0;
		long long m,j,ans=1;
		struct yak yaku[1000];
		scanf("%d%lld",&n,&m);
		if(n==1||m==1){
				puts("1");
				return 0;
		}
		for(i=0;i<1000;i++)yaku[i].c=0;
		for(j=2;j*j<=m;j++){
				if(m%j==0){
						int f=0;
						for(i=0;i<c;i++){
								if(yaku[i].a==j){
										yaku[i].c+=1;
										f=1;
										break;
								}
						}
						if(f==0){
								yaku[c].a=j;
								yaku[c].c=1;
								c++;
						}
						m/=j;
						j=1;
				}
										//printf("%lld\n",yaku[0].c);
		}
		if(c==0){
				printf("%d\n",n);
				return 0;
		}
		if(m!=1){
				int f=0;
				for(i=0;i<c;i++){
						if(yaku[i].a==m){
								yaku[i].c++;
								f=1;
								break;
						}
				}
				if(f==0){
						yaku[c].a=m;
						yaku[c].c=1;
						c++;
				}
		}
		for(i=0;i<c;i++){
//				printf("%lld\n",ncm(n+yaku[i].c-1,n-1));
				ans=(ans*ncm(n+yaku[i].c-1,n-1))%mod;
		}
		printf("%lld\n",ans%mod);
		return 0;
}


Measured memory_bytes: 128
import sys
from itertools import product
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().strip()))
A1 = [a%2 for a in A]
for i in range(31, -1, -1):
    if (1<<i) & len(A1):
        k = 1<<i
        B = []
        B.append(sum(A1[:k])%2)
        for j in range(k, len(A1)):
            B.append((B[-1] + A1[j] - A1[j-k])%2)
        A1 = B[:]
    if (1<<i) & len(A1):
        k = 1<<i
        B = []
        B.append(sum(A1[:k])%2)
        for j in range(k, len(A1)):
            B.append((B[-1] + A1[j] - A1[j-k])%2)
        A1 = B[:]
pari = A1[0]
if pari == 1:
    ans = 1
else:
    if 2 in A:
        ans = 0
    else:
        A2 = [abs(a2-a1)//2 for a1, a2 in zip(A, A[1:])]
        N2 = len(A2)
        for i in range(31, -1, -1):
            if (1<<i) & len(A2):
                k = 1<<i
                B = []
                B.append(sum(A2[:k])%2)
                for j in range(k, len(A2)):
                    B.append((B[-1] + A2[j] - A2[j-k])%2)
                A2 = B[:]
            if (1<<i) & len(A2):
                k = 1<<i
                B = []
                B.append(sum(A2[:k])%2)
                for j in range(k, len(A2)):
                    B.append((B[-1] + A2[j] - A2[j-k])%2)
                A2 = B[:]
        
        if A2[0] == 0:
            ans = 0
        else:
            ans = 2

print(ans)

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

int ans;
signed main(){
	
    int n,l;
    cin>>n>>l;
    int sum=0,min=INF;
    pair<int,int> p[1111];
    rep(i,n){
        p[i].second=l+i;
        p[i].first=abs(l+i);
        sum+=p[i].second;
    }
    sort(p,p+n);
    cout<<sum-p[0].second<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll r;
	cin >> r;
	if(n>=10)
		cout << r << endl;
	else
		cout << r+100*(10-n) << 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 n = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		int [][]co = new int [c][c];
		
		for(int i = 0 ; i < c ;i++) {
			for(int j = 0 ; j < c ;j++) {
				co[i][j] = Integer.parseInt(sc.next());
			}
		}
		
		int [][]grid = new int [n][n];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < n ;j++) {
				grid[i][j] = Integer.parseInt(sc.next())-1;
			}
		}
		int [][]cnt = new int [c][3];
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j <n ;j++) {
				if((i+j)%3 == 0) {
					cnt[grid[i][j]][0]++;
				}
				else if((i+j)%3 == 1) {
					cnt[grid[i][j]][1]++;
				}
				else {
					cnt[grid[i][j]][2]++;
				}
			}
		}
		
		int ans = 1000000000;
		for(int i = 0 ; i < c ; i++) {
			for(int j = 0 ; j < c ; j++) {
				for(int k = 0 ; k < c ; k++) {
					if(i == j || j == k || i == k) {
						continue;
					}
					int temp = 0;
					for(int nx = 0; nx < c ; nx++) {
						temp += co[nx][i]*cnt[nx][0];
						temp += co[nx][j]*cnt[nx][1];
						temp += co[nx][k]*cnt[nx][2];
					}
					
					ans = Math.min(ans,temp);
				}
			}
		}
		System.out.println(ans);
		
		
	}
}


Measured memory_bytes: 60240
def distance_n(x, y, p)
    d = 0.0
    x.length.times { |i|
        d += ((x[i]-y[i]).abs**p)
    }
    d**(1/p)
end

def distance_i(x, y)
    d = 0.0
    x.length.times { |i|
        du = (x[i]-y[i]).abs
        d = du if du > d
    }
    d
end

n = gets.to_i
x = gets.chomp.split(" ").map &:to_f
y = gets.chomp.split(" ").map &:to_f

3.times{ |i| puts distance_n(x, y, (i+1).to_f) }
puts distance_i(x, y)

Measured memory_bytes: 8876
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
int main() {

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vi> dist(h, vi(w, INF));
  int ans = 0;
  int si = 0;
  int sj = 0;
  if (s[si][sj] == '#' || s[h - 1][w - 1] == '#') {
    cout << -1 << endl;
    return 0;
  }

  else {
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF)
        return;
      dist[i][j] = x;
      q.emplace(i, j);
    };
    update(si, sj, 0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir, 4) {
        int ni = i + di[dir], nj = j + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w)
          continue;
        if (s[ni][nj] == '#')
          continue;
        update(ni, nj, dist[i][j] + 1);
      }
    }
  }
  ans = dist[h - 1][w - 1];
  if (ans == INF) {
    cout << -1 << endl;
    return 0;
  }
  int sum = 0;
  rep(ih, h) rep(jw, w) {
    if (s[ih][jw] == '.')
      sum++;
  }
  cout << sum - ans - 1 << endl;
}


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

int main(){
    string s;
    cin>>s;
    if(s=="SUN"){
        cout<<7<<endl;
    }
    else if(s=="MON"){
        cout<<6<<endl;
    }
    else if(s=="TUE"){
        cout<<5<<endl;
    }
    else if(s=="WED"){
        cout<<4<<endl;
    }
    else if(s=="THU"){
        cout<<3<<endl;
    }
    else if(s=="FRI"){
        cout<<2<<endl;
    }
    else{
        cout<<1<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n; cin >> n;
    map<int,int> mp;
    for(int i = 2; i <= n; ++i){
        int m = i;
        for(int x = 2; x*x <= i;++x){
            while(m%x == 0) {
                m /= x;
                mp[x]++;
            }
        }
        if(m != 1) mp[m]++;
    }
    int ans = 0;
    int n3 = 0,n5 = 0,n25 = 0,n75 = 0,n15 = 0;
    for(auto x : mp){
        if(x.second >= 74) n75++;
        if(x.second >= 2) n3++;
        if(x.second >= 4) n5++;
        if(x.second >= 24) n25++;
        if(x.second >= 14) n15++;
    }
    cout << n75+n15*(n5-1)+n25*(n3-1)+n5*(n5-1)/2*(n3-2) << endl;
}

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

ways n x = let allComb = [(a,b,c) | a <- [1..n], b <- [1..n], c <- [1..n], a < b && b < c] in
    length $ filter (\(l,m,n)->l+m+n == x) allComb

processInputLine [n,x] =
    if n == 0 && x == 0 then return () else print $ ways n x

main = do
    mapM_ processInputLine =<< map (map (read :: String->Int) . words) <$> lines <$> getContents

Measured memory_bytes: 5572
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

total = sum(A)
each = N*(N+1) // 2
if total % each != 0:
    NO()
    exit()
# 操作回数
K = total // each

# A各値の差分で数列Bを作る
B = [0] * N
for i in range(N):
    j = (i+1) % N
    B[i] = A[j] - A[i]
# ここからK引けば、1度の操作につきBのいずれかの要素を+N、とできる
B = [b-K for b in B]

if all(b % N == 0 and b <= 0 for b in B):
    YES()
else:
    NO()


Measured memory_bytes: 14440
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        _N: usize,
        M: usize,
        yobo: [(usize, usize); M],
    }

    yobo.sort_by_key(|a| a.0);
    let mut hashi: Vec<(usize, usize)> = Vec::new();
    for next in yobo.iter() {
        let mut is_merged = false;
        for prev in hashi.iter_mut() {
            let s_max = cmp::max(next.0, prev.0);
            let e_min = cmp::min(next.1, prev.1);
            if s_max < e_min {
                *prev = (s_max, e_min);
                is_merged = true;
                break
            }
        }
        if !is_merged {
            hashi.push(*next);
        }
    }
    println!("{}", hashi.len());
}



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

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

  int c=0;
  if(n >= 105){
    for(int i=105;i<=n;i+=2){
      int count=0;
      for(int j=1;j<=i;j++){
	if(i%j==0)count++;
      }
      if(count == 8)c++;
    }
  }
  
  cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	bool OK = true;
	

	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	
	for (int i = N - 1; i > 0; i--)
	{
		if(h[i - 1] > h[i]){
			h[i - 1]--;
			if (h[i - 1] > h[i]) {
				OK = false;
				break;
			}
		}
	}

	if (OK) cout << "Yes" << endl;
	else cout <<"No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
 
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")
 
#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

const int N=500005,P=998244353;

int fpow(int a,int t){
	static int r;
	for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}

int n,k,fac[N],ifac[N],ret;
int C(int n,int m){return n<m||m<0?0:(ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}
int G(int x,int y){return C(x,(x+y)/2);}
int S(int x,int y,int z){return z>=0?0:(G(x,y)-G(x,2*z-y)+P)%P;}

int main(){
	scanf("%d%d",&n,&k);
	fac[0]=1;
	fo(i,1,k)fac[i]=(ll)fac[i-1]*i%P;
	ifac[k]=fpow(fac[k],P-2);
	fd(i,k,1)ifac[i-1]=(ll)ifac[i]*i%P;
	fo(red,1,k){
		int blue=k-red;
		if(red<blue)continue;
		if(red==blue){
			ret=(ret+S(k-1,1,-k/2+n-1))%P;
		}
		if(red>blue){
			int fix=n-(red-blue);
			ret=(ret+S(red+blue,red-blue,fix-blue-1))%P;
		}
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 4096
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[50],b[50],c[50],mn[400111],x,y,ans=inf;
int main()
{
	for(int i=0;i<400111;i++)mn[i]=inf;
	get3(n,x,y);
	for(int i=0;i<n;i++)
		get3(a[i],b[i],c[i]);
	for(int i=0;i<n;i++)
	{
		a[i]*=y;
		b[i]*=x;
	}
	
	int t=n>>1,t2=n-t;
	mn[100000]=0;
	for(int mask=1;mask<(1<<t);mask++)
	{
		int tx=0,ty=0,tz=0;
		for(int i=0;i<t;i++)if((mask>>i)&1)
		{
			tx+=a[i];
			ty+=b[i];
			tz+=c[i];
		}
//		printf("mask %d tx %d ty %d tz %d\n",mask,tx,ty,tz);
		if(tx==ty)ans=min(ans,tz);
		mn[tx-ty+100000]=min(mn[tx-ty+100000],tz);
	}
	for(int mask=1;mask<(1<<t2);mask++)
	{
		int tx=0,ty=0,tz=0;
		for(int i=0;i<t2;i++)if((mask>>i)&1)
		{
			tx+=a[i+t];
			ty+=b[i+t];
			tz+=c[i+t];
		}
		ans=min(ans,tz+mn[ty-tx+100000]);
//		printf("mask %d tx %d ty %d tz %d\n",mask,tx,ty,tz);
	}
	printendl(ans==inf?-1:ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Double> li = new ArrayList<>();
        double allv = 0;
        for(int i = 0; i < n; i++){
            double d = sc.nextDouble();
            li.add(d);
            allv += d;
        }
        Collections.sort(li, Comparator.reverseOrder());
        if(li.get(m-1) >= (allv/(4*m))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}

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

int main(){

  int X,Y;
  int N,M;
  cin >> N >> M >> X >> Y;

  int x[100];
  cin >> x[0];
  int xmax = x[0];
  for(int i = 1;i < N;i++){
    cin >> x[i];
    if(xmax < x[i])xmax = x[i];
  }

  int y[100];
  cin >> y[0];
  int ymin = y[0];
  for(int i = 1;i < M;i++){
    cin >> y[i];
    if(ymin > y[i])ymin = y[i];
  }

  bool flag = false;

  for(int i = X+1;i <= Y;i++){
    if(i > xmax and i <= ymin)flag = true;
  }

  if(flag)cout << "No War" << endl;
  else cout << "War" << endl;


}

Measured memory_bytes: 384
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
from copy import deepcopy
import queue
from collections import deque





def main():
    num = int(input())
    data = list(map(int, input().split()))

    now_num = 10 ** 10
    ans = 0

    for i in range(num):
        if data[i] < now_num:
            now_num = data[i]
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99476
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int al=a.length(),bl=b.length();
    for(int i=0;i<al-1;i++)
        cout<<a[i]<<b[i];
    cout<<a[al-1];
    if(al==bl) cout<<b[bl-1];
    cout<<endl;
    return 0;
} 

Measured memory_bytes: 256
import math

K = int(input())
tot = 0
for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        gcd = math.gcd(i, j)
        tot += 6 * gcd
        for k in range(j + 1, K + 1):
            tot += 6 * math.gcd(gcd, k)

tot += sum(range(1, K + 1))
print(tot)


Measured memory_bytes: 9176
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')

    elif total < 50 and r < 50:
        print('D')

    elif total < 65 or r >= 50:
        print('C')
        
    elif total < 80:
        print('B')

    else:
        print('A')
        

Measured memory_bytes: 7728
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n;
    cin>>n;
    string s=to_string(n);
    lint t=0;
    rep(i,s.size()){
        t+=s[i]-'0';
    }
    if(n%t)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
A = Array.new
B = Array.new
C = Array.new
for i in 0..N-1
    A[i] = i+1
    B[i] = 0
    C[i] = 0
    while B[i] == 0
        if A[i] % 2 == 0
            A[i] /= 2
            C[i] += 1
        else
            B[i] += 1
        end
    end
end

puts C.index(C.max)+1

Measured memory_bytes: 1788
#include<iostream>

bool prime[1000001], dp[1000001];

int main(){
	for(int i=0;i<=1000000;i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = 0;
	for(int i=2;i*i<1000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i)prime[j] = false;
		}
	}

	int n, x, a[30];
	while(std::cin >> n >> x, n){
		for(int i=0;i<=x;i++){
			dp[i] = false;
		}

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

		int res = 0;

		dp[0] = true;
		for(int i=1;i<=x;i++){
			for(int j=0;j<n;j++){
				if(i-a[j] >= 0 && dp[i-a[j]]){
					dp[i] = true;
					break;
				}
			}
			if(dp[i] && prime[i]){
				res = i;
			}
		}

		if(res != 0){
			std::cout << res << std::endl;
		}else{
			std::cout << "NA" << std::endl;
		}
	}
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("/home/pushkar/cpp/input.txt", "r", stdin);
    //freopen("/home/pushkar/cpp/output.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    if (n >= 30)
    cout << "Yes\n";
    else
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if (k <= a + b) cout << a << endl;
    else cout << a - (k-a-b) << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#include <unordered_map>
#include <unordered_set>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;

template<class T> void SWAP(T& a, T& b) { a ^= b; b ^= a; a ^= b; }

class D {
	int n, m;
	vector<int> p;
	unordered_map<int, unordered_set<int>> unions;
	vector<int> parent;

public:
	D()
	{
		cin >> n >> m;
		p.resize(n);

		int tmp;
		REP(i, n)
		{
			cin >> tmp;
			p[i] = tmp - 1;
		}
		parent.resize(n, -1);

		int a, b;
		REP(i, m)
		{
			cin >> a >> b;
			add(a - 1, b - 1);
		}
	}

	int root(int a)
	{
		if (parent[a] < 0)
			return a;

		parent[a] = root(parent[a]);
		return parent[a];

	}

	void add(int a, int b)
	{
		int a_root{ root(a) };
		int b_root{ root(b) };

		if (a_root == b_root)
			return;

		int size_a{ parent[a_root] };
		int size_b{ parent[b_root] };

		if (size_a > size_b)
		{
			SWAP(a_root, b_root);
			SWAP(size_a, size_b);
		}

		parent[b_root] = a_root;
		parent[a_root] += size_b;

	}

	void solve()
	{
		int ans{ 0 };

		REP(i, n)
		{
			if (parent[i] == -1)
			{
				if (p[i] == i)
					++ans;
			}
			else if (parent[i] < 0)
			{
				if (unions.find(i) == unions.end())
				{
					unordered_set<int> tmp{ i };
					unions.emplace(MP(i, tmp));
				}
			}
			else
			{
				int rt{ root(i) };
				auto un{ unions.find(rt) };
				if (un == unions.end())
				{
					unordered_set<int> tmp{ i, rt };
					unions.emplace(MP(rt, tmp));
				}
				else
					un->second.insert(i);
			}
		}

		for (auto un{ unions.begin() }; un != unions.end(); un++)
		{
			for (int i : un->second)
			{
				if (un->second.count(p[i]))
					++ans;
			}
		}

		cout << ans << endl;
	}

	void debug()
	{
		cout << "=========== debug FROM HERE =============" << endl << endl;

		for (auto un{ unions.begin() }; un != unions.end(); un++)
		{
			cout << "key = " << un->first << "  val(set) : { ";

			for (int x : un->second)
				cout << x << " ";
			cout << "}" << endl;

		}
		cout << endl;

		//cout << "printing vector parent..." << endl;
		//REP(i, n)
		//	cout << parent[i] << " ";

		cout << endl << "=========== debug END =============" << endl << endl;

	}

};

int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define CIN(a) cin >> a;
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a
#define COUT2(a, b) cout << a << ' ' << b
#define COUT3(a, b, c) cout << a << ' ' << b << ' ' << c
#define ENDL cout << '\n'
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };

ll X, K, D;

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

	CIN3(X, K, D);
	X = abs(X);
	ll tmp = X / D;
	if (K >= tmp)
	{
		K -= tmp;
		X %= D;
		if (K % 2) COUT(abs(X - D));
		else COUT(X);
	}
	else
	{
		COUT(X - (K * D));
	}



	return 0;
}

Measured memory_bytes: 3644
N=int(input())
dic={0:0}
for i in range(N):
    s=input()
    if dic.get(s,0)==0:
        dic[s]=1
    else:
        dic[s]+=1
M=int(input())
for i in range(M):
    s=input()
    if dic.get(s,0)!=0:
        dic[s]-=1
print(max(list(dic.values())))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    sort(a.begin(),a.end());

    cout << a[0] << " " << a[1] << " " << a[2] << endl;
  
    return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  string s,t;
  cin>>s>>t;
  int n;
  cin>>n;
  vector<int> rs(s.size()+1,0);
  for(int i=0;i<s.size();i++){
    if(s[i]=='A')rs[i+1]=rs[i]+1;
    else rs[i+1]=rs[i]+2;
  }
  vector<int> rt(t.size()+1,0);
  for(int i=0;i<t.size();i++){
    if(t[i]=='A')rt[i+1]=rt[i]+1;
    else rt[i+1]=rt[i]+2;
  }

  for(int i=0;i<n;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    c--;
    int sp=rs[b]-rs[a];
    int tp=rt[d]-rt[c];
    if(sp%3==tp%3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define  LL long long
const int N = 1e5+33;
int t[N],x[N],y[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	}
	int flag=1;
	for(int i=1;i<=n;i++){
		int dis=abs(x[i-1]-x[i])+abs(y[i-1]-y[i]);
		int pre=t[i]-t[i-1];
		if(pre>=dis&&(pre-dis)%2==0){

		}else{
			flag=0;
			break;
		}
	}
	if(flag) puts("Yes");
	else puts("No");



	
	return 0;
}


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

int main() {
  int N;
  int longest = 0;
  int sum = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    int l;
    cin >> l;
    if(l >= longest) longest = l;
    sum += l;
  }
  if(longest < (sum - longest)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)

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

Measured memory_bytes: 576
from heapq import heappush, heappop

s = input()
K = int(input())

min_s = sorted(list(set(s)))

res = [min(s)]
q = []
x = 0

while len(set(q)) < K:
    min_index = [n for n, v in enumerate(s) if v == min_s[x]]
    for m in min_index:
        for i in range(1, 6):
            if m+i <= len(s):
                q.append(s[m:m+i])
    x += 1

ans = sorted(list(set(q)))[K-1]

print(ans)


Measured memory_bytes: 4716
import java.util.Scanner;
class Main
{
 public static void main(String args[])
 {
 Scanner scan=new Scanner(System.in);
 int n=scan.nextInt();
 
 char s[][]={{'.',',','!','?',' '},
             {'a','b','c'},
			 {'d','e','f'},
			 {'g','h','i'},
			 {'j','k','l'},
			 {'m','n','o'},
			 {'p','q','r','s'},
			 {'t','u','v'},
			 {'w','x','y','z'},
			 };
 for(int i=0;i<n;i++)
 {
  String str=scan.next();
  String ans="";
  for(int j=0;j<str.length();j++)
  {
   int count=-1,select=0,waru=3;
   while(str.charAt(j)!='0')
   {
    count++;
	j++;
   }
   if(count==-1)continue;
   select=Integer.parseInt(str.charAt(j-1)+"")-1;
   if(select==0)waru=5;
   if(select==6||select==8)waru=4;
   ans+=s[select][count%waru];
  }
  System.out.println(ans);
 }
 
 }
}

Measured memory_bytes: 24180
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int N;

static double dp[310][310][310];

double cal_E(int i, int j, int k)
{
    if (dp[i][j][k] >= 0)
    {
        return dp[i][j][k];
    }

    if (i == 0 && j == 0 && k == 0)
    {
        return 0;
    }

    double tmp = 0;

    if (i > 0)
    {
        tmp += cal_E(i - 1, j, k) * i;
    }

    if (j > 0)
    {
        tmp += cal_E(i + 1, j - 1, k) * j;
    }

    if (k > 0)
    {
        tmp += cal_E(i, j + 1, k - 1) * k;
    }

    tmp += N;

    tmp *= 1.0 / (i + j + k);

    return dp[i][j][k] = tmp;
}

int main()
{
    int a;
    int one, two, three;
    int i, j, k;

    cin >> N;

    one = two = three = 0;

    rep(i, 1, N)
    {
        cin >> a;

        if (a == 1)
        {
            one++;
        }
        else if (a == 2)
        {
            two++;
        }
        else
        {
            three++;
        }
    }

    memset(dp, -1, sizeof(dp));

    printf("%.10f\n", cal_E(one, two, three));
}

Measured memory_bytes: 233088
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).OrderBy(x => x).ToArray();
        var array = new int[100003];
        for (int i = 0; i < N; ++i)
        {
            array[a[i]]++;
            array[a[i] + 1]++;
            array[a[i] + 2]++;
        }
        var ans = array.Max();
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 22624
#include <stdio.h>

int main(void){
  int w, h, n;
  int i, xb, yb, xn, yn, xgap, ygap, count = 0;
  scanf("%d%d%d", &w, &h, &n);
  //printf("%d %d %d\n", w, h, n);
  for(i = 0; i < n; i++){
    if(i != 0){
      xb = xn;
      yb = yn;
    }
    scanf("%d%d", &xn, &yn);
    //printf("%d %d\n", xn, yn);
    if(i != 0){
      xgap = xn - xb;
      ygap = yn - yb;
      //printf("count:%d\n", count);
      //printf("xgap : %d ygap : %d\n", xgap, ygap);
      if(xgap == 0){ count += ygap > 0 ? ygap : -ygap; continue; }
      if(ygap == 0){ count += xgap > 0 ? xgap : -xgap; continue; }
      if(ygap > 0 && xgap > 0){
	count += ygap > xgap ? ygap : xgap;
	//count += (ygap - xgap) > 0 ? ygap - xgap : xgap - ygap;
	continue;
      }
      if(ygap < 0 && xgap < 0){
	count -= ygap < xgap ? ygap : xgap;
	//count -= (ygap - xgap) < 0 ? ygap - xgap : xgap - ygap;
	continue;
      }
      if(ygap > 0){ count += ygap - xgap; continue; }
      if(xgap > 0){ count += xgap - ygap; continue; }
    }
  }
  printf("%d\n", count);

  return 0;
}

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

inline bool in_maze(int n, int max)
{
	return (0 <= n && n < max);
}

typedef struct
{
	int x;
	int y;
} POINT;

int main()
{
	int h, w;
	int max_cost = -1;

	cin >> h >> w;

	vector<string> maze;

	for (int i = 0; i < h; i++)
	{
		string s;
		cin >> s;
		maze.push_back(s);
	}

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			vector<vector<int>> v(h, vector<int>(w, -1));
			queue<POINT> q;
			int cost = 0;
			int x = j, y = i;

			if (maze[i][j] == '#')
			{
				continue;
			}

			q.push({x, y});
			v[y][x] = 0;

			while (!q.empty())
			{
				POINT point = q.front();
				q.pop();

				x = point.x;
				y = point.y;
				cost = v[y][x];
				vector<POINT> next_points = {
					{x - 1, y}, {x + 1, y}, {x, y - 1}, {x, y + 1}};

				if (max_cost < cost)
				{
					max_cost = cost;
				}

				for (auto &next_p : next_points)
				{
					int n_x = next_p.x;
					int n_y = next_p.y;

					if (in_maze(n_x, w) && in_maze(n_y, h) && v[n_y][n_x] == -1 && maze[n_y][n_x] != '#')
					{
						q.push({n_x, n_y});
						v[n_y][n_x] = cost + 1;
					}
				}
			}
		}
	}

	cout << max_cost << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

struct data{
  int from,to,type;
};

bool cmp(data a, data b){
  if(a.to != b.to){
    return a.to < b.to;
  }else{
    return a.type < b.type;
  }
}

int main(){
  int n,m,q; cin >> n >> m >> q;
  vector<data> v(m+q);
  vector<int> alts;
  rep(i,m+q){
    cin >> v[i].from >> v[i].to;
    v[i].to++;
    if(i<m) v[i].type = -1;
    else v[i].type = i-m;
    alts.push_back(v[i].from), alts.push_back(v[i].to);
  }
  sort(alts.begin(),alts.end());
  alts.erase(unique(alts.begin(),alts.end()), alts.end());
  sort(v.begin(),v.end(),cmp);
  
  rep(i,m+q){
    int left = lower_bound(alts.begin(),alts.end(),v[i].from) - alts.begin();
    int right = lower_bound(alts.begin(),alts.end(),v[i].to) - alts.begin();
    v[i].from = left + 1;
    v[i].to = right + 1;
  }
  BIT<int> bit((m+q)*2+10);
  vector<int> res(q);
  rep(i,m+q){
    if(v[i].type == -1) bit.add(v[i].from,v[i].from+1,1);
    else res[v[i].type] = bit.sum(v[i].from,v[i].to);
  }
  rep(i,q) cout << res[i] << endl;
  
  return 0;
}

Measured memory_bytes: 13420