akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int k;
    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        k = sc.nextInt();

        LinkedList<Long> q = new LinkedList<>();
        for (int i = 1; i < 10; i++) {
            q.add((long)i);
        }

        long x = -1;
        for (int i = 0; i < k; i++) {
            x = q.removeFirst();
            if (x % 10 != 0)
                q.addLast(x * 10 + (x % 10 - 1) );
            q.addLast(x * 10 + (x % 10));
            if (x % 10 != 9)
                q.addLast(x * 10 + (x % 10 + 1) );
        }

//        int cnt = 0;
//        long i;
//        for (i = 1; cnt < k; i++) {
//            if (ok(i)) cnt++;
//        }

//        out.println(i - 1);

        out.println(x);
        out.flush();
    }

    boolean ok(long v) {
        String s = "" + v;
        int l = s.length();
        for (int i = 0; i < l - 1; i++) {
            if (Math.abs(s.charAt(i) - s.charAt(i + 1)) > 1) {
                return false;
            }
        }
        return true;
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 37588
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int[] l = new int[n];
                for(int i = 0 ; i < n ; i++){
                        l[i] = sc.nextInt();
                }
                long yono = 0;
                sc.close();
                for(int i = 0 ; i < n ; i++){
                        for(int j = 0 ; j < i ; j++){
                                for(int k = 0 ; k < j ; k++){
                                        if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k] && l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) yono++;
                                }
                        }
                }
                System.out.println(yono);
        }
}

Measured memory_bytes: 36628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>; 

int main() {
    double N, M;
    cin >> N >> M;
    vector<double> A(N);
    double sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    } 
    bool ok = false;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    rep(i, M){
        double test = sum / (4*M);
        if(A[i] < test){
            ok = false;
            break;
        }else{
            ok = true;
        }
    }
    if(ok){
        cout << "Yes";
    }else{
        cout << "No";
    }

}


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

typedef long long ll;
const ll mod = 1e9 + 7;

int n;
ll k;

vector<int> g[100005];

ll ans = 1;

void dfs(int d, int prev, int v, int sc) {
  ll gf = d > 2 ? 1 : 0;
  ll f = d > 1 ? 1 : 0;
  ans = ans * (k - gf - f - sc) % mod;

  int t = 0;
 

  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i];
    if(u != prev) {
      dfs(d+1,v,u,t);
      t++;
    }
  }

  return;
}
    

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

  for(int i = 0; i < n - 1; i++) {
    int a,b;
    cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs(1,-1,0,0);

  cout << ans << endl;
}


  


Measured memory_bytes: 11520
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    if(N%10==3) {
        cout << "bon" << endl;
    } else if((N%10!=1 && N%10%2==1) || N%10==2 || N%10==4) {
        cout << "hon" << endl;
    } else {
        cout << "pon" << endl;
    }


    return 0;
    
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

const int MOD = 1e9+7;
const int MAXR = 510000;

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    int N; cin >> N;
    vector<int> count(N+1,0);
    mint ans = 1;
    count[0] = 3;
    REP(i,N){
        int a;
        cin >> a;
        ans *= count[a];
        count[a]--;
        count[a+1]++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15648
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        ArrayList<String[]> list = new ArrayList<String[]>();
        int[][] ans = new int[12][10];
        for(int i = 0; i < 12; i++) {
            for(int j = 0; j < 10; j++) {
                ans[i][j] = 0;
            }
        }
        //S:0 H:1 c:2 D:3
        Scanner sc = new Scanner(System.in);
        //1番目の読み取り回数nを取得
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        //n回繰り返して配列をlistへ
        for(int i = 0; i < n; i++) {
            String line1 = sc.nextLine();
            String[] linesp1 = line1.split(" ");
            list.add(linesp1);
        }
         
        for(int i = 0; i < list.size(); i++) {
            int tou = Integer.parseInt(list.get(i)[0]);//1~4
            int kai = Integer.parseInt(list.get(i)[1]);//1~3
            int ban = Integer.parseInt(list.get(i)[2]);//1~10
            int nin = Integer.parseInt(list.get(i)[3]);// 
             
            if(tou == 1) {
                ans[kai - 1][ban - 1] += nin;
            }
            if(tou == 2) {
                ans[kai + 2][ban - 1] += nin;
            }
            if(tou == 3) {
                ans[kai + 5][ban - 1] += nin;
            }
            if(tou == 4) {
                ans[kai + 8][ban - 1] += nin;
            }
        }
        for(int i = 0; i < 12; i++) {
            for(int j = 0; j < 10; j++) {
                System.out.print(" ");
                System.out.print(ans[i][j]);
                 
                if(j == 9) {
                    System.out.println("");
                }
            }
            if(i % 3 == 2 && i != 11) {
                System.out.println("####################");
            }
        }
    }
}


