akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, k, c; cin >> n >> k >> c;
    c++;
    vector<int> days;

    cin >> skipws;
    rep(i, 0, n) {
        char c; cin >> c;
        if (c == 'o') days.push_back(i + 1);
    }

    vector<vector<int>> groups;
    vi cg;

    trav(i, days) {
        if (!cg.empty() && i - cg.front() >= c) {
            groups.push_back(cg);
            cg.clear();
        }
        cg.push_back(i);
    }
    groups.push_back(cg);

    set<int> vals;
    vector<int> lo(k), hi(k);
    if (groups.size() == k) {
        {
            int cur = groups[0].front();
            lo[0] = cur;
            for (int i = 1; i < groups.size(); i++) {
                for (int j = 0; j < groups[i].size(); i++) if (groups[i][j] - cur >= c) {
                    lo[i] = cur = groups[i][j];
                    break;
                }
            }
        }
        {
            int cur = groups[groups.size() - 1].back();
            hi[groups.size() - 1] = cur;

            for (int i = groups.size() - 2; i >= 0; i--) {
                for (int j = groups[i].size() - 1; j >= 0; j--) if (cur - groups[i][j] >= c) {
                    hi[i] = cur = groups[i][j];
                    break;
                }
            }
        }
        rep(i, 0, k) if (lo[i] == hi[i]) cout << lo[i] << endl;
    } else if (groups.size() < k) {
        exit(1);
    }
}

Measured memory_bytes: 14824
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int N;
  cin>>N;
  int mxn = 1;
  int sum = 1;
  int nouse = 0;
  while(sum < N)
  {
    mxn++;
    nouse = mxn - (N - sum);
    sum += mxn;
  }
  FOR(i,1,mxn+1)
  {
    if(i==nouse) continue;
    cout << i << endl;
  }
  return 0;
}


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

if n < 100000:

    ans = 0
    x = 1

    while x < n:
        if n % x == 0:
            m = n // x - 1
            if m <= x:
                break
            else:
                ans += m
        x += 1

    print(ans)

    exit()


ans = 0
x = 1

t = int(n ** 0.5)

while x <= int(n ** 0.5):
    if n % x == 0:
        ans += n // x - 1
    x += 1

if t * t == n:
    ans -= t - 1

print(ans)


Measured memory_bytes: 41452
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int main(void)
{
	int N;
	scanf("%d", &N);
	if (N > 82) {
		printf("No");
		return 0;
	}
	for (int i = 1; i < 10; i++) {
		if (N % i == 0) {
			if (N / i < 10) {
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;

}


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

#define pb         push_back

typedef long long ll;
//const ll INF = 1000000000000000000ll;
const ll INF = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;
#define NOEDGE 1000000009

vector<pair<ll, ll>> e[1005];
ll score[1005];
ll n, m;
bool f = true;

void bellman_ford(int s){
	for(int i=0; i<n; i++) score[i] = -INF;
	score[s] = 0;
	ll cnt = 0;
	while(true){
		bool update = false;
		ll bef = score[n-1];
		for(int i=0; i < n; i++){
			for(int j=0; j < e[i].size(); j++){
				auto to = e[i][j].first;
				auto cost = e[i][j].second;
				if(score[i] != -INF && score[to] < score[i] + cost){
					score[to] = score[i] + cost;
					update = true;
				}
			}
		}
		if(!update) break;
		cnt++;
		if(cnt > n*5){
			if(bef != score[n-1]){
				f =false;
			}
			break;
		}
	}
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	cin >> n >> m;
	for(int i=0; i<m; i++){
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		e[a].pb(make_pair(b, c));
	}

	bellman_ford(0);

	/*
	for(int i=0; i<n; i++){
		cout << score[i] << endl;
	}
	*/
	if(f){
		cout << score[n-1] << endl;
	}else{
		cout << "inf" << endl;
	}
	
	return 0;
}



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

vector<set<int>> g(4);


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

    for(int i = 0,a,b; i < 3; ++i){
        cin >> a >> b;
        a--;
        b--;
        g[a].insert(b);
        g[b].insert(a);
    }
    int cnt = 0;
    for(int i = 0; i < 4; ++i){
        cnt += g[i].size() == 1;
    }
    if(cnt != 2){
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }



    return 0;
}

Measured memory_bytes: 256
using System;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        int K = int.Parse(Console.ReadLine());

        int[] temp = Convert(GetLines());

        int A = temp[0];
        int B = temp[1];
        int V = A / K;

        while (true)
        {
            if (V * K >= A && V * K <= B)
            {
                Console.WriteLine("OK");
                return;
            }
            else
            {
                if (V * K > B)
                {

                    Console.WriteLine("NG");
                    return;
                }
            }
            V++;

        }
    }


    static int[] Convert(string[] v)
    {
        var temp = new int[v.Length];

        for (int i = 0; i < temp.Length; i++)
        {
            temp[i] = int.Parse(v[i]);
        }

        return temp;
    }




    static string[] GetLines()
    {
        return Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
    }


}

