akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
from string import digits

def convert(S):
    S = S + "$"
    cur = 0
    def expr():
        nonlocal cur
        res = []
        op = '+'
        while 1:
            r = fact()
            if op == '-':
                for e in r:
                    e[0] *= -1
            res.extend(r)
            if S[cur] not in '+-':
                break
            op = S[cur]
            cur += 1 # '+' or '-'
        r = []
        for e0 in res:
            k0, es0 = e0
            for e1 in r:
                k1, es1 = e1
                if es0 == es1:
                    e1[0] += k0
                    break
            else:
                r.append(e0)
        res = list(filter(lambda x: x[0] != 0, r))
        res.sort()
        return res

    def fact():
        nonlocal cur
        res = [[1, []]]
        while 1:
            r = idt()
            r0 = []
            for v0, es0 in res:
                for v1, es1 in r:
                    d = {}
                    for k, v in es0:
                        d[k] = d.get(k, 0) + v
                    for k, v in es1:
                        d[k] = d.get(k, 0) + v
                    *es, = d.items()
                    es.sort()
                    r0.append([v0*v1, es])
            res = r0

            while S[cur] == ' ':
                cur += 1 # ' '
            if S[cur] in '+-$)':
                break
        return res
    def idt():
        nonlocal cur
        while S[cur] == ' ':
            cur += 1 # ' '
        if S[cur] == '(':
            cur += 1 # '('
            r = expr()
            cur += 1 # ')'
        elif S[cur] in digits:
            v = number()
            r = [[v, []]]
        else:
            c = S[cur]
            cur += 1 # 'a' ~ 'z'

            while S[cur] == ' ':
                cur += 1 # ' '
            if S[cur] == '^':
                cur += 1 # '^'
                while S[cur] == ' ':
                    cur += 1 # ' '
                v = number()
            else:
                v = 1
            r = [[1, [(c, v)]]]
        return r

    def number():
        nonlocal cur
        v = 0
        while 1:
            c = S[cur]
            if c not in digits:
                break
            v = 10*v + int(c)
            cur += 1 # '0' ~ '9'
        return v

    res = expr()
    return res


def solve():
    s0 = readline().strip()
    if s0 == '.':
        return False
    d0 = convert(s0)
    while 1:
        s = readline().strip()
        if s == '.':
            break
        d = convert(s)
        write("yes\n" if d0 == d else "no\n")
    write(".\n")
    return True
while solve():
    ...


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    int n;
    string s;
    cin>>n>>s;

    map<char,int> occ;
    map<char,int> occs[4005];

    REV(i, n-1, 0) {
        occ[s[i]]++;
        occs[i] = occ;
    }

    ll sum=0;

    FOR(j, n) {
        FOR(i, j) {
            if(s[i] != s[j]) {
                int d = j-i;
                char other = (char)((int)'R'+'G'+'B'-s[i]-s[j]);
                sum += occs[j][other];
                if(j+d < n && s[j+d]==other)
                    sum--;
            }
        }
    }

    cout<<sum<<endl;
    


}

Measured memory_bytes: 4312
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (X, Y): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if X % Y == 0 {
        -1
    } else {
        X
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException
	{
		int n;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		n = Integer.parseInt(br.readLine() );

		System.out.println( (int)Math.pow(n, 3) );
	}

}

