akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

def selectionSort():
  cnt = 0
  for i in range(n):
    minj = i
    for j in range(i, n):
      if a[j]<a[minj]:
        minj = j
    if i!=minj:
      a[i], a[minj] = a[minj], a[i]
      cnt += 1
  return cnt

cnt = selectionSort()
print(" ".join(map(str, a)))
print(cnt)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll _lcm(ll a,ll b){
    if (a==-1 || b==-1)return -1;
    return (a/__gcd(a,b))*b;
}
ll a[1000000];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    ll m;
    cin>>n>>m;
    m=m*2;
    ll L = 1;
    for (int i=1;i<=n;i++) {
        ll x;
        cin>>x;
        a[i]=x;
        L = _lcm(L, x);
        if (L>m)L=-1;
    }
    if (L==-1){
        cout<<0<<endl;
        return 0;
    }
    for (int i=1;i<=n;i++)
    {
        ll num = L/a[i];
        if (num%2==0){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<1+(m-L)/(2*L)<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int h[N], cost[N];
  for (int i=0; i<N; i++) cin >> h[i];
  cost[0] = 0;
  cost[1] = abs(h[1]- h[0]);
  for (int i=2; i<N; i++) {
    int c1 = abs(h[i] - h[i-1]) + cost[i-1];
    int c2 = abs(h[i] - h[i-2]) + cost[i-2];
    if (c1 < c2) cost[i] = c1;
    else cost[i] = c2;
  }
  cout << cost[N-1] << endl;
}


Measured memory_bytes: 1024
from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] >= 0:
    M = sum(A[1:])-A[0]
    print(M)
    for i in range(N-1):
        if i == 0:
            x = A[0]
            y = A[N-1]
            print(x, y)
        elif i <= N - 3:
            x = new
            y = A[N-1-i]
            print(x, y)
        else:
            x = A[N-1-i]
            y = new
            print(x, y)
        new = x - y
elif A[-1] <= 0:
    M = sum(A[:-1]) * (-1) + A[-1]
    print(M)
    for i in range(N-1):
        if i == 0:
            x = A[N-1]
            y = A[0]
            print(x, y)
        elif i <= N-3:
            x = new
            y = A[i]
            print(x, y)
        else:
            x = new
            y = A[i]
            print(x,y)
        new = x- y
else:
    absa = [abs(i) for i in A]
    M = sum(absa)
    print(M)
    if A[1] >= 0 :
        for i in range(N - 1):
            if i == 0:
                x = A[0]
                y = A[N - 1]
                print(x, y)
            elif i <= N - 3:
                x = new
                y = A[N - 1 - i]
                print(x, y)
            else:
                x = A[N - 1 - i]
                y = new
                print(x, y)
            new = x - y
    else:
        A = deque(A)
        for i in range(N - 1):
            if i <= N - 3 and A[1] < 0:
                x = A.pop()
                y = A.popleft()
                print(x, y)
                A.append(x-y)
            elif i <= N-3 :
                x = A.popleft()
                y = A.pop()
                print(x,y)
                A.appendleft(x-y)
            else:
                # print(A)
                x = A.pop()
                y = A.popleft()
                print(x, y)




Measured memory_bytes: 14740
#include <stdio.h>
#include <math.h>

int main(void)
{
  double x1,x2,y1,y2;
  double distance;

  scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
  
  distance = ((x2 - x1) * (x2 - x1))+((y2 - y1) * (y2 - y1));

  printf("%f\n",sqrt(distance));
  
  return(0);
}

Measured memory_bytes: 652
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector< vector<int> > G(n);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	queue<int> que;
	vector<int> dist(n, 1e9 + 10);
	que.push(0);
	dist[0] = 0;
	
	bool yes = true;
	
	while( !que.empty() ) {
		int now = que.front();
		que.pop();
		
		for(auto& v : G[now]) {
			if( dist[v] > dist[now] + 1 ) {
				dist[v] = dist[now] + 1;
				que.push(v);
			}
		}	
	}
	
	if( dist[n - 1] == 2 ) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}


Measured memory_bytes: 13168
ans = 0
N = int(input())
L = [0] * 10**6
ans = 0
for i in range(2,10**6):
    while N%i == 0:
        N = N//i
        L[i] += 1
