akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

ll pow(ll A, ll P){
	ll a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	ll adash = a * a;
	if(p % 2) return pow(adash, p / 2) * a;
	else return pow(adash, p / 2);
}

int main(){
	ll N;
	cin >> N;
	vector<ll> C(N), V(N);
	for(ll i=0;i<N;i++){
		cin >> V[i];
	}
	for(ll i=0;i<N;i++){
		cin >> C[i];
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		if(V[i] - C[i]>0){
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
}

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

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

    unsigned long long ans = 1;
    bool flag = 1;
    rep(i,n){
        unsigned long long temp;
        cin >> temp;
        if(temp == 0){
            ans = 0;
            flag = 1;
            break;
        }
        if(flag){
            if(1000000000000000000/ans < temp || ans*temp > 1000000000000000000) flag = 0;
            ans *= temp;
        }
    }

    if(flag) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner
import scala.util.control.Breaks

object Main {

  def heisei_or_TBD(date: String): String = {
    val y_m_d = date.split("/")
    if (y_m_d(0).toInt <= 2019 && y_m_d(1).toInt <= 4 && y_m_d(2).toInt <= 30) {
      "Heisei"
    } else {
      "TBD"
    }
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
        print(heisei_or_TBD(sc.next))
  }
}

Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


//mod inv
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

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

    map<ll, ll> x;

    ll a[n];
    rep(i, 0, n){
        cin >> a[i];
        vector<pair<ll, int>> tmp = factorize(a[i]);
        fore(j, tmp){
            if(x.count(j.first)){
                if(x[j.first] < j.second){
                    x[j.first] = j.second;
                }
            }else{
                x[j.first] = j.second;
            }
        }
    }

    ll lcm = 1;
    fore(i, x){
        rep(j, 0, i.second){
            lcm *= i.first;
            lcm %= MOD;
        }
    }

    ll ans = 0;
    rep(i, 0, n){
        ans += lcm * modinv(a[i], MOD);
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>

using namespace std;

int main(){

  int in, k;

  while(cin >> in >> k){
    if(in == 0 && k == 0) break;
    int data[in];
    int sum;

    for(int i = 0; i < in; i++){
      cin >> data[i];
    }

    int tmp = 0;

    for(int i = 0; i < k; i++){
      tmp += data[i];
    }
    sum = tmp;
    int num = 0;

    for(int i = k; i < in; i++){
      tmp -= data[num];
      num++;
      tmp += data[i];
      if(i == 0 || sum < tmp) sum = tmp;
    }

    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    double a, b, C, S, L, h;
    cin >> a >> b >> C;
    C = C / 180 * M_PI;
    S = a * b * sin(C) / 2;
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(C));
    h = b * sin(C);
    cout << fixed << setprecision(8) << S << endl;
    cout << L << endl;
    cout << h << endl;
    return 0;
}


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a >= d) {
		cout << d << endl;
	} else if (b >= (d - a)) {
		cout << a << endl;
	} else {
		cout << a - (d - a - b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  string S,T; cin>>S>>T;
  ll ssz=S.size(),ans=0;
  rep(i,ssz) if(S[i]!=T[i]) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3912
#include <iostream>
using namespace std;
int main(void){
    int n,c[500],s[500],f[500];
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=1;i<n;i++){
        int t=0;
        for(int j=i;j<n;j++){
            if(t<=s[j]){
                t=s[j]+c[j];
            }else if(t%f[j]==0){
                t=t+c[j];
            }else{
                t=t-t%f[j]+f[j]+c[j];
            }
            
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[100000233];
int w=0,n;
int main(){
scanf("%s",&s);
	n=strlen(s);
	scanf("%d",&w);
	for (int i=0;i<n;i+=w)
		printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 256
from collections import deque
A=deque()
n=int(input())


for i in range(n):
            command=input().split()
            if command[0] == "insert":
                A.appendleft(command[1])
            elif command[0] == "delete":
                if command[1] in A:
                    A.remove(command[1])
            elif command[0] == "deleteFirst":
                A.popleft()
            elif command[0] == "deleteLast":
                A.pop()

print(*A)



Measured memory_bytes: 69736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 200050, INF = 1<<25;

int in[N], n, cc[129];
bool used[N];
char str[N];
vector<int>g[129];

int lowbit(int t)
{
    return t&(t^(t-1));
}

int sum(int end)
{
    int ans=0;
    while(end>0)
    {
        ans+=in[end];
        end-=lowbit(end);
    }
    return ans;
}

void add(int pos,int num)
{
    while(pos<=n)
    {
        in[pos]+=num;
        pos+=lowbit(pos);
    }
}

void solve()
{
    memset(in, 0, sizeof(in));
    for(int i=1; i<=n+1; i++)
    {
        add(i,1);
    }
    LL ans = 0;
    int v, u, size;
    char s;
    memset(used, 0, sizeof(used));
    for(int i=1; i<=n; i++)
    {
        if(!used[i])
        {
            s = str[i];
            size = g[s].size();
            u = g[s][size-1];
            if(i == u)
            {
                ans += (sum(n) - sum(i))/2;
            }
            else
            {
                ans += sum(n) - sum(u);
            }
            add(u, -1);
            add(i, -1);
            used[i] = used[u] = 1;
            g[s].erase(g[s].end()-1);
        }
    }
    printf("%lld\n", ans);
}

int main()
{
    scanf("%s", str+1);
    n = strlen(str+1);
    memset(cc, 0, sizeof(cc));
    for(int i=1; i<129; i++)
        g[i].clear();

    for(int i=1; i<=n; i++)
    {
        cc[str[i]]++;
        g[str[i]].push_back(i);
    }
    int flag = 0;
    for(int i=0; i<26; i++)
    {
        if(cc['a'+i]%2) flag++;
        if(cc['A'+i]%2) flag++;
    }
    if(flag > 1)
    {
        printf("-1\n");
        return 0;
    }
    else
        solve();
}


Measured memory_bytes: 2424
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int cnt=0;
    while(b<=a) {b*=2; cnt++;}
    while(c<=b) {c*=2; cnt++;}
    if(cnt<=k)
        puts("Yes");
    else puts("No");
    return 0;
}


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

int main()
{
    int len;
    char a[200005], b[200005];
    cin >> a;
    cin >> b;
    int ans = 0;
    int i = 0;
    while (a[i] != '\0')
    {
        if (a[i] != b[i])
            ans++;
        i++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
int N,Q;
cin>>N>>Q;
vector<ll> A(N);
for(int i=0;i<N;i++){
    cin>>A.at(i);
}
int right=0;
ll x,res,sum;
for(int j=0;j<Q;j++){
    cin>>x;
    res=0;
    right=0;
    sum=0;
    for(int left=0;left<N;left++){
        while(right<N&&sum+A.at(right)<=x){
            sum+=A.at(right);
            right++;
        }
        res+=(right-left);
        if(right==left)right++;
        else sum-=A.at(left);
    }

  cout<<res<<endl;
    
}

}



Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	stack<char>st;
	for (int i = 0; i < s.size(); i++) {
		if (st.size() == 0 || st.top() == s[i])st.push(s[i]);
		else st.pop();
	}
	cout << s.size() - st.size() << endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e16;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  ll ans=0;
  for(ll i=0;i<k;i++)
    ans+=a[i];
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

int i, j, k;
vector<vector<int>> g;

vector<int> dp;

int dfs(int v, int par=-1){
    if (dp[v]==-1) {
        // v is next
        int d = 0;
    //    dbg(v, d, par);
        for (auto to : g[v]) {
            if (to!=par) {
                d = max(d, 1+dfs(to, v));
            }
        }
        dp[v] = d; 
    }
    return dp[v];
}

void solve()
{
    int n, m;
    cin >> n >> m;
    dp = vector<int>(n, -1);

    g = vector<vector<int>>(n);
    for (int i = 0; i < m; ++i) {
        int t1, t2;
        cin >> t1 >> t2;
        t1--; t2--;
        g[t1].push_back(t2);
    }

    int res=0;
    for (int i = 0; i < n; ++i) {
        res = max(res, dfs(i));
    }

    //dbg(dp);
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8832
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main() {
    int n;
    scanf("%d",&n);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]);
    }
    long long Max=2,Min=2;
    for(int i=n;i>=1;i--)
    {
        Min=(Min+a[i]-1)/a[i]*a[i];
        Max=Max/a[i]*a[i]+a[i]-1;
    }
    if(Min>Max)
    {
        puts("-1");
        return 0;
    }
    printf("%lld %lld\n", Min, Max);
    return 0;
}

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

public static class Permutation
{
    public static int Factorial(int n)
    {
        if (n == 0)
        {
            return 1;
        }
        return n * Factorial(n - 1);
    }

    public static IEnumerable<int[]> GetPermutations(int n)
    {
        int max = Factorial(n);
        for (int i = 0; i < max; i++)
        {
            yield return GetPermutation(n, i);
        }
    }

    public static int[] GetPermutation(int n, int serialNum)
    {
        var m = new int[n];
        for (int i = 0; i < n; i++)
        {
            m[i] = i;
        }

        var perm = new int[n];
        int cur = 0;
        for (int i = n; i >= 1; i--)
        {
            int nn = serialNum % i;
            perm[cur++] = m[nn];
            for (int j = nn; j < i - 1; j++)
            {
                m[j] = m[j + 1];
            }
            serialNum = serialNum / i;
        }
        return perm;
    }
}

public class Solution
{
    public static void Main()
    {
        var path = new int[3][];
        for (int i = 0; i < 3; i++)
        {
            path[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        bool result = false;
        foreach (var pattern in Permutation.GetPermutations(3))
        {
            var first = pattern[0];
            for (int i = 0; i <= 1; i++)
            {
                bool ok = true;
                var cur = path[first][i];
                foreach (var j in pattern.Skip(1))
                {
                    if (path[j].Contains(cur))
                    {
                        cur = path[j].First(v => v != cur);
                    }
                    else
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    result = true;
                    break;
                }
            }
        }


        Console.WriteLine(result ? "YES" : "NO");
    }
}

Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve(long long N, std::string S){
    ll len = S.length();
    // debg(len);
    for (ll i = 0; i < len; i++) {
        S[i] = S[i]+N;
        if(S[i]>'Z'){
            // S[i] = S[i]-N;
            ll r = (S[i]-'A')%26;
            S[i] = 'A'+r;
        }
    }
    cout << S << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def dc(n, m):
    return -(-n // m)

# @mt
def slv(H, N, AB):
    ans = 0
    abc = [(a/b, b, a) for a, b in AB]

    abc.sort(key=lambda x: x[1])
    abc.sort(key=lambda x: x[2])
    abc.sort(key=lambda x: x[0], reverse=True)
    # ri = set()
    # mm = INF
    # for i in range(N):
    #     if abc[i][1] >= mm:
    #         ri.add(i)
    #     else:
    #         mm = abc[i][1]
    # ri = set(ri)
    # abc_ = []
    # for i in range(N):
    #     if i not in ri:
    #         abc_.append(abc[i])
    # error_print(abc)
    # abc = abc_
    # error_print(abc)

    HD = defaultdict(lambda : INF)
    HD[H] = 0
    _, b, a = abc[0]
    for i in range(1, dc(H, a)+1):
        HD[H - i*a] = i*b
    for _, b, a in abc[1:]:
        for k, v in reversed(list(HD.items())):
            for i in range(1, dc(k, a)+1):
                if HD[k - i*a] > v+i*b:
                    HD[k- i*a] = v+i*b
                else:
                    break
    ans = INF
    for k, v in HD.items():
        if k <= 0:
            ans = min(ans, v)


    return ans


def main():
    H, N = read_int_n()
    AB = [read_int_n() for _ in range(N)]
    print(slv(H, N, AB))
    # H = 10**4
    # N = 10
    # AB = [[random.randint(1, 100), random.randint(1, 100)] for _ in range(N)]
    # print(slv(H, N, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 97496
open System

let alphabets = [| 'a' .. 'z' |]

let rec solve x =
    if x <= 26L then
        [ alphabets.[x - 1L |> int] ]
    else
        let q, r = ((x - 1L) / 26L, (x - 1L) % 26L |> int)
        alphabets.[r] :: solve q

let judge =
    solve >> List.rev >> Array.ofList >> String.Concat

//let inputs = [| 1L; 2L; 26L; 27L; 123456789L |]
//for i in inputs do judge i |> printfn "%A"

[<EntryPoint>]
let main argv =
    stdin.ReadLine() |> int64 |> judge |> printfn "%s"
    0


Measured memory_bytes: 29792
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (_n, k) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let n:u64 = split.next().unwrap().parse().unwrap();
        let k:u64 = split.next().unwrap().parse().unwrap();
        (n, k)
    };

    let mut s:Vec<char> = get_input().chars().collect();
    let i = (k - 1) as usize;
    s[i] = s[i].to_lowercase().next().unwrap();

    let ans: String = s.into_iter().collect();
    println!("{}", ans);
}

Measured memory_bytes: 4352
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 510000;
 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;
 }

int main() {
    COMinit();
    ll n,k;
    std::cin >> n>>k;
    for (int i = 1; i <= k; i++) {
        if(n-k-i+1>=0){
            std::cout << fac[k-1]*finv[i-1]%MOD*finv[k-i]%MOD*fac[n-k+1]%MOD*finv[n-k-i+1]%MOD*finv[i]%MOD << std::endl;
        }else{
            std::cout << 0 << std::endl;
        }
    }
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define reff(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long int
#define pll pair<ll,ll>
#define fill(a,x) memset(a,x,sizeof(a))
#define mb make_pair
#define pb push_back
#define F first
#define S second
#define M 1000000007
#define sc(x) scanf("%d",&x)
#define scc(x1,x2) scanf("%d%d",&x1,&x2)
#define sccc(x1,x2,x3) scanf("%d%d%d",&x1,&x2,&x3)
#define pr(x) printf("%lld ",x)
#define dbg(a)          std::cerr<<#a<<"="<<(a)<<"\n"
#define dbg1(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define dbg2(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define dbg3(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define all(v) v.begin(),v.end()
#define PI 3.14159265
#define co cout<<"fuck"<<endl
const int INF = 2034567891;
const ll INF64 = 4234567890123456789ll;
long long nc3(long long v){return (v * (v - 1ll) * (v - 2ll)) / 6ll;}
long long nc2(long long v){return (v * (v - 1ll)) / 2ll;}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
const int N = 10+2e5;
bool isprime(ll n) {
    if (n < 2) return 0;
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;
    return 1;
}
double dist(pll p1, pll p2)
 {
    return (p1. F - p2.F)*(p1.F - p2.F) +
          (p1.S - p2.S)*(p1.S - p2.S);
 }
ll power(ll x,ll y)
{
    ll ans=1;
    while(y>0){
        if(y&1)
            ans=(ans*x)%M;
        x=(x*x)%M;
        y/=2;
    } 
    return ans;
}
int main()
{
     fast;
     string s;
     cin>>s;
     if(s=="ABC")
     cout<<"ARC";
     else
     cout<<"ABC";
}   

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

void trace(int arr[], int N)
{
    for(int i=0; i<N; i++){
        if(i>0) cout<<' '<<flush;
        cout<<arr[i]<<flush;
    }
    cout<<endl;
}

int main()
{
    int N;
    cin>>N;
    int* arr=new int[N];
    int comp;
    int j;
    for(int i=0; i<N; i++){
        cin>>arr[i];
    }
    trace(arr,N);



    for(int i=1; i<N; i++){
        comp=arr[i];
        j=i-1;
        while( arr[j] > comp && j>=0 ){
            arr[j+1]=arr[j];
            j--;//j==-1????????£?????????arr[-1]????????§???????????¨????????????(for???????????????????????????)
        }
        arr[j+1]=comp;
        trace(arr,N);

    }
    delete[] arr;

}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n, m;
	cin >> n >> m;
	int ter[m];
	REP(i, m) cin >> ter[i];
	int ans[n] = {};
	REP(i, m){
		int misscount = 0;
		REP(j, n+1){
			if (j < n){
				int tmp;
				cin >> tmp;
				if (tmp == ter[i]) ans[j]++;
				else misscount++;
			}
			else {
				ans[ter[i]-1] += misscount;
			}
		}
	}

	REP(i, n) cout << ans[i] << endl;
}



Measured memory_bytes: 3112
n, m = [int(x) for x in input().split()]
locs = [int(x) for x in input().split()]

locs.sort()
 
difLocs = []
first = locs[0]
for bot,top in zip(locs, locs[1:]):
  if top == first:
    break
  difLocs.append(top-bot)
 
difLocs.sort()
if (m-n) < 0:
  print(0)
else:
  newLocs = difLocs[0:m-n]
  print(sum(newLocs))

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
#define modul 1000000007

//no of ways to reach ith row and jth column
int dp[1001][1001];


int main()
{
	int H, W;
	cin >> H >> W;
	char arr[H][W];
	for(int i=0; i<H;i++ ){
		for(int j=0;j<W;j++){
			cin >> arr[i][j];			 
		}
	}

	//trivial cases                   //since rows and column in dp[][] are items not indices
	for(int i=0;i<1001;i++)
	{
		dp[0][i]=0;
		dp[i][0]=0;
	}

	//base cases: 
	int flag=0;
	for(int i=0;i<H;i++)
	{
		if(arr[i][0]=='#')             //once you encounter a # on the first column then you cannot
			flag=1;                    //reach any cell below in that column.
		if(flag)
			dp[i+1][1]=0;
		else
			dp[i+1][1]=1;
	}

	flag=0;
	for(int i=0;i<W;i++)
	{
		if(arr[0][i]=='#')				//once you encounter a # on the first row then you cannot 
			flag=1;						//reach any cell to the right of it.
		if(flag)
			dp[1][i+1]=0;
		else
			dp[1][i+1]=1;
	}


	//NOTE due to the constrain by equation (1), i or j cannot be less than 2 hence
	//value dp[1][j] and dp[i][1] are handled by the base case above.
	for(int i=2;i<=H;i++)
	{
		for(int j=2;j<=W;j++)
		{
			if(arr[(i-1)-1][j-1]=='#' && arr[i-1][(j-1)-1]=='#')                 //-(1)
				dp[i][j] = 0;
			else if(arr[(i-1)-1][j-1]=='#' || arr[i-1][(j-1)-1]=='#')
			{
				if(arr[(i-1)-1][j-1]=='#')
					dp[i][j] = dp[i][j-1]; 
				if(arr[i-1][(j-1)-1]=='#')
					dp[i][j] = dp[i-1][j];
			}
			else
				dp[i][j] = (dp[i-1][j]%modul + dp[i][j-1]%modul)%modul;
		}
	}

	cout << dp[H][W];

	return 0;
}

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

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

  vector<int> m(100);
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;

    m[d - 1]++;
  }
  
  int total = 0;
  for (int i = 100; i > 0; i--) {
    if (m[i - 1] == 0) continue;
    
    total++; 
  }

  cout << total << endl;
}


Measured memory_bytes: 256
n = input()
en=len(n)//2
evn=[]
odn=[]
for i in range(len(n)):
    if i%2==0 and n[i] == "L":
        print("No")
        exit()
    if i%2>0 and n[i] == "R":
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;

    priority_queue<ll> kind[N];
    for (int i = 0; i < N; ++i) {
        int t;
        ll d;
        cin >> t >> d;
        kind[t - 1].push(d);
    }

    priority_queue<ll> best, remain;
    // best: 各種類で一番美味しいやつを集めたもの
    // remain : bestの余り
    for (int i = 0; i < N; ++i) {
        if (!kind[i].empty()) {
            best.push(kind[i].top());
            kind[i].pop();

            while (!kind[i].empty()) {
                remain.push(kind[i].top());
                kind[i].pop();
            }
        }
    }

    vector<ll> bsum = {0};
    // bestの累積和
    while (!best.empty()) {
        bsum.push_back(bsum.back() + best.top());
        best.pop();
    }

    vector<ll> rsum = {0};
    // remainの累積和
    while (!remain.empty()) {
        rsum.push_back(rsum.back() + remain.top());
        remain.pop();
    }

    ll ans = 0;
    for (ll x = 1; x <= K; ++x) {
        // x種類選んだときの美味しさ

        // 種類が多すぎるケース
        if (x >= bsum.size()) break;

        // 種類が少なすぎて、余り物が足りないケース
        if (K - x >= rsum.size()) continue;

        ans = max(ans, bsum[x] + rsum[K - x] + x * x);
    }

    cout << ans << endl;
    return 0;
}


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

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

  long long n,m,d;
  double ans=0.0;
  cin >> n >> m >> d;
  for(int i=0;i<m-1;i++){
    if(d==0){
      ans+=(double)(1.000/n);
    }else{
      ans+=(double)(2.000*(n-d)/n/n);
    }
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	if (n <= 999)
		cout << "ABC";
	else
		cout << "ABD";
}

Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    ans = len(t)
    
    for i in range(len(s)-len(t)+1):
        count = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                count += 1
        ans = min(ans, count)
    print(ans)
        
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
	
using namespace std;


typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

 
const int MAX = 1e6+10;
const ll inf = 1e9+10;





int main(){
	fastio;
	ll a;
	f(i,1,6){
		cin>>a;
		if(a==0){
			cout<<i<<endl;
			return 0;	
		}
	}
}	

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL dp[50][2];
LL f(int bit, bool less, const LL K, const VL&a) {
	if (bit == -1) {
		return 0LL;
	}
	if (dp[bit][less] != -1)return dp[bit][less];
	LL onecnt = 0;
	for (auto it : a)if (it&(1LL << bit))onecnt++;

	LL ret = 0;
	if (less) {// 0/1どちらでも可
		ret = max(ret, max(onecnt, SZ(a) - onecnt)*(1LL << bit) + f(bit - 1, less, K, a));
	}
	else {
		// 1なら0(0),1(less)
		// 0なら0(0)
		if (K&(1LL << bit)) {
			ret = max(ret, (SZ(a) - onecnt)*(1LL << bit) + f(bit - 1, less, K, a));
			ret = max(ret, (        onecnt)*(1LL << bit) + f(bit - 1, 1   , K, a));
		}
		else {
			ret = max(ret, (        onecnt)*(1LL << bit) + f(bit - 1, less, K, a));
		}
	}

	return dp[bit][less] = ret;
}


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

	LL N, K; cin >> N >> K;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	fill(*dp, *dp + 50 * 2, -1);
	// dp(bit,less?)
	LL ans = f(45, 0, K, a);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

#define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int n,m,q;
vector<int> as(50),bs(50),cs(50),ds(50);
vector<int> xs;

bool next_comb() {
    for (int i = n-1; i >= 0; i--) {
        if (xs[i] < m-1) {
            xs[i]++;
            for (int j = i+1; j < n; j++) {
                xs[j] = xs[i];
                // debug("comb", j);
            }
#ifndef NDEBUG
            rep(i, n) { cerr << xs[i] << ' '; }
            cerr << '\n';
#endif
            return true;
        }
    }
    return false;
}

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n>>m>>q;
    rep(i,q) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--; b--;
        as[i]=a;bs[i]=b;cs[i]=c;ds[i]=d;
    }

    int res = 0;
    xs.resize(n);
    #ifndef NDEBUG
    int cnt = 0;
    #endif
    do
    {
        int score = 0;
        rep(i, q) {
            if (xs[bs[i]] - xs[as[i]] == cs[i]) {
                score += ds[i];
            }
        }
        res = max(res, score);
#ifndef NDEBUG
        cnt++;
        debug(cnt);
#endif
    } while (next_comb());
    cout << res << '\n';

    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int sum = 0;
	for (int i = 1; i <= b - a; i++) {
		sum += i;
	}
	cout << sum - b << endl;
	return 0;
}


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

    vector<int> A(N);
    for(int i=0; i<N; i++) cin>>A[i];
    sort(A.begin(),A.end(),greater<int>());

    int res = 0;
    res += A[0];

    for (int i = 1; i < N-1; i++) res += abs(A[i]);

    res -= A[N-1];
    cout << res << endl;
    int i=1;
    for (; i < N - 1 && A[i] >= 0; i++){
        cout << A[N-1] << ' ' << A[i] << endl;
        A[N-1] -= A[i];
    }
    cout << A[0] << ' ' << A[N-1] << endl;
    A[0] -= A[N-1];
    for (; i < N - 1; i++){
        cout << A[0] << ' ' << A[i] << endl;
        A[0] -= A[i];
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll R;
    cin>>R;
    double ans=R*2*M_PI;
    printf("%.12f\n",ans);
}

Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    cout << (s<t?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<P,int> PP;

ll d[2][2222][2222],mm;
ll calc(ll x1,ll y1,ll x2,ll y2,ll k) {
  return d[k][min(mm,x2)][min(mm,y2)]-d[k][min(mm,x2)][y1]-d[k][x1][min(mm,y2)]+d[k][x1][y1];
}

void Main() {
  ll n,m;
  cin >> n >> m;
  mm=m*2;
  rep(i,n) {
    int x,y;char c;
    cin >> x >> y >> c;
    if(c=='W') d[0][x%mm+1][y%mm+1]++;
    else d[1][x%mm+1][y%mm+1]++;
  }
  rep(k,2) {
    rep(i,mm+1) {
      rep(j,mm) d[k][i][j+1]+=d[k][i][j];
    }
    rep(j,mm+1) {
      rep(i,mm) d[k][i+1][j]+=d[k][i][j];
    }
  }
  ll ans=0;
  rep(k,2) {
    rep(x,m) {
      rep(y,m) {
        ll sum=0;
        sum+=calc(x,y,x+m,y+m,k);
        sum+=calc(x+m,y+m,x+mm,y+mm,k);
        sum+=calc(0,0,x,y,k);
        sum+=calc(0,y+m,x,y+mm,k);
        sum+=calc(x+m,0,x+mm,y,k);
        sum+=d[1^k][mm][mm];
        sum-=calc(x,y,x+m,y+m,1^k);
        sum-=calc(x+m,y+m,x+mm,y+mm,1^k);
        sum-=calc(0,0,x,y,1^k);
        sum-=calc(0,y+m,x,y+mm,1^k);
        sum-=calc(x+m,0,x+mm,y,1^k);
        ans=max(ans,sum);
      }
    }
  }
  pr(ans);
}

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



Measured memory_bytes: 71936
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	VI v(n), c(n);
	rep(i, n)cin >> v[i];
	rep(i, n)cin >> c[i];

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		int x = 0, y = 0;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i))x += v[i], y += c[i];
		}
		ans = max(ans, x - y);
	}
	Cout(ans);
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

