akhauriyash/Code-Regression huggingface dataset:
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

const int mod = 1e9+7;
enum{N=200023};

il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if( b&1 ){
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }

struct Edge{ int nxt,to; } bow[N*2];
int head[N],tot_e;
il void add(int x,int y){
	tot_e++;
	bow[tot_e<<1]=(Edge){head[x],y};
	bow[tot_e<<1|1]=(Edge){head[y],x};
	head[y]=(head[x]=tot_e<<1)|1;
}

int fa[N],size[N];
void dfs1(int u){
	size[u] = 1;
	each(i,u){
		int v=bow[i].to;
		if( v==fa[u] ) continue;
		fa[v] = u;
		dfs1(v);
		size[u] += size[v];
	}
}
int n;
ll ans[N];
void dfs2(int u){
	if( fa[u] ){
		ans[u] = ans[fa[u]]*(n-size[u])%mod*inv(size[u])%mod;
	}
	each(i,u){
		int v=bow[i].to;
		if( v==fa[u] ) continue;
		dfs2(v);
	}
}


int main(){
	n=ci();
	rep(i,1,n-1) add(ci(),ci());
	dfs1(1);
	ans[1]=1;
	rep(i,1,n) ans[1]=ans[1]*size[i]%mod;
	dfs2(1);
	ll fac=1;
	rep(i,1,n) fac=fac*i%mod;
	rep(i,1,n) ans[i]=fac*inv(ans[i])%mod;
	rep(i,1,n) printf("%lld\n",(ans[i]+mod)%mod);
	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100002;
const int MAX_M = 20;

int sm[MAX_M][MAX_N];
int cnt[MAX_M];
int dp[1<<MAX_M];
int num[1<<MAX_M];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	int a;
	for(int i=1;i<n+1;i++){
		scanf("%d",&a);
		cnt[a-1]++;
		rep(j,m){
			if(j==a-1){
				sm[j][i] = sm[j][i-1] + 1;
				continue;
			}
			sm[j][i] = sm[j][i-1];
		}
	}
	rep(i,1<<m){
		dp[i] = INF;
	}
	rep(i,1<<m){
		rep(j,m){
			if(i & (1<<j)){
				num[i] += cnt[j];
			}
		}
	}
	dp[0] = 0;
	for(int i=1;i<(1<<m);i++){
		rep(j,m){
			if(i & (1<<j)){
				dp[i] = min(dp[i],dp[i-(1<<j)]+cnt[j]-(sm[j][num[i]]-sm[j][num[i-(1<<j)]]));
			}
		}
	}
	printf("%d\n",dp[(1<<m)-1]);
	return 0;
}

Measured memory_bytes: 19104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
string S;
vector<ll> v;
ll twosum[1002000];

ll combination(ll a, ll b) {
    ll ret = twosum[a] - twosum[b] - twosum[a-b];
    return ret == 0;
}

bool One() {
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        if(v[i] == 1) {
            sum += combination(N-1, i);
        }
        //cerr << i << " " << v[i] << " " << sum << endl;
    }
    return sum % 2 == 1;
}

bool Two() {
    for(int i = 0; i < N; i++) {
        if(v[i] == 1) return false;
    }
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        if(v[i] == 2) {
            sum += combination(N-1, i);
        }
    }
    return sum % 2 == 1;
}