Measured memory_bytes: 27424
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#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 <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[200005],h,b(200005,0),f(200005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n;cin>>n;
    vector <lli> a(n);
    lli sum=0,mx=0;
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=mx-a[i];
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 12660
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

vector<ll> fact, factinv, inv;
ll mod = 1e9 + 7;
void prenCkModp(ll n) {
	fact.resize(n + 5);
	factinv.resize(n + 5);
	inv.resize(n + 5);
	fact.at(0) = fact.at(1) = 1;
	factinv.at(0) = factinv.at(1) = 1;
	inv.at(1) = 1;
	for (ll i = 2; i < n + 5; i++) {
		fact.at(i) = (fact.at(i - 1) * i) % mod;
		inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
		factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
	}

}
ll nCk(ll n, ll k) {
	return (fact.at(n) * ((factinv.at(k) * factinv.at(n - k)) % mod)) % mod;
}
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

int main() {
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	prenCkModp(r2 + c2+4);
	ll an = nCk(r2 + c2 + 2, c2 + 1) - nCk(r2 + c1 + 1, c1) - nCk(r1 + c2 + 1, r1) + nCk(r1 + c1, r1);
	an += mod * 4;
	an %= mod;
	cout << an << endl;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  cin >> n;
  if(n%10==9 || n/10 == 9) cout <<"Yes\n";
  else cout <<"No\n";
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
int main(void){
    int K;
    unsigned long sum=0;
    cin>>K;
    
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int g=1;g<=K;g++){
                sum=sum+gcd(gcd(i,j),g);
            }
        }
    }
    
    cout<<sum;
    
    return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>

int main(){
	double max=0,mini=0,data[5000]={0};
	int i=0;
	
	while(scanf("%lf",&data[i])!=EOF){
		if(i==0){
		mini=data[0];
		max=data[0];
		}
		if(max<data[i] && i!=0)max=data[i];
		if(mini>data[i] && i!=0)mini=data[i];
		++i;
	}
	
	printf("%f\n",max-mini);
	
return 0;	
}

