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

int main(){
  unordered_set<string> s;
  int n;
  cin >> n;
  while(n--){
    string str;
    cin >> str;
    s.insert(str);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 17696
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
          string s = cin.Read;
          WriteLine(a < 3200 ? "red" : s);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int dp[100001];

int dfs(int node, vector<int> edges[])
{
  if(dp[node] != -1)
  {
    return dp[node];
  }

  if(edges[node].size() == 0)
  {
    dp[node] = 0;
    return 0;
  }

  int max_depth = 0;
  for(auto nxt: edges[node])
  {
    max_depth = max(max_depth, dfs(nxt, edges));
  }

  dp[node] = max_depth + 1;
  return dp[node];
}

int main(){
    std::ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> edges[n];
    for(int i=0;i<m;++i)
    {
      int x, y;
      cin >> x >> y;
      --x; --y;
      edges[x].push_back(y);
    }

    FILL(dp, -1);

    for(int i=0;i<n;++i)
    {
      if(dp[i] == -1)
      {
        dfs(i, edges);
      }
    }

    int ret = 0;
    for(int i=0;i<n;++i)
    {
      ret = max(ret, dp[i]);
    }

    cout << ret << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

int main() {
    ll N;
    cin >> N;
    ll i;
    ll dp[MAX][3]={};
    
    for(i=0; i<N; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        chmax(dp[i+1][0], max(dp[i][1]+a, dp[i][2]+a));
        chmax(dp[i+1][1], max(dp[i][2]+b, dp[i][0]+b));
        chmax(dp[i+1][2], max(dp[i][0]+c, dp[i][1]+c));
    }
    
    pt(max(dp[N][0], max(dp[N][1], dp[N][2])));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a.begin(), a.end());
	if(a.size() % 2 == 1) {
		long long med, ans = 0;
		med = a[a.size() / 2];
		for(int i = 0; i < n; i++) {
			ans += abs(a[i] - med);
		}
		cout << ans << endl;
	}
	else {
		long long med1, med2 , ans1 = 0, ans2 = 0;
		med1 = a[(a.size() - 1) / 2];
		med2 = a[a.size() / 2];
		for(int i = 0; i < n; i++){
			ans1 += abs(med1 - a[i]);
			ans2 += abs(med2 - a[i]);
		}
		cout << min(ans2, ans1) << endl;
	}
		
		
	return 0;                                              
}
	


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d\n",&a,&b);

    if(a<b){
       printf("a < b\n");
    }
    else if(a>b){
       printf("a > b\n");
    }
    else
       printf("a == b\n");
 
  return 0;
}

Measured memory_bytes: 584
N = gets.to_i
A = gets.split.map(&:to_i)

s = [0]
A.reverse.each{|a| s << a + s.last}
s.reverse!

ans = 0
A.each_with_index do |a,i|
  ans += a * s[i+1]
end

puts (ans % 10_0000_0007)


Measured memory_bytes: 35272
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
########################################################
F=[1]*(10**6+1)
for i in range(2,10**6+1):
    for j in range(i,10**6+1,i):
        F[j]+=1
ans=0
n=int(input())
for c in range(1,n):
    ans+=F[n-c]
print(ans)


Measured memory_bytes: 91176
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	// 入力
	vector<int> x(4);
	vector<int> y(4);
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	
	int xdiff = x[1] - x[0];
	int ydiff = y[1] - y[0];
	
	// 反時計周り
	x[2] = x[1] - ydiff;
	y[2] = y[1] + xdiff;
	x[3] = x[0] - ydiff;
	y[3] = y[0] + xdiff;
	
	// 出力
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3];
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000001
char add[N];
int solve(int a, int b, int n) {
  int i, m;
  m = 0;
  for (i = 0; i < N; i ++) add[i] = 0;
  add[0] = 1;
  for (i = 1; i < N; i ++) {
    if (i >= a && i < b) {
      add[i] = add[i - a];
    } else if (i < a && i >= b) {
      add[i] = add[i - b];
    } else if (i >= a && i >= b) {
      add[i] = add[i - a] || add[i - b];
    }
  }
  for (i = 0; i <= n; i ++) m += !add[i];
  return m;
}
int main() {
  int a, b, n;
  while (1) {
    scanf("%d %d %d", &n, &a, &b);
    if(! (a||b||n)) break;
    printf("%d\n", solve(a, b, n));
  }
  return 0;
}

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