int main() {
    for(ll i = 1; i <= 1e6; i++) {
        twosum[i] = twosum[i-1];
        ll copy = i;
        while(copy % 2 == 0) {
            copy /= 2;
            twosum[i]++;
        }
    }
    cin >> N >> S;
    v.resize(N - 1);
    for(int i = 0; i < N - 1; i++) {
        v[i] = abs(S[i] - S[i+1]);
    }
    N--;
    if(One()) {
        cout << 1 << endl;
    } else if(Two()) {
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<ll> a(n + 1), sum(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    vector<vector<ll>> dp(n, vector<ll>(n));
    for (int size = 2; size <= n; ++size) {
        for (int l = 0; l + size <= n; ++l) {
            const int r = l + size - 1;
            dp[l][r] = a[l + 1] + (sum[r + 1] - sum[l + 1]) + dp[l + 1][r];

            // [l, m] [m + 1, r] に分割
            for (int m = l; m < r; ++m)
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r]
                               + (sum[m + 1] - sum[l]) + (sum[r + 1] - sum[m + 1]));
        }
    }

    cout << dp[0][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1536
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

long double calc(vector<int> a) {
	map<int, int> next;
	REP(i, a.size()) {
		next[a[i]]++;
	}
	long double ans = 0;
	for (auto x : next) {
		ans -= (long double)x.second / (long double)a.size() * log((long double)x.second / (long double)a.size());
	}
	return ans;
}

long double gogo(tuple<int, int, int> a,vector<int> b) {
	vector<int> c;
	c.push_back(get<0>(a));
	while (c.size()-1 != b.size()) {
		c.push_back((c.back() * get<1>(a)) + get<2>(a));
		c.back() %= 256;
	}
	REP(i, b.size()) {
		b[i] += c[i+1];
		b[i] %= 256;
	}
	return calc(b);
}

void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		vector<int> inputs;
		REP(i, n) {
			int a;
			cin >> a;
			inputs.push_back(a);
		}
		tuple<int, int, int> ans = make_tuple(0, 0, 0);
		REP(S, 16) {
			REP(A, 16) {
				REP(C, 16) {
					if (gogo(ans, inputs)-eps > gogo(make_tuple(S, A, C),inputs)) {
						ans = make_tuple(S, A, C);
					}
				}
			}
		}
		cout << get<0>(ans) << " " << get<1>(ans) << " " << get<2>(ans) << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
ll idx[200005], rev[200005];
#define P 200003
typedef array<double, 2> ad;
ad ml(ad l, ad r){
  double tmp_x = l[0]*r[0] - l[1]*r[1];
  double tmp_y = l[0]*r[1] + l[1]*r[0];
  return ad{tmp_x, tmp_y};
}
vector<ad> fft(vector<ad> &f, bool inv) {
  int n, N = f.size();
  for(n=0;;n++) if(N == (1<<n)) break;
  for (int m=0;m<N;m++) {
    int m2 = 0;
    for(int i=0;i<n;i++) if(m&(1<<i)) m2 |= (1<<(n-1-i));
    if(m < m2) swap(f[m], f[m2]);
  }
  for(ll t=1;t<N;t*=2) {
    double theta = (double)(acos(-1.0)/t);
    ad w{cos(theta), sin(theta)};
    if(inv) w = ad{cos(theta), -sin(theta)};
    for(int i=0;i<N;i+=2*t){
      ad power{1.0, 0.0};
      for (int j=0;j<t;j++) {
        double tmp_x = f[i+j][0]+f[i+t+j][0]*power[0]-f[i+t+j][1]*power[1];
        double tmp_y = f[i+j][1]+f[i+t+j][0]*power[1]+f[i+t+j][1]*power[0];
        double tmp2_x = f[i+j][0]-f[i+t+j][0]*power[0]+f[i+t+j][1]*power[1];
        double tmp2_y = f[i+j][1]-f[i+t+j][0]*power[1]-f[i+t+j][1]*power[0];
        f[i+j][0] = tmp_x;
        f[i+j][1] = tmp_y;
        f[i+t+j][0] = tmp2_x;
        f[i+t+j][1] = tmp2_y;
        tmp_x = power[0]*w[0]-power[1]*w[1];
        tmp_y = power[0]*w[1]+power[1]*w[0];
        power[0] = tmp_x;
        power[1] = tmp_y;
      }
    }
  }
  if(inv) {
    for(int i=0;i<N;i++) {
      f[i][0] = (double)(f[i][0]/N);
      f[i][1] = (double)(f[i][1]/N);
    }
  }
  return f;
}

int main(){
  ll base = 1;
  for(int i=0;i<200002;i++){
    idx[base] = i;//num -> 2^x
    rev[i] = base;//2^x -> num
    base = (base * 2)%P;
  }

  ll n;scanf("%lld", &n);
  vll a(n);
  re(i, n) scanf("%lld", &a[i]);
  vector<ad> A(1<<19), B(1<<19);
  re(i, n) {
    if(a[i]==0) continue;
    A[idx[a[i]]][0]++;
    B[idx[a[i]]][0]++;
  }
  A = fft(A, 0);
  B = fft(B, 0);
  for(int i=0;i<A.size();i++) A[i] = ml(A[i], B[i]);
  A = fft(A, 1);
  ll ans = 0;

  for(int i=0;i<=200002;i++){
    ll tmp = (ll)round(A[i][0]) + (ll)round(A[i+200002][0]);
    ll num = rev[i];
    //if(tmp!=0) std::cout << tmp << " " << num << '\n';
    ans += tmp * num;
  }

  for(int i=0;i<n;i++) ans -= (a[i]*a[i])%P;
  std::cout << ans/2 << '\n';
}


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

const int mod = 1000*1000*1000+7;
const int N = 55;

int memo[N][N][N*N];

int mul(int a, int b) {
	return 1LL * a * b % mod;
}

void add_self(int& a, int b) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
}

int dp(int i, int j, int k) {
	if(i < 0 || j < 0 || k < 0 || j == N) return 0;
	int& ans = memo[i][j][k];
	if(ans != -1) return ans;
	if(i == 0 && j == 0 && k == 0) {
		return ans = 1;
	}
	ans = 0;
	add_self(ans, mul(2*j+1, dp(i-1, j, k-2*j)));
	add_self(ans, mul(mul(j+1, j+1), dp(i-1, j+1, k-2*j)));
	add_self(ans, dp(i-1, j-1, k-2*j));
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	memset(memo, -1, sizeof memo);
	cout << dp(n, 0, k) << endl;
}


Measured memory_bytes: 35968
#include<stdio.h>

#define M 100005

 

int n;
  int A[M];
int B[M];
int C[M];
int DG[M];
 struct Node{ int p, l, r;};
struct Node 
Tree[M];

int getHeight(int u,int left,int right){
 
  if(Tree[u].l == -1 && Tree[u].r == -1) return 0;
   
  if(Tree[u].l != -1){ 
    left = getHeight(Tree[u].l,left,0)+1;
  }
  if(Tree[u].r != -1){
 right = getHeight(Tree[u].r,0,right)+1;
  } 
  if(left > right) {
    return left;
  }
  else{
    return right;
  }
}
 
int getDepth(int u){
  int d = 0;
  int i = 0;
  while(1){
    if(Tree[u].p == -1) break;
    d++;
    u = Tree[u].p;
  }
  return d;
}
 

 
void print(int u){
   
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "

,u,Tree[u].p, C[u],DG[u], B[u], A[u]);
   
  if( Tree[u].p == -1) printf("root\n");
  else if(Tree[u].l == -1 && Tree[u].r == -1) {
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}
 
 
main(){
  int i=0, j=0;
  int v, l;
  
   
  scanf("%d", &n);
   
  while(i < n){
    Tree[i].p =-1;
      Tree[i].l =-1;
 Tree[i].r = -1;

    i++;
  }


  i = 0;   
  while(i < n){
    scanf("%d",&v);
    scanf("%d %d",&Tree[v].l,&Tree[v].r);
    Tree[Tree[v].l].p = v;
    Tree[Tree[v].r].p = v;
    i++;
  }

  i=0;


  while(i < n){
    C[i] = getSibling(i);
    DG[i] = getDegree(i);
    B[i] = getDepth(i);
    A[i] = getHeight(i,0,0);
    i++;
  }  
     
  for ( i = 0; i < n; i++ ){

 print(i);

  }
  return 0;
}


int getDegree(int u){
  if((Tree[u].l == -1) && (Tree[u].r == -1)) return 0;
  else if((Tree[u].l == -1) || (Tree[u].r == -1)) return 1;
  else return 2;
}
 
int getSibling(int u){
   
   
  if(Tree[u].p == -1) return -1;
   
  else if(Tree[Tree[u].p].l != u){ 
    return Tree[Tree[u].p].l;  
  }
   
  else { 
    return Tree[Tree[u].p].r;  
  }
}

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

const int MAXN = 100005;
typedef long long ll;

int col[MAXN];
vector<int> g[MAXN];

bool dfs(int v, int c)
{
    col[v] = c;
    bool flag = true;
    for (int i = 0; i < g[v].size(); i++)
    {
        int to = g[v][i];
        if (!col[to]) flag &= dfs(to, 3-c);
        else if (col[to] != 3-c) flag = false;
    }
    return flag;
}


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

    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    ll iso = 0, bip = 0, othr = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!col[i])
        {
            if (g[i].size() == 0) iso++;
            else if (dfs(i, 1)) bip++;
            else othr++;
        }
    }

    cout << (n-iso)*iso + iso*n + 2*bip*bip + 2*othr*bip + othr*othr;

    return 0;
}