if N != 1:
    L[10**6 - 1] = 1
L.sort(reverse=True)
for i in range (10**6):
    if L[i] == 0:
        break
    k = 1
    while L[i] > 0:
        L[i] -= k
        if L[i] >= 0:
            k += 1
            ans += 1
print(ans)

Measured memory_bytes: 16796
// Problem : E - M's Solution
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e18
#define PI acos(-1.0)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int x[15],y[15],p[15],D[15],d[15];
ll ans[16];

void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>p[i];
    memset(ans,0x3f,sizeof(ans));
    ans[0] = 0;
    for(int i=0;i<n;i++){
        D[i] = min(abs(x[i]),abs(y[i]));
        ans[0] += (ll)D[i]*p[i];
    } 
    for(int mask1=0;mask1<(1<<n);mask1++){
        for(int mask2=mask1;~mask2;mask2=(mask2-1)&mask1){
            memcpy(d,D,sizeof(d));
            for(int i=0;i<n;i++){
                if((mask1>>i)&1){
                    if((mask2>>i)&1){
                        for(int j=0;j<n;j++) d[j] = min(d[j],abs(x[i]-x[j]));
                    } else {
                        for(int j=0;j<n;j++) d[j] = min(d[j],abs(y[i]-y[j]));
                    }
                }
            }
            ll cur = 0;
            for(int i=0;i<n;i++) cur += (ll)d[i]*p[i];
            int oc = __builtin_popcountll(mask1);
            ans[oc] = min(ans[oc],cur);
            if(!mask2) break;
        }
    }
    for(int i=0;i<=n;i++) cout<<ans[i]<<'\n';
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;
typedef pair<string, ll> psi;

ll p;

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n, 0) { }
  T sum(int i, int j) {
    if (i == 0) {
      T S = 0;
      for (j; j >= 0; j = (j & (j + 1)) - 1) S = (S+x[j])%p;
      return S;
    } else return sum(0, j) - sum(0, i-1);
  }
  void add(int k, T a) {
    for (; k < x.size(); k |= k+1) x[k] = (x[k]+a)%p;
  }
};

int main() {
  ll a, b;
  while(cin>>a>>b>>p,a||b||p) {
    vector<psi> v;
    for (ll i=a; i<=b; ++i) {
      char tmp[30];
      sprintf(tmp, "%lld", i);
      v.push_back(psi(string(tmp), i-a));
    }
    sort(ALL(v));
    int table[b-a+1];
    REP(i, v.size()) {
      table[v[i].second] = i;
    }
    int n = b-a+1;
    // REP(i, b-a+1)
    //   cout << table[i] << " ";
    // cout << endl;

    fenwick_tree<ll> dp(n);
    REP(i, n) {
      //cout << dp.sum(0, table[i]) + 1 << " ";
      dp.add(table[i], dp.sum(0, table[i]) + 1);
    }
    //cout << endl;
    cout << dp.sum(0, n-1) << endl;
  }
}

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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define debug(x) cerr << #x << " = " << x << endl;
#define puts_name() cerr << "\n\t\t\t\tAdson_S\n";
#define SET(c, v) memset(c, v, sizeof c)
#define pi 3.14159265358979323846264338
#define all(S) (S).begin(), (S).end()
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
#define MAX 405
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef unsigned long long int ull;
int dy[] = {-1, 1, 0, 0};
int dx[] = {0, 0, -1, 1};
int v[401 * 401];
int vis[MAX][MAX];
char m[MAX][MAX];
int N, M, P = 1, p;

bool ver(int i, int j) {
	return(i >= 0 && i < N && j >= 0 && j < M);
}

void solve(int i, int j) {
	if(m[i][j] == '.') p++;
	vis[i][j] = P;
	rep(k, 0, 4) {
		int y = i + dy[k];
		int x = j + dx[k];
		if(!ver(y, x)) continue;
		if(!vis[y][x] && m[i][j] != m[y][x])
			solve(y, x);
	}
}


