akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
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;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void solv() {
	
	ll k, s;
	cin >> k >> s;
	int r = 0;
	for (int x = 0; x <= k; x++)
	{
		for (int y = 0; y <= k; y++)
		{
			int v = s - x - y;
			if (v >= 0 && v <= k) r++;
		}
	}
	cout << r << endl;

}

int main() {
	COMinit();
	solv();

	return 0;
}
 

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

int main() {
    long long N, K, max_e = 0;
    cin >> N >> K;
    vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    long long sum[1001];
    long long sum_tmp = 0;
    for (int i = 0; i < 1001; i++) {
        sum_tmp += i;
        sum[i] = sum_tmp;
    }

    double exp, max_exp = 0.0;
    vector<double> e_sum(N);
    double exp_sum = 0.0;
    for (int i = 0; i < N; i++) {
        exp_sum += (double)sum[p[i]] / (double)p[i];
        e_sum[i] = exp_sum;
        if (i >= K) {
            exp = e_sum[i] - e_sum[i - K];
            if (exp > max_exp) {
                max_exp = exp;
            }
        }
    }
    if (N == K) {
        max_exp = e_sum[N-1];
    }
    cout << fixed << max_exp << "\n";
    return 0;
}


Measured memory_bytes: 3328
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

//~ typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define int long long int 
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const int MAX = -1000000000000000000;
const int MIN = 1000000000000000000;
const int inf = 1000000000;
const int KOK = 100000;
const int LOG = 30;
const int li = 500005;
const int mod = 1000000007;

int n,m,b,a[li],k,flag,vis[2005][2005],deger[2005][2005],deger1[2005][2005],deger2[2005][2005],deger3[2005][2005],mx;
int cev;
char s[2005][2005];
vector<int> v[2005];
vector<int> vv[2005];

void YES(int xxxxxxx){
	if(xxxxxxx==1){cout<<"YES\n";exit(0);}
	printf("YES\n");
	exit(0);
}

void NO(int xxxxxxx){
	if(xxxxxxx==1){cout<<"NO\n";exit(0);}
	printf("NO\n");
	exit(0);
}

main(void){
	fio();
	cin>>n>>m;
	FOR{
		for(int j=1;j<=m;j++){
			cin>>s[i][j];
			if(s[i][j]=='#'){vis[i][j]=1;v[i].pb(j);vv[j].pb(i);}
			//~ if(v[i].size())
			deger[i][j]=v[i].size();
			deger1[i][j]=vv[j].size();
			//~ cout<<deger<<" "<<deger1<<endl;
		}
	}
	//~ cout<<"**";
	FOR{
		//~ cin>>s[i];
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#'){continue;}
			if(deger[i][j]!=(int)v[i].size()) deger2[i][j]=v[i][deger[i][j]]-1;
			else if(deger[i][j]==(int)v[i].size()) deger2[i][j]=m;
			if(deger[i][j]!=0) deger[i][j]=v[i][deger[i][j]-1];
			if(deger1[i][j]!=(int)vv[j].size()) deger3[i][j]=vv[j][deger1[i][j]]-1;
			else if(deger1[i][j]==(int)vv[j].size()) deger3[i][j]=n;
			if(deger1[i][j]!=0) deger1[i][j]=vv[j][deger1[i][j]-1];
			cev=0;
			cev+=deger3[i][j]-deger1[i][j];
			//~ cout<<cev<<" ";
			cev+=deger2[i][j]-deger[i][j];
			//~ cout<<cev<<endl;
			mx=max(mx,cev-1);
		}
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 228736
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(a-x)<abs(b-x))
        cout << 'A' << endl;
        else
            cout << 'B' << endl;
        return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < n; i++) cin >> y[i];
    pair<int, int> pa[n];
    for(int i = 0; i < n; i++) pa[i] = pair<int, int> (x[i], y[i]);
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(pa[i].first > pa[i].second){
            int tasu = pa[i].first - pa[i].second;
            ans += tasu;
        }
    }
    cout << ans;
}


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