Measured memory_bytes: 27540
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) 
	{
		String s = in.nextLine();
		solve(s);
	}
	
	static void solve(String ss)
	{
		String [] s = ss.split("");
		int largest = -1;
		int curr = 0;
		for(int i = 0; i < s.length; i++)
		{
			if(s[i].equals("R"))
				curr++;
			else
			{
				largest = Math.max(largest, curr);
				curr = 0;
			}
		}
		largest = Math.max(largest, curr);
		System.out.println(largest);
	}
	
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}





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

using namespace std;

int main(int argc, char ** argv){
  int N,sum = 0;
  vector<int> len;
  cin >> N;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    len.push_back(tmp);
  }
  
  sort(len.begin(), len.end(), greater<int>());
  for(int i = 1; i < len.size(); i++) sum += len[i];
  if(len[0] < sum) cout << "Yes";
  else cout << "No";
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
int main() {
    int a,b;
    cin >> a >> b;
    if (a<=8 && b<=8) cout << "Yay!" << endl;
    else cout << ":(" << endl; 
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	char S[3];
	char T[3];
	cin >> S[0] >> S[1] >> S[2];
	cin >> T[0] >> T[1] >> T[2];
	int count = 0;
	if (S[0] == T[0]) {
		count++;
	}
	if (S[1] == T[1]) {
		count++;
	}
	if (S[2] == T[2]) {
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    sort(a.begin(),a.end());
    ll num1=a[n/2-1];
    ll num2=a[n/2];
    ans=num2-num1;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

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

typedef long long LL;
const int M=4005;
char s[M];

int main()
{
	int n;
	scanf("%d%s",&n,s);
	int cntr=0,cntg=0,cntb=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
			cntr++;
		if(s[i]=='G')
			cntg++;
		if(s[i]=='B')
			cntb++;
	}
	LL ans=(LL)cntr*cntg*cntb;
	for(int i=2;i<n;i++)
		for(int j=i-1,k;(k=j-(i-j))>=0;j--)
		{
			if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
				ans--;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>

using namespace std;

#define ull unsigned long long

/* simple solution */
int main() {
	ull n, temp;
	cin >> n;
	temp = n;

	unsigned nod = 0, digits[16];
	unsigned isAll9 = 1;
	while (temp) {
		digits[nod] = temp % 10;
		temp /= 10;
		if (temp && digits[nod] != 9) isAll9 = 0;
		nod++;
	}

	if (nod == 1) {
		cout << n << endl;
		return 0; 
	}

	unsigned total = 9 * (nod - 1) + digits[nod - 1] - (isAll9 ? 0:1);
	cout << total << endl;

	return 0;

}



Measured memory_bytes: 256
import kotlin.math.max

fun main() {
    val (n, m, q) = readLine()!!.split(' ').map { it.toInt() }
    val qs = (0 until q).map { readLine()!!.split(' ').map { it.toInt() } }

    fun f(list: List<Int>): Int {
        if (list.size == n) {
            val l = list.reversed()
            var score = 0
            for ((a, b, c, d) in qs) {
                if (l[b - 1] - l[a - 1] == c) score += d
            }
            return score
        }
        var ans = 0
        val x = if (list.isEmpty()) m else list.last()
        for (i in 1..x) {
            ans = max(ans, f(list + listOf(i)))
        }
        return ans
    }

    println(f(emptyList()))
}

Measured memory_bytes: 68524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

const int MAX = 1000005;

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



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

    ll n, m, k; cin >> n >> m >> k;
    COMinit();

    ll ans = 0;
    for(int d=1; d<n; ++d){
        ans += COM(n*m-2, k-2)*d%mod*(n-d)%mod*m%mod*m;
        chmod(ans);
    }

    for(int d=1; d<m; ++d){
        ans += COM(n*m-2, k-2)*d%mod*(m-d)%mod*n%mod*n;
        chmod(ans);
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int cost[11] = {0,2,5,5,4,5,6,3,7,6};
vector<string> cache(20000,string(""));
vector<int> A;

int comp(string s, string t){
    if(s == "N")
        return false;
    if(t == "N")
        return true;
    if(s.size() < t.size())
        return false;
    else if(s.size() > t.size())
        return true;
    else{
        int n = s.size();
        REP(i,n){
            if(s[i] > t[i])
                return true;
            else if(s[i] < t[i])
                return false;
        }
        return true;
    }
}

string rec(int N){
    if(N == 0)
        return "";
    if(cache[N] != "")
        return cache[N];
    string res="N";
    for(int a: A){
        if(cost[a] <= N && rec(N-cost[a])!="N"){
            string s = (char)('0' + a) + rec(N-cost[a]);
            if(comp(s, res))
                res = s;
        }
    }
    cache[N] = res;
    return res;
}

int main(void){
    int N,M;
    GI(N);GI(M);
    vector<int> B(M);
    REP(i,M)
        GI(B[i]);
    A = B;
    string ans = rec(N);
    printf("%s\n",ans.c_str());
    return 0;
}

Measured memory_bytes: 44928
#include<stack>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M, Q;
VI G[100011];

pair<int, int> C[100011][11];
int X[100011];

void dfs(int v, int d) {
    stack<pair<int, int> > st;
    st.emplace(v, d);
    pair<int, int> c = C[v][d];
    while (!st.empty()) {
	v = st.top().first;
	d = st.top().second;
	st.pop();
	if (d == 0) continue;
	EACH (e, G[v]) if (C[*e][d-1].first < c.first) {
	    C[*e][d-1] = c;
	    st.emplace(*e, d-1);
	}
    }
}

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, M) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    REP (i, N) {
	REP (j, 11) {
	    C[i][j].first = -1;
	    C[i][j].second = 0;
	}
    }

    scanf("%d", &Q);
    REP (i, Q) {
	int v, d, c;
	scanf("%d%d%d", &v, &d, &c);
	v--;
	C[v][d] = make_pair(i, c);
	X[i] = v;
    }
    for (int i=Q; i--;) {
	int v = X[i];
	for (int d=10; d>0; d--) if (C[v][d].first == i) {
	    dfs(v, d);
	    break;
	}
    }

    REP (v, N) {
	int color = 0, time = -1;
	REP (d, 11) if (C[v][d].second >= 0 && time < C[v][d].first) {
	    time = C[v][d].first;
	    color = C[v][d].second;
	}
	printf("%d\n", color);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

//conversion
//------------------------------------------
inline int toInt(string s) {int 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;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  int A,B;
  cin >> A >> B;
  
  if(A<=8 && B<=8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d; cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) cin >> s[i][j];
    }
    vector<ll> t(d);
    for (ll i = 0; i < d; i++) {cin >> t[i]; t[i]--;}
    
    auto calc = [&] () {
        ll ret = 0;
        vector<ll> v(26, -1);
        for (ll i = 0; i < d; i++) {
            v[t[i]] = i;
            ret += s[i][t[i]];
            for (ll j = 0; j < 26; j++) ret -= c[j] * (i - v[j]);
            //cout << ret << endl;
        }
        return ret;
    };
    
    ll score = calc();
    
    vector<set<ll>> v(26);
    for (ll i = 0; i < 26; i++) v[i].insert(-1);
    for (ll i = 0; i < d; i++) v[t[i]].insert(i);
    for (ll i = 0; i < 26; i++) v[i].insert(d);
    
    auto modified = [&] (ll day, ll into) {
        ll ret = score;
        ret += s[day][into] - s[day][t[day]];
        auto itr1 = v[t[day]].find(day);
        ll p = *(--itr1), q = *(++itr1), r = *(++itr1);
        ret += ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[t[day]] / 2;
        ret -= (r - p) * (r - p - 1) * c[t[day]] / 2;
        auto itr2 = v[into].upper_bound(day);
        p = *(--itr2); q = day; r = *(++itr2);
        ret -= ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[into] / 2;
        ret += (r - p) * (r - p - 1) * c[into] / 2;
        return ret;
    };
    
    ll m; cin >> m;
    while (m--) {
        ll day, into; cin >> day >> into; day--; into--;
        score = modified(day, into);
        cout << score << endl;
        v[t[day]].erase(day);
        v[into].insert(day);
        t[day] = into;
    }
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

int a[10001],n;
vector<int> v;

int main(void){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b<c)cout<<a+2*b+1<<endl;
    else cout<<b+c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){
  int n,a,b,c,d,M[22][22],i,j,k;
  std::cin>>n>>k;
  for(i=0;i++<n;)for(j=0;j++<n;)M[i][j]=1<<29;
  for(;k+1;){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    if(k--){M[a][b]=c;M[b][a]=d;}
  }
  for(k=0;k++<n;)for(i=0;i++<n;)for(j=0;j++<n;)
    M[i][j]=std::min(M[i][j],M[i][k]+M[k][j]);
  printf("%d\n",c-d-M[a][b]-M[b][a]);
}

Measured memory_bytes: 0
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
x,y=n1()

f=False
for i in range(0,x+1):
    j=x-i
    a=2*i+4*j
    if a==y:
        f=True
        break
p0(f)

Measured memory_bytes: 9244
#include <iostream>
#include <vector>
#include <functional>


struct Pair {
    int a, b, c, d;
};

static int N, M, Q;
static int max;
static std::vector<Pair> pairs;

void count(std::vector<int> vals) {
    int sum = 0;
    for (auto && pair : pairs) {
        if (vals[pair.b - 1] - vals[pair.a - 1] == pair.c) {
            sum += pair.d;
        }
    }
    if (max < sum) {
        max = sum;
    }
}

void combination() {
    std::vector<int> indices(N);
    int start_index = 1;
    int size = 0;

    while (size >= 0) {
        for (int i = start_index; i <= M;) {
            indices[size++] = i;
            if (size == N) {
                count(indices);
                break;
            }
        }
        size--;
        start_index = indices[size] + 1;
    }
}


int main() {
    std::cin >> N >> M >> Q;

    pairs = std::vector<Pair>(Q);
    max = 0;

    for (int i = 0; i < Q; i++) {
        std::cin >> pairs[i].a >> pairs[i].b >> pairs[i].c >> pairs[i].d;
    }

    combination();

    std::cout << max << std::endl;
}


Measured memory_bytes: 3628
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

int main() {
    i64 n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    int m = 1e6;
    int sum = 0;
    vector<int> s(n);
    REP(i,n){
        cin >> s[i];
        if(s[i]%10!=0){
            chmin(m,s[i]);
        }
        sum+=s[i];
    }
    
    if(sum%10!=0){
        put(sum);
    }else{
        put(max(sum-m,0));
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n,d = map(int,input().split())
list=[list(map(int,input().split())) for i in range(n)]
arr_list = np.array(list)
count = 0
for i in range(n):
    for j in range(i+1,n):
        if(i != j):
            distance = 0.0
            for k in range(d):
                distance += (arr_list[i][k] - arr_list[j][k])**2
            if(distance > 0):
                result = np.sqrt(distance)
                if(result.is_integer()):
                    count += 1
print(count)

Measured memory_bytes: 12468
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int64{
  sc.Scan()
  i, e :=strconv.ParseInt(sc.Text(), 10, 64)
  if e!=nil{
    panic(e)
  }
  return i
}
func min (a *int64, b int64)bool{
  if *a>b{
    *a=b
    return true
  }
  return false
}
func main(){
  var i, sum, j, ans int64
  ans=0
  dp:=make([][]int64, 110)
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  w:=nextInt()
  a:=make([]int64, 110)
  b:=make([]int64, 110)
  for i=0;i<n;i++{
    a[i]=nextInt()
    b[i]=nextInt()
  }
  for i=0;i<110;i++{
    dp[i]=make([]int64, 100100)
  }
  for i=0;i<110;i++{
    for j=0;j<100100;j++{
      dp[i][j]=10000000000
    }
  }
  dp[0][0]=0
  for i=0;i<n;i++{
    for sum=0;sum<100100;sum++{
      if sum-b[i]>=0{
        min(&dp[i+1][sum], dp[i][sum-b[i]]+a[i])
      }
      min(&dp[i+1][sum], dp[i][sum])
    }
  }
  for sum=0;sum<100100;sum++{
    if dp[n][sum]<=w{
      ans=sum
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 89728
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n;
    int a[10] = {};
    int b[10] = {};
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      if(a[i] % 2 == 0){
        b[i] = 2;
      }else{
        b[i] = 1;
      }
    }

    int ans = pow(3, n);
    int str = 1;
    for(int i = 0; i < n; i++){
      str *= b[i];
    }
    ans -= str;
    cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 102;
const int S = N * N;
int dp[N][S];
int ANS;
int n, k;
int prod[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);

	prod[0] = 1;
	for (int i = 1; i <= n; i++)
		prod[i] = mult(prod[i - 1], k + 1);

	dp[n][0] = 1;
	for (int p = n; p > 0; p--)
		for (int x = 0; x <= k * (n - p); x++)
			for (int y = 0; y <= k; y++) {
				if (y > p) {
					dp[p - 1][x] = add(dp[p - 1][x], dp[p][x]);
					continue;
				}
				int z = x + (x + y) / p;
				dp[p - 1][z] = add(dp[p - 1][z], dp[p][x]);
			}
	ANS = k * (k + 1) / 2;
	ANS = mult(ANS, prod[n - 1]);
	ANS = mult(ANS, n);

	for (int p = 1; p <= n; p++)
		for (int x = 0; x <= k * (n - p); x++)
			for (int y = 0; y <= k; y++) {
				if (y > p) continue;
				int z = (x + y) / p;
				ANS = sub(ANS, mult(z, mult(dp[p][x], prod[p - 1])));
			}
	printf("%d\n", ANS);

	return 0;
}


Measured memory_bytes: 3968
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long sum=1;
		for(int i=0;i<n;i++){
			if(i==0){
				sum*=k;
			}else{
				sum*=(k-1);
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	
}
int main(){
  ll N;
  cin>>N;
  
  ll min=INF;
 
  
  for(ll i=0;i<=N;i++){
    ll sum=0;
    ll t=i;
    while(t>0){
      sum+=(t)%6;
      t/=6;
    }
    
    ll rest=N-i;
    
    while(rest>0){
      sum+=rest%9;
      rest/=9;
    }

    if(min>sum){
      min=sum;
    }
  }

  
  cout<<min<<endl;
}


Measured memory_bytes: 256
# 使えるのは、'a' ~ 今まで使われた次の文字
n = int(input())
def dfs(cnt,s):
    if cnt == n:
        print(s)
        return
    biggest = 'a'
    c = 0
    while c < len(s):# 最後はどこまで？
        if s[c] == biggest:
            biggest = chr(ord(biggest)+1)
            c += 1
        else:
            c += 1
    #print(c)
    for i in range(0,ord(biggest) - ord('a')+1):
        sc = chr(ord('a') + i)
        #print(sc)
        s += sc
        dfs(cnt + 1, s)
        s = s[:-1]

dfs(0,"")


Measured memory_bytes: 47576
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
count = 0
a = -1
a_count = 0
for i in range(N):
    if a!=A[i]:
        count+=1
        a_count=1
    elif a_count%2==1:
        count-=1
        a_count+=1
    else:
        count+=1
        a_count+=1
    a=A[i]
print(count)

Measured memory_bytes: 7516
#N = int(input())
#N = int(input())
#S = input()
# = input().split()
# = input().split()
# = map(int,input().split())
X,Y = map(int,input().split())
# = list(map(int,input().split()))
# = list(map(int,input()).split())

if Y % 2 != 0:
    print("No")
    exit()
if Y <= 4*X and Y >= 2*X:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61640
from collections import deque

N = int(input())

data = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    data[b].append(a)

stack = deque([0])
visit_in = [-1]*N
visit_in[0] = 0

while stack:
    x = stack.pop()
    for y in data[x]:
        if visit_in[y] >= 0:
            continue
        visit_in[y] = x
        stack.append(y)

path = [N-1]

while path[-1] != 0:
    path.append(visit_in[path[-1]])

#print(path)

group = [-1]*N

for x in path:
    group[x] = x

stack = deque(path[:])

while stack:
    x = stack.pop()
    for y in data[x]:
        if group[y] != -1:
            continue
        group[y] = group[x]
        stack.append(y)

#print(group)

num = [0]*N
for i in range(N):
    num[group[i]] += 1

#print(num)

p = len(path)-1
q = 0
fennec = num[0]
snuke = num[N-1]
#print(fennec,snuke)
while q < p - 1:
    p -= 1
    fennec += num[path[p]]
    if q < p -1:
        q += 1
        snuke += num[path[q]]
    #print(fennec,snuke)
    

if fennec <= snuke:
    print("Snuke")
else:
    print("Fennec")

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N, M;
  cin >> N >> M;
  if (M >= N) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll dp[101][100003] = {};

int main() {
  ll N, W;
  vector<ll> w, v;
  cin >> N >> W;
  REP(i, N) {
    ll po, yo;
    cin >> po >> yo;
    w.push_back(po);
    v.push_back(yo);
  }
  for (ll i = N - 1; i >= 0; i--) {
    REP(j, W + 1) {
      if (j < w[i])
        dp[i][j] = dp[i + 1][j];
      else
        dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]);
    }
  }
  cout << dp[0][W] << endl;
  return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    auto start = std::chrono::system_clock::now();
    int input[3];
    for(auto &x : input) cin >> x;
    random_device rnd;
    while(true) {
        auto end = std::chrono::system_clock::now();
        auto dur = end - start;
        auto msec =
            std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec > 1998) break;
        int idx1 = rnd() % 3;
        int idx2 = rnd() % 3;
        if(input[idx1] != input[idx2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	int saa = x-a;
	int sab = x-b;
	if(saa<0) saa=-saa;
	if(sab<0) sab=-sab;
	if(saa<=sab) cout << 'A' << endl;
	if(saa>sab) cout << 'B' << endl;
}


Measured memory_bytes: 3652
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]

row = []
col = []
for i in range(h):
  if a[i].count(".") != w: row.append(i)
for i in range(w):
  t = 0
  for j in range(h):
    if a[j][i] == ".": t+=1
  if t != h: col.append(i)

for i in row:
  ans = ""
  for j in col:
    ans += a[i][j]
  print(ans)

Measured memory_bytes: 9204
import numpy as np
import math
a,b,h,m = map(int, input().split())
ty = ((h*60+m)/60)/12
ta = (m)/60
if abs(ty-ta)>0.5:
    k = 1-abs(ty-ta)
else:
    k = abs(ty-ta)
#print(k)
if h*60+m==12*m:
    print(abs(b-a))
else:
    ans = a**2+b**2-2*a*b*(np.cos(k*2*math.pi))
    print(math.sqrt(ans))

Measured memory_bytes: 27224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef int i32;
typedef long long i64;
typedef vector<int> VI32;
typedef vector<long long> VI64;
int main(){
  i32 N;
  cin >> N;
  VI32 v(N);
  for(i32 i = 0; i < N; i++){
    cin >> v[i];
  }
  VI32 c(N);
  for(i32 i = 0; i < N; i++){
    cin >> c[i];
  }
  i32 count1 = 0, count2 = 0;
  for(i32 i = 0; i < N; i++){
    if(v[i] > c[i] ){
      count1 += v[i];
      count2 += c[i];
      //cout << count1 << " " << count2 << endl;
    }
  }
  cout << count1 -  count2 << endl;
  return 0;
}

Measured memory_bytes: 256
n, yen = gets.split(' ').map(&:to_i)
for i in 0..n do
  for j in 0..n-i do
    k = n - i - j
    if i * 10000 + j * 5000+ k * 1000 == yen
      puts i.to_s + ' ' + j.to_s + ' ' + k.to_s
      exit
    end
  end
end

puts '-1 -1 -1'

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
 
std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    std::vector<std::string> result;
 
    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}
 
int main() {
  std::string str;// = "samurai,engineer,programmer,se";
  std::cin >> str;
  char del = '/';
  
  int a[3];
  int i=0;
  for (const auto subStr : split(str, del)) {
    a[i] = stoi(subStr);
    i++;
  }
  if(a[0]>=2019 && a[1]>=5){
    std::cout << "TBD";
  }else{
    std::cout << "Heisei";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
int N; cin>>N;
  int64_t S=0;
  for(int i=0; i<N; i++){
   if((i+1)%3!=0&&(i+1)%5!=0)
     S+=(i+1);
    else continue;
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3632
from bisect import bisect_left
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(n)]
for i in range(n-1):
    u,v = map(lambda z:int(z)-1,input().split())
    G[u].append(v)
    G[v].append(u)

ans = [0 for i in range(n)]
dp = [10**10 for _ in range(n+1)]
check = [True for _ in range(n)]
def dfs(now):
    check[now] = False
    ite = bisect_left(dp, a[now])
    tmp = dp[ite]
    dp[ite] = a[now]
    ans[now] = bisect_left(dp, 10**10)
    #print(now,dp)
    for to in G[now]:
        if check[to]:
            dfs(to)
    dp[ite] = tmp

dfs(0)
print(*ans, sep="\n")

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

int main(){
char b;
cin >>b;
if((b=='A')or (b=='T') ){
    if(b=='A')cout <<'T' <<endl;
    else cout <<'A' <<endl;
}
if((b=='C') or (b=='G')){
    if(b=='C') cout <<'G' <<endl;
    else cout <<'C' <<endl;
}
    return 0;
}

Measured memory_bytes: 256
s=input()
t='01'*(len(s))
d1=0
#0101...と違う個数
d2=0
#1010...と違う個数
for i in range(len(s)):
    if s[i]!=t[i]:
        d1+=1
    if s[i]!=t[i+1]:
        d2+=1
print(min(d1,d2))
    

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


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

    ll k, n;
    cin >> k >> n;
    vector<ll> as(n);
    rep(i, n){
        cin >> as[i];
    }

    ll m = as[0] + k - as[as.size()-1];
    rep(i, n-1){
        m = max(m, as[i+1] - as[i]);
    }
    cout << k - m << endl;

    return 0;
}


Measured memory_bytes: 1792