int main(int argc, char ** argv) {
	ll ans = 0;
	scanf("%d%d", &N, &M);
	rep(i, 0, N) scanf("%s", m[i]);
	rep(i, 0, N)
		rep(j, 0, M)
			if(m[i][j] == '#' && !vis[i][j]) {
				solve(i, j);
				v[P++] = p;
				p = 0;
			}
	rep(i, 0, N)
		rep(j, 0, M)
			if(m[i][j] == '#')
				ans += v[vis[i][j]];
	printf("%lld\n", ans);
	puts_name();
	return 0;
}



Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,pi;
string p[200009];
string s[200009];
map <string, int> m,n;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    for(b=1; b<=a; b++) cin>>s[b];
    for(b=1; b<=a; b++){
        m[s[b]]++;
        if(c<m[s[b]]) c=m[s[b]];
    }
    for(b=1; b<=a; b++){
        if(m[s[b]]==c){
            m[s[b]]=0;
            pi++;
            p[pi]=s[b];
        }
    }
    sort(p+1,p+pi+1);
    for(b=1; b<=pi; b++) cout<<p[b]<<endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int countred=0;
  int countblue=0;
  for(int i=0;i<S.length();i++){
    if(S.at(i)=='0'){
      countred++;
    }
    else {
      countblue++;
    }
  }
  int ans=0;
  ans=countblue+countred-abs(countblue-countred);
  cout <<ans<<endl;
  return 0;
}

  
  

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

using namespace std;

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


Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def s_raw():
    return input().rstrip("\r")

def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


def main():
    
    n,q = ints_raw()
    graph = [[] for _ in range(n)] 
    counters = [0 for _ in range(n)]
    for _ in range(n-1):
        a,b = ints_raw()
        a = a-1
        b = b-1
        graph[a].append(b)
        graph[b].append(a)
    for _ in range(q):
        p,x = ints_raw()
        p = p-1
        counters[p]+=x
    ans = [-1 for _ in range(n)]
    qu = deque()
    qu.append((0,0))

    while len(qu) != 0:
        node,parC = qu.popleft()
        curC = counters[node]+ parC
        ans[node]=curC
        for toN in graph[node]:
            if ans[toN] == -1:
                qu.append((toN,curC))
    return " ".join([str(a) for a in ans])


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 126072
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M ,K = map(int, input().split())

ndic = {i:set() for i in range(1,N+1)}
bdic = {i:set() for i in range(1,N+1)}

uf = UnionFind(N+1)
rlt = []

for _ in range(M):
  a,b = map(int, input().split())
  ndic[a].add(b)
  ndic[b].add(a)
  uf.union(a,b)
  
for _ in range(K):
  a,b = map(int, input().split())
  bdic[a].add(b)
  bdic[b].add(a)
  
for i in range(1,N+1):
  tmp = uf.size(i)
  for a in bdic[i]:
    if uf.find(a) == uf.find(i):
      tmp -= 1
  tmp -= len(ndic[i])
  rlt.append(tmp-1)
  
print(" ".join(map(str, rlt)))

Measured memory_bytes: 159008
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 310;
const int Mod = 1e9 + 7;
vector< int > q[N];
vector< int >::iterator it;

int f[N][N][N],from[N],r[N],x[N];