namespace ABC158
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
            //b();
        }

        public static void b()
        {
            long[] nab = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nab[0], a = nab[1], b = nab[2];
            long sum = 0;
            long aa = n % (a + b);
            long bb = n / (a + b);
            long sum1 = 0;
            for(long i = 0; i < aa; i++)
            {
                sum1++;
            }
            sum = bb * a + sum1;
            Console.WriteLine(sum);
        }

        public static void c()
        {
            long[] ab = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = ab[0], b = ab[1];
            double aa = 0, bb = 0;
            long ans = 0;
            for (long i = 1; i < 1300; i++)
            {
                aa = Math.Floor(i * 0.08);
                for (long j = 1; j <= i; j++)
                {
                    bb = Math.Floor(j * 0.1);
                    if (i == j && aa == a && bb == b)
                    {
                        Console.WriteLine(j);
                        return;
                    }
                    //Console.WriteLine("aa == {0}  bb == {1} j == {2}", aa, bb, j);
                }
            }
             Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13396
# ABC130B - Bounding
n, x = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
cur, ans = 0, 0
for i in lst:
    if cur <= x:
        ans += 1
    cur += i
print(ans + 1 if cur <= x else ans)

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

const int INF = (int)1e9;

const int MAX_N = 16;

int N;
int NONE[MAX_N];
int D[MAX_N][MAX_N];

int memo[MAX_N][1 << MAX_N];

int tsp(int v, int bit) {
	if(memo[v][bit] != -1) return memo[v][bit];
	if(bit == (1 << N) - 1) return 0;
	int res = INF;
	for(int i = 0; i < N; i++) {
		if(bit & (1 << i)) continue;
		int d = NONE[i];
		for(int j = 0; j < N; j++) {
			if(bit & (1 << j)) d = min(d, D[i][j]);
		}
		res = min(res, tsp(i, bit | (1 << i)) + d);
	}
	return memo[v][bit] = res;
}

int main() {
	for(; cin >> N, N; ) {
	for(int i = 0; i < N; i++) {
		cin >> NONE[i];
		for(int j = 0; j < N; j++) {
			cin >> D[i][j];
		}
	}
	
	for(int i = 0; i < N; i++) {
		fill(memo[i], memo[i] + (1 << MAX_N), -1);
	}
	
	int res = INF;
	for(int i = 0; i < N; i++) {
		res = min(res, tsp(i, 1 << i) + NONE[i]);
	}
	cout << res << endl;
	}
}

Measured memory_bytes: 5256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int K = sc.nextInt();
		int T = sc.nextInt();
		int[] a = sc.nextIntList(T);

		Arrays.sort(a);
		int max = a[a.length - 1];
		int sum = Arrays.stream(a).sum();

		int v = sum - max;
		System.out.println(max <= v + 1 ? 0 : max - v - 1);
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 14404
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int ret = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    if((a[i]-a[j])*(a[j]-a[k])*(a[k]-a[i])==0) continue;

                    if((long)Math.max(Math.max(a[i],a[j]),a[k])*2<(long)a[i]+a[j]+a[k]){
                        ret++;
                        
                    }
                }
            }
        }
        System.out.println(ret);
        sc.close();
    }


}


Measured memory_bytes: 36584
M, D = map(int, input().split())
def judge(m, d):
    if len(d) == 2 and m == int(d[0]) * int(d[1]) and int(d[0]) >= 2 and int(d[1]) >= 2:
        return 1
    else:
        return 0
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        ans += judge(m, str(d))
print(ans)

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