Measured memory_bytes: 688
//https://vjudge.net/contest/333005#problem/D
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 200005;
int n, a[N], b[N];

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> n;
    rep(i, 0, n - 1){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n);
    int right = n/2;
    int left = right - 1;
    rep(i, 0, n - 1){
        if(a[i] > b[left]){
            cout << b[left];
        }else{
            cout << b[right];
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int total_E = 0;
        int[] x = new int[N+1];
        x[0] = 0;

        for(int i=0;i<N;i++){
            if(S.charAt(i) == 'E'){
                total_E++;
                x[i+1] = x[i] + 1;
            }else{
                x[i+1] = x[i];
            }
        }

        int ans = (int) 1e9;

        for(int i=0;i<N;i++){
            ans = Math.min(ans, total_E + i - x[i+1] -x[i]);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 28804
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		ArrayList<String> list = new ArrayList<String>();
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();
		
		String[] str = s.split("");
		for(String a : str){
			list.add(a);
		}
		Collections.reverse(list);
		
		for(String a : list){
			System.out.print(a);
		}
		System.out.println("");
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,k;
int main()
{
    n=read();k=read();
    if(k>(n-1)*(n-2)/2)
    {
        puts("-1");
        return 0;
    }
    int cnt=n-1+(n-1)*(n-2)/2-k;
    cout<<cnt<<endl;
    cnt-=(n-1);
    for(int i=2;i<=n;i++)  cout<<1<<" "<<i<<endl;
    if(!cnt)  return 0;
    for(int i=2;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            cout<<i<<" "<<j<<endl;
            cnt--;
            if(!cnt)  return 0;
        }
    }
    return 0;
}

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


int main()
{
    string S;
    int c=0,f=0;
    cin>>S;

    for(int i=0;i<S.length();i++){
        if(S[i]=='C')c=1;
        if(c==1&&S[i]=='F')f=1;
    }

    if(c==1&&f==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rr = lambda: sys.stdin.readline().rstrip()

h, w = rm()
li = np.array([np.array(list(rr())) for _ in range(h)])
li2 = []
li3 = []
for i in li:
  if '#' in i:
    li2.append(i)
li2 = np.array(li2).T
for i in li2:
  if '#' in i:
    li3.append(i)
li3 = np.array(li3).T
for i in li3:
  print(''.join(i))


Measured memory_bytes: 27168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
priority_queue<int>f;
priority_queue<int,vector<int>,greater<int> >z;
vector<pair<int,int> >p;
void print()
{
    for(auto i:p)
    {
        printf("%d %d\n",i.first,i.second);
    }
}
int main()
{
   int n,a;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
        scanf("%d",&a);
        if(a<0)
            f.push(a);
        else
            z.push(a);
   }
   if(z.empty())
   {
       int x=f.top();
       f.pop();
      while(!f.empty())
      {
          p.push_back({x,f.top()});
          x-=f.top();
          f.pop();
      }
      printf("%d\n",x);
      print();
   }
   else if(f.empty())
   {
       int x=z.top();
       z.pop();
       while(z.size()!=1)
       {
           p.push_back({x,z.top()});
           x-=z.top();
           z.pop();
       }
       p.push_back({z.top(),x});
       printf("%d\n",z.top()-x);
       print();
   }
   else
   {
        while(z.size()!=1)
        {
            p.push_back({f.top(),z.top()});
            f.push({f.top()-z.top()});
            f.pop(),z.pop();
        }
        while(f.size())
        {
            p.push_back({z.top(),f.top()});
            z.push(z.top()-f.top());
            z.pop(),f.pop();
        }
        printf("%d\n",z.top());
        print();
   }
    return 0;
}


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL a,b;
    cin>>a>>b;
    set<LL> da;
    //for(LL i = 1; i*i <= min(a,b); i++){
    //    if(a % i == 0 && b % i == 0){
    //        d.insert(i);
    //    }
    //}
    for(LL i = 1; i*i <= a; i++){
        if(a % i == 0){
            da.insert(i);
            da.insert(a/i);
        }
    }
    set<LL> d;
    for(LL i = 1; i*i <= b; i++){
        if(b % i == 0){
            if(EXIST(da, i))d.insert(i);
            if(EXIST(da, b/i))d.insert(b/i);
        }
    }
    LL ans = 0;
    EACH(itr, d){
        LL num = *itr;
        bool is_p = true;
        for(LL i = 2; i*i <= num; i++){
            if(num % i == 0){
                is_p = false;
                break;
            }
        }
        if(is_p)ans++;
    }
    PUTS(ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define SIZE 100005
#define INF 1000000000000000LL
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE];
ll lim[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n;i++) scanf("%lld",&A[i]);
	lim[0]=1;
	for(int i=1;i<=n;i++)
	{
		ll m=(lim[i-1]-A[i-1])*2LL;
		if(m<0)
		{
			puts("-1");
			return 0;
		}
		lim[i]=min(INF,m);
	}
	if(lim[n]<A[n])
	{
		puts("-1");
		return 0;
	}
	ll ret=A[n],now=A[n];
	for(int i=n-1;i>=0;i--)
	{
		now+=A[i];
		now=min(now,lim[i]);
		ret+=now;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 5280
#include<stdio.h>
 int main(void)
 {
     char a,b;

     scanf("%c %c",&a,&b);

     if(a=='H'){
       if(b=='H') printf("H\n");
       else printf("D\n");
     }

     if(a=='D'){
       if(b=='H') printf("D\n");
       else printf("H\n");
     }

     return 0;
 }



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    map<char, ll> mp;
    mp['R'] = mp['G'] = mp['B'] = 0;
    rep(i, 0, n) mp[s[i]]++;
    ll ans = mp['R'] * mp['G'] * mp['B'];

    // ll a = 0, b = 0, c = 0;
    // rep(i, 0, n)
    // {
    //     if (s[i] == 'R')
    //         a++;
    //     if (s[i] == 'G')
    //         b++;
    //     if (s[i] == 'B')
    //         c++;
    // }
    // ll ans = a * b * c;

    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            int k = j + (j - i);
            if (k >= n)
                break;
            if (s[i] != s[j] && s[k] != s[j] && s[i] != s[k])
                ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <cstdio>

int main(){
	int h, w;
	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w==0){
			break;
		}
		for(int j=0; j<h; j++){
			for(int i=0; i<w; i++){
				if(i%2==0 && j%2==0){
					printf("#");
				}
				else if(i%2!=0 && j%2!=0){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2604
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LLINF = 4e18;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int r; input(r);
    cout << 3 * r * r << endl;
    getchar(); getchar();
}

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

int dp[123456];//dp[i]:i与えるのに必要な最小魔力
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int h,n;cin>>h>>n;
  for(int i=1;i<123456;i++)dp[i]=LINF;
  while(n--){
    int a,b;cin>>a>>b;
    for(int i=0;i+a<123456;i++)chmin(dp[i+a],dp[i]+b);
  }
  int ans=LINF;
  for(int i=h;i<123456;i++)chmin(ans,dp[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
     
    using namespace std;
    const long long INF = 1LL <<60;  
     
    long long gcn(long long x,long long y){
      if(x%y==0){
        return y;
      }
      else{
        return gcn(y,x%y);
      }
    }
     
    int main(void){
      long long tmp;
      long long n,k;
      long long i,j;
      long double res=0.0;
      long double sum=0.0;
      
      cin>>n>>k;
      long a[n];
      for(i=0;i<n;i++){
        cin>>tmp;
        a[i]=(1+tmp);
        //cout<<a[i]<<endl;
      }
      for(i=0;i<k;i++){
        res+=a[i];
      }
      sum=res;
      //cout<<sum<<endl;
      for(i=k;i<n;i++){
        sum+=a[i]-a[i-k];
        res=max(sum,res);
      }
            
      cout<<scientific<<setprecision(10)<<res/2.0<<endl;
      return 0;
    }

Measured memory_bytes: 5200
def main():
    s = input()

    ss = [i for i in s if i != 'x']
    for i in range(len(ss)//2):
        if ss[i] != ss[len(ss)-1-i]:
            print("-1")
            return

    x_idx, idx, j = [0 for i in range(len(ss)+1)], 0, 0
    while idx < len(s):
        cnt = 0
        while idx < len(s) and s[idx] == 'x':
            cnt += 1
            idx += 1
        x_idx[j] = cnt

        while idx < len(s) and s[idx] != 'x':
            idx += 1
            j += 1

    ans = 0
    for i in range(len(ss)+1):
        if x_idx[i] != x_idx[len(ss)-i]:
            ans += max(x_idx[len(ss)-i], x_idx[i]) - min(x_idx[len(ss)-i], x_idx[i])
            x_idx[i] = x_idx[len(ss)-i] = max(x_idx[len(ss)-i], x_idx[i])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4860
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, X, Y;
    cin >> N >> X >> Y;
    VEC(int) Counts(N, 0);
    FOR(i, 1, N + 1)
        FOR(j, i + 1, N + 1) {
            int d = abs(j - i);
            d = min(d, abs(i - X) + 1 + abs(j - Y));
            d = min(d, abs(i - Y) + 1 + abs(j - X));
            Counts[d]++;
        }

    FOR(d, 1, N)
        cout << Counts[d] << endl;
    return 0;
};


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

int main(void){
  int N,A[100],i,j,diff,max = 0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(max < abs(A[i] - A[j])){
        max = abs(A[i] - A[j]);
      }
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 1736
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
const int N = 2e5 + 100;
const ll MAX = 1e18;
#define iii i++
ll A[N];
ll S[N];
int n;
inline ll cal( int i ){
    ll b = A[i];
    return b* ( 2 * ( i + 1 ) - n) - S[i] + S[n-1] - S[i];
}
void inp(){
    scanf("%d",&n);
    for(int i = 0;i<n;i++)scanf("%lld", &A[i]), A[i]-=i+1;
    sort(A, A+n);
    S[0]=A[0]; for(int i =1 ;i<n;i++) S[i]=S[i-1]+A[i] ;
    ll ans = MAX;
    for(int i =0 ;i<n;iii){
        ans = min(ans, cal(i));
    }
    printf("%lld\n", ans);
}
//c.cc by xsthunder at Tue Jul 31 17:19:35 2018


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

ll dp[52][52][2600];

int main(){
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  REP(i, N){
    cin >> x[i];
  }
  int T = A * N;
  dp[0][0][0] = 1;
  REP(i, N){
    REP(j, i+1){
      REP(k, T+1){
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  FOR(i, 1, N+1){
    ans += dp[N][i][A*i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 52096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r,d,x;cin >> r >> d >> x;
	rep(i,10){
		x=r*x-d;
		cout << x << endl;
	}
}


Measured memory_bytes: 256
/*input
2
RR
*/

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

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

  int l = 0, r = n-1;
  int ans = 0;
  while (l < r) {
    if (s[l] == 'W' && s[r] == 'R') {
      ans++;
      l++; r--;
      continue;
    }
    if (s[l] == 'R') l++;
    if (s[r] == 'W') r--;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3724
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map(String::toInt)
    val b = LinkedList<Int>()

    for (i in 0..n - 1) {
        if (i % 2 > 0) {
            b.addFirst(a[i])
        } else {
            b.add(a[i])
        }
    }
    if (n % 2 > 0) {
        b.reverse()
    }
    val sb = StringBuilder()
    for (bi in b) {
        sb.append(bi).append(' ')
    }
    println(sb)
}

Measured memory_bytes: 84856
N = int(input())
slimes = list(map(int, input().split()))

sums = [[None for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(i, N):
        sums[i][j] = sum(slimes[i:j+1])

dp = [[-1 for i in range(N)] for j in range(N)]

def recurse(i, j):
    if i == j: return 0
    
    if dp[i][j] != -1:
        return dp[i][j]

    cost = float('inf')
    for s in range(i, j):
        cost = min(cost, sums[i][j] + recurse(i, s) + recurse(s+1,j))

    dp[i][j] = cost
    return cost

print(recurse(0, N - 1))


Measured memory_bytes: 48988
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n,m=pM(split(readline()))
  graph=[Int[] for i=1:n]
  for i=1:m;
    a,b=pM(split(readline()))
    push!(graph[a],b)
    push!(graph[b],a)
  end
  que=Int[1]
  mezirusi=zeros(Int,n)
  mezirusi[1]=1
  while !isempty(que)
    look=popfirst!(que)
    for next=graph[look]
      if mezirusi[next]!=0;continue;end
      mezirusi[next]=look+1
      push!(que,next)
    end
  end
  println("Yes")
  for i=mezirusi[2:end];println(i-1);end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 230188
a = Array.new(5)
for i in 0..4
	a[i] = gets
	if a[i].to_i < 40
		a[i] = 40
	end
end
puts (a[0].to_i + a[1].to_i + a[2].to_i + a[3].to_i + a[4].to_i) / 5

Measured memory_bytes: 8636
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M),B(M-1);
  for(int &i:A)cin>>i;
  sort(A.begin(),A.end());
  for(int i=0;i<M-1;i++)B[i]=A[i+1]-A[i];
  sort(B.begin(),B.end());
  int ans=0;
  for(int i=0;i<M-N;i++)ans+=B[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 4740
#include<bits//stdc++.h>
using namespace std;
int main(){
  int n,m,sum = 0,d;string s,t;
  vector<int> a(n);
  cin >> n ;
  for(int i =0;i <n;i++) cin >> a[i];
  for(int i = 0; i< n;i++){
    if(i % 2==0 && a[i] % 2 == 1) sum++;
  }cout << sum << endl;
}

Measured memory_bytes: 3724
N = gets.to_i
dp = []
dp[0] = [['a']]
(N - 1).times do |i|
  arr = []
  dp[i].each do |a|
    (a.uniq.size + 1).times do |i|
      arr.push(a + [('a'.ord + i).chr])
    end
  end
  dp[i+1] = arr
end

dp[N-1].each do |arr|
  puts arr.join('')
end

Measured memory_bytes: 48636
import sys
readline = sys.stdin.readline

# Sのそれぞれの項目について
# (1)Tに属さない
# (2)Tに属すが計算に使われない
# (3)Tに属して計算に使われる
# の3通りがある

# dp[i][j] = i番目の数を処理したときに、合計がjになるものは何通りあるか

DIV = 998244353
N,S = map(int,readline().split())
A = list(map(int,readline().split()))

dp = [[0] * (S + 1) for i in range(N + 1)]

dp[0][0] = 1
for i in range(N):
  val = A[i]
  for j in range(len(dp[i]) - 1, -1, -1):
    if dp[i][j] == 0:
      continue
    dp[i + 1][j] += dp[i][j] * 2 # 使わない場合、選ばない場合
    dp[i + 1][j] %= DIV
    if j + val <= S:
      dp[i + 1][j + val] += dp[i][j]
      dp[i + 1][j + val] %= DIV
  
print(dp[-1][-1])

Measured memory_bytes: 135300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll H,N; cin >> H >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    Yn(accumulate(ALL(A),0LL)>=H);

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	
	public static void main (String[] args) {
		
		Scanner scan = new Scanner(System.in);
		double x1 = scan.nextDouble();
		double y1 = scan.nextDouble();
		double x2 = scan.nextDouble();
		double y2 = scan.nextDouble();
		
		double dis = Math.pow(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2), 0.5);
		
		System.out.println(dis);
	}
}

Measured memory_bytes: 18360
#include<iostream>
using namespace std;
int vis[105];
int x,n,t;
int main()
{
	cin>>x>>n;
	for(int i=0;i<n;++i)
	{
		cin>>t;
		vis[t]=1;
	}
	int k1=1005,k2=0;
	for(int i=0;i<=101;++i)
	{
		if((!vis[i])&&abs(i-x)<k1)
		{
			k1=abs(i-x);
			k2=i;
		}
	}
	cout<<k2<<endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vll a(3);
  rep(i,3) cin>>a[i];
  vsort(a);
  ll ans=0;
  ans=a[2]-a[1];
  a[0]+=ans;
  ll d=(a[2]-a[0])/2;
  ans+=d;
  a[0]+=2*d;
  if(a[0]!=a[2]) ans+=2;
  cout<<ans<<endl;
}

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

li = list(map(int,input().split()))
li_1 = []
mod = 10**9+7

a = 0
for i in range(1,len(li)):
    total = li[i] * (a +li[i-1])
    a += li[i-1]
    li_1.append(total)

print(sum(li_1)%mod)

Measured memory_bytes: 31612
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[100020] = {};
int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 != m2) {
		cout << 1;
	}
	else {
		cout << 0;
	}
}

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

using namespace std;


const int inf = 40 * 100 + 23;

const int MAXN = 45;
const int MAXS = 410;

int A[MAXN][MAXS][MAXS];

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

    int n, ma, mb;
    cin >> n >> ma >> mb;

    for (int i = 0; i < MAXN; i++)
        for (int j = 0; j < MAXS; j++)
            for (int k =0 ; k < MAXS; k++)
                A[i][j][k] = inf;

    A[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        int ca, cb, c;
        cin >> ca >> cb >> c;
        for (int cur_ca = 0; cur_ca < MAXS; cur_ca++) {
            for (int cur_cb = 0; cur_cb < MAXS; cur_cb++) {
                if (A[i][cur_ca][cur_cb] == inf) {
                    continue;
                }

                A[i + 1][cur_ca + ca][cur_cb + cb] = min(
                    A[i + 1][cur_ca + ca][cur_cb + cb],
                    A[i][cur_ca][cur_cb] + c
                );
                A[i + 1][cur_ca][cur_cb] = min(
                    A[i + 1][cur_ca][cur_cb],
                    A[i][cur_ca][cur_cb]
                                           );
            }
        }
    }

    int best_ans = inf;
    for (int mul = 1; mul < MAXS; mul++) {
        int ca = mul * ma;
        int cb = mul * mb;
        if (ca >= MAXS or cb >= MAXS) {
            continue;
        }
        best_ans = min(best_ans, A[n][ca][cb]);
    }
    if (best_ans >= inf) {
        cout << -1 << endl;
    } else {
        cout << best_ans;
    }
}


Measured memory_bytes: 29824
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<double,double>par;
int main(){
    int n;
    scanf("%d",&n);
    string a,b;
    cin>>a>>b;
    for(int i=n;i>=1;i--){
        if(a.substr(n-i,i)==b.substr(0,i)){
            printf("%d\n",n*2-i);
            return 0;
            }
        }
    printf("%d\n",n*2);
    return 0;
    }


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

int main() {
  string S,T;
  cin>>S>>T;
  int N=S.size(),M=T.size();
  int Z=18972;
  for(int i=0;i<=N-M;i++){
    int A=0;
    for(int j=0;j<M;j++){
      if(S[i+j]!=T[j]){
        A++;
      }
    }
    Z=min(Z,A);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3624