bool check(int i,int j,int k)
{
	
	bool flag=true;
	for(it = q[i].begin();it != q[i].end();it ++)
	{
		int now = *it;
		int num = 1;
		if(j >= from[now]) num ++;
		if(k >= from[now]) num ++;
		if(num != x[now]) flag=false;
	}
	return flag;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d%d",&from[i],&r[i],&x[i]);
		q[r[i]].push_back(i);
	}
	if(check(1,0,0)) f[1][0][0]=1;
	for(int i = 2;i <= n;i++)
	{
		for(int j = 0;j <= i - 1;j ++)
		{
			for(int k = 0;k <= j; k++)
			{
				if(k == j && j) continue;
				if(!check(i,j,k)) continue;
				f[i][j][k] = f[i - 1][j][k];
				if(j == i - 1 || k == i - 1) 
				{
					for(int l = 0;l <= i - 1;l ++)
					if(l<k) f[i][j][k] = (f[i][j][k] + f[j][k][l]) % Mod;
					else f[i][j][k] = (f[i][j][k] + f[j][l][k]) % Mod;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0;i < n;i ++)	
		for(int j = 0;j < i;j ++)
		{
			ans = (ans + f[n][i][j]) % Mod;
		}
	ans = 6ll * ans % Mod;
	ans = (ans + f[n][0][0] * 3) % Mod;
	printf("%d",ans);
	return 0;
}

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

using namespace std;

string s,t;

int main(){
    cin >> s;
    cin >> t;
    int c = 0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
// {{{
#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;
// }}}

int N, M;

void init()
{
}

void solve()
{
    int t = 1900 * M + 100 * (N - M);
    cout << t * (1<<M) << endl;
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#include <tuple>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#define println(str) cout << str << endl;

#pragma endregion

#pragma region Utility
#pragma region 最大公約数
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
#pragma endregion

#pragma region 最小公倍数
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
#pragma endregion

#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion

#pragma region 素数判定
bool isPrime(ll num)
{
    if (num <= 1)
    {
        return false;
    }
    for (int i = 2; i < num / 2 + 1; i++)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int N;
    string S, T;
    cin >> N >> S >> T;

    string ans = "";
    forn(i, N)
    {
        ans += S[i];
        ans += T[i];
    }
    println(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
int main(){
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  FOR(i,0,N) cin >> P[i];
  FOR(i,0,N) cin >> Q[i];
  int fact[10]; fact[0] = 1;
  FOR(i,1,10) fact[i] = i * fact[i-1];
  auto F = [&](vector<int> V){
    int num = 0;
    set<int> S;
    RPT(i,1,N) S.insert(i);
    FOR(i,0,N-1){
      int cnt = 0;
      for(auto x : S){
        if(x < V[i]) cnt++;
      }
      cnt *= fact[N-i-1];
      num += cnt;
      S.erase(V[i]);
    }
    return (num+1);
  };
  cout << abs(F(P)-F(Q)) << endl;
  return 0;
}

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

int main() {
	int n, a[200002], maxi[200002]={}; cin>>n;
	for(int i=0;i<n;i++){
		int tmp; cin>>tmp;
		a[i]=tmp; maxi[i]=tmp;
	}
	sort(maxi,maxi+200002);
	for(int i=0;i<n;i++){
		if(a[i]==maxi[200001]) cout<<maxi[200000]<<endl;
		else cout<<maxi[200001]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int N, D; cin >> N >> D;
    vii X(N, vi(D));
    rep(i, 0, N){
        rep(j, 0, D){
            cin >> X[i][j];
        }
    }
    int cnt = 0;
    rep(i, 0, N){
        rep(j, i+1, N){
            int dist = 0;
            rep(k, 0, D){
                dist += pow(X[i][k] - X[j][k], 2);
            }
            rep(l, 0, 130){
                if(dist == pow(l, 2)){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3592
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var s = next();
  var count = {};
  var output = 1;
  var mod = 1000000007;
  for(var i = 0; i < N; i++){
    if(count[s[i]] == null){
       count[s[i]] = 1;
    }else{
       count[s[i]]++;
    }
  }
  var keys = Object.keys(count);
  for(var i = 0; i < keys.length; i++){
    output = (output * (count[keys[i]] + 1)) % mod;
  }
  myout(output - 1);
}


Measured memory_bytes: 11468
#include <algorithm>
#include <cstdio>
using namespace std;

int A[5565];

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", A + i);
    }
    sort(A, A + n);
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += A[i];
    }
    printf("%d\n", sum);

    return 0;
}


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

bool bin(int A[], int n, int s) {

	int h = n / 2;
	if (A[h] == s) {
		return true;
	} else if (A[h] > s && h > 0) {
		return bin(A, h, s);
	} else if (A[h] < s && h < n - 1) {
		return bin(&A[h + 1], n - h - 1, s);
	} else {
		return false;
	}

}

int main()
{
	int n;
	scanf("%d", &n);
	int S[100000];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &S[i]);
	}

	int q;
	scanf("%d", &q);
	int count = 0;
	for (int i = 0; i < q; ++i) {
		int t;
		scanf("%d", &t);
		if (bin(S, n, t)) ++count;
	}
	cout << count << endl;
}

Measured memory_bytes: 1600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 129
	// https://atcoder.jp/contests/abc129/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int p = sc.nextInt();
		System.out.println((a*3 + p)/2);
	}
		
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i],--a[i];
	vector<int> ans;
	function<bool(vector<int>)> solve=[&](vector<int> a) {
		if(a.empty()) return true;
		for(int i=a.size()-1;~i;i--)
			if(a[i]==i) {
				a.erase(a.begin()+i);
				bool ret=solve(a);
				ans.push_back(i); 
				return ret;
			}
		return false;
	};
	if(solve(a)) {
		for(auto x:ans) printf("%d\n",x+1);
	}
	else puts("-1");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer num1 = sc.nextInt();
		Integer num2 = sc.nextInt();
		Integer num3 = sc.nextInt();
      	System.out.print(num3 + " ");
      	System.out.print(num1 + " ");
      	System.out.print(num2);
	}
}

Measured memory_bytes: 22228
///////////////////////////////
// Template By: Agus Sentosa //
//       17 - 5 - 2014       //
///////////////////////////////
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <climits>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <utility>

//I/O
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <istream>
#include <ostream>

//Data Type
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <bitset>

//Data Type
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define LL long long
#define ULL unsigned long long

//Data Type Properties
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define popb pop_back

//Macro
#define sqr(x) ((x) * (x))
#define all(v) (v).begin(),(v).end()
#define sortv(v) sort(all(v))
#define num(x) ((x)-'0')
#define ch(x) ((x)+'0')
#define bit_count __builtin_popcount
#define bit_countll __builtin_popcountll
#define THIS (*this)

//Output
#define endl '\n'

//Compiling & Debugging
#ifdef DEBUG
#define DO_IF_DEBUG_FLAG_IS_ON 1
#else
#define DO_IF_DEBUG_FLAG_IS_ON 0
#endif
#define DoDebug if(DO_IF_DEBUG_FLAG_IS_ON)

//???????????????????
#define Fokus using
#define Tahun_Terakhir namespace std;

Fokus Tahun_Terakhir;

#ifdef _WIN32
#define getchar_unlocked getchar
#endif
#define g getchar_unlocked
template<class T>
bool io(T &res){
    static char c=' ';
    while(c == ' ' || c == '\n')c = g();
    if(c == -1)return 0;
    res = num(c);
    while((c=g()) && c != ' ' && c != '\n' && c!=-1){ res = (res << 3) + (res << 1) + num(c); }
    return 1;
}

template<class T>
string inttostr(T x){
    string res="";
    while(x){
        char t=ch(x%10); x/=10; res=t+res;
    }
    return res;
}

template<class T>
T strtoint(string x){
    T res=0;
    for(int i=0;i<x.size();i++){
        res=(res<<3)+(res<<1)+num(x[i]);
    }
    return res;
}
void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}
void close(){
    fclose(stdin);
    fclose(stdout);
}

//Constant
#define INF 1000000007
#define LINF 1000000000000000007ll
#define DINF 1000000000000000007.00
#define INV (-INF)
#define LINV (-LINF)
#define DINV (-DINF)
#define EPS 1e-9
#define MOD 1000000007
///////////////////////////////
//      End of Template      //
///////////////////////////////

int main(){
	ios::sync_with_stdio(0);
	
	LL a,b,c; cin >> a >> b >> c;
	
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		cout << 0 << endl;
	}else{
		if(a > b)swap(a,b);
		if(a > c)swap(a,c);
		if(b > c)swap(b,c);
		
		cout << a * b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans;
  ans = 0;
  for(int a = 1 ; a <= N ; a++){
    for(int b = a; b<= N; b++){
      for ( int c = b ; c<= N ; c++){
        for (int i = N; i >= 1 ; i--){
          if (a % i==0 && b % i == 0 && c % i == 0 ){
            if ( a != b && b != c && c != a){
              ans += 6*i;
            }
            else if (a != b || b!= c){
              ans += 3*i;
            }
            else {
              ans += i;
            }
            break;
          }
        }
      }
    }
  }
    cout << ans << endl;
  }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second
main(){
  int n;
  string s;
  cin>>s;
  r(i,s.size()-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int a, b, c;

int main() {
  scanf("%d %d %d", &a, &b, &c);
  if ((a == b && b != c) || (a == c && b != c) || (b == c && a != c)) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

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

#define sz(x) ((int)x.size())
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll; 

vector<vector<pair<int,int>>> adj; 
vector<int> color; 

void dfs(int u, int p){
  for(pair<int,int> v:adj[u]){
    if(v.first==p) continue; 
    else {
      if(v.second % 2==0){
        color[v.first]=color[u]; 
      }
      else {
        color[v.first]=1-color[u]; 
      }
      dfs(v.first,u); 
    }
  }
}

int main(){
  int n; cin>>n; 
  adj=vector<vector<pair<int,int>>> (n+1); 
  color=vector<int>(n+1);
  for(int i=1;i<n;i++){
    int u,v,w; cin>>u>>v>>w; 
    adj[u].push_back({v,w}); 
    adj[v].push_back({u,w}); 
  }
  color[1]=0;  
  dfs(1,0); 
  for(int i=1;i<=n;i++){
    cout<<color[i]<<endl;
  }
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, M;
    cin >> n >> M;
    vector<ll> b(M);
    vector<ll> c(M);
    map<ll, ll> m;
    for(int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        m[a]++;
    }
    for(int i = 0; i < M; i++)
    {
        cin >> b[i] >> c[i];
    }
    for(int i = 0; i < M; i++)
    {
        ll cand = c[i];
        ll count = b[i];
        auto itr = m.begin();
        while(itr != m.end() && itr->first < cand && count > 0)
        {
            if(itr->second > count)
            {
                m[cand] += count;
                itr->second -= count;
                count = 0;
                itr++;
            }
            else if(itr->second == count)
            {
                 m[cand] += count;
                 count = 0;
                 ll k = itr->first;
                 m.erase(m.find(k));
                itr++;
            }
            else
            {
                count -= itr->second;
                m[cand] += itr->second;
                ll k = itr->first;
                itr++;
                m.erase(m.find(k));
            }
        }
    }
  ll ans = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++)
    {
        ans += itr->first * itr->second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> A(9);
  vector<bool> B(9, false);
  rep(i, 9) cin >> A[i];
  int N; cin >> N;
  rep(i, N) {
    int b; cin >> b;
    rep(j, 9) {
      if(A[j] == b) B[j] = true;
    }
  }
  if(
    (B[0] && B[1] && B[2]) ||
    (B[3] && B[4] && B[5]) ||
    (B[6] && B[7] && B[8]) ||
    (B[0] && B[4] && B[8]) ||
    (B[2] && B[4] && B[6]) ||
    (B[0] && B[3] && B[6]) ||
    (B[1] && B[4] && B[7]) ||
    (B[2] && B[5] && B[8]) )
  { cout << "Yes" << endl; }
  else { cout << "No" << endl; }
}


Measured memory_bytes: 256
# AGC027
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
cnt = 0
if x > sum(A):  #お菓子が多い時は最後の一人に残った分をあげる
    print(N-1)
    exit()
if x == sum(A): # ちょうどのとき
    print(N)
    exit()
if x < A[0]:    # 誰も満足させれない
    print(0)
    exit()
# 複数人満足させられる時
for i in range(N):
    if x >= A[i]:
        x -= A[i]
    else:
        ans = i
        break
print(ans)

Measured memory_bytes: 3064
n = int(input())
factor = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
factor_num = [0] * len(factor)
if n <= 9:
	print(0)
else:
	for i in range(2, n+1):
		for j in range(len(factor)):
			cnt = 0
			while i % factor[j] == 0:
				cnt += 1
				i = i // factor[j]
			factor_num[j] += cnt

	two_three = 0
	over_four = 0
	over_fourteen = 0
	over_twentyfour = 0
	over_seventyfour = 0

	for i in range(len(factor)):
		if 2 <= factor_num[i] <= 3:
			two_three += 1
		elif factor_num[i] >= 4:
			over_four += 1
			if factor_num[i] >= 14:
				over_fourteen += 1
			if factor_num[i] >= 24:
				over_twentyfour += 1
			if factor_num[i] >= 74:
				over_seventyfour += 1

	ans = two_three * (over_four * (over_four - 1) // 2) + over_four * ((over_four - 1) * (over_four - 2) // 2)
	ans += over_fourteen * (over_four - 1) + over_twentyfour * (two_three + over_four - 1)
	ans += over_seventyfour

	print(ans)

Measured memory_bytes: 39280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long X = n[0];
            long Y = n[1];

            int ans = 0;
            while(X <= Y)
            {
                X *= 2;
                ans++;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;
set<long long, greater<long long>> A;

inline void f() {
  auto it = A.begin();
  long long top = *it;
  it = A.erase(it);
  top %= *it;
  if (top != 0) A.insert(top);
}

int main(int argc, char const* argv[])
{
  int N;
  cin >> N;
  while (N--) {
    long long a;
    cin >> a;
    A.insert(a);
  }

  for (; A.size() > 1;) {
    f();
  }
  cout << *A.begin() << endl;

  return 0;
}


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    int count=0;
    for(int i=0; i<n; ++i){
        if(a[i]==a[i+1])
            continue;

        if(a[i]<a[i+1]){
            int j=0;
            while(i+j+1<n && a[i+j] <= a[i+j+1]){
                j++;
            }
            i += j;
            count++;
        }
        else{
            int j=0;
            while(i+j+1<n && a[i+j] >= a[i+j+1]){
                j++;
            }
            i += j;
            count++;
        }
    }
    cout << count<<endl;
}


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

int main(){
	string s1,s2,u;
	int n,m;
	cin>>s1>>s2>>n>>m>>u;
	
	if(u==s1)
		n--;
	else
		m--;
		
	cout<<n<<' '<<m;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,mod=1e9+7;
map<long long,long long> dp;
long long dfs(long long x)
{
	if (x<2) return x+1;
	if (dp[x]) return dp[x];
	return dp[x]=(dfs(x/2)+dfs((x-1)/2)+dfs((x-2)/2))%mod;
}
int main()
{
	cin>>n;
	cout<<dfs(n);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
	int i,n,a,b,x_min,x_max;
	
	if(scanf("%d%d%d", &n, &a, &b)<2){
		fprintf(stderr, "error: ill-formed fraction.\n");
		exit(1);
	}
	
	if(a+b<n){
		x_min = 0;
		x_max = (a>b) ? b : a;
	}else if(a+b>=n){
		if(a-b>=0){
			x_min = b -(n - a);
			x_max = b;
		}else if(a==b){
			x_max = a;
			x_min = n -((n - a) + (n - b));
		}else if(a-b<0){
			x_min = a -(n - b);
			x_max = a;
		}
	}
	if(a+b==2*n){
		x_max = a;
		x_min = a;
	}
	
	printf("%d %d",x_max,x_min);
	
	return 0;

}

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

int main(void){
    int a[3], n, m, s[5], c[5], ans = -1;
    cin >> n >> m;
    bool can = true;

    for(int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }

    for(int i = 9; i >=0; i--){
        a[0] = i;
        for(int j = 9; j >= 0; j--){
            if((j > 0) && (n < 2)) continue;
            a[1] = j;
            for(int k = 9; k >= 0; k--){
                if((k > 0) && (n < 3)) continue;
                a[2] = k;
                for(int l = 0; l < m; l++){
                    if(a[n-s[l]] != c[l]) can = false;
                }
                if((a[n-1] == 0) && (n != 1)) can = false;
                if(can) ans = k * 100 + j * 10 + i;
                can = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int num;
    cin >> num;
    double x1, x2, x3, y1, y2, y3;
    double px, py, r;
    double a, b, c, d, e, f;

    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3)
    {
        a = 2 * (x1 - x2);
        b = 2 * (y1 - y2);
        c = 2 * (x2 - x3);
        d = 2 * (y2 - y3);
        e = x1*x1 - x2*x2 + y1*y1 - y2*y2;
        f = x2*x2 - x3*x3 + y2*y2 - y3*y3;
        px = (d*e - b*f) / (a*d - b*c);
        py = (a*f - c*e) / (a*d - b*c);
        r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));

        cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
    }
}

Measured memory_bytes: 1288
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

struct Edge {
    int from, to, cost;
}

class UnionFind {
    int[] parent;
    int[] group_size;
    this(int N) {
        parent = new int[N];
        parent[] = -1;
        group_size = new int[N];
        group_size[] = 1;
    }
    int root(int x) {
        if (parent[x] == -1) return x;
        return parent[x] = root(parent[x]);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        parent[y] = x;
        group_size[x] += group_size[y];
    }
    bool query(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        x = root(x);
        return group_size[x];
    }
}

void main() {
    int N; scanf("%d\n", &N);
    Edge[] es;
    foreach (i; 0 .. N - 1) {
        int a, b, c; scanf("%d %d %d\n", &a, &b, &c);
        es ~= Edge(a, b, c);
    }
    es.sort!"a.cost < b.cost";
    //writeln(es);
    auto uf = new UnionFind(N);
    long Ans = 0;
    foreach (e; es) {
        if (uf.query(e.from, e.to)) assert(0);
        Ans += cast(long)(e.cost) * uf.size(e.from) * uf.size(e.to);
        uf.merge(e.from, e.to);
    }
    writeln(Ans);
}

Measured memory_bytes: 6172
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans1=0,ans2=0;
  cin >> n;
  int a[n];
  map<int, int> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[min(8,a[i]/400)]++;
  }
  for(int i=0;i<8;i++){
    if(mp[i]>0){
      ans1++;
      ans2++;
    }
  }
  if(ans1==0){
    ans1++;
  }
  ans2+=mp[8];
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a,h,p,q,i;
main(){
  cin.sync_with_stdio(false);
  while(cin>>n>>m>>a,n){
    int x[1001][101]={};
    while(cin>>h>>p>>q,x[h][p]=q,x[h][q]=p,--m);
    for(i=1000;i--;)x[i][a]&&(a=x[i][a]);
    cout<<a<<endl;
  }
}

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

long long int gcd(long long int a, long long int b) {
	if (a < b) { swap(a, b); } a = a % b;
	return (a == 0 ? b : gcd(a, b));
}

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

int main() {
	long long int a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 2984
from itertools import permutations
n,a,b,c=map(int,input().split())
target=[a,b,c]
lst=[int(input()) for _ in range(n)]
p=list(permutations(lst,3))
ans=float("inf")

def Base_10_to_n(X, n,keta):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    out="0"*(keta-len(out))+out
    return out
for q in range(len(p)):
    base_tri=list(p[q])
    extra=lst[:]
    for i in base_tri:
        extra.remove(i)
    tmp=0
    for i in range(3):
        tmp+=abs(base_tri[i]-target[i])
    ans=min(tmp,ans)
    for i in range(1,4**(n-3)):
        tmp=0
        tri=base_tri[:]
        yonshin=Base_10_to_n(i,4,n-3)
        for j in range(n-3):
            if yonshin[j]=="1":
                tri[0]+=extra[j]
                tmp+=10
            elif yonshin[j]=="2":
                tri[1]+=extra[j]
                tmp+=10
            elif yonshin[j]=="3":
                tri[2]+=extra[j]
                tmp+=10
        for j in range(3):
            tmp+=abs(tri[j]-target[j])
        ans=min(tmp,ans)
print(ans)

Measured memory_bytes: 70104
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    ll n;
    cin >> n;
    int input[n];
    rep0(i, n)
    {
        cin >> input[i];
    }
    int res = 0;
    int tmpRes = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (input[i] >= input[i + 1])
        {
            tmpRes++;
        }
        else
        {
            if (tmpRes >= res)
            {
                res = tmpRes;
            }
            tmpRes = 0;
        }
    }
    if (tmpRes >= res)
    {
        res = tmpRes;
    }
    cout << res << endl;
}


Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MAX = 1e18;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a) cin >> e;
  sort(a.begin(), a.end());

  bool valid = true;
  __int128 r = 1;
  for (auto e : a) {
    valid = valid && r * e <= MAX;
    r *= e;
  }
  cout << (valid ? (ll)r : -1) << endl;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    cout<<2*n/gcd(2,n)<<endl;


}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll n,mini=INF;
    cin >> n;
    REP(i,1,sqrt(n)+1){
        if(n%i==0) mini = min(mini, i+n/i-2);
    }
    if(mini==INF) mini=n-1;
    P(mini);
}

Measured memory_bytes: 256