#include <cassert>
using namespace std;

const int MOD = 1e9 + 7;

inline void ModMul(int& x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int GetModMul(int x, int y) {
    ModMul(x, y);
    return x;
}

inline void ModSum(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
    if (x < 0) {
        x += MOD;
    }
}

inline int GetModSum(int x, int y) {
    ModSum(x, y);
    return x;
}

inline int GetBinaryPow(int x, int pw) {
    int r = 1;
    while (pw > 0) {
        if (pw & 1) {
            ModMul(r, x);
        }
        ModMul(x, x);
        pw >>= 1;
    }
    return r;
}

inline int GetInv(int x) {
    return GetBinaryPow(x, MOD - 2);
}

const int MAX_FACT = 1e6;

vector<int> fact(MAX_FACT);
vector<int> invFact(MAX_FACT);

void BuildFact() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACT; ++i) {
        fact[i] = fact[i - 1];
        ModMul(fact[i], i);
    }
    for (int i = 0; i < MAX_FACT; ++i) {
        invFact[i] = GetInv(fact[i]);
    }
}

inline int GetC(int n, int k) {
    if (k > n) {
        return 0;
    }
    int r = fact[n];
    ModMul(r, invFact[k]);
    ModMul(r, invFact[n - k]);
    return r;
}

