akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
typedef signed long long sll;
typedef unsigned long long ull;

template <typename T> class UnionFind {
    vector<T> parent_of;

public:
    UnionFind(T num_nodes): parent_of(num_nodes) {
        REP(i, num_nodes) {
            parent_of[i] = i;
        }
    }

    bool are_same_roots(T a, T b) {
        return root_of(a) == root_of(b);
    }

    T root_of(T a) {
        if (a == parent_of[a])
            return a;

        T root = root_of(parent_of[a]);
        parent_of[a] = root;
        return root;
    }

    void insert(T a, T parent) {
        merge(a, parent);
    }

    void merge(T a, T b) {
        parent_of[root_of(a)] = root_of(b);
    }
};

int main() {
    init();
    sll n, m;
    cin >> n >> m;
    vector<sll> ps(n);
    UnionFind<sll> swaps(n);
    REP(i, n) { cin >> ps[i]; ps[i]--; }
    REP(i, m) {
        sll x, y;
        cin >> x >> y;
        swaps.insert(x - 1, y - 1);
    }

    int ans = 0;
    REP(i, n) {
        if (swaps.are_same_roots(i, ps[i]))
            ans++;
    }

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

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int fibonacci(int);

int *F;
int main()
{
  int n,a;

  scanf("%d",&n);
  F=malloc(sizeof(int)*n+1);
  a=fibonacci(n);
  printf("%d\n",a);

  return 0;
}

int fibonacci(int n)
{
  if(n==0 || n==1) return F[n]=1;
  if(F[n]!=NULL) return F[n];

  return F[n]=fibonacci(n-2)+fibonacci(n-1);
}



Measured memory_bytes: 2112
$trump
$ns
$ew
def play(cards, first)
    suit = cards[first].suit
    winner = cards[first]
    cards.each do |c|
        if c.suit == $trump && winner.suit == $trump
            winner = c if c.rank > winner.rank
        elsif c.suit == $trump && winner.suit != $trump
            winner = c
        elsif c.suit == suit && winner.suit == suit
            winner = c if c.rank > winner.rank
        end
    end
    id = cards.index(winner)
    if id == 0 || id == 2
        $ns += 1
    else
        $ew += 1
    end
    return id
end
class Cards
    attr_accessor :suit, :rank
    def initialize(s)
        @rank = s[0].gsub((/T|J|Q|K|A/), "T" => "10", "J" => "11", "Q" => "12", "K" => "13", "A" => "14").to_i
        @suit = s[1]
    end
    def to_s
        "#{@rank} of #{@suit}"
    end
    def win?(c)
        if self.suit == $trump && c.suit != $trump
            return self
        elsif self.suit != $trump && c.suit == $trump
            return c
        elsif self.suit == $cur_suit && c.suit != $cur_suit
            return self
        elsif self.suit != $cur_suit && c.suit == $cur_suit
            return c
        elsif self.rank > c.rank
            return self
        else
            return c
        end
    end
end
loop do
    $trump = gets.chomp
    break if $trump == "\#"
    p = 4.times.map{gets.split.map{|e| Cards.new(e)}}
    $ns = $ew = 0
    first = 0
    13.times do |i|
        first = play([p[0][i],p[1][i],p[2][i],p[3][i]], first)
    end
    puts $ns > 6 ? "NS #{$ns - 6}" : "EW #{$ew - 6}"
end

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	char pre = '@';
	int ans = 0;
	for(char c : s)
		if(c != pre) {
			ans++;
			pre = c;
		} 
	cout << ans - 1 << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int n, l;

bool comp(string a, string b) {
	for(int i = 0; i < l; i++) {
		if(a[i] < b[i]) return true;
		else return false;
	}
	
	return false;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	cin >> n >> l;
	
	vector<string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];
	
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n - 1; j++) {
			if(!lexicographical_compare(s[j].begin(), s[j].end(), s[j + 1].begin(), s[j + 1].end())) swap(s[j], s[j + 1]);
		}
	}
	
	for(int i = 0; i < n; i++) cout << s[i];
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
from bisect import bisect_left, bisect_right

N=input()
seq=[ int(sys.stdin.readline().strip())*-1  for _ in range(N) ]