int main() {
	long long n,a,b;
	vector<pair<long long, long long> > vp;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		vp.push_back(make_pair(a,b));
	}
	long long sum=0;
	for(int i=n-1;i>=0;i--){
		long long x = vp[i].first+sum;
		if(x%vp[i].second==0) continue;
		
		long long y=x%vp[i].second;
		if(x>vp[i].second){
			long long z=x/vp[i].second;
			y=x-vp[i].second*z;
			sum+=vp[i].second-y;
		}
		else{
			sum+=vp[i].second-x;
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
	int n,k,max,buf,*a;
	
	while(1){
		cin >> n >> k;
		
		if(n || k){
			max = buf = 0;
			
			a = new int[n];
			
			for(int i = 0; i < n; i++){
				cin >> a[i];
			}
			
			for(int i = 0; i < k-1; i++){
				buf += a[i];
			}
			
			for(int i = k-1; i < n; i++){
				buf += a[i];
				if(max < buf) max = buf;
				buf -= a[i-k+1];
			}
			
			cout << max << endl;
		}else{
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1284
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
const int N = 2e5;
const int mod = 998244353;
int pwr(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % mod;
		}
		y >>= 1;
		x = x * x % mod;
	}
	return res;
}
void solve() {
	vector<int> fact(N + 1);
	fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	int n, m, k;
	cin >> n >> m >> k;
	auto ncr = [&](int n, int r) {
		int ans = fact[n];
		ans = ans * pwr(fact[r], mod - 2) % mod;
		ans = ans * pwr(fact[n - r], mod - 2) % mod;
		return ans;
	};
	int ans = 0;
	for (int i = 0; i <= k; i++) {
		int flag = m;
		flag = flag * pwr(m - 1, n - i - 1) % mod;
		flag = flag * ncr(n - 1, i) % mod;
		ans += flag;
		ans %= mod;
	}
	cout << ans << endl;
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 4732
#include <iostream>

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

const int MOD = (int) 1e9 + 7;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	ll A[n][n];
	REP(i, n) {
		REP(j, n) {
			cin >> A[i][j];
		}
	}
	
	bool exist = true;
	bool f[n][n];
	REP(i, n) {
		REP(j, n) {
			f[i][j] = false;
		}
	}
	REP(k, n) {
		REP(i, n) {
			REP(j, n) {
				if (A[i][j] > A[i][k] + A[k][j]) {
					cout << "-1" << endl;
					return 0;
				}
				if (A[i][j] == A[i][k] + A[k][j] && k != i && k != j) {
					f[i][j] = true;
				}
			}
		}
	}
	
	ll sum = 0;
	REP(i, n) {
		REP(j, n) {
			if (!f[i][j]) {
				sum += A[i][j];
			}
		}
	}
	
	cout << sum / 2 << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

    int backet1[100100] = {0};
    int backet2[100100] = {0};

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    for(int i = 0; i < n; i += 2){
        backet1[v[i]]++;
    }

    int most = 0;
    int mostindex = 0;
    int secondmost = 0;
    int secondmostindex = 0;
    for(int i = 0; i < 100100; i++){
        if(most < backet1[i]){
            most = backet1[i];
            mostindex = i;
        }
    }
    for(int i = 0; i < 100100; i++){
        if(i == mostindex)continue;
        if(secondmost < backet1[i]){
            secondmost = backet1[i];
            secondmostindex = i;
        }
    }

      for(int i = 1; i < n; i += 2){
        backet2[v[i]]++;
    }

    int most2 = 0;
    int mostindex2 = 0;
    int secondmost2 = 0;
    int secondmostindex2 = 0;
    for(int i = 0; i < 100100; i++){
        if(most2 < backet2[i]){
            most2 = backet2[i];
            mostindex2 = i;
        }
    }
    for(int i = 0; i < 100100; i++){
        if(i == mostindex2)continue;
        if(secondmost2 < backet2[i]){
            secondmost2 = backet2[i];
            secondmostindex2 = i;
        }
    }

    // cout << mostindex2 << endl;

    if(mostindex != mostindex2){
        int counter1 = 0;
        int counter2 = 0;
        for(int i = 0; i < n; i += 2){
            if(v[i] != mostindex){
                counter1++;
            }
        }
        for(int i = 1; i < n; i += 2){
            if(v[i] != mostindex2){
                counter2++;
            }
        }

        cout << counter1 + counter2 << endl;
        return 0;
    } else {
        int ans1, ans2;

        int counter1 = 0;
        int counter2 = 0;
        for(int i = 0; i < n; i += 2){
            if(v[i] != mostindex){
                counter1++;
            }
        }
        for(int i = 1; i < n; i += 2){
            if(v[i] != secondmostindex2){
                counter2++;
            }
        }

        ans1 = counter1 + counter2;

        counter1 = 0;
        counter2 = 0;

        for(int i = 0; i < n; i += 2){
            if(v[i] != secondmostindex){
                counter1++;
            }
        }
        for(int i = 1; i < n; i += 2){
            if(v[i] != mostindex2){
                counter2++;
            }
        }

        ans2 = counter1 + counter2;

        cout << min(ans1, ans2) << endl;

        

    }



}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n-1;i++){
    if(v[i].back()!=v[i+1].front()){
      cout<<"No";
      exit(0);
    }
  }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(v[i]==v[j]){
          cout<<"No";
      exit(0);
    }
  }
    }
     cout<<"Yes";
    }


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