int h,w,ans;
char a[1004][1003];
queue<pair<int,int>> qu;
int main(){
	cin>>h>>w;
	f(i,h){
		f(j,w){
			cin>>a[i][j];
			if(a[i][j]=='#')qu.push({i,j});
		}
	}
	while(!qu.empty()){
		
		bool did=false;
		int count=qu.size();
		for(int i=0;i<count;i++){
			pair<int,int> o=qu.front();
			int sai=o.first;
			int go=o.second;
			if(sai-1>=0&&a[sai-1][go]=='.'){
				a[sai-1][go]='#';
				qu.push({sai-1,go});
				did=true;
			}
			if(sai+1<h&&a[sai+1][go]=='.'){
				a[sai+1][go]='#';
				qu.push({sai+1,go});
				did=true;
			}
			if(go-1>=0&&a[sai][go-1]=='.'){
				a[sai][go-1]='#';
				qu.push({sai,go-1});
				did=true;
			}
			if(go+1<w&&a[sai][go+1]=='.'){
				a[sai][go+1]='#';
				qu.push({sai,go+1});
				did=true;
			}
			qu.pop();
		}
		if(did)ans++;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 9360
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

string s, t;
pair<int, pair<int, P> > dp[3001][3001];

void solve()
{
    int sl = s.size(), tl = t.size();
    FOR (i, 1, sl+1) {
        FOR (j, 1, tl+1) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = make_pair(dp[i-1][j-1].fi + 1, make_pair(i-1, make_pair(i-1, j-1)));
            } else {
                dp[i][j] = (dp[i-1][j].fi > dp[i][j-1].fi ? dp[i-1][j] : dp[i][j-1]);
            }
        }
    }
    string ans;
    auto p = dp[sl][tl];
    while (p.fi > 0) {
        ans += s[p.se.fi];
        p = dp[p.se.se.fi][p.se.se.se];
    }
    reverse(ALL(ans));
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s >> t;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 140928
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

template <class T>
struct BIT {
    vector<T> dat;
    BIT(int n) : dat(n+1) { }
    // initialize by a constant
    BIT(int n, T a) : dat(n+1, a) {
        dat[0] = 0;
        for (int k = 1; k+(k&-k) <= n; ++k) dat[k+(k&-k)] += dat[k];
    }
    // initialize by a vector
    BIT(vector<T> y) : dat(y.size()+1) {
        for (int k = 0; k < y.size(); ++k) dat[k+1] = y[k];
        for (int k = 1; k+(k&-k) < dat.size(); ++k) dat[k+(k&-k)] += dat[k];
    }
    void add(int k, T a) {
        for (++k; k < dat.size(); k += k&-k) dat[k] += a;
    }
    T sum(int k) {
        T s = 0;
        for (; k > 0; k &= k-1) s += dat[k];
        return s;
    }
    int lower_bound(T a) {
        if (a <= 0) return 0;
        int k = dat.size()-1;
        for (int s: {1,2,4,8,16}) k |= (k >> s);
        for (int p = ++k; p > 0; p >>= 1, k |= p)
            if (k < dat.size() && dat[k] < a) a -= dat[k]; else k ^= p;
        return k+1;
    }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll Q;cin>>Q;
  vector<pair<ll,Pll> > query(Q);
  vll x;
  for(ll q=0;q<Q;q++){
    cin>>query[q].first;
    if(query[q].first==1){
      ll a,b;cin>>a>>b;
      query[q].second = {a,b};
      x.push_back(a);
    }
  }
  sort(x.begin(),x.end());
  x.erase(unique(x.begin(),x.end()),x.end());
  debugArray(x,x.size());
  map<ll,ll> mp;
  for(ll i=0;i<x.size();i++){
    mp[x[i]]=i;
  }
  BIT<ll> bit1(x.size()),bit2(x.size());
  ll sumb=0;
  ll n=0;
  for(ll q=0;q<Q;q++){
    if(query[q].first==1){
      ll a,b;
      tie(a,b)=query[q].second;
      sumb += b;
      ll i = mp[a];
      //debug(i);
      bit1.add(i,1);
      bit2.add(i,a);
      n++;
    }else{
      //debug((n+1)/2);
      ll i=bit1.lower_bound((n+1)/2);
      /*
      debug(i);
      debug(sumb);
      debug(bit2.sum(x.size()));
      debug(2*bit2.sum(i));
      */
      ll ans = sumb;
      ans += bit2.sum(x.size());
      ans -= 2*bit2.sum(i);
      ans += (2*bit1.sum(i)-bit1.sum(x.size()))*x[i-1];
      cout<<x[i-1]<<" "<<ans<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 15860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			double val = in.nextDouble();
			if (val < 0) {
				break;
			}
			String ans;
			if (val >= 256) {
				ans = "NA";
			} else {
				int seisu = (int) val;
				int syosu = (int) ((val - seisu) * 16);
				if ((val - seisu) * 16 - syosu != 0) {
					ans = "NA";
				} else {
					StringBuilder sb = new StringBuilder("00000000.0000");
					String seisuB = Integer.toBinaryString(seisu);
					sb.replace(8 - seisuB.length(), 8, seisuB);
					String syosuB = Integer.toBinaryString(syosu);
					sb.replace(13 - syosuB.length(), 13, syosuB);
					ans = sb.toString();
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 27972
#include <stdio.h>

int main(void){

	int a, b, a1, b1;
	int gcd, lcm,r;
	int tmp;

	while (scanf("%d %d", &a1, &b1) != EOF){

		a = a1;
		b = b1;
		if (a < b){
			tmp = a;
			a = b;
			b = tmp;
		}

		r = a%b;

		while (r != 0)
		{
			a = b;
			b = r;
			r = a%b;
		}
		gcd = b;
		lcm = a1 / gcd*b1;

		printf("%d %d\n", gcd,lcm);
	}

	return 0;

}

Measured memory_bytes: 596
#include<stdio.h>
int main(void)
{
	int a,b,c,d,i,s;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(c>=b||d<=a)
	printf("0\n");
	else
	{
		if(c>=a&&d>b)
		printf("%d\n",b-c);
		if(c>=a&&d<=b)
		printf("%d\n",d-c);
		if(c<a&&d<=b)
		printf("%d\n",d-a);
		if(d>b&&c<a)
		printf("%d\n",b-a);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,n;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=p*a;
	if(p>c){
		n=p-c;
		y=b+n*d;
		
	}
	else if(p<=c){
		y=b;
	}
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    vector<pair<ll,ll>> suzu(N);
    for(int i=0; i<N; i++){
        cin >> suzu[i].first >> suzu[i].second;
    }
    ll ans = 0;
    for(int i=0; i<N; i++){
        if((suzu[i].first & K) == suzu[i].first) ans += suzu[i].second;
    }
    for(int bit=0; bit<31; bit++){
        if(K & (1LL<<bit)){
            ll temp = (1LL<<bit) - 1;
            for(int j=bit+1; j<31; j++){
                if(K & (1LL<<j)) temp += (1LL<<j);
            }
            ll sum = 0;
            for(int i=0; i<N; i++){
                if((suzu[i].first & temp) == suzu[i].first) sum += suzu[i].second;
            }
            chmax(ans,sum);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC\n";
	}
	else if (r < 2800) {
		cout << "ARC\n";
	}
	else {
		cout << "AGC\n";
	}
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(void){
  vector<long long> a;
  int n,in;
  cin>>n;
  rep(i,n){
    cin>>in;
    a.push_back(in);
  }
  sort(a.begin(),a.end());
  vector<long long> ret;
  for(int i = a.size() - 1 ; i >= 1 ; i --){
    if(a[i] == a[i-1]){
      ret.push_back(a[i]);
      i --;
    }
    if(ret.size() == 2){
      break;
    }
  }
  if(ret.size() != 2){
    cout<<"0"<<endl;
  } else {
    cout<<ret[0] * ret[1]<<endl;
  }
}

Measured memory_bytes: 1400
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (c1).begin(),(c1).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n, m, c;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

long long lcm(long long a, long long b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> n >> m >> c;
	cout << n / gcd(n, m)*m / gcd(n, m)*c << endl;
}


Measured memory_bytes: 3080
#include <iostream> 
#include <cstring>
using namespace std;
long long gcd(long long a, long long b) { 
	return b == 0 ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
int main()
{
	ios::sync_with_stdio(false);
	int N;
	while(cin >> N) {
		long long ans, num;
		cin >> num; ans = num;
		for (int i = 2; i <= N; ++i) {
			cin >> num;
			ans = lcm(ans, num);
		}
		cout<< ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma region

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (register int i = (begin); i < (end); i++)
#define IFOR(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define MOD 1000000007
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  REP(i, vec.size())
  i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &deq) {
  os << "deq[ ";
  REP(i, deq.size())
  i == 0 ? os << deq[i] : os << ", " << deq[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}

#pragma endregion
#pragma region

#define out(x) cout << (x) << '\n';

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(a - b, b);
}

#pragma endregion
#define INF 2147483647

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

  int N;
  cin >> N;
  vector<int> A(N);
  cin >> A;
  REP(i, N) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    REP(i, N)
    cout << A[i] << (i == N - 1 ? "" : " ");
    cout << '\n';
  }
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db double
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
const int mxn=1e5+7,du=1e9+7;
int n,k;
int dp[mxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    dp[0]=1;
    for (int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        vector<int> sum(k+1);
        for (int j=k;j>=0;j--)
       // for (int take=1;take<=x;take++)
        {
            int l=j+1;
            int r=j+min(x,k-j);
            if (l<=r)
            {
                sum[l]+=dp[j]; sum[l]%=du;
                if (r+1<=k) 
                {
                    sum[r+1]-=dp[j];
                    sum[r+1]=(sum[r+1]+du)%du;
                }
            }
        }
        int pref=0;
        for (int j=0;j<=k;j++)
        {
            pref=(pref+sum[j])%du;
            dp[j]=(dp[j]+pref)%du;
        }
    }
    cout<<dp[k];
    return 0;
}

Measured memory_bytes: 5172
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<ll> lis;
bool vis[maxn];
bool pos;

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

  ll t = 1;

  //cin>>t;

  while(t--){
    
     ll n, i, j, k, te;

     cin>>n;

     ll a[n], freq[n+1];
     clr(freq);

     for(i =0 ;i < n-1;i++){
         cin>>te;
         freq[te]++;
     }
     for(i  = 1;i <= n;i++)
      cout<<freq[i]<<"\n";
  }     
        
}


Measured memory_bytes: 5228
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		
		// 計算
		int result = 1;
		for(int i = 1; i <= x; i++){
		    for(int j = 2; j <= x; j++){
		        if((int)pow(i, j) <= x) result = max(result, (int)pow(i, j));
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


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

using namespace std;

int main(){
int n;
string fac[21] = {"1","1","2","6","24","120","720","5040","40320","362880","3628800","39916800","479001600","6227020800","87178291200","1307674368000"
			,"20922789888000","355687428096000","6402373705728000","121645100408832000","2432902008176640000"};

cin >> n;
cout << fac[n] << endl;

return 0;
}

Measured memory_bytes: 0
import math
import os
import sys
# from fractions import gcd
input = sys.stdin.readline

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


def main():
    X, Y = list(map(int, input().split()))

    if (X + Y) % 3 != 0:
        print(0)
        return

    n = int((2 * Y - X) / 3)
    m = int(Y - 2 * n)
    # print(n, m)
    # print(cmb(n+m, min(n, m)))

    for i in range(2, m + n + 1):
        g1.append((g1[-1] * i) % MOD)
        inverse.append((-inverse[MOD % i] * (MOD//i)) % MOD)
        g2.append((g2[-1] * inverse[-1]) % MOD)

    print(cmb(m+n, min(n, m), MOD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 118764
#include<stdio.h>
int main(void){

  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x>=r && x<=(W-r)){
    
    if(y>=r && y<=(H-r)){
      
      printf("Yes\n");
    }
    else printf("No\n");
  }
  
  else
    printf("No\n");
  
  return 0;
}
  


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int S=0,A[4]={0};
  int T=0,B[4]={0};
  for(int i=0;i<4;i++){
      cin >> A[i];
      S+=A[i];
  }
  for(int i=0;i<4;i++){
      cin >> B[i];
      T+=B[i];
  }
  if(S>T){
      cout << S << endl;
  }else if(S<T){
      cout << T << endl;
  }else if(S==T){
      cout << S << endl;
  }
}


Measured memory_bytes: 3092
from collections import defaultdict
N, M = map(int, input().split())
py = [list(map(int, input().split())) for i in range(M)]
PY = sorted(py, key=lambda x: x[1])
pydict = defaultdict(lambda: 0)
ans = {}
for i in PY:
    pydict[i[0]] += 1
    ans[str(i[0]) + str(i[1])] = "{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))

for i in py:
    print(ans.get(str(i[0]) + str(i[1])))


Measured memory_bytes: 56908
h, w = map(int, input().split())
while h != 0 or w != 0:
    l = "#." * (w // 2) + "#" * (w % 2)
    nl = ".#" * (w // 2) + "." * (w % 2)
    for i in range(h):
        print(l)
        l, nl = nl, l
    print()
    h, w = map(int, input().split())



Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

class apple{
public:
  char c;
  int v;
  bool operator<(const apple &another) const{
    return v > another.v;
  }
};

void solve(){
  int x, y, a, b, c, n; cin >> x >> y >> a >> b >> c;
  vector<apple> ap(a + b), ap2(c), sum;
  for(int i = 0; i < a + b; i++){
    cin >> ap[i].v;
    if(i < a) ap[i].c = 'r';
    else ap[i].c = 'g';
  }
  for(int i = 0; i < c; i++){
    cin >> ap2[i].v;
    ap2[i].c = 'y';
  }
  sort(ap.begin(), ap.end());
  sort(ap2.begin(), ap2.end());
  int xcnt = 0, ycnt = 0;
  for(int i = 0; i < a + b; i++){
    char c = ap[i].c;
    if(c == 'r'){
      if(xcnt == x) continue;
      xcnt++;
    }
    else{
      if(ycnt == y) continue;
      ycnt++;
    }
    sum.push_back(ap[i]);
  }
  n = sum.size();
  int cnt2 = 0;
  for(int i = n - 1; i >= 0; i--){
    if(ap2[cnt2].v > sum[i].v){
      sum[i] = ap2[cnt2];
      cnt2++;
    }
    else break;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += sum[i].v;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807


int n,z,w,a[2000];

signed main() {
    cin >> n >> z >> w;
    rep(i,n) cin >> a[i];
    if (n==1) cout << abs(a[0]-w) << endl;
    else cout << max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])) << endl;
}


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


using namespace std;

typedef long long ll;

#define pi 2*acos(0.0)
#define eps 1e-9
const int N = 1e7+1;
bool isprime[N];

void sieve()
{
    memset(isprime,true,sizeof(isprime));
    isprime[0]=isprime[1]=false;

    for(ll i=2; i*i<=N; i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i; j<=N; j+=i)
            {
                isprime[j]=false;
            }
        }
    }
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    if(s=="RRS" || s=="SRR")
    {
        cout<<2<<endl;
    }
    else if(s=="RRR")
    {
        cout<<3<<endl;
    }
    else if(s=="SSS")
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<1<<endl;
    }


}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        ans += 2*min(x, abs(x-k));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int n=s.length(),MIN=642;
    for(int i=0;i<n-2;i++){
        int ans=stoi(s.substr(i,3));
        MIN=min(abs(753-ans),MIN);
        //cout<<ans<<endl;
    }
    cout<<MIN<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <time.h>


using namespace std;

int main(void) {

	int a = 0, b = 0, c = 0, d = 0;
	cin >> a >> b >> c >> d;
	int ab = 0, bc = 0, ca = 0;

	if (a <= b && a <= c) {
		
		if (b <= c) {
			ab = abs(a - b);
			bc = abs(b - c);
			if (ab <= d  && bc <= d ) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;

			}
			return 0;
		}
		else {
			ca = abs(c - a);
			bc = abs(b - c);
			if (ca <= d) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;

			}
			return 0;
		}
	}

	if (b <= a && b <= c) {

		if (a <= c) {
			ab = abs(a - b);
			ca = abs(a - c);
			if ( ca <= d) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;

			}
			return 0;
		}
		else {
			ca = abs(c - a);
			bc = abs(b - c);
			if ( ca <= d) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;

			}
			return 0;
		}
	}

	if (c <= a && c <= b) {

		if (a <= b) {
			ab = abs(a - b);
			ca = abs(a - c);
			if ( ca <= d) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;

			}
			return 0;
		}
		else {
			ab = abs(b - a);
			bc = abs(b - c);
			if (ab <= d  && bc <= d) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;

			}
			return 0;
		}
	}
	

	
}



Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int get_sum(int x)
{
	int f=0;
	while(x>0)
	{
		f+=(x%10);
		x/=10;
	}
	return f;
}
int main()
{
	
	int n;
	scanf("%d",&n);
	int ans=0x3f3f3f3f;
	for(int i=1;i<n;i++)
		ans=min(ans,get_sum(i)+get_sum(n-i));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void square(int h, int w) {
	int i, j;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
	return;
}

int main(void) {
	int h, w;
	while (1) {
		scanf("%d%d", &h, &w);
		if (h == 0 && w == 0) break;
		else square(h, w);
	}
	return 0;
}



Measured memory_bytes: 2100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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(){ 
    string s; cin >> s;
    int cnt = 0; ll res = 0;
    for(char c:s){
        if(c=='B')cnt++;
        else res += cnt;
    }
    cout << res << ln;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
S = input()

hap = 0
bef = ''
for s in S:
  if s == bef:
    hap += 1
  bef = s

hap = hap + K*2
if hap > N-1:
  hap = N-1

print(hap)

Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int romanNumberToInt(string s){
  int n = s.size(), i, res = 0;

  rep(i,n){
    if(i < n-1 && s[i] == 'C' && s[i+1] == 'M'){ res += 900; i++; continue;}
    if(i < n-1 && s[i] == 'C' && s[i+1] == 'D'){ res += 400; i++; continue;}
    if(i < n-1 && s[i] == 'X' && s[i+1] == 'C'){ res += 90; i++; continue;}
    if(i < n-1 && s[i] == 'X' && s[i+1] == 'L'){ res += 40; i++; continue;}
    if(i < n-1 && s[i] == 'I' && s[i+1] == 'X'){ res += 9; i++; continue;}
    if(i < n-1 && s[i] == 'I' && s[i+1] == 'V'){ res += 4; i++; continue;}
    if(s[i] == 'M') res += 1000;
    else if(s[i] == 'D') res += 500;
    else if(s[i] == 'C') res += 100;
    else if(s[i] == 'L') res += 50;
    else if(s[i] == 'X') res += 10;
    else if(s[i] == 'V') res += 5;
    else if(s[i] == 'I') res++;
  }

  return res;
}

int main(){
  string in;

  while(cin >> in){
    printf("%d\n",romanNumberToInt(in));
  }

  return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999

using namespace std;

#define int long long

int32_t main(){
	int h, w;
	cin >> h >> w;
	string str[h];
	REP(i, h) cin >> str[i];

	REP(i, h-1){
		REP(j, w-1){
			bool flag=false;
			FOR(k, j+1, w){
				if(str[i][k]=='#'){
					flag=true;
				}
			}
			FOR(k, i+1, h){
				if(str[k][j]=='#' && flag){
					cout << "Impossible" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Possible" << endl;
}

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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if (x1 == 0) {
    cout << 1 << endl;
  }
  else if (x2 == 0) {
    cout << 2 << endl;
  }
  else if (x3 == 0) {
    cout << 3 << endl;
  }
  else if (x4 == 0) {
    cout << 4 << endl;
  }
  else if (x5 == 0) {
    cout << 5 << endl;
  }
}


Measured memory_bytes: 3588
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define int long long
#define INF 0x3fffffffffffffff
#define MOD 1000000007
using namespace std;
const double PI=acos(-1);
int k,l=1,r,d[8000001],p[8000001],ans;
string s;
int ksm(int a,int b)
{
	int tmp=1;
	while(b)
	{
		if(b&1)
		{
			tmp=(tmp*a)%MOD;
		}
		a=(a*a)%MOD;
		b>>=1;
	}
	return tmp;
}
int C(int a,int b)
{
	return d[b]*p[a]%MOD*p[b-a]%MOD;
}
const int _25=ksm(25,MOD-2);
signed main()
{
	cin>>k>>s;
	d[0]=p[0]=1;
	for(int i=1;i<=k+(int)s.length();++i)
	{
		d[i]=(d[i-1]*i)%MOD;
		p[i]=ksm(d[i],MOD-2);
	}
	l=ksm(25,k+1);
	r=ksm(26,MOD-2);
	for(int i=0;i<=k;++i)
	{
		l=(l*_25)%MOD;
		r=(r*26)%MOD;
		ans=(ans+l*r%MOD*C(k-i,k-i+s.length()-1)%MOD)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 35524
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
lint gcd( lint a, lint b ){
lint temp;
if( a < b ) { temp = a; a = b; b = temp; }
if( b < 1 ) return -1;
if( a % b == 0 ) return b;
return gcd( b, a % b );}

lint lcm(lint a, lint b) {
  return a/ gcd(a, b)*b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<lint> t(n);
    REP(i,n) cin>>t[i];
    lint ans = 1;
    REP(i,n){
        ans =lcm(ans,t[i]);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
S = input()
count = []

count.append(S.count('a'))
count.append(S.count('b'))
count.append(S.count('c'))

max = max(count)
min = min(count)

if count.count(max) == 2:
    if min == max-1:
        print ("YES")
    else :
        print("NO")
elif count.count(min) == 2:
    if min == max-1:
        print ("YES")
    else :
        print("NO")
elif max == min:
    print ("YES")
else:
    print("NO")

Measured memory_bytes: 3188
from collections import deque

INF = 9999999

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

que = deque([0])
dist = [INF] * N
pre = [0] * N
dist[0] = 0
while que:
    from_v = que.popleft()
    for to_u in to[from_v]:
        if dist[to_u] != INF:
            continue
        dist[to_u] = dist[from_v]+1
        pre[to_u] = from_v
        que.append(to_u)

print('Yes')
for i in range(N):
    if i == 0:
        continue
    print(pre[i]+1)


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

int main(){
 
 string o,e;
 cin>>o>>e;
 long int l = min(o.size(), e.size());
 long int i=0;
 for(i=0;i<l;i++){
     cout<<o[i]<<e[i];
 }
 if(o.size()>l)
    cout<<o[i];
 else if(e.size()>l)
    cout<<e[i];
 return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) {
        cin >> d.at(i);
    }
    int sum = 0;
    REP(i, N - 1)
    {
        FOR(j, N, i+1) {
            // cout << d.at(i) << " " << d.at(j) << endl;
            sum += d.at(i) * d.at(j);
        }
    }
    cout << sum << endl;
    return 0;
}

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

void A(){
	cout << "Alice\n";
}
void B(){
	cout << "Bob\n";
}
void D(){
	cout << "Draw\n";
}


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

	if (a == 1){
		if (b == 1)D();
		else A();
	}
	else if (b == 1)B();
	else if (a == b)D();
	else if (a > b)A();
	else B();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
LL gcd(LL a,LL b){return b>0?gcd(b,a%b):a;}
LL ksm(LL a,LL b){LL ans = 1;while(b){if(b&1) ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans % mod;}
int n;
int a[N];
int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i,n)
    {
        if(i == 1 || i == n)
            continue;
        if((a[i] < a[i + 1] && a[i] > a[i - 1]) || (a[i] > a[i + 1] && a[i] < a[i - 1]))
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())

l = []
c = 2 * x
l.append(c)
for nn in range(x):
    c += 2
    l.append(c)

flag = False
for ll in l:
    if ll == y:
        print("Yes")
        flag = False
        break

    else:
        flag = True

if flag:
    print("No")

Measured memory_bytes: 9184
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
void Radix32(int A[],const int sz)
{
  int temp[200001];const int bit=8;
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&((1<<bit)-1)]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&((1<<bit)-1)]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,A[200000];
  long K,count=0,l=-2e18,r=-l,mid;x=scanf("%ld",&K);
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

Measured memory_bytes: 3044
x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

li=[]
for i in a:
  for j in b:
    li.append(i+j)
li.sort(reverse=True)
 
ansli=[]
for i in c:
  for j in range(min(k,len(li))):
    ansli.append(i+li[j])
ansli.sort(reverse=True)
 
for i in range(k):
  print(ansli[i])

Measured memory_bytes: 143844
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int main() {
  int a, b; cin >> a >> b;
  cout << max({a+b, 2*a-1, 2*b-1}) << endl;

  return 0;
}


//EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define db double
#define ld long db
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}

signed main()
{
	ri n=read(),k=read();
	if(n<10)k+=(10-n)*100;
	cout<<k<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(X, 1, N + 1) {
		double x = X;
		x = (int)(x * 1.08);
		if (x == N) {
			cout << X << endl;
			return;
		}
	}
	cout << ":(" << endl;
}







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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}


void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int bits = 1; bits < (1<<N); bits++) {
        bool ok = true;
        for (int i = 1; i <= N; i++) {
            if (!(bits & (1 << (i-1)))) continue;
            for (int j=1; j <= A[i]; j++) {
                if (((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 384