int main() {
    BuildFact();

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, k;
    cin >> n >> m >> k;

    vector<int> pw3(m + k + 1);
    pw3[0] = 1;
    for (int i = 1; i <= m + k; ++i) {
        pw3[i] = pw3[i - 1];
        ModMul(pw3[i], 3);
    }

    int l = 0;
    int r = 0;
    int sum = 1;

    int result = 0;
    for (int s = 0; s <= m + k; ++s) {
        const int cl = max(0, s - k);
        const int cr = min(m, s);

        if (l == r) {
            sum = 0;
            for (int i = cl; i <= cr; ++i) {
                ModSum(sum, GetC(s, i));
            }
            l = cl;
            r = cr;
        } else {
            ModMul(sum, 2);
            ModSum(sum, -GetC(s - 1, l));
            ModSum(sum, -GetC(s - 1, r));
            ++l;

            while (r < cr) {
                ModSum(sum, GetC(s, r + 1));
                ++r;
            }
            while (l > cl) {
                ModSum(sum, GetC(s, l - 1));
                --l;
            }

            while (r > cr) {
                ModSum(sum, -GetC(s, r));
                --r;
            }
            while (l < cl) {
                ModSum(sum, -GetC(s, l));
                ++l;
            }
        }

        int curResult = GetC(s + (n - 1), n - 1);
        ModMul(curResult, pw3[m + k - s]);
        ModMul(curResult, sum);

        ModSum(result, curResult);
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
      cout << x+(y-x)*2 << endl;
}

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

//#pragma GCC optimize("Ofast", "no-stack-protector")
//#pragma GCC target("sse4", "avx", "popcnt", "lzcnt", "sse3", "sse4.1", "sse4.2", "sse2", "tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;

typedef long double old;
typedef long long ll;

const int N = 1222333;

ll segs[N];

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n), pref(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pref[i] = (i ? pref[i - 1] : 0) + a[i];
    }
    int kek = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            segs[kek++] = pref[i] - (j ? pref[j - 1] : 0);
        }
    }
    vector<ll> bad(kek);
    ll ans = 0;
    for (int i = 40; i >= 0; --i) {
        ll t = 1LL << i;
        int cnt = 0;
        for (int j = 0; j < kek; ++j) {
            if (!bad[j] && (segs[j] & t)) {
                ++cnt;
            }
        }
        if (cnt >= k) {
            ans ^= t;
            for (ll j = 0; j < kek; ++j) {
                if (~segs[j] & t) {
                    bad[j] = 1;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8320
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 1000005;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    string s;   
    vector<LL> n(MXN, 0);
    static LL dp[MXN][2];
    cin >> s;
    s = '0' + s;
    FOR(i, 0, s.size())
    {
        n[i] = int(s[s.size() - 1 - i] - '0');
    }
    dp[0][0] = n[0];
    dp[0][1] = (10 - n[0]);
    FOR(i, 1, s.size())
    {
        dp[i][0] = min(dp[i - 1][0] + n[i], dp[i - 1][1] + n[i] + 1);
        dp[i][1] = min(dp[i - 1][0] + (10 - n[i]), dp[i - 1][1] + 10 - (n[i] + 1));
    }
    cout << min(dp[(int)s.size() - 1][0], dp[(int)s.size() - 1][1]) << '\n';
}


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

int main (){
  string a,b;
  cin >> a >>b;
  
  for(int i =0; i<1000;i++){
    if(stoi(a+b) == i*i){
      cout << "Yes" << endl;
      
      return 0;
   
    }
  }
  
  cout <<"No" << endl;
  
}
  


Measured memory_bytes: 256