int main(){
	int a,b,c;
	cin>>a>>b>>c;

	for (int i = a; i <= b*a ; i+=a){
		if(i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}

	cout<<"NO"<<endl;
}


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

int main() {
	int N,K;
  	cin>> N >> K;
  	int p[N];
  	int sum=0;
  	rep(i,N) cin>>p[i];
  	
  	sort(p,p+N);
  	
  	rep(i,K)	sum+=p[i];
  	cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main()
{

  int a, b, c;

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

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
	ll n, a;
	cin >> n >> a;
	vector<ll> as(n);
	rep(i, n) {
		cin >> as[i];
		as[i] -= a;
	}
	const int c = 2510;
	vector<vector<ll>> dp(2, vector<ll>(c*2, 0));
	for (int i = 0; i < n; i++) {
		swap(dp[0], dp[1]);
		dp[1].assign(c * 2, 0);
		dp[1][c + as[i]]++;
		for (int j = 0; j < c * 2; j++) {
			dp[1][j] += dp[0][j];
		}
		for (int j = 0; j < c * 2; j++) {
			int k = j + as[i];
			if (k < 0 || k >= c * 2) continue;
			dp[1][k] += dp[0][j];
		}
	}
	cout << dp[1][c] << endl;
    return 0;
}


Measured memory_bytes: 3740
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
AGC028 D
"""

import itertools
from functools import reduce
from functools import lru_cache

nn, k = map(int, input().split())
n = 2*nn
abli = []
for i in range(k):
    a, b = map(int, input().split())
    if a < b:
        abli.append((a, b))
    else:
        abli.append((b, a))
flattenabli = itertools.chain.from_iterable(abli)

cut = 10**9+7

unused = [1 for i in range(n+1)]
for a in flattenabli:
    unused[a] -= 1
unusedacum = list(itertools.accumulate(unused))


def modInverse(a, b, divmod=divmod):
    r0, r1, s0, s1 = a, b, 1, 0
    while r1 != 0:
        q, rtmp = divmod(r0, r1)
        stmp = s0-q*s1
        r0, s0 = r1, s1
        r1, s1 = rtmp, stmp
    return s0 % cut


@lru_cache(maxsize=None)
def doubleFactorial(x):
    return reduce(lambda y, z: y*z % cut, range(x, 0, -2))


@lru_cache(maxsize=None)
def isSandwiched(i, j):
    return any(map(lambda k: abli[k][0] < i <= abli[k][1] <= j or i <= abli[k][0] <= j < abli[k][1], range(k)))


nonSandwichedNums = [[] for i in range(n+1)]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if not isSandwiched(i, j):
            nonSandwichedNums[i].append(j)


def numberUnderterminedBetween(i, j):
    return unusedacum[j]-unusedacum[i-1]


def pairCombinations(x):
    if x == 0:
        return 1
    elif x % 2 == 0:
        return doubleFactorial(x-1)
    else:
        return 0


def g(i, j):
    x = numberUnderterminedBetween(i, j)
    return pairCombinations(x)


undetermined = numberUnderterminedBetween(1, n)

ggg = [[0]*(i+1) for i in range(n+1)]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        ggg[i].append(g(i, j))

ans = 0
dp = [[0]*(n+1) for i in range(n+1)]
for i in range(1, n+1):
    for j in nonSandwichedNums[i]:
        gg = ggg[i][j]
        if gg != 0:
            dp[i][j] = (ggg[i][j]-sum([dp[i][kk]*ggg[kk+1][j] for kk in nonSandwichedNums[i] if kk < j])) % cut
        else:
            dp[i][j] = 0
        ans = (ans + dp[i][j]*pairCombinations(undetermined-numberUnderterminedBetween(i, j))) % cut


print(ans)


Measured memory_bytes: 101720
#include <stdio.h>
int main(void){
    // Your code here!
    char str[100];
    scanf("%s", str);
    for(int i = 0; i < 3; i++){
        if(str[i] == str[i+1]){
            printf("Bad");
            return 0;
        }
    }
    printf("Good");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 2e18

int ans;
int n, m, q;
int a[50], b[50], c[50], d[50];
int A[15];

void dfs(int vi, int len){
    // printf("%d %d\n", vi, len);
    if(len==n){
        int tmp = 0;
        rep(i, q){
            if(A[b[i]]-A[a[i]]==c[i]) tmp += d[i];
        }
        chmax(ans, tmp);
    }else{

        repr(i, vi, m){
            A[len+1] = i;
            dfs(i, len+1);
        }
    }
}


int main(){
    cin >> n >> m >> q;
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    // int AA[15];
    // printf("%d\n", N);
    dfs(1, -1);

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626;
signed main(){
  int a,b,x;
  cin>>a>>b>>x;
  double xl = (double) x / (a * a);
  double al = (double) 2.0 * a * xl / b;
  double ans1 = 180.0*acos((double)a/(2.0*sqrt((b-xl)*(b-xl)+a*a/4.0)))/PI;
  double ans2 = 180.0*acos(al/sqrt(b*b+al*al))/PI;
  cout<<setprecision(12)<<(b/2.0<=xl?ans1:ans2);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<complex>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	vector<llint>a(n);
	llint x;
	for (int i = 0;i < n;i++) {
		if (i == 0) {
			cin >> a[i];
		}
		else {
			cin >> x;
			a[i] = a[i - 1] + x;
		}
	}
	llint tmp = a[n - 1];
	llint ans = 2000000000;
	for (int i = 0;i < n - 1;i++) {
		if (ans > abs(tmp - 2 * a[i])) {
			ans = abs(tmp - 2 * a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#define MAX 100


int n,c,d=0;
int pre[1000],in[1000],post[1000];

int find(int x);
void rec(int l,int r);

int main(void){
	int i;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&pre[i]);
	}
	
	for(i=0;i<n;i++){
		scanf("%d",&in[i]);
	}
	
	rec(0,n);
	
	for(i=0;i<n;i++){
		if(i!=n-1){
			printf("%d ",post[i]);
		}
		else {
			printf("%d\n",post[i]);
		}
	}
	return 0;
}


int find(int x){
	int i;
	for(i=0;i<n;i++){
		if(x==in[i]){
			return i;
		}
	}
	return 0;
}

void rec(int l,int r){
	int x,y;
	if(l>=r){
		return;
	}
	
	x=pre[d++];
	y=find(x);
	rec(l,y);
	rec(y+1,r);
	post[c++]=x;
}




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

int main(){
    int n; cin>>n;
    vector<pair<int,int>> p(n);
    for(int i=0;i<n;i++){
        int x,l; cin>>x>>l;
        p[i]=make_pair(x+l,x-l);
    }
    sort(p.begin(),p.end());
    
    int ans=0;
    int t=-1e9;
    for(int i=0;i<n;i++){
        if(p[i].second>=t){
            ans++;
            t=p[i].first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
n = int(input())
t = []
a = []
for i in range(n):
    T, A = map(int, input().split())
    t.append(T)
    a.append(A)

x = t[0]
y = a[0]

for i in range(1, n):
    j = max(x//t[i], y//a[i])
    xn = t[i] * j
    yn = a[i] * j
    if xn >= x and yn >= y:
        x = xn
        y = yn
    else:
        x = t[i] * (j+1)
        y = a[i] * (j+1)

print(x + y)

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll LOG = 31;
const ll MOD = (ll)1e9 + 7;
struct RNG{
  ll lef;
  ll rig;
  ll vv;
  ll ans;
};

int main(){
  fastIO;
  ll n, k;
  cin >> n >> k;
  vector<RNG> cur;
  ll p = 1;
  ll ni;
  while(p<=n){
    ni = p;
    for(ll j = LOG - 1; j >= 0 ; j -- ){
      if((ni + (1 << j)) > n) continue;
      if((n/p) == n/(ni + (1 << j))){
        ni += (1 << j);
      }
    }
    cur.push_back({p, ni, n/p, 1});
    p = ni + 1;
  }
  ll m = cur.size();
  vector<RNG> nx;
  ll q;
  ll pref;
  for(ll i = 2 ; i <= k ; i ++ ){
    nx = cur;
    for(auto &p : nx) p.ans = 0;
    q = 0;
    pref = 0;
    for(ll p = nx.size() - 1; p >= 0 ; p -- ){
      while(cur[q].rig < nx[p].vv){
        pref += ((cur[q].rig - cur[q].lef + 1) * 1ll * cur[q].ans) % MOD;
        q ++ ;
      }
      nx[p].ans = pref;
      nx[p].ans += ((nx[p].vv - cur[q].lef + 1) * 1ll * cur[q].ans) % MOD;
      if(nx[p].ans >= MOD) nx[p].ans -= MOD;
    }
    cur = nx;
  }
  ll res = 0;
  for(auto pq : nx){
    res += ((pq.rig - pq.lef + 1) * 1ll * pq.ans) % MOD;
    if(res >= MOD) res -= MOD;
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int pay = (n + 999) / 1000 * 1000;
    cout << pay - n << "\n";
    return 0;
}

Measured memory_bytes: 3616
N=int(input())
S=set()
ans=0
index=1
while(index*index<=N):
    if N%index==0:
        S.add(index)
        S.add(N//index)
    index+=1
for k in S:
    if k==1:
        continue
    m=k-1
    if (N//m)==(N%m):
        ans+=m
print(ans)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e5+5;
const ll mod = 1e9+7;
ll b[N];
ll a[N];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>b[i];
    ll sum = 0;
    for(int i=0;i<n;i++){
        sum+=b[i];
    }
    for(int i=0;i<n-1;i+=2){
        sum-=b[i];
        sum-=b[i];
    }
    a[n-1] = sum;
    for(int i=n-2;i>=0;i--){
        a[i] = 2*b[i]-a[i+1];
    }
    for(int i=0;i<n;i++)cout<<a[i]<<" ";
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
/// 3 8 7 5 5
/// a0/2 + a1/2
/// a1/2 + a2/2
/// a2/2 + a3/2
/// a3/2 + a4/2
/// a4/2 + a0/2




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

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);

    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < M; i++)
    {
        cin >> y[i];
    }

    int xmax = *max_element(x.begin(), x.end());
    int ymin = *min_element(y.begin(), y.end());

    if (xmax >= Y || ymin <= X || xmax >= ymin)
    {
        cout << "War" << endl;
    } else {
        cout << "No War" << endl;
    }
}

Measured memory_bytes: 256
#! /usr/bin/env python3

n, m =  map(int, input().split())

a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

cur = 0

res = False

for r in range(n):
    offset = -1
    while True:
        offset = a[r].find(b[0], offset + 1)

        if offset == -1:
            break

        flg = True
        for r2 in range(1, m):
            if r + r2 >= n:
                flg = False
                break
            if a[r + r2].find(b[r2], offset) != offset:
                flg = False
                break

        if flg == True:
            res = True
            break

    if res == True:
        break
            
if res == True: print("Yes")
else: print("No")


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

int main(){

  string s, t;

  cin >> s >> t;

  bool ok = true;
  for(int i=0;i<s.size();i++){
    if(s[i] != t[i]) ok = false;
  }

  if(ok && s.size() <= 10 && s.size() >= 1) puts("Yes");
  else puts("No");
  
}


Measured memory_bytes: 3636
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab.sort()
p = [0]*n
for i in range(q):
  i = list(map(int, input().split()))
  p[i[0] - 1] += i[1]
s = ""
for i in ab:
  p[i[1]-1] += p[i[0]-1]
print(" ".join(map(str, p)))

Measured memory_bytes: 78408
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	x, y = LI()
	for turtle in range(x+1):
		turu = x - turtle
		if 4 * turtle + 2 * turu == y:
			print('Yes')
			break
	else:
		print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 27136
a1, b1 = list(map(int, input().split()))
a2, b2 = list(map(int, input().split()))
a3, b3 = list(map(int, input().split()))

city_list = [a1, a2, a3, b1, b2, b3]
count_list = []
count_list.append(city_list.count(1))
count_list.append(city_list.count(2))
count_list.append(city_list.count(3))
count_list.append(city_list.count(4))
if count_list.count(3)>=1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

#define MAX_N 100000
#define MAX_M 100000

template <class T, class InputIterator>
bool isin(T x, InputIterator first, InputIterator last) {
  return std::any_of(first, last, [x](T y){return x==y;});
}

int main() {
  int n,m;
  std::vector<int> x(MAX_M), mark(MAX_M - 1);
  std::cin >> n >> m;

  if (n >= m) {
    std::cout << 0 << std::endl;
    return 0;
  }

  for(int i = 0; i < m; ++i) {
    std::cin >> x[i];
    mark[i] = i;
  }
  std::sort(x.begin(), x.begin()+m);

  std::vector<int> dist(MAX_M-1);
  for(int i = 1; i < m; ++i) {
    dist[i] = x[i] - x[i - 1];
  }
  std::sort(dist.begin(), dist.begin()+m);

  int cost = x[m-1] - x[0];
  for(int i = 0; i < n - 1; ++i) {
    cost -= dist[m-1-i];
  }

  std::cout << cost << std::endl;
  return 0;
}

Measured memory_bytes: 1408
#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-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i, 3){
		if (s[i] == s[i+1]){ cout << "Bad" << endl; return 0; }
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
def divide(a):
    if a == 1:
        s.append("1")
        return
    amari = a % 2
    shou =  (a - amari) // (-2)
    s.append(str(amari))
    divide(shou)
if n:
    divide(n)
    print("".join(reversed(s)))
else:
    print(n)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long n = sc.nextLong();
			String tmp = Long.toString(n);
			int sn = 0;
			for (char c : tmp.toCharArray()) {
				sn += c - '0';
			}
			if (n % sn == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 22100
#include<iostream>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double x[n],y[n];
	map<char,pair<double,double> >m;
	pair<double,double> d[n];
	m['U']=make_pair(0.0,1.0);
	m['D']=make_pair(0.0,-1.0);
	m['L']=make_pair(-1.0,0.0);
	m['R']=make_pair(1.0,0.0);
	for(int i=0;i<n;i++){
		double x1,y1;
		char ch;
		cin>>x1>>y1>>ch;
		x[i]=x1;
		y[i]=y1;
		d[i]=m[ch];
	}
	//cout<<setprecision(12);
	double l=0.0,r=1e10,a1=1e18,a2=1e18;
	for(int i=0;i<200;i++){
		double l1=l+(r-l)/3.0,r1=r-(r-l)/3.0;
		double minx=1e18,miny=1e18,maxx=-1e18,maxy=-1e18;
		for(int j=0;j<n;j++){
			double x1=x[j]+l1*d[j].first;
			double y1=y[j]+l1*d[j].second;
			minx=min(minx,x1);
			maxx=max(maxx,x1);
			miny=min(miny,y1);
			maxy=max(maxy,y1);
		}
		a1=(maxx-minx)*(maxy-miny);
      	minx=1e18,miny=1e18,maxx=-1e18,maxy=-1e18;
		for(int j=0;j<n;j++){
			double x1=x[j]+r1*d[j].first;
			double y1=y[j]+r1*d[j].second;
			minx=min(minx,x1);
			maxx=max(maxx,x1);
			miny=min(miny,y1);
			maxy=max(maxy,y1);
		}
		a2=(maxx-minx)*(maxy-miny);
		if(a1<a2)r=r1;
		else l=l1;
	}
	printf("%.12lf",min(a1,a2));
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

int main()
{
	std::string str;
	
	std::getline(std::cin, str);
	
	for (unsigned i = 0; i < str.length(); ++i) {
		char c = str.at(i);
		if ('a' <= c && c <= 'z') str.at(i) += 'A' - 'a';
	}
	
	std::cout << str << std::endl;
	
	return 0;
}

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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)

long long ans(int num){
  //if(num==2)return 2;
  vector<pair<long long, long long> > res;
  long long count=1;
  long long N=num;
  for (long long a = 2; a * a <= N; ++a) {
      if (N % a != 0) continue;
      long long ex = 0; // 指数

      // 割れる限り割り続ける
      while (N % a == 0) {
          ++ex;
          N /= a;
      }
      if(ex!=0)count*=ex+1;
    //cout<<count<<"||"<<ex<<endl;
      // その結果を push
      res.push_back({a, ex});
  }
  
    if (N != 1) count*=2;
  return count;
}

int main()
{
  long long N;
  long long A,B,count=0;
  cin>>N;
  for(int i=1;i<N;i++){
    count+=ans((N-i));
    //cout<<count<<"|"<<i<<endl;
  }
  cout<<count;
  return 0;
}




Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String ans = S.charAt(0) + String.valueOf((S.length()-2)) + S.charAt(S.length()-1);
        System.out.println(ans);
    }
}

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

#define int long long
using namespace std;
int n;

int solve(int dp[100010][3]) {
    for (int i = n - 2; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            int ans = -1e14;
            for (int k = 0; k < 3; k++) {
                if (j != k)
                    ans = max(dp[i + 1][k], ans);
            }
            dp[i][j] += ans;
        }
    }
    int ans = -1e14;
    for (int l = 0; l < 3; ++l) {
        ans = max(ans, dp[0][l]);
    }
    return ans;
}


int32_t main() {

    int dp[100010][3];
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; ++j) {
            cin >> dp[i][j];
        }
    }
    cout << solve(dp) << endl;

}



Measured memory_bytes: 2560
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
n.times{
  inp=gs
  h[inp[0]]+=1 if ['M','A','R','C','H'].include? inp[0]
}

ar=h.to_a.map{|i|i[1]}
ar.combination(3) do |a,b,c|
  cnt+=a*b*c
end

puts cnt

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next(), B = sc.next(), C = sc.next();
		if (A.charAt(A.length() - 1) == B.charAt(0) &&
				B.charAt(B.length() - 1) == C.charAt(0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

lo t,n,a,b,c,d,r,m,l,k;



int main() {
	cin >> t;
	fori0(t) {
		cin >> a>>b>>c>>d;
		n = b;
		r = d;
		while (r > 0) {
			lo p = r;
			r = n % r;
			n = p;
		}
		if (a%n + b - n > c) { l = 0; }
		else { l = 1; }



		if (a < b) { NN}
		else if (d < b) { NN }
		
		else if (c>=b) {YY }
		else if(l){YY}
		else{NN}
	}
	
	
	
	
	//system("pause");
	return 0;

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for _ in range(M)]

N=int(input())


while N>0:
    tmp = N
    while tmp%2 == 0:
        tmp = tmp//2
    if tmp == 1:
        print(N)
        sys.exit()
    N -= 1

Measured memory_bytes: 77456
#include <bits/stdc++.h>
using namespace std;
bool huiwen(string s,int q,int p)
{
    for(int i=q;i<p;i++)
       {  if(s[i]!=s[p-1-i])return 0;
       }
    return 1;
}


int main()
{   string s;
    cin>>s;
    int n=s.length();
    if(huiwen(s,0,n)&&huiwen(s,0,n/2)&&huiwen(s,n/2+1,n))printf("Yes");
    else printf("No");




    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

i = a.index(a.max_by{|e| e.abs})

if a[i] == 0
    puts 0
elsif a[i] > 0
    puts 2 * n
    puts "#{i+1} #{1}", "#{i+1} #{1}"
    (n-1).times {|j| puts "#{j+1} #{j+2}", "#{j+1} #{j+2}"}
else
    puts 2 * n
    puts "#{i+1} #{n}", "#{i+1} #{n}"
    (n-1).downto(1) {|j| puts "#{j+1} #{j}", "#{j+1} #{j}"}
end

Measured memory_bytes: 14336
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val ans = Iterator.continually(io.StdIn.readLine.split(" ").par)
    .take(n)
    .forall(in => {
      val c = in(0).toInt - in(1).toInt - in(2).toInt
      if (c >= 0 && (c & 1) == 0) true else false
    })

  println(if(ans) "Yes" else "No")
}

Measured memory_bytes: 47260
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<typename T>
vector<T> dijkstra(const vector<vector<pair<int, T>>> &graph, int root) {
  using P = pair<T, int>;
  vector<T> dists(graph.size(), numeric_limits<T>::max());
  priority_queue<P, vector<P>, greater<P>> que;
  dists[root] = 0;
  que.emplace(dists[root], root);
  while (!que.empty()) {
    T d; int cur;
    tie(d, cur) = que.top(); que.pop();
    if (dists[cur] < d) continue;
    for (auto e : graph[cur]) {
      int nx; T cost;
      tie(nx, cost) = e;
      if (dists[nx] > dists[cur] + cost) {
        dists[nx] = dists[cur] + cost;
        que.emplace(dists[nx], nx);
      }
    }
  }
  return dists;
}

int main() {
  int n; cin>>n;
  vector<vector<pair<int, long long>>> g(n);
  rep(i, n-1) {
    int a, b, c; cin>>a>>b>>c;
    --a; --b;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  int q, k; cin>>q>>k;
  --k;
  auto dists = dijkstra(g, k);
  rep(i, q) {
    int x, y; cin>>x>>y;
    --x; --y;
    print(dists[x]+dists[y]);
  }

  return 0;
}

Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
#define pi 3.141592653589793238
main()
{
    int n,i;
    cin>>n;
    int a[n+1];int b[n+1]={0};
    for(i=2;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(i=1;i<=n;i++)
    cout<<b[i]<<endl;
    
}

Measured memory_bytes: 5192
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector <vec> mat;
ll n,m,a,b,c,T;

mat mul(mat A,mat B){
  mat res;
  res.resize(n);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) res[i].push_back(0);

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++){
	res[i][j]+=A[i][k]*B[k][j];
	res[i][j]%=m;
      }
  return res;
}

mat mod_pow(mat x,ll y){
  mat res;
  res.resize(n);
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)res[i].push_back(i==j);
  
  while(y){
    if(y%2) res=mul(res,x);
    x=mul(x,x);
    y/=2;
  }
  return res; 
}
int main(){ 
  while(1){
    cin>>n>>m>>a>>b>>c>>T;
    if(!n&&!m&&!a&&!b&&!c&&!T)break;

    mat s;
    s.resize(n);
    for(int i=0;i<n;i++) s[i].resize(n);
    for(int i=0;i<n;i++) cin>>s[i][0];
    
    mat x;
    x.resize(n);
    for(int i=0;i<n;i++) x[i].resize(n);

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(i==j) x[i][j]=b;
	else if(i+1==j&&i+1<n) x[i][j]=c;
	else if(i==j+1&&j+1<n) x[i][j]=a;
	else x[i][j]=0;
    
    x=mod_pow(x,T);
    mat ans=mul(x,s);
    for(int i=0;i<n-1;i++)cout << ans[i][0]<<" ";
    cout << ans[n-1][0]<<endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;

struct interval{
	int a,b;
};

int solve0(const vector<interval>& I){
	int n=I.size();
	multiset<int> L,R;
	rep(i,n){
		L.emplace(I[i].a);
		R.emplace(I[i].b);
	}

	int res=0;
	rep(i,n){
		int l=I[i].a,r=I[i].b;
		L.erase(L.find(l));
		R.erase(R.find(r));
		int l2=*L.rbegin();
		int r2=*R.begin();
		res=max(res,max(r-l+1,0)+max(r2-l2+1,0));
		L.emplace(l);
		R.emplace(r);
	}
	return res;
}

int solve(const vector<interval>& I){
	int n=I.size();
	multiset<int> L,R;
	rep(i,n-1){
		L.emplace(I[i+1].a);
		R.emplace(I[i+1].b);
	}

	int res=0;
	int l=I[0].a,r=I[0].b;
	rep(i,n-1){
		int l2=*L.rbegin();
		int r2=*R.begin();
		res=max(res,max(r-l+1,0)+max(r2-l2+1,0));
		l=max(l,I[i+1].a);
		r=min(r,I[i+1].b);
		L.erase(L.find(I[i+1].a));
		R.erase(R.find(I[i+1].b));
	}
	return res;
}

int main(){
	int n; cin>>n;
	vector<interval> I(n);
	rep(i,n) cin>>I[i].a>>I[i].b;

	int ans=solve0(I);
	sort(I.begin(),I.end(),[](const interval& I,const interval& J){ return tie(I.a,I.b)<tie(J.a,J.b); });
	ans=max(ans,solve(I));
	sort(I.begin(),I.end(),[](const interval& I,const interval& J){ return tie(I.b,I.a)<tie(J.b,J.a); });
	ans=max(ans,solve(I));
	sort(I.begin(),I.end(),[](const interval& I,const interval& J){ return tie(I.a,J.b)<tie(J.a,I.b); });
	ans=max(ans,solve(I));
	sort(I.begin(),I.end(),[](const interval& I,const interval& J){ return tie(I.b,J.a)<tie(J.b,I.a); });
	ans=max(ans,solve(I));
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>
#include <stdlib.h>
int asc(const void*a , const void*b){
	return *(int *)a - *(int * )b;
}

int main(void){
	
	int a,b,c,x,y;
	int total[3];
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	
	total[0] = a*x+b*y;
	if(x>y){
		total[1] = (2*c*y)+a*(x-y);
		total[2] = 2*c*x;
	}else{
		total[1] = (2*c*x)+b*(y-x);
		total[2] = 2*c*y;
	}
	qsort(total,3,sizeof(int),asc);
	printf("%d\n",total[0]);
	return 0;
}

Measured memory_bytes: 128