Measured memory_bytes: 24328
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a1=sc.next();
		String a2=sc.next();
		int a1m=a1.length();
		int a2m=a2.length();
		int[] a1su=new int[a1m];
		int[] a2su=new int[a2m];

		for(int i=0; i<a1m; i++) {
			a1su[i]=a1.charAt(i)*1;
		}

		for(int i=0; i<a2m; i++) {
			a2su[i]=a2.charAt(i)*1;
		}
		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<a1m; i++) {
			for(int j=i; j<a1m; j++) {
				if(a1su[i]>a1su[j]) {
					tmp1=a1su[i];
					tmp2=a1su[j];
					a1su[i]=tmp2;
					a1su[j]=tmp1;
				}
			}
		}

		for(int i=0; i<a2m; i++) {
			for(int j=i; j<a2m; j++) {
				if(a2su[i]<a2su[j]) {
					tmp1=a2su[i];
					tmp2=a2su[j];
					a2su[i]=tmp2;
					a2su[j]=tmp1;
				}
			}
		}

		/*for(int i=0; i<a2m; i++) {
			System.out.println(a2su[i]);
		}*/

		boolean ts=false;
		boolean pd=false;
		for(int i=0; i<Math.min(a1m, a2m); i++) {
			if(a1su[i]<a2su[i]) {
				ts=true;
				System.out.println("Yes");
				System.exit(0);
			}
			else if(a1su[i]==a2su[i]){
				pd=true;
			}

			if(pd==true && a1su[i]>a2su[i]) {
				System.out.println("No");
				System.exit(0);
			}
		}
		if(ts==false && pd==true) {
			if(a1m==a2m) {
				System.out.println("No");
				System.exit(0);
			}
			else if(a1m<a2m){
				System.out.println("Yes");
				System.exit(0);
			}

			else if(a1m>a2m){
				System.out.println("No");
				System.exit(0);
			}
		}
		/*int sa=0;

		for(int i=0; i<Math.min(a1m, a2m); i++) {
			if(a1su[i]<a2su[i]) {
				sa=1;
				System.out.println("Yes");
				System.exit(0);
			}
			else if(a1su[i]>a2su[i]) {
				sa=-1;
				System.out.println("No");
				System.exit(0);
			}
		}
		if(sa==0) {
			if(a1m>a2m) {
				System.out.println("No");
			}
			else {
				System.out.println("Yes");
			}
		}*/
	}
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<ll>a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i+1;
        sum+=a[i];
    }
    sort(all(a));
    ll ave=sum/=n;
    if(ave<0)ave--;
    if(n%2!=0)
        ave=a[n/2];
    else
        ave=(a[n/2-1]+a[n/2])/2;
    ll ans=0;ll ans1=0,ans2=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-ave);
    }
    ave--;
    for(int i=0;i<n;i++){
        ans1+=abs(a[i]-ave);
    }
    ave+=2;
    for(int i=0;i<n;i++){
        ans2+=abs(a[i]-ave);
    }
    chmin(ans,ans1);chmin(ans,ans2);
    cout<<ans<<Endl;
    
    
    
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(ll i=0; i<n; ++i)
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define FORR(i,a,b) for (ll i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main() {
    int n;
    cin >> n;
    int a = 0, b = 0, p = 0;
    REP(i,n){
        int t, x, y;
        scanf("%d %d %d", &t, &x, &y);
        bool ok = true;
        int d = abs(x - a) + abs(y - b);
        if (d > t - p) ok = false;
        if (d % 2 != (t - p) % 2) ok = false;

        if (!ok){
            cout << "No" << endl;
            return 0;
        }

        p = t;
        a = x;
        b = y;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a + 1):  #500円玉の枚数を変化
    for j in range(b + 1):  #100円玉の枚数を変化
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	int a[20];
	cin>>n;
	for(int i=0;i<n;i++)
	  cin>>a[i];
	for(int i=1;i<n-1;i++)
	{
		if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]))
		  ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a+b < c+d) cout << "Right";
	else if(a+b > c+d) cout << "Left";
	else cout << "Balanced";
	cout << endl;
	return 0;
}


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

typedef long long ll;

const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);