LIS = [seq[0]]
for i in range(len(seq)):
	if i==0: continue
	if seq[i] >= LIS[-1]:
		LIS.append(seq[i])
	else:
		LIS[bisect_right(LIS, seq[i])] = seq[i]

print(len(LIS))

Measured memory_bytes: 40220
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main()
{
    ll t,n,i,j,k,l,m,f,a,b,c,d,s;
    cin>>n>>m>>c;
    ll arr[m+10];
    for(i=0;i<m;i++)
    {
        cin>>arr[i];
    }
    s=0;
    for(i=0;i<n;i++)
    {
        l=0;
        for(j=0;j<m;j++)
        {
            cin>>k;
            l+=(k*arr[j]);
        }
        l+=c;
        if(l>0){s++;}

    }
    cout<<s<<endl;
    return 0;
}


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


const int INF = 1e9+5;

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int& x : h) scanf("%d", &x);

    vector<int> dp(n, INF);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout<<dp[n-1];
}

Measured memory_bytes: 4084
import math
a,b,C=map(float,input().split())
θ=math.radians(C)
h=b*math.sin(θ)
S=(a*h)/2
c=math.sqrt(a**2+b**2-2*a*b*math.cos(θ))
L=a+b+c
print(S,L,h,sep="\n")


Measured memory_bytes: 5764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	int D = 0;
	for (int i = 0; i < N; i++) cin >> d[i];
	sort(d.begin(), d.end());
	int ans;
	int diff = d[N / 2] - d[N / 2 - 1];
	if (diff == 0) ans = 0;
	else ans = diff;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main()
{
    int n, m, s, c;
    int a[3] = {-1, -1, -1};
    int ans = 1;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> s >> c;
        s--;
        if(a[s] == -1) a[s] = c;
        if(a[s] !=  c) ans = 0;
    }
    if(ans == 0){
        cout << -1 << endl;
        return 0;
    }
    if(n == 1){
        cout << (a[0] == -1 ? 0 : a[0]) << endl;
        return 0;
    }
    if(a[0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        if(i == 0 && a[i] == -1) a[i] = 1;
        else if(a[i] == -1)      a[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cout << a[i] << flush;
    }
    cout << endl;
    return 0;
}

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

bool color[8] = {false};

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

    int x;
    int over = 0;
    for (int i = 0; i < N; i++) {
        cin >> x;
        if (x >= 3200) {
            over++;
        }
        else {
            color[x / 400] = true;
        }
    }

    int ans_max = over;
    int ans_min = 0;
    for (int i = 0; i < 8; i++) {
        if (color[i]) {
            ans_min++;
        }
    }

    if (ans_min == 0) {
        ans_min = 1;
        ans_max = ans_max;
    }
    else {
        ans_max += ans_min;
    }

    cout << ans_min << " " << ans_max << endl;
}