Measured memory_bytes: 10880
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String line2 = sc.nextLine();
        
        int n = Integer.parseInt(line1);
        String[] array = line2.split(" ");
        
        int maxPosition = 0;
        int minPosition = 101;
        
        for(int i = 0; i < n; i++)
        {
            int bufPosition = Integer.parseInt(array[i]);
            if(bufPosition > maxPosition)
            {
                maxPosition = bufPosition;
            }
            if(bufPosition < minPosition)
            {
                minPosition = bufPosition;
            }
        }
        int minSum = 1000000;
        for(int p = minPosition; p <= maxPosition; p++)
        {
            int bufSum = 0;
            for(int i = 0; i < n; i++)
            {
                int bufPosition = Integer.parseInt(array[i]);
                bufSum += (bufPosition - p) * (bufPosition - p);
            }
            if(bufSum < minSum)
            {
                minSum = bufSum;
            }
        }    
        System.out.println(minSum);
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    enum Color { white, gray, black }

    class Program
    {
        static readonly int INFTY = int.MaxValue;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[][] table = new int[n][];
            for (int i = 0; i < n; i++)
            {
                table[i] = Enumerable.Repeat(INFTY, n).ToArray();
            }

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int k = int.Parse(input[1]);

                for (int j = 0; j < k; j++)
                {
                    int v = int.Parse(input[2 + j * 2]);
                    int c = int.Parse(input[3 + j * 2]);

                    table[u][v] = c;
                }
            }

            Dijkstra(table, n);
        }

        static void Dijkstra(int[][] table, int n)
        {
            int i, minCost;
            int[] minCostArr = Enumerable.Repeat(INFTY, n).ToArray();
            Color[] colors = new Color[n];

            minCostArr[0] = 0;
            colors[0] = Color.gray;

            while (true)
            {
                minCost = INFTY;
                int u = -1;

                for (i = 0; i < n; i++)
                {
                    if (minCost > minCostArr[i] && colors[i] != Color.black)
                    {
                        u = i;
                        minCost = minCostArr[i];
                    }
                }

                if (u == -1) break;

                colors[u] = Color.black;

                for (i = 0; i < n; i++)
                {
                    if (colors[i] != Color.black && table[u][i] != INFTY)
                    {
                        if (minCostArr[i] > minCostArr[u] + table[u][i])
                        {
                            minCostArr[i] = minCostArr[u] + table[u][i];
                            colors[i] = Color.gray;
                        }
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (i = 0; i < n; i++)
            {
                int temp = minCostArr[i] == INFTY ? -1 : minCostArr[i];
                sb.AppendLine(i + " " + temp);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9744
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> c(n);
    REP(i, k){
        ll d;
        cin >> d;
        REP(j, d){
            ll a;
            cin >> a;
            a--;
            c[a]++;
        }
    }
    ll cnt = 0;
    REP(i, n){
        if(c[i] == 0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
#include <iostream>

#define DEBUG1  false

int main(void)
{
    std::string S;
    std::cin >> S;

    std::string d;
    for (int i = 0; i < S.length(); i++)
    {
        switch (S[i])
        {
        case '0':
            d += '0';
            break;

        case '1':
            d += '1';
            break;

        case 'B':
            d = d.substr(0, d.length() - 1);
            break;

        default:
            break;
        }
#if DEBUG1
        std::cout << "DEBUG1: S[" << i << "]: " << S[i] << " d: " << d << std::endl;
#endif
    }
    std::cout << d << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {

	int sum = 0, book[9] = {};
	const int f = 5;

	while(f == 5) {

		std::cin >> sum;

		if (sum == 0) {
			goto chin;
		}

		for (int i = 0; i < 9; i++) {
			std::cin >> book[i];
		}
		for (int j = 0; j < 9; j++) {
			sum = sum - book[j];
		}
		std::cout << sum << std::endl;

	}
	chin:
	return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int a,b;
int main()
{
   scanf("%d%d",&a,&b);
   if(a<b)
   {
       printf("0\n");
   }
   else printf("%d\n",a-b);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    //配列の定義.
    String a[] = new String[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.next();
    }
    Arrays.sort(a);
    int ans = n;
    for(int i = 0; i < n - 1; i++) {
      //文字列の比較
      //a[i] == a[i + 1]でなく .equals を使う.
      if(a[i].equals(a[i + 1])) ans--;
    }
    System.out.println(ans);
  }
}



Measured memory_bytes: 70648
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main(){
        goku
     string s,t;
     cin>>s>>t;
     cout<<t<<s;
       return 0;
    }


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

using namespace std;

int H, W;
char a[50][50];
bool has_reached[50][50] = {};
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int n = 0;

int main() {
    cin >> H >> W;
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            char c; cin >> c;
            a[i][j] = c;
            if(c == '.') ++n;
        }
    }

    // BFS
    queue<vector<int>> q;
    q.push({0, 0, 0});
    int d = -1;

    while(!q.empty()) {
        vector<int> v = q.front(); q.pop();

        if(v[0] == H-1 && v[1] == W-1) {
            d = v[2];
            break;
        }

        for(int i = 0; i < 4; ++i) {
            int ny = v[0] + dy[i];
            int nx = v[1] + dx[i];

            if(0 <= nx && nx < W && 0 <= ny && ny < H && a[ny][nx] == '.' && !has_reached[ny][nx]) {
                has_reached[ny][nx] = true;
                q.push({ny, nx, v[2] + 1});
            }
        }
    }

    if(d == -1) {
        cout << -1 << endl;
    } else {
        cout << n - d - 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

#define EPS (1e-10)
#define equals (fabs((a)-(b)<EPS)
int n;

struct Point
{
    double x, y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator +(Point a)
    {
        return Point(x+a.x,y+a.y);
    }
    Point operator -(Point a)
    {
        return Point(x-a.x,y-a.y);
    }
    Point operator *(double a)
    {
        return Point(x*a,y*a);
    }

    double norm()
    {
        return x*x+y*y;
    }
};
Point p1,p2,p;
double cross(Point a,Point b)
{
    return a.x*b.y-b.x*a.y;
}
double dot(Point a,Point b)
{
    return a.x*b.x+a.y*b.y;
}
void solve()
{
    Point a=p2-p1;
    Point b=p-p1;
    double r=dot(a,b)/a.norm();
    Point p=p1+a*r;
    printf("%.8lf %.8lf\n",p.x,p.y);
}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf",&p.x,&p.y);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3244
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0 ; i < n ; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j < n ; j++) {
                if (i != j) {
                    int p = x[i] - x[j];
                    int q = y[i] - y[j];
                    String s = p + "," + q;
                    if (map.containsKey(s)) {
                        map.put(s, map.get(s) + 1);
                    } else {
                        map.put(s, 1);
                    }
                }
            }
        }

        int max = 0;
        for (Integer num : map.values()) {
            max = Math.max(max, num);
        }

        System.out.println(n - max);
    }


}

Measured memory_bytes: 23892
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		HashMap< Character, Integer> h = new HashMap<Character, Integer>();

		h.put('I',1);//I Í1, 

		h.put('V',5);//V Í5,

		h.put('X',10);//X Í10, 

		h.put('L',50);//L Í50, 

		h.put('C',100);// C Í100,

		h.put('D',500);// D Í500,

		h.put('M',1000);//M Í1000

		for(;sc.hasNext();){

			String s = sc.next();

			int prev =0;

			int sum = 0;

			for(int i = s.length()-1; i >= 0; i--){

				int value= h.get(s.charAt(i));

				if(prev <= value){

					sum += value;

				}else{

					sum -= value;

				}

				prev = value;

			}

			System.out.println(sum);

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#include<string.h>
#include<iostream>
using namespace std;

int a[100], b[100];
signed main() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += a[j];
		}
		for (int j = i; j < n; j++) {
			sum += b[j];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=400005,INF=1<<30;
int dp[MAX][2];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K,C;cin>>N>>K>>C;
    C++;
    string S;cin>>S;
    
    if(C==1){
        int cnt=0;
        for(int i=0;i<N;i++){
            if(S[i]=='o') cnt++;
        }
        if(cnt==K){
            for(int i=0;i<N;i++){
                if(S[i]=='o') cout<<i+1<<"\n";
            }
        }else{
            cout<<"\n";
        }
        
        return 0;
    }
    
    dp[0][0]=0;
    
    for(int i=1;i<=N;i++){
        if(S[i-1]=='o'){
            if(i-C>=0) dp[i][0]=max(dp[i-1][0],dp[i-C][0]+1);
            else dp[i][0]=max(dp[i][0],1);
        }else{
            dp[i][0]=dp[i-1][0];
        }
    }
    
    for(int i=N;i>=1;i--){
        if(S[i-1]=='o'){
            dp[i][1]=max(dp[i+1][1],dp[i+C][1]+1);
        }else{
            dp[i][1]=dp[i+1][1];
        }
    }
    
    vector<int> imos(400005);
    
    for(int i=1;i+C<=N;i++){
        if(dp[i][0]+dp[i+C][1]>=K){
            imos[i+1]++;
            imos[i+C]--;
        }
    }
    
    for(int i=1;i<=400003;i++) imos[i]+=imos[i-1];
    
    for(int i=1;i<=N;i++){
        if(dp[i+1][1]>=K) imos[i]=1;
        if(dp[i-1][0]>=K) imos[i]=1;
    }
    
    for(int i=1;i<=N;i++){
        if(S[i-1]=='o'&&imos[i]==0){
            cout<<i<<"\n";
        }
    }
}



Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main()
{
    int n,h,m,ans=1;
    cin>>n;
    cin>>m;
    for(int i=1;i<n;i++)
    {
        cin>>h;
        if(h>=m) ans++,m=h;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    vector<ll> a(N+2,0);

    ll sum = 0;
    ll ma = -INF, mi = INF;
    for(int i=1;i<=N+1;++i){
        if(i!=N+1) cin >> a[i];
        sum += abs(a[i] - a[i-1]);
        if(ma < a[i]) ma = a[i];
        if(mi > a[i]) mi = a[i];
    }

    for(int i=1;i<=N;++i){
        ll c = abs(a[i+1] - a[i]);
        ll p = abs(a[i] - a[i-1]);
        ll pp = abs(a[i+1] - a[i-1]);
        ll d = c+p-pp;
        ll ans = sum - d;
        cout << ans << endl;
    }

}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int result = b;
        if(a<=5) {
            result = 0;
        }
        else if(a<=12) {
            result = b/2;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 22228
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

int main()
{
    string S;
    cin >> S;

    map<char, int> mp;

    rep (i, SZ(S))
    {
        mp[S[i]] = 0;
    }

    if (mp.size() != 2)
    {
        cout << "No" << "\n";
    }
    else
    {
        char c = S[0];
        int cnt = 0;
        rep (i, SZ(S))
        {
            if (S[i] == c)
            {
                cnt++;
            }
        }
        if (cnt == 2)
        {
            cout << "Yes" << "\n";
        }
        else
        {
            cout << "No" << "\n";
        }
    }


    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
	}

	current := 0
	flag := true
	for _, h := range H {
		if current > h {
			flag = false
			break
		} else if current < h {
			current = h - 1
		}
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003;
int n, m, head[N], to[N << 1], nxt[N << 1];
LL ans;
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
int tot, tot1, tot2, dep[N];
bool vis[N], flag;
inline void dfs(int x){
	vis[x] = true;
	tot1 += dep[x] & 1; ++ tot;
	for(Rint i = head[x];i;i = nxt[i])
		if(!vis[to[i]]){
			dep[to[i]] = dep[x] + 1;
			dfs(to[i]);
		} else flag |= !(dep[x] - dep[to[i]] & 1);
}
int main(){
	scanf("%d%d", &n, &m);
	for(Rint i = 1;i <= m;i ++){
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b); add(b, a);
	}
	for(Rint i = 1;i <= n;i ++)
		if(!vis[i]){
			tot = tot1 = flag = 0; dfs(i);
			if(flag) ans += (LL) tot * (tot - 1) / 2;
			else ans += (LL) tot1 * (tot - tot1);
		}
	printf("%lld", ans - m);
}

Measured memory_bytes: 3072
#include<stdio.h>

int main()
{
   char a[4][4];
   int i,j,k;
   for(i=0;i<2;i++)
    scanf("%s",a[i]);
   if(a[0][0]==a[1][2])
   {
       if(a[0][1]==a[1][1])
       {
           if(a[0][2]==a[1][0])
           {
               printf("YES");
           }else
           printf("NO");
       }
       else
        printf("NO");

   }else
   printf("NO");

      return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}


const ll SIZE = 1e7+10;
ll a,b;
ll mema[SIZE],memb[SIZE];

int main(){
    cin >> a >> b;
    vector<ll> aso,bso;

    ll n = gcd(a,b);

    ll mem_b = sqrt(n)+1;
    for(ll i = 2; i <= mem_b; i++){
        if(n == 1)  break;
        if(n % i == 0){
            while(n % i == 0){
                n /= i;
            }
            ++memb[i];
        }
    }

    ll ans = 1;
    for(ll i = 2; i <= SIZE; i++){
        if(memb[i] > 0){
            ++ans;
        }
    }

    if(n > 1)   ++ans;
    cout << ans << endl;

}

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

#define 	ll 						long long int
#define 	pb 						push_back
#define 	mp 						make_pair
#define 	fast 					ios_base::sync_with_stdio(false);cin.tie(NULL);
#define 	ff 						first
#define 	ss 						second
#define 	nil 					-10e+9
#define 	initial 				0
#define 	waiting 				1
#define 	visit 					2
#define 	inf  					10e+9
#define 	mx   					200005
#define 	mxx  					1000005
#define 	mod  					1000000007
#define 	pr   					pair<ll,ll>
#define 	pp_queue 			priority_queue<pr,vector<pr>, greater<pr> >
#define 	dp_queue 			priority_queue<int,vector<int>, greater<int> >
#define 	sp_queue 			priority_queue<int>
#define 	fr(i,p,q)			for(int i=p;i<q;++i)
#define 	frr(i,p,q) 		for(int i=p;i<=q;++i)
#define 	mem(a,b) 			memset(a,b,sizeof(a))
#define 	len(a)   			(int)a.size()
#define 	input  				freopen("input.txt", "r", stdin);
#define 	output 				freopen("output.txt", "w", stdout);
#define 	debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

ll power(ll a,ll b){ll aa=1;while(b){if(b&1){aa=aa*a;aa%=mod;}a=a*a;a%=mod;b/=2;}return aa;}

using namespace std;

int main()
{
  int n;
	cin>>n;
	ll a[n];
	fr(i,0,n) cin>>a[i];

	ll lcm=a[0];

	fr(i,1,n){
		lcm=(lcm*a[i])/__gcd(a[i],lcm);
	}
	ll deno=0;

	fr(i,0,n){
		deno+=lcm/a[i];
	}
	cout<<setprecision(15)<<lcm/(deno*1.0)<<"\n";

}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

cnt = 0
for i, x in enumerate(A):
	if x < 0:
		cnt += 1
		A[i] *= -1

if cnt%2:
	print(sum(A) - 2*min(A))
else:
	print(sum(A))


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    int p = n/100;
    for(int i = 100*p; i <= 105*p; ++i) {
        if(i==n) {
            cout << 1 << '\n';
            return 0;
        } 
    }
    cout << 0 << '\n';
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  string s;
  ll c=0, p=0;
  cin >> s;

  forll(i, 0, s.size()){
	if (p == (ll)(s[i] - '0'))
	  c += 1;
	p = 1 - p;
  }
  cout << min(c, (ll)s.size()-c) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

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


Measured memory_bytes: 256
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

# 青木くんが左に動かせるということは、駒の生存可能範囲の右端を1つのばせる
# 高橋くんが左に動かせるということは、駒の生存可能範囲の左端を1つ縮める
l = 1
r = W
u = 1
d = H
for s, t in zip(S[::-1], T[::-1]):
    if t == 'L':
        r = min(r + 1, W)
    elif t == 'R':
        l = max(1, l - 1)
    elif t == 'U':
        d = min(d + 1, H)
    else:
        u = max(u - 1, 1)

    if s == 'L':
        l += 1
    elif s == 'R':
        r -= 1
    elif s == 'U':
        u += 1
    else:
        d -= 1

    if l > r or u > d:
        print('NO')
        exit()

if l <= sc <= r and u <= sr <= d:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 4024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll N, R;
    input(N, R);

    if (N >= 10)
    {
        cout << R << endl;
    }
    else
    {
        cout << (R + 100 * (10 - N)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long a[n];
    for(long long i=0; i<n; i++){
        cin >> a[i];
    }
    long long b[n];
    for(long long i=0; i<n; i++){
        b[i] = a[i] - (i+1);
    }
    sort(b,b+n);
    long long mid = b[n/2];
    long long ans1=0,ans2=0;
    for(long long i=0; i<n; i++){
        ans1 += abs(a[i]-mid-i-1);
        ans2 += abs(a[i]-mid-i-2);
    }
    cout << ((ans1<ans2)? ans1:ans2) << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int l = s.length();
    int ans = l;
    int seen = 0;

    for(int i = 0; i < l; i++){
        if(s[i] == 'T' && seen == 0){
            continue;
        }
        else if(s[i] == 'T' && seen != 0){
            ans -= 2;
            seen--;
        }
        else{
            seen++;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
fun main (args:Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map(String::toLong)
    var ans = 1L
    if(0 in list) {
        print(0)
        return
    }
    for (i in 0..n-1){
        if(list[i] <= 1000000000000000000/ans){
            ans *= list[i]
        }
        else{
            print("-1")
            return
        }
    }
//    list.forEach{
//        if(ans * it <= 1000000000000000000/1){
//            ans *= it
//        }
//        else{
//            print("-1")
//            return
//        }
//    }
    print(ans)
}


Measured memory_bytes: 61616
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5+5;

int par[MAX];
int rk[MAX];
//初期化
void init(int n){
	for(int i=1;i<=n;i++){
		par[i]=i;
		rk[i]=0;
	}
}
//根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x]=find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(rk[x]<rk[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(rk[x]==rk[y])rk[x]++;
	}
}
//xとyが同じ集合に属するか判定
bool same(int x,int y){
	return find(x)==find(y);
}

//言語iの話者リスト
vector<int> ct[MAX];

int main(){
	int N,M;
	cin>>N>>M;
	rep1(i,N){
		int k;
		cin>>k;
		rep(j,k){
			int l;
			cin>>l;
			ct[l].push_back(i);
		}
	}
	
	init(N);
	rep1(i,M){
		int l=ct[i].size();
		if(l<=1)continue;
		else{
			int p=ct[i][0];
			rep1(j,l-1){
				int q=ct[i][j];
				unite(p,q);
			}
		}
	}
	bool ans=true;
	rep1(i,N-1){
		if(!same(i,N)){
			ans=false;
			break;
		}
	}
	if(ans)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
 
int main(){
  int l, i=0, a[3];
  while(cin>>l){
    a[i] = l;
    i++;
  }
  sort(a,a+3);
  int ans = a[0] + a[1];
  cout<< ans <<endl; 
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+4;
const int A=1e6+4;
int vis[A];
int n,a[N];
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main() {
//	freopen("in3.txt","r",stdin);
	n=read();
	for (register int i=1;i<=n;++i) {
		a[i]=read();
		++vis[a[i]];
	}
	int cnt=0;
	for (register int i=1;i<=n;++i) {
		if (vis[1]) {
			if (a[i]^1) continue;
			else if (vis[1]>1) continue;
			else {
				++cnt;
				continue;
			}
		}
		if (vis[a[i]]>1) continue;
		bool ok=true;
		for (int x=2;x*x<=a[i];++x)
			if (a[i]%x==0) {
				int y=a[i]/x;
				if (vis[x]||vis[y]) {
					ok=false;
					break;
				}
			}
		cnt+=ok;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 8436
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,x,a[100],ans=0,bns=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    
    for(int i=0;i<m;i++){
        if(a[i]<x){
            bns++;
        }
        else if(x<a[i]){
            ans++;
        }

    }
    
    cout<<min(ans,bns)<<endl;
}


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

int main() {
  ll n, a;
  cin >> n;
  multiset<ll> st;
  rep(i, n) {
    cin >> a;
    st.insert(a);
  }
  ll ans = 0;
  ll p2 = pow(2, 34);
  while(!st.empty()) {
    auto it = st.end();
    st.erase(--it);
    ll p = p2;
    while(p > *it) {
      p /= 2;
      auto jt = st.find(p - *it);
      if(jt == st.end()) continue;
      st.erase(jt);
      ans++;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9600
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][] MAX, MEMO;

void main()
{
    auto s = readln.chomp.to!(wchar[]);
    auto t = readln.chomp.to!(wchar[]);

    MEMO.length = s.length;
    MAX.length = s.length;
    foreach (i; 0..s.length) {
        MEMO[i].length = t.length;
        MAX[i].length = t.length;
        MAX[i][] = -1;
    }

    int solve(int i, int j) {
        if (i == s.length || j == t.length) return 0;
        if (MAX[i][j] != -1) return MAX[i][j];

        auto r1 = s[i] == t[j] ? solve(i+1, j+1) + 1 : -1;
        auto r2 = solve(i+1, j);
        auto r3 = solve(i, j+1);

        auto max_r = max(r1, r2, r3);

        if (max_r == r1) {
            return MAX[i][j] = r1;
        } else if (max_r == r2) {
            MEMO[i][j] = 1;
            return MAX[i][j] = r2;
        } else {
            MEMO[i][j] = 2;
            return MAX[i][j] = r3;
        }
    }
    solve(0, 0);

    wchar[] answer(int i, int j) {
        if (i == s.length || j == t.length) return [];

        switch (MEMO[i][j]) {
            case 0:
                return s[i] ~ answer(i+1, j+1);
            case 1:
                return answer(i+1, j);
            case 2:
                return answer(i, j+1);
            default:
                return [];
        }
    }
    writeln(answer(0, 0));
}

Measured memory_bytes: 86908
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b){
        if((a*b)&1){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll N;
    string s;
    cin >> N >> s;
    int r = 0, b = 0;
    for (char c : s)
    {
        if (c == 'R')
        {
            ++r;
        }
        else
        {
            ++b;
        }
    }
    cout << (r > b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 300 + 10;
int n, m, l, ques, g[maxn][maxn], d[maxn][maxn];

int main(int argc, char const *argv[])
{
  memset(g, 0x3f, sizeof g), memset(d, 0x3f, sizeof d);
  scanf("%d%d%d", &n, &m, &l);
  for(int i = 1; i <= n; ++i) g[i][i] = 0, d[i][i] = 0;
  for(int u = 0, v = 0, w = 0, i = 1; i <= m; ++i) scanf("%d%d%d", &u, &v, &w), g[u][v] = g[v][u] = w;
  for(int k = 1; k <= n; ++k) {
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  }
  for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) if( i != j && g[i][j] <= l ) d[i][j] = 1;
  for(int k = 1; k <= n; ++k) {
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
  scanf("%d", &ques);
  for(int u = 0, v = 0, i = 1; i <= ques; ++i) scanf("%d%d", &u, &v), printf("%d\n", d[u][v] == 0x3f3f3f3f ? -1 : d[u][v] - 1);

  return 0;
}

Measured memory_bytes: 1152