int main()
{
  ll n, a, b, x, y, z, x1, x2, cnt = 0 ;
  cin >> n >> a >> b ;
  if((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl ;
  }
  else {
    x = max(n - a, n - b) ;
    y = max(a - 1, b - 1) ;
    z = min(x, y) ;

    x1 = min(a - 1, b - 1) ;
    x2 = min(n - a, n - b) ;

    if(x1 < x2) {
      cnt += x1 ;
      b -= x1 ;

      cnt += (b - 1) / 2 ;
      if((b - 1) % 2 != 0)  cnt++ ;
    }
    else {
      cnt += x2 ;
      a += x2 ;

      cnt += (n - a) / 2 ;

      if((n - a) % 2 != 0) cnt++ ;
    }

    cout << min(cnt, z) << endl ;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int depth;
int leaf;
int node[3000000];
std::vector<int > h(300004), w(300004);
/*void init(){
  for (int i=0; i<M; i++) {
    int index = i+leaf;
    while(index>0) {
      node[index] += w[i];
      index /= 2;
    }
  }
  return;
}*/

int getmax(){
  return node[1];
}

void add(int i, int val) {
  int index = i+leaf;
  node[index] += val;
  index /= 2;
  while(index > 0) {
    node[index] = std::max(node[index*2], node[index*2+1]);
    index /= 2;
  }
  return;
}

int main() {
  int H, W, M;
  std::cin >> H >> W >> M;
  leaf = 1;
  depth = 1;
  while(leaf<W) {
    depth++;
    leaf*=2;
  }
  for (int i=0; i<M; i++) {
    std::cin >> h[i] >> w[i];
    h[i]--;
    w[i]--;
  }
  std::vector<int > row[300004];
  for (int i=0; i<M; i++) {
    row[h[i]].push_back(w[i]);
    add(w[i],1);
  }
  // printf("initial getmax = %d\n", getmax());
  /*for (int i=0; i<W; i++) {
    // printf("leaf[%d]=%d\n", i, node[i+leaf]);
  }*/
  int ans = 0;
  for (int i=0; i<H; i++) {
    int cnt = row[i].size();
    // printf("row[%d] size=%d\n",i,row[i].size());
    for (int j : row[i]) {
      add(j, -1);
    }
    cnt += getmax();
    // printf("getmax=%d\n", getmax());
    ans = std::max(ans, cnt);
    for (int j : row[i]) {
      add(j, 1);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 23916
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ,mod = 1e9+7 ;

int mem[N][13] ;
string s ;
int solve(int i,int rem){
    if(i==s.size()) return rem==5 ;
    int&ret = mem[i][rem] ;
    if(~ret) return ret;
    if(s[i]!='?') return ret = solve(i+1,(rem*10+s[i]-'0')%13) ;
    ret = 0 ;
    for(int j=0;j<10;++j) ret = (ret + solve(i+1,(rem*10+j)%13))%mod ;
    return ret;
}
int main(){
    cin >> s ;
    memset(mem,-1,sizeof mem);
    cout << solve(0,0) ;
    return 0;
}


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

const int SENTINEL = 2000000000;
const int MAX = 500000;
int L[MAX];
int R[MAX];
int cnt;

void merge(int A[], int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;

  // create new arrays L, R
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }

  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }

  // SENTINEL
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;

  int i {0}, j {0};
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if ((left + 1) < right) {
    int mid = (right + left) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) cin >> A[i];
  mergeSort(A, 0, n);

  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl << cnt << endl;

  return 0;
}



Measured memory_bytes: 6940
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define _ std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9+7;
const int LOG = 17;
const int N = 5e5+123;
const ll INF = (ll)1e18 + 7;

int dp[10010][110];

int main()
{
    string s;
    cin >> s;
    int d;
    cin >> d;
    dp[0][0] = 1;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < d; j++) {
            for (int k = 0; k <= 9; k++) {
                dp[i + 1][(j + k) % d] += dp[i][j];
                dp[i + 1][(j + k) % d] %= mod;
            }
        }
    }
    int sum = 0;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s[i] - '0'; j++) {
            ans += dp[(int)s.size() - i - 1][(d - (sum + j) % d) % d];
            ans %= mod;
        }
        sum += s[i] - '0';
    }
    if (sum % d == 0) {
        ans++;
    }
    ans += mod - 1;
    ans %= mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
void solve(int n){
    int ans=INT_MAX;
    int j,tmp;
    for(int i=0;i*i*i<=n;i++){
        tmp=n-i*i*i;
        for(j=0;j*j<=tmp;j++){}
        j--;
        ans=min(ans,i+j+tmp-j*j);
    }
    cout<<ans<<endl;
}

int main(void){
    int n;
    while(cin>>n,n){
        solve(n);
    }
    
}



Measured memory_bytes: 3080
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    L = list(map(int,input().split()))
    for i in range(100):
        if X - i not in L:
            print(X-i)
            break
        elif X + i not in L:
            print(X+i)
            break

Measured memory_bytes: 9080
import java.util.Scanner;

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

		if (S.length() % 2 != 0) {
			S = S.substring(0, S.length()/ 2) + S.substring(S.length() / 2 + 1);
		}

		String before = S.substring(0, S.length() / 2);
		String after = S.substring(S.length() / 2);
		int answer = 0;

		for (int i = 0; i < S.length() / 2; i++) {
			if (!(before.charAt(i) == after.charAt(S.length() / 2 - i - 1))) answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 22100
//カタラン数を語らん!w

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	long long n, k;
	cin >> n >> k;
	if (n == 0) {
		if (k == 0) {
			cout << "0 0" << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	if (n == 1) {
		if (k == 0) {
			cout << "0 0 1 1" << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	if ((1 << n) <= k) {
		cout << -1 << endl;
		return 0;
	}
	REP(i, (1 << n)) {
		if (i != k) {
			cout << i << " ";
		}
	}
	cout << k << " ";
	for (int i = (1 << n) - 1; i >= 0;--i) {
		if (i != k) {
			cout << i << " ";
		}
	}
	cout << k << endl;
	return 0;
}

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

int main(){
  int n;
  string s,t;
  cin >>n >>s >>t;
  int ans = 0;
  for(int i = n; 0<=i; i--){
    if(s.substr(n-i)==t.substr(0,i)){
      ans = 2*n-i;
      break;
    }
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
	cin >> n;

	cout << (double)(((n + 1) / 2) / (double)n) << endl;

	return 0;
}

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

using namespace std;
const int NMAX = 300000;
int a[NMAX+2], b[NMAX+2];
int best = (1 << 30);

int main()
{
    string str;
    int N;
    cin >> N;
    cin >> str;
    for( int i = 1;  i <= N;  ++i ) {
        int val = (str[i - 1] == 'E');
        a[i] = a[i - 1] + val;
        b[i] = b[i - 1] + 1 - val;
    }
    for( int i = 1;  i <= N;  ++i ) {
        best = min(best, i - 1 - a[i - 1] + N - i - (b[N] - b[i]));
    }

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


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int x;
    cin>>x;
    int n;
    cin>>n;
    int ans=0;
    vector<int> A(n);
    for(int i=0; i<n; i++) {
        cin>>A[i];
    }
    vector<bool> present(101);
    for(int i=0; i<n; i++) {
        present[A[i]]=true;
    }
    for(int i=0; ;i++) {
        if(!present[x-i]) {
            ans=x-i;
            break;
        }
        if(!present[x+i]) {
            ans=x+i;
            break;
        }
    }
    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  long long int a,b,c,k,ans;
  cin>>a>>b>>c>>k;
  if(k<=a){
    ans = k;
  }
  else if(k<=a+b){
    ans = a;
  }
  else{
    ans = 2*a + b - k;
  }
  cout<< ans <<endl;
  return 0;
}

Measured memory_bytes: 3624
#coding:UTF-8
def LS(n,S,q,T):
    count=0
    if n>q:
        for i in range(q):
            if T[i] in S:
                count+=1
    else:
        for i in range(n):
            if S[i] in T:
                count+=1
    print(count)
  
if __name__=="__main__":
    n=int(input())
    S=input().split(" ")
    q=int(input())
    T=input().split(" ")
    LS(n,S,q,T)

Measured memory_bytes: 8220
using System;

namespace ConsoleApplication4.Properties
{
    public class Class1
    {
        public static void Main()
        {

            var a = Console.ReadLine();
            String[] v = a.Split();
            double sum = 0;
            var d = int.Parse(v[0]);
            var n = int.Parse(v[1]);
            var x = int.Parse(v[2]);
            sum = x;
            for (int i = 0; i < 10; i++)
            {
                sum = d * sum - n;
                Console.WriteLine(sum);
            }
        }
    }
}



Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		LinkedList<Integer> res=new LinkedList<Integer>();

		while(true) {
			String line=br.readLine();
			String[] charArray=line.split(" ");
			int h=Integer.parseInt(charArray[0]), w=Integer.parseInt(charArray[1]);
			if(h==0&&w==0) break;
			char[][] tile=new char[h][];
			for(int i=0; i<h; i++) {
				tile[i]=br.readLine().toCharArray();
			}

			boolean[][] record=new boolean[h][];
			for(int i=0; i<record.length; i++) {
				record[i]=new boolean[w];
				Arrays.fill(record[i], false);
			}

			int px=0, py=0;
			while(true) {
				if(record[py][px]) {
//					System.out.println("LOOP");
					res.add(-1);
					break;
				}
				record[py][px]=true;
				switch(tile[py][px]) {
				case '<':
					px--;
					break;
				case '>':
					px++;
					break;
				case '^':
					py--;
					break;
				case 'v':
					py++;
					break;
				}
				if(tile[py][px]=='.') {
					res.add(px*200+py);
					break;
				}
			}
		}

		for(int val: res)
			if(val==-1)
				System.out.println("LOOP");
			else
				System.out.println(val/200+" "+val%200);

		br.close();
	}
}

Measured memory_bytes: 18884
use std::io::{self, BufRead};
use std::str;

fn main() {
    let stdin = io::stdin();
    let mut s = String::new();
    let _ = stdin.read_line(&mut s);
    let vec: Vec<i64> = s.split_whitespace().map(|v| str::parse::<i64>(v).unwrap()).collect();

    let x = vec[0];
    let y = vec[1];
    let xa = x.abs();
    let ya = y.abs();
    let d = (ya - xa).abs();
    let res = if y == 0 {
        if x <= 0 { xa } else { xa + 1 }
    } else if (x < 0 && y >= 0) || (x >= 0 && y < 0) {
        d + 1
    } else if x <= y {
        d
    } else {
        d + 2
    };
    println!("{}", res);
}


Measured memory_bytes: 508
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
c=[0]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
    s[b].append(a)
def dfs(v,t):
    c[v]=t
    # print('start :'+str(c))
    for i in s[v]:
        if c[i]==t:
            return False
        if c[i]==0 and not dfs(i,-t):
            return False
    else:
        return True
if dfs(1,1):
    q=c.count(1)
    print((n-q)*q-m)
else:
    print((n*(n-1)//2)-m)

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

bool is_prime(int N) {
    if (N == 1) return false;
    for (int i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

signed main(){
	int N; cin >> N;
	int counter = 0;
	for(int i = 2; i <= 55555; i++){
		if(counter == N) break;
		if(is_prime(i) && (i % 5 == 1)){
			cout << i << " ";
			counter++;
		}
	}
	cout << endl;
}


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


struct Node {
    int id;
    int parentId;
    int leftId;
    int rightId;
};


class BinaryTree {

public:
    static const int NIL_ID = -1;
    Node *nodes;

    BinaryTree(int cnt) {
        nodes = (Node *)malloc(sizeof(Node) * cnt);
        for (int i = 0; i < cnt; i++)
        {
            nodes[i] = Node{i, NIL_ID, NIL_ID, NIL_ID};
        }
    }

    ~BinaryTree() {
        free(nodes);
    }

    void push_values(int id, int leftId, int rightId) {
        nodes[id].leftId = leftId;
        nodes[id].rightId = rightId;

        if (leftId != NIL_ID)
            nodes[leftId].parentId = id;
        if (rightId != NIL_ID)
            nodes[rightId].parentId = id;
    }

    int getSibling(int id) {
        Node node = nodes[id];

        int parentId = node.parentId;
        if (parentId == NIL_ID)
            return NIL_ID;
        
        Node parent = nodes[parentId];

        if (parent.leftId == id) {
            return parent.rightId;
        } else {
            return parent.leftId;
        }    
    }

    int getDegree(int id) {
        Node node = nodes[id];

        int degree = 0;
        
        if (node.leftId != NIL_ID)
            degree++;
        if (node.rightId != NIL_ID)
            degree++;

        return degree;
    }

    int getDepth(int id) {
        Node node = nodes[id];
        int depth = 0;

        while(node.parentId != NIL_ID) {
            node = nodes[node.parentId];
            depth++;
        }

        return depth;
    }

    int getHeight(int id) {
        int h1 = 0, h2 = 0;
        Node node = nodes[id];

        if (node.rightId != NIL_ID)
            h1 = getHeight(node.rightId) + 1;
        if (node.leftId != NIL_ID)
            h2 = getHeight(node.leftId) + 1;

        return max(h1, h2);
    }

    string getType(int id) {
        Node node = nodes[id];

        if (node.parentId == NIL_ID)
            return "root";
        
        if (getDegree(id) > 0) {
            return "internal node";
        } else {
            return "leaf";
        }
    }

    void printNode(int id) {
        Node node = nodes[id];
        cout << "node " << id << ": parent = " << node.parentId << ", sibling = ";
        cout << getSibling(id) << ", degree = " << getDegree(id) << ", depth = ";
        cout << getDepth(id) << ", height = " << getHeight(id) << ", " << getType(id);
    }
};


int main() {
    int N;
    int i, id, leftId, rightId;

    cin >> N;

    unique_ptr<BinaryTree> tree(new BinaryTree(N));

    for (i = 0; i < N; i++) {
        cin >> id >> leftId >> rightId;
        tree->push_values(id, leftId, rightId);
    }

    for (i = 0; i < N; i++) {
        tree->printNode(i);
        cout << endl;
    }
}



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

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

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

  map<int, int> m;
  rep(i, n) {
    m[min(8, a[i]/400)]++;
  }

  int cnt = 0;
  for (auto&& i : m) {
    if (i.first != 8) cnt++;
  }
  cout << max(cnt, (int)(m[8] > 0)) << " " << cnt+m[8] << endl;
}


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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	ll sum = 0;
	vector<ll> minus;
	for (auto i = 0; i < N; ++i)
	{
		ll A, B;
		cin >> A >> B;
		sum += A;
		minus.push_back(-A - B);
	}

	sort(minus.begin(), minus.end());
	for (auto i = 1; i < N; i += 2)
	{
		sum += minus[i];
	}
	cout << sum << endl;

	return 0;
}

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

using namespace std;

const int MD = 1e9 + 7;
const int MN = 1010;
int h, w;
char mp[MN][MN];
int dp[MN][MN];

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

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

    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (mp[i][j] == '#') continue;
            if (i + 1 < h) {
                dp[i + 1][j] += dp[i][j];
                if (dp[i + 1][j] >= MD) dp[i + 1][j] -= MD;
            }
            if (j + 1 < w) {
                dp[i][j + 1] += dp[i][j];
                if (dp[i][j + 1] >= MD) dp[i][j + 1] -= MD;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

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

int main(){
      int a,b,c,x;cin >> a >> b >> c >> x;
      int ans = 0;
      for(int i = 0;i <= a;i++){
            for(int j = 0;j <= b;j++){
                  for(int k = 0;k <= c;k++){
                        if(500 * i + 100 * j + 50 * k == x)ans++;
                  }
            }
      }
      cout << ans;
}

Measured memory_bytes: 256
<?php
  
  fscanf(STDIN,"%d",$N);
$v_list = explode(" ",trim(fgets(STDIN)));

sort($v_list);
$min = ($v_list[0] +$v_list[1])/2;

for($i=2;$i<$N;$i++){
  	$min = ($min+$v_list[$i])/2;
}

echo $min."\n";
  	




Measured memory_bytes: 4604
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry
            
    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)
    
u = UnionFind(N)
for a, b, _ in L:
    u.unite(a, b)
    
s = set()
for i in range(N):
    s.add(u.get_root(i))

print(len(s))

Measured memory_bytes: 49584
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int V, E, S, T; ll W, ans;
vector <Pli> Graph[10005];
bool visited[10005];

int main(){
  scanf("%d%d", &V, &E);
  for (int i = 0; i < E; i++){
    scanf("%d%d%lld", &S, &T, &W);
    Graph[S].push_back(mp(W, T));
    Graph[T].push_back(mp(W, S));
  }
  
  visited[0] = true;
  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  for (int i = 0; i < Graph[0].size(); i++) que.push(Graph[0][i]);

  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (visited[Q.se] == true) continue;
    ans += Q.fi;
    visited[Q.se] = true;
    for (int i = 0; i < Graph[Q.se].size(); i++){
      Pli next = Graph[Q.se][i];
      if (visited[next.se]) continue;
      que.push(next);
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 10316
#include<iostream>
using namespace std;
int main()
{
    int m,d;
	cin>>m>>d;
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			int gw,sw;
			gw=j%10;
			sw=j/10;
			if(i==gw*sw&&gw!=1&&sw!=1)
			{
				ans++;
			}
		}
	}
	cout<<ans;
    return 0;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  map<char,int> f;
  f['m'] = 1000;
  f['c'] = 100;
  f['x'] = 10;
  f['i'] = 1;
  map<int,char> g;
  g[1000] = 'm';
  g[100] = 'c';
  g[10] = 'x';
  g[1] = 'i';
  int n; cin >> n;
  rep(j,n){
    string s,t; cin >> s >> t;
    int a = 0, b = 0;
    rep(i,sz(s)){
      if(isdigit(s[i])) continue;
      else
	if(i > 0 and isdigit(s[i-1]))
	  a += int(s[i-1] - '0') * f[s[i]];
	else if(i == 0 or (i > 0 and not isdigit(s[i-1])))
	  a += f[s[i]];
    }
    rep(i,sz(t)){
      if(isdigit(t[i])) continue;
      else
	if(i > 0 and isdigit(t[i-1]))
	  b += int(t[i-1] - '0') * f[t[i]];
	else if(i == 0 or (i > 0 and not isdigit(t[i-1])))
	  b += f[t[i]];
    }
    dump(a,b);
    dump(f);
    a += b;
    string ans;
    int x = 1000;
    rep(i,4){
      if(a >= 2 * x)
	ans += (a / x) + '0';
      if(a >= x)
	ans += g[x];
      a %= x;
      x /= 10;
    }
    cout << ans << endl;
  }
}


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

int main() {

	int A, B, C;
	int remainder[110] = {0};
	bool flag = false;

	cin >> A >> B >> C;

	for (int i = 1; true; i++) {
		remainder[i] = (i * A) % B;
		if (remainder[0] == (i * A) % B)break;
	}

	for (int i = 0; i < 100; i++) {
		if (remainder[i] == C) {
			flag = true;
			break;
		}
	}

	cout << ((flag) ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    long long W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << W * H / 2.0 << " ";
    if(W == 2 * x && H == 2 * y){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,max=0,num;
  cin >>n;
  int b,a[100001]={0};
  for(int i=0;i<n;i++){
    cin >>b;
    a[b]++;
  }
  max=a[0]+a[1];
  max=(max>a[100000]+a[100000-1])?max : a[100000-1]+a[100000];
  for(int i=1;i<100000;i++){
    num=a[i-1]+a[i+1]+a[i];
    max=(num>max)?num:max;
  }
  cout << max << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int k = sc.nextInt();
			int x = sc.nextInt();
			
			System.out.println(k*500 >= x ? "Yes": "No");
		}
	}
}

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

int timer = 0;

struct needed {

	needed(int verNum) {
		for (int i = 0; i < verNum; i++) {
			visited.push_back(false);
			preNum.push_back(1 << 30);
			lowest.push_back(1 << 30);
			parent.push_back(-1);
		}
	}

	vector<bool> visited;
	vector<int> preNum; //?¨?????????????
	vector<int> lowest;
	vector<int> parent;

};

void DFS(int current, int previous, vector<int> verVal[], needed &need) {

	need.preNum[current] = timer;
	need.lowest[current] = timer;
	timer++;

	need.visited[current] = true;

	for (int i = 0; i < verVal[current].size(); i++) {
		int next = verVal[current][i];
		if (!need.visited[next]) {
			need.parent[next] = current;
			DFS(next, current, verVal, need);
			need.lowest[current] = min(need.lowest[current], need.lowest[next]);
		}
		else if (next != previous) {
			need.lowest[current] = min(need.lowest[current], need.preNum[next]);
		}
	}
}

void ArticulationPoint(vector<int> verVal[], int verNum) {

	needed need(verNum);
	DFS(0, -1, verVal, need);

	set<int> artPoints;
	int childNumOfRoot = 0;
	//root??????????????¨??¨
	for (int i = 1; i < verNum; i++) {
		int nowP = need.parent[i];
		if (nowP == 0) childNumOfRoot++;
		else if (need.preNum[nowP] <= need.lowest[i])
			artPoints.insert(nowP);
	}
	//root?????¢?????????????????????????????????????????£??????????????§?????????
	if (childNumOfRoot > 1) artPoints.insert(0);

	for (set<int>::iterator it = artPoints.begin(); it != artPoints.end(); it++)
		cout << *it << endl;
}

int main() {

	int verNum, edgeNum;
	cin >> verNum >> edgeNum;
	vector<int> verVal[100000];

	for (int i = 0; i < edgeNum; i++) {
		int firVal, secVal;
		cin >> firVal >> secVal;
		verVal[firVal].push_back(secVal);
		verVal[secVal].push_back(firVal);
	}

	ArticulationPoint(verVal, verNum);

	return 0;
}

Measured memory_bytes: 7080
<?php
fscanf(STDIN, '%d %d', $len, $cnt);
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
$nums[] = $nums[0] + $len;
$ans = 0;
for ($i=0; $i < $cnt; $i++) { 
    $ans = max($ans, $nums[$i+1] - $nums[$i]);
}
$ans = $len - $ans;
echo $ans;
echo "\n";

Measured memory_bytes: 27120
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e2+5;
const double PI = acos(-1);
struct Vec
{
    double x, y; int id;
    Vec(double x = 0, double y = 0, int id = 0):x(x), y(y), id(id) {};
    double len() { return sqrt(x*x+y*y); }
    friend Vec operator + (Vec a, Vec b) { return Vec(a.x+b.x, a.y+b.y, a.id); }
    friend Vec operator - (Vec a, Vec b) { return Vec(a.x-b.x, a.y-b.y, a.id); }
    friend double operator * (Vec a, Vec b) { return a.x*b.y-a.y*b.x; }
    friend double operator ^ (Vec a, Vec b) { return a.x*b.x+a.y*b.y; }
    friend bool operator < (Vec a, Vec b) { return a*b != 0?a*b < 0:a.x < b.x; }
    void print() { printf("%lf %lf\n", x, y); }
}p[N], f[N];
int n, m; double ans[N];
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) 
    {
        int x = read(), y = read();
        p[i] = Vec(x, y, i);
    }
    if(n == 2) return puts("0.5"), puts("0.5"), 0;
    for(int i = 2; i <= n; ++i) 
        if(p[i].x < p[1].x||(p[i].x == p[1].x&&p[i].y < p[1].y)) 
            swap(p[1], p[i]);
    p[0] = p[1]; for(int i = 1; i <= n; ++i) p[i] = p[i]-p[0];
    sort(p+2, p+1+n), f[m = 1] = p[1];
    for(int i = 2; i <= n; ++i)
    {
        while(m > 1&&(f[m]-f[m-1])*(p[i]-f[m]) > 0) --m;
        f[++m] = p[i];
    }
    f[0] = f[m], f[m+1] = f[1];    
    for(int i = 1; i <= m; ++i) 
    {
        Vec a = f[i-1]-f[i], b = f[i+1]-f[i];
        ans[f[i].id] = (PI-acos((a^b)/a.len()/b.len()))/(2*PI);
    }
    for(int i = 1; i <= n; ++i) printf("%.9lf\n", ans[i]);
    return 0;
}

Measured memory_bytes: 384
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}


__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	long long a,n,m;cin>>a>>n>>m;
	long long nw = 1;
	int ans = 0;
	while(true){
		long long t = 1;
		for(int i = 0; n > i; i++){
			t*=nw;
		}
		if(m<t)break;
		int z = 0;
		for(int i = 0; to_string(t).size() > i; i++){
			z += to_string(t)[i]-'0';
		}
		if(a+z==nw)ans++;

		nw++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int h, n;
    cin >> h >> n;
    int a[100100];
    int total = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        total += a[i];
    }

    if(h > total) cout << "No" << endl;
    else cout << "Yes" << endl;
}
  

Measured memory_bytes: 4024
#include <stdio.h>
int main()
{
    int i,j,k,n,m;
    int mat1[100][100],mat2[100], matnew[100];
    scanf("%d%d",&n,&m);
    for (i=0; i<n; i++)
    {
        for (j=0; j<m; j++)
        {
            scanf("%d",&mat1[i][j]);
        }
    }
    for (i=0; i<m; i++)
    {
        scanf("%d",&mat2[i]);

    }
    for (i=0; i<n; i++)
    {
        matnew[i]=0;
        for(j=0; j<m; j++)
        {
            matnew[i]+=mat1[i][j]*mat2[j];
        }

    }
    for(i=0; i<n; i++)
    {

        printf("%d\n",matnew[i]);

    }
        return 0;
}



Measured memory_bytes: 2096
#include <stdio.h>

int main() {
	int a[5], min = 9, mini = -1, i, sum = 0;

	for (i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 10 != 0 && a[i] % 10 <= min) {
			min = a[i] % 10;
			mini = i;
		}
	}

	for (i = 0; i < 5; i++) {
		if (i != mini) {
			if (a[i] % 10 == 0) {
				sum += a[i];
			}
			else {
				sum += (a[i] / 10 + 1) * 10;
			}
		}
		else {
			sum += a[i];
		}
	}

	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vector<string> S(N);
    for(ll i=0;i<N;i++)cin>>S[i];
    
    vll count(5,0);
    
    for(ll i=0;i<N;i++){
        if(S[i][0]=='M')count[0]++;
        if(S[i][0]=='A')count[1]++;
        if(S[i][0]=='R')count[2]++;
        if(S[i][0]=='C')count[3]++;
        if(S[i][0]=='H')count[4]++;
    }
    
    ll ans=0;
    for(ll i=0;i<5;i++){
        for(ll j=i+1;j<5;j++){
            for(ll k=j+1;k<5;k++){
                ans+=count[i]*count[j]*count[k];
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 5760