Measured memory_bytes: 256
// Author: Jinhai Chen
#include <bits/stdc++.h>
typedef long long ll;
ll INF = 0x3f3f3f3f3f3f3f3f;
#define mst(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 2e5+5;
int c[maxn];
ll cnt[maxn];
int n;
const int M = 1e9+7;
ll dp[maxn];
void add(ll &a,ll b) { a=(a+b)%M; }

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>c[i];
	}
	dp[0]=1;
	for(int i=1;i<=200000;i++) {
		dp[i] = dp[i-1];
		if(c[i]==c[i-1]) continue;
		add(dp[i],cnt[c[i]]);
		add(cnt[c[i]],dp[i-1]);
	}
	cout<<dp[n]<<endl;
	
	return 0;
}















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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) //多次元初期化
{
    std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

constexpr int MAX_V = 10010;
int cost[MAX_V][MAX_V]; //d[u][v]は辺e=(u,v)のコスト,(存在しないときはINF),d[i][i]=0
int mincost[MAX_V];     //集合xから辺の最小コスト
bool used[MAX_V];       //頂点Iがxに含まれているか
int V;             //頂点数

int prim()
{
    fill(mincost, mincost + V, INF);
    fill(used, used + V, false);
    mincost[0] = 0;
    int res = 0;
    while (true)
    {
        int v = -1;
        //xに属さない頂点のうちxからの辺のコストが最小になる頂点を探す
        rep(u, 0, V)
        {
            if (!used[u] && (v == -1 || mincost[u] < mincost[v]))
                v = u;
        }
        if (v == -1)
            break;
        used[v] = true;    //頂点vをxに追加
        res += mincost[v]; //辺のコストを加える
        rep(u, 0, V) if (cost[v][u] != -1) chmin(mincost[u], cost[v][u]);
    }
    return res;
}

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

    cin >> V;
    rep(i, 0, V) rep(j, 0, V) cin >> cost[i][j];

    cout<<prim()<<'\n';
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
	string s;
	int b;
	cin>>s;
	int k=0;
	for (int i=0; i<=s.length(); ++i)
		if (s[i]=='C'&& k==0){
			++k; b=i;
			break;
		}
	for (int i=b; i<=s.length(); ++i)
		if (s[i]=='F'&& k==1){
			++k;
			break;
		}
		if (k>=2) printf("Yes\n");
		else
		printf("No\n"); 	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include <cassert>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int gcd (int a,int b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
int gcd3(int a,int b,int c){
    int g = 0;
    g = gcd(a,b);
    g = gcd(g,c);
    return g;
}
int K;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>K;
    int ans =0;
    REP(i,1,K+1){
        REP(j,1,K+1){
            REP(k,1,K+1){
                ans += gcd3(i,j,k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
n = int(input())
l = list(map(int,input().split()))
l.sort();

ans = [0]*(l[n-1]+1)
p=0

while(p<n):
     
    for i in range(l[p],l[n-1]+1,l[p]):
        ans[i]+=1
    p+=1
   
    

c=0
#print(ans)
for i in l:
    if(ans[i]==1):
        c+=1
print(c)
    
        
    
    
     

Measured memory_bytes: 32068
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

int main() {
  cpp_int a, b;
  cin >> a >> b;
  cout << (a > b ? "GREATER" : (a == b ? "EQUAL" : "LESS")) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(void)
{
        int x;

        scanf("%d\n", &x);

        int h = x / (60 * 60);
        int m = x % (60 * 60) / 60;
        int s = x % 60;

        printf("%d:%d:%d\n", h, m, s);

        return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	char s;
	cin>>s;
	if(s=='a' || s=='i' || s=='e' || s=='o' || s=='u')
		cout<<"vowel"<<endl;
	else
		cout<<"consonant"<<endl;
		
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int w = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            if (a < b)
                out.println(Math.max(b - a - w, 0));
            else
                out.println(Math.max(a - b - w, 0));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define N 500005
using namespace std;
typedef long long LL;
LL sum[N],pre[N],succ[N],dp[N];
int even[N],n,a[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
	for (int i=1;i<=n;i++){
		pre[i]=sum[i];
		pre[i]=min(pre[i],pre[i-1]+(a[i]<2?2-a[i]:(a[i]&1)));
	}
	for (int i=n-1;i>=0;i--){
		succ[i]=sum[n]-sum[i];
		succ[i]=min(succ[i],succ[i+1]+(a[i+1]<2?2-a[i+1]:(a[i+1]&1)));
	}
	for (int i=1;i<=n;i++)
		even[i]=even[i-1]+(a[i]&1^1);
	dp[n]=even[n]+succ[n];
	for (int i=n-1;i>=0;i--)
		dp[i]=min(dp[i+1],even[i]+succ[i]);
	LL ans=1e18;
	for (int i=0;i<=n;i++)
		ans=min(ans,pre[i]+dp[i]-even[i]);
	printf("%lld\n",ans);
}

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

int main(){
	int N;
	long long x;
	std::cin >> N >> x;
	int m[N];
	long long sum = 0;
	long long counter = N;
	int min = 1001;
	for(int i = 0; i < N; i++){
		std::cin >> m[i];
		sum += m[i];
		if(m[i] < min){
			min = m[i];
		}
//		std::cout << min;
	}
//	std::cout << x/min;
	x -= sum;
	counter = counter + (x/min);
	std::cout << counter;
}

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

using namespace std;
int main() {
	int x,i;
	long long int j = 0;
	cin >> x;
	for (i = 1;;i++) {
		j += i;
		if (j >= x) break;
	}
	cout << i << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30);
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
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);
    }
};
struct UnionFind {
    vector<int> par, siz;
    UnionFind(int n) {
        par.resize(n);
        siz.resize(n, 1);
        for(int i = 0; i < n; i++)
            par[i] = i;
    }
    int find(int x) {
        if(par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if(u == v)
            return false;
        if(siz[u] < siz[v])
            swap(u, v);
        par[v] = u;
        siz[u] += siz[v];
        return true;
    }
    bool same(int u, int v) { return find(u) == find(v); }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool f1 = true, f2 = true;
    if(s[2] == '0') {
        if(s[3] == '0') {
            f1 = false;
        }
    } else if(s[2] == '1') {
        if(s[3] == '0' || s[3] == '1' || s[3] == '2') {
            f1 = true;
        } else {
            f1 = false;
        }
    } else {
        f1 = false;
    }
    if(s[0] == '0') {
        if(s[1] == '0') {
            f2 = false;
        }
    } else if(s[0] == '1') {
        if(s[1] == '0' || s[1] == '1' || s[1] == '2') {
            f2 = true;
        } else {
            f2 = false;
        }
    } else {
        f2 = false;
    }
    if(f1 && f2) {
        cout << "AMBIGUOUS" << endl;
    } else if(f1 == false && f2 == false) {
        cout << "NA" << endl;
    } else if(f1) {
        cout << "YYMM" << endl;
    } else {
        cout << "MMYY" << endl;
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N),ans(N);
  int64_t sum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  int64_t x=0;
  for(int i=1;i<N;i+=2){
    x+=A.at(i);
  }
  ans.at(0)=sum-2*x;
  cout << ans.at(0) << " ";
  for(int i=1;i<N;i++){
    ans.at(i)=2*A.at(i-1)-ans.at(i-1);
    cout << ans.at(i);
    if(i==N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;


int main(){
    string s;
    cin >> s;
    if(s.at(1) == 'B') cout << "ARC" <<endl;
    else cout << "ABC" <<endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	string t, u;
	cin >> s >> t;
	n = s.size();
	m = t.size();
	if(n > m) {
		puts("GREATER");
		return 0;
	}
	else if(n < m) {
		puts("LESS");
		return 0;
	}
	
	rep(i, n){
		if(s[i] > t[i]){
			puts("GREATER");
			return 0;
		}else if(s[i] < t[i]){
			puts("LESS");
			return 0;
		}
	}

	puts("EQUAL");

}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;
        if(op == '+') printf("%d\n",a+b);
        else if(op == '-') printf("%d\n",a-b);
        else if(op == '*') printf("%d\n",a*b);
        else if(op == '/') printf("%d\n",a/b);
    }
    return 0;
}


Measured memory_bytes: 2724
use proconio::{input, fastout};
use std::time::{Duration, Instant};
use rand::prelude::*;

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }
    let start = Instant::now();

    let mut last = vec![0; TYPE_COUNT];

    let mut ans = vec![];

    for s in ss.iter() {
        let mut max = 0;
        let mut index = 0;
        for (i, &x) in s.iter().enumerate() {
            let x = x + cc[i] * last[i] * 5;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        ans.push(index);
    }

    let mut score = calc_score(&cc, &ss, &ans);
    let mut rng = thread_rng();

    while Instant::now().duration_since(start) < Duration::from_millis(1900) {
        let mut dts = vec![];
        let mut olds = vec![];

        for _ in 0..10 {
            let day = rng.gen_range(0, d);
            let ty = rng.gen_range(0, 26);
            dts.push((day, ty));
            let old = ans[day];
            ans[day] = ty;
            olds.push((day, old));
        }

        let new_score = calc_score(&cc, &ss, &ans);
        if new_score < score {
            for (day, old) in olds {
                ans[day] = old;
            }
        } else {
            score = new_score;
        }
    }

    for x in ans {
        println!("{}", x+1);
    }
    
}

fn calc_score(cc: &Vec<usize>, ss: &Vec<Vec<usize>>, tt: &Vec<usize>) -> isize {
    let mut last = vec![0; TYPE_COUNT];

    let mut v = 0;
    for (s, &t) in ss.iter().zip(tt.iter()) {
        v += s[t] as isize;
        for l in last.iter_mut() {
            *l += 1;
        }
        last[t] = 0;
        v -= last.iter().zip(cc.iter()).map(|(&l, &c)| (l * c) as isize).sum::<isize>();
    }
    v
}

Measured memory_bytes: 2768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
int n,a[610],h[610],f[610][610];
void upd(int&a,ll b){a=(a+b)%mod;}
int main(){
	cin>>n;
	for(int i=1;i<=2*n;i++){
		read(a[i]);
		if(a[i]>0) h[a[i]]=i;
	}
	int s1=0,s2=0;
	for(int i=1;i<=n;i++){
		if(~a[i*2]&&~a[i*2-1]) continue;
		if((a[i*2]>0)+(a[i*2-1]>0)==1) s1++;
		else s2++;
	}
	f[0][0]=1;
	int sum1=0,sum2=0;
	for(int i=1;i<=2*n;i++)
		if(!h[i]){
			int g[610][610]={};
			for(int j=0;j<=2*n;j++)
				for(int k=0;k<=2*n;k++){
					upd(g[j+1][k],f[j][k]);
					if(k) upd(g[j][k-1],f[j][k]);
					upd(g[j][k+1],f[j][k]);
				}
			memcpy(f,g,sizeof(g));
		}
		else{
			if(h[i]&1){
				if(a[h[i]+1]>0) continue;
			}
			else{
				if(a[h[i]-1]>0) continue;
			}
			int g[610][610]={};
			for(int j=0;j<=2*n;j++)
				for(int k=0;k<=2*n;k++){
					if(j) upd(g[j-1][k],1ll*f[j][k]*j);
					upd(g[j][k+1],f[j][k]);
				}
			memcpy(f,g,sizeof(g));
		}
	ll ans=f[0][0];
	for(int i=1;i<=s2;i++) ans=ans*i%mod;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9 + 7;
int main() {
    ll N;
    cin >> N;
    vector<ll> T(N), A(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll maxl = max_element(T.begin(), T.end()) - T.begin();
    reverse(A.begin(), A.end());
    ll maxr = max_element(A.begin(), A.end()) - A.begin();
    maxr = N - 1 - maxr;
    reverse(A.begin(), A.end());

    bool flag = true;
    if (maxl > maxr) {
        flag = false;
    }
    if (T[N - 1] != A[0]) {
        flag = false;
    }

    ll sum = 1;
    for (int i = 1; i < maxl; i++) {
        if (T[i] == T[i - 1]) {
            sum *= T[i];
            sum %= M;
        }
    }
    for (int i = N - 2; i > maxr; i--) {
        if (A[i] == A[i + 1]) {
            sum *= A[i];
            sum %= M;
        }
    }

    ll gap = maxr - maxl - 1;
    while (gap > 0) {
        sum *= T[N - 1];
        sum %= M;
        gap--;
    }

    cout << (flag ? sum : 0) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    string n;
    cin>>n;
    int tmp;
    for (int i =0;i<n.size();i++){
        tmp+=n[i]-'0';
    }
    if(tmp%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

string JOI = "JOI";
LL calc(string& S){
  int N = SZ(S);
  VVL cnt(N+1, VL(3));
  REP(i,N){
	REP(j,3)
	  cnt[i+1][j] = cnt[i][j] + (JOI[j] == S[i]);
  }

  LL res = 0;
  REP(i,N){
	if(S[i] == 'O'){
	  res += cnt[i][0] * (cnt[N][2] - cnt[i][2]);
	}
  }
  return res;
}

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

  int N;
  cin >> N;
  string S;
  cin >> S;

  string J = "J" + S;
  string I = S + "I";

  LL ans = max(calc(J), calc(I));

  VVL cnt(N+1, VL(3));
  REP(i,N){
	REP(j,3)
	  cnt[i+1][j] = cnt[i][j] + (JOI[j] == S[i]);
  }
  LL orig = calc(S);
  REP(i,N)
	maxi(ans, orig + cnt[i][0] * (cnt[N][2] - cnt[i][2]));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 14096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n,a[4][4],x[105]={0},y[105]={0};
	for(int i=1;i<4;i++)
		for(int j=1;j<4;j++){
			cin>>a[i][j];
			x[a[i][j]]=i;
			y[a[i][j]]=j;
		}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>m;
		if(x[m]){
			a[x[m]][y[m]]=-1;
		}
	}
	int ok=0;
	for(int i=1;i<4;i++)
		if(a[i][1]==-1&&a[i][2]==-1&&a[i][3]==-1)
			ok=1;
	for(int i=1;i<4;i++)
		if(a[1][i]==-1&&a[2][i]==-1&&a[3][i]==-1)
			ok=1;
	if((a[1][1]==-1&&a[2][2]==-1&&a[3][3]==-1)||(a[1][3]==-1&&a[2][2]==-1&&a[3][1]==-1))
		ok=1;
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>

using namespace std;
int r, c;

string ConvertDecToBinString(int dec_num) {
    if (dec_num == 0) { return string("0"); }
    string bin_num_str;
    while (dec_num) {
        if ((dec_num & 1) == 0) { bin_num_str.insert(bin_num_str.begin(), '0'); }
        else { bin_num_str.insert(bin_num_str.begin(), '1'); }
        dec_num >>= 1;
    }

    return bin_num_str;
}

int GetTurnOverMaxGoodNum(vector<vector<int> >& senbeis, int raw) {
    string bin_raw_string = ConvertDecToBinString(raw);
    for (size_t i = 0; i < r; i++) {
        if (bin_raw_string[i] == '1') {
            for (size_t j = 0; j < c; j++) {
                senbeis[i][j] = 1 - senbeis[i][j];
            }
        }
    }

    int max_good_senbei_num = 0;
    for (size_t j = 0; j < c; j++) {
        int zero_num = 0;
        for (size_t i = 0; i < r; i++) {
            if (senbeis[i][j] == 0) { zero_num++; }
        }
        max_good_senbei_num += max(zero_num, r - zero_num);
    }

    for (size_t i = 0; i < r; i++) {
        if (bin_raw_string[i] == '1') {
            for (size_t j = 0; j < c; j++) {
                senbeis[i][j] = 1 - senbeis[i][j];
            }
        }
    }

    return max_good_senbei_num;
}

int main() {
    scanf("%d %d", &r, &c);
    while (r * c != 0) {
        auto senbeis = vector<vector<int> >(r, vector<int>(c));
        int max_good_senbei_num = 0;
        for (size_t i = 0; i < r; i++) {
            for (size_t j = 0; j < c; j++) {
                scanf("%d", &senbeis[i][j]);
            }
        }
        for (size_t i = 0; i < 2 << (r - 1); i++) {
            int good_num = GetTurnOverMaxGoodNum(senbeis, i);
            if (max_good_senbei_num < good_num) { max_good_senbei_num = good_num; }
        }
        printf("%d\n", max_good_senbei_num);
        scanf("%d %d", &r, &c);
    }

    return 0;
}

Measured memory_bytes: 2996
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r,t;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;

    cin >> n >> m >> x >> y;

    ll x_max = -101;
    ll y_min = 101;

    rep(i, n){
        ll tm;
        cin >> tm;
        x_max = max(x_max, tm);
    }

    rep(i,m){
        ll tm;
        cin >> tm;
        y_min = min(y_min,tm);
    }

    sans = "War";

    if(y<x){}
    else{
        for(ll i=x+1; i <=y; i++){
            if(x_max < i && i <= y_min){
                sans = "No War";
                break;
            }
        }
    }





    // std::cout << ans << endl; 

    std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, M, X;
int C[15], A[15][15];

int main() {
    cin >> N >> M >> X;
    for_(i,0,N) {
        cin >> C[i];
        for_(j,0,M) cin >> A[i][j];
    }

    int ans = 1L << 30;
    for_(S,1,1<<N) {
        vector<int> sum(M, 0);
        int money = 0;
        for_(i,0,N) {
            if ((S >> i) & 1) {
                for_(j,0,M) sum[j] += A[i][j];
                money += C[i];
            }
        }
        if (*min_element(ALL(sum)) >= X) ans = min(ans, money);
    }
    cout << (ans == 1L << 30 ? -1 : ans) << endl;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n; cin >> n;
	deque<int> q;
	int head = 0;
	
	for(int i=0,v;i<n;i++){
		cin >> v;
		
		if(!head){
			q.push_front(v);
		}
		else{
			q.push_back(v);
		}
		head=1-head;
	}
	
	if(head){
		for(auto v:q){
			cout << v << " ";
		}
		cout << endl;
	}
	else{
		for(auto it=q.rbegin();it!=q.rend();it++){
			cout << *it << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4452
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

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

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

// ---------------------
#define INF 922337203685477580
typedef long long ll;

int dp[1010][1010];

int main() {
  int q;
  cin >> q;
  REP(loop, q) {
    char S[1000], T[1000];
    cin >> S >> T;

    REP(i, strlen(S)) {
      REP(j, strlen(T)) {
        dp[i][j] = 0;
      }
    }
    for (int i = 0; i < strlen(S); i++) {
      for (int j = 0; j < strlen(T); j++) {
        if (S[i] == T[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }
    cout << dp[strlen(S)][strlen(T)] << endl;
  }

  return 0;
}

Measured memory_bytes: 7036
import collections


n,k=map(int, input().split()) 
A = list(map(int, input().split()))
C = collections.Counter(A)

if (k>=len(C)):
    ans = 0
else:
    ans = 0
    nums = sorted(C.values(),reverse=True)
    for i in range(k,len(nums)):
        ans += nums[i]
print(ans)

Measured memory_bytes: 32556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 7;
const ll mod = 998244353;
ll arr[N];
ll ksm(ll a, ll b){
	ll sum =1;
	while(b){
		if(b&1)
			sum = sum * a % mod;
		a=a*a%mod;
		b>>=1;
	}
	return sum;
}

int main(){
	ll n,a,flag=0,flag1=0;
	ll sum = 1;
	cin >> n;
	for(int i = 0; i < n; i ++ ){
		scanf("%lld",&a);
		if(i==0&&a==0){
			flag1=1;
		}
		arr[a]++;
		if(a>flag){
			flag = a;
		}
	}
	if(arr[0]!=1||!flag1){
		printf("0\n");
	}
	else{
		for(int i=2;i<=flag;i ++ ){
			if(arr[i]==0){
				sum=0;
				break;	
			}
			sum = sum * ksm(arr[i-1],arr[i])%mod;
		}
		printf("%lld\n",sum);
	}
	
	
	
	return 0;
}

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

int main(){
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout <<"ARC" <<endl;
    else cout << "AGC" <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String ans = "";
    for(int i=0;i<S.length();i++){
      String Step = S.substring(i,i+1);
      if (i%2==0){
        if ((Step.equals("R")) || (Step.equals("U")) || (Step.equals("D"))){
          ans = "Yes";
        }else{
          ans = "No"; break;
        }
      }else{
        if ((Step.equals("L")) || (Step.equals("U")) || (Step.equals("D"))){
          ans = "Yes";
        }else{
          ans = "No"; break;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
import sys
from math import floor, sqrt
from collections import defaultdict

MOD = 10 ** 9 + 7

n = int(sys.stdin.readline().rstrip())

res = defaultdict(int)

def primeFactorize(n):
    while n % 2 == 0:
        res[2] += 1
        n //= 2
    if n == 1:
        return
    for i in range(3, floor(sqrt(n))+1, 2):
        while n % i == 0:
            res[i] += 1
            n //= i
        if n == 1:
            return
    res[n] += 1

def main():
    for i in range(1, n+1):
        primeFactorize(i)
    
    ans = 1
    for c in res.values():
        ans *= c + 1
        ans %= MOD
    
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

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

//0 1->codeforces
#define LL "%lld"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf(LL,&a);return a;}

int main() {
  int n=gi(), b=MODV,t;
  vi a(n);
  for(auto i=0;i<n;i++){ a[i]=gi(); }
  sort(a.begin(), a.end());
  
  for(int i=a[0];i<=a[n-1];i++){
    t=0;
    for(int j=0;j<n;j++){
      t+=((a[j]-i)*(a[j]-i));
    }
    if(t<b)b=t;
  }
  cout<<b<<endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int *node[N+1], n_edge[N+1];
	for(int i = 0; i <= N; i++){
		node[i] = NULL;
		n_edge[i] = 0;
	}
	for(int m = 1; m <= M; m++){
		int i, j;
		scanf("%d %d", &i, &j);
		n_edge[i]++;
		n_edge[j]++;
		node[i] = (int *) realloc(node[i], sizeof(int) * n_edge[i]);
		node[i][n_edge[i]-1] = j;
		node[j] = (int *) realloc(node[j], sizeof(int) * n_edge[j]);
		node[j][n_edge[j]-1] = i;
	}

	int start = 1, end = start, vacant = 2;
	int queue[N+1], state[N+1];
 	for(int i = 1; i <= N; i++)
    	state[i] = -1;
	queue[1] = 1;
	state[1] = 1;
	while(start <= end){
		for(int current = start; current <= end; current++){
			int base = queue[current]; 
			for(int i = 0; i < n_edge[base]; i++){
				int neighbor = node[base][i];
				if(state[neighbor] < 0){
					queue[vacant] = neighbor;
					state[neighbor] = base;
					vacant++;
				}
			}
		}
		start = end + 1; 
		end = vacant - 1;
	}
	printf("Yes\n");
	for(int n = 2; n <= N; n++)
		printf("%d\n", state[n]);
	for(int i = 0; i <= N; i++)
		free(node[i]);
	return 0;
}

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

// main.cpp

int main() {
  std::string s;
  std::cin >> s;
  std::cout << std::accumulate(s.begin(), s.end(), static_cast<std::int_fast64_t>(0), [](const std::int_fast64_t sum, const char c) {
    return sum + (c - '0');
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int SZ = 100005;
queue<int> q;
int ind[SZ];
int parent[SZ];
vector<int> graph[SZ];
int main(void){
	int n,m; scanf("%d %d",&n,&m);
	for(int i=0;i<n+m-1;i++){
		int x,y; scanf("%d %d",&x,&y);
		graph[x].push_back(y);
		ind[y]++;
	}
	for(int i=1;i<=n;i++){
		if(ind[i]==0) q.push(i);
	}
	while(!q.empty()){
		int f = q.front(); q.pop();
		for(int nxt : graph[f]){
			ind[nxt]--;
			if(ind[nxt]==0){
				parent[nxt]=f;
				q.push(nxt);
			} 
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",parent[i]);
	return 0;
}

Measured memory_bytes: 7040
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:https://atcoder.jp/contests/abc140/tasks/abc140_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    
    vector<pll> P(N);
    for(int i = 0; i < N;i++){
        cin >> P[i].first;
        P[i].second = i+1;
    }
    sort(P.rbegin(),P.rend());
    set<ll> S;
    S.insert(0); S.insert(N+1);
    S.insert(P.front().second); P.erase(P.begin());
    
    for(auto p:P){
        ll v,id; tie(v,id) = p;
        
        auto it = S.lower_bound(id);
        ll x1,x2,x3,x4;
        
        x3 = *it;
        {
            it++;
            if(it == S.end()){
                x4 = x3;
            }else{
                x4 = *it;
            }
            it--;
            it--;
        }
        x2 = *it;
        {
            if(it == S.begin()){
                x1 = x2;
            }else{
                it--;
                x1 = *it;
            }
        }
        res += v * ((x2 - x1) * (x3 - id) + (id - x2) * (x4 - x3));
        S.insert(id);
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 6528
import java.util.HashSet;
import java.util.Set;

public class Main {
 
  private static void solve() {
    int n = ni();
    Set<String> set = new HashSet<>();
    char last = 0;
    for (int i = 0; i < n; i ++) {
      String s = next();
      if (set.contains(s)) {
        System.out.println("No");
        return;
      }
      set.add(s);
      if (last != 0 && last != s.charAt(0)) {
        System.out.println("No");
        return;
      }
      last = s.charAt(s.length() - 1);
    }
    System.out.println("Yes");
  }
 
  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }
 
  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;
 
  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
 
  private static double nd() {
    return Double.parseDouble(next());
  }
 
  private static long nl() {
    return Long.parseLong(next());
  }
 
  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }
 
  private static char[] ns() {
    return next().toCharArray();
  }
 
  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }
 
  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }
 
  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }
 
  private static int ni() {
    return Integer.parseInt(next());
  }
 
  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
 }

Measured memory_bytes: 23252
K = int(input())
S = input()

MAX = 2 * 10 ** 6 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD

N = len(S)
ans = 0
for i in range(K + 1):
    tmp = (pow(25, K - i, MOD) * pow(26, i, MOD)) % MOD
    ans += comb(N + K - i - 1, N - 1) * tmp
    ans %= MOD
print(ans)


Measured memory_bytes: 121188