akhauriyash/Code-Regression huggingface dataset:
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut cube = HashMap::new();
 
    cube.entry('0').or_insert(0);
    cube.entry('1').or_insert(0);
 
    for c in s.iter() {
        let count = cube.entry(*c).or_insert(0);
        *count += 1;
    }
 
    let min = cube.values().min().unwrap();
 
    println!("{}", min * 2);
    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
void solve();

signed main () {
	cout.precision(10);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		solve();
	}
	return 0;
}
int arr[100];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> arr[i];
	int s = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			s += arr[i] * arr[j];
		}
	}
	cout << s;
}		


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

int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int cnt[maxn];
int main(){
    int n,m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    for(int i = 1; i <= n; ++i)
        cout << cnt[i] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m= map(int,input().split())
A = [ int(input()) for _ in range(n)]
a=sorted(A)
ans = 10 **10
for i in range(n-m+1):
    ans = min(abs(a[i+m-1] - a[i]),ans)
print(ans)

Measured memory_bytes: 8276
#include<iostream>
#include<string>
#define max(a,b) a>b?a:b
using namespace std;
int dp[2005][2005][2];
int main(){
	int n,m;
	int i,j,k;
	int a,b;
	string t[2];
	string sa="IO";
	int s=0;
	cin>>n>>m;
	for(i=0;i<2;i++){
		cin>>t[i];
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			for(k=0;k<2;k++){
				a=(i+j+k)%2;
				if(a==0 && dp[i][j][k]==0){
					if(t[0][i]=='I')dp[i+1][j][k]=max(dp[i+1][j][k],1);
					if(t[1][j]=='I')dp[i][j+1][k]=max(dp[i][j+1][k],1);
				}
				if(dp[i][j][k]==0)continue;
				if(t[0][i]==sa[a]){
					dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]+1);
				}
				if(t[1][j]==sa[a]){
					dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]+1);
				}
			}
		}
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			for(k=0;k<2;k++){
				if(dp[i][j][k]%2==0)continue;
				s=max(s,dp[i][j][k]);
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 34544
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt))
  val A = ls(1)
  //println(A.toSeq)
  val B = ls(2)
  //println(B.toSeq)
  val X = ls.tail.tail.tail
  
  val mina = A.min
  val minb = B.min
  var min = mina + minb
  X.foreach{ x =>
    val ai = x(0)
    val bi = x(1)
    val c = x(2)
    val local = A(ai-1) + B(bi-1) - c
    min = Math.min(min, local)
  }
  println(min)
}


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














int N, A[201010];
ll dp[201010][2][4][3];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	rep(i, 0, N + 1) rep(top, 0, 2) rep(two, 0, 3) rep(three, 0, 2) dp[i][top][two][three] = -infl;

	dp[0][0][0][0] = 0;

	dp[1][1][0][0] = A[0];
	dp[2][0][0][0] = A[1];
	dp[3][0][1][0] = A[2];

	rep(i, 0, N) rep(top, 0, 2) rep(two, 0, 3) rep(three, 0, 2) if(-infl < dp[i][top][two][three]) {
		chmax(dp[i + 2][top][two][three], dp[i][top][two][three] + A[i + 1]);
		chmax(dp[i + 3][top][two + 1][three], dp[i][top][two][three] + A[i + 2]);
		chmax(dp[i + 4][top][two][three + 1], dp[i][top][two][three] + A[i + 3]);
	}

	ll ans = -infl;
	rep(i, 1, N + 1) rep(top, 0, 2) rep(two, 0, 3) rep(three, 0, 2) if (-infl < dp[i][top][two][three]) {
		int cnt = 0;
		int tot = i;
		if (top == 1) cnt++, tot--;

		tot -= two;
		tot -= three * 2;

		cnt += tot / 2;

		if (cnt == N / 2) chmax(ans, dp[i][top][two][three]);
	}
	cout << ans << endl;
}







Measured memory_bytes: 41912
from collections import defaultdict
h,w,n=map(int,input().split())
d=defaultdict(int)
s=set()
for _ in range(n):
  a,b=map(int,input().split())
  a-=1
  b-=1
  for dy in [-2,-1,0]:
    for dx in [-2,-1,0]:
      ny,nx=a+dy,b+dx
      if 0<=ny<h and 0<=nx<w and ny+2<h and nx+2<w:
        d[(ny,nx)]+=1
        s.add((ny,nx))
cnt=[0]*10
q=0
for y,x in s:
  cnt[d[(y,x)]]+=1
cnt[0]=(h-2)*(w-2)-len(s)
for i in cnt:
  print(i)


Measured memory_bytes: 212968
def nyu():
    N = list(map(str,input()))
    return N

def check(LOP1,LOP2,LOP3):  
    global flg1
    ls =  N[0]+LOP1+N[1]+LOP2+N[2]+LOP3+N[3]
    if flg1 == True:
        return
    elif(eval(ls) == 7):
        print(N[0],LOP1,N[1],LOP2,N[2],LOP3,N[3],"=7",sep='')
        flg1 = True
        return



    if LOP1 =='+':
        check('-',LOP2,LOP3)
    if LOP2 == '+':
        check(LOP1,'-',LOP3)
    if LOP3 == '+':
        check(LOP1,LOP2,'-')



N = nyu()
flg1 = False
OP1 = "+"
OP2 = "+"
OP3 = "+"
check(OP1,OP2,OP3)

Measured memory_bytes: 3192
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

st = set()
i = 1
li = []
while i not in st:
    st.add(i)
    li.append(i)
    i = a[i]

s = i
until_s = li.index(s)

if k < until_s:
    i = 1
    for _ in range(k):
        i = a[i]

    ans = i

else:
    k -= until_s
    loop_size = len(li) - until_s
    sim_time = k % loop_size
    i = s
    for _ in range(sim_time):
        i = a[i]

    ans = i

print(ans)


Measured memory_bytes: 32492
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)cout << "hon";
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)cout << "pon";
	else cout << "bon";
}


Measured memory_bytes: 3636
// List_of _Top_3_Hills.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>

#define sort 10

int main()
{
	int bab[sort], temp;
	for (int n = 0; n < sort; n++)
	{
		scanf("%d", &bab[n]);
	}
	for (int i = 0; i < sort - 1; i++)
	{
		for (int j = sort -1; j > i; j--)
		{
			if (bab[j - 1] < bab[j])
			{
				temp = bab[j];
				bab[j] = bab[j - 1];
				bab[j - 1] = temp;
			}
		}
	}
	for (int m = 0; m < 3; m++)
	{
		printf("%d\n", bab[m]);
	}
	return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b && b < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[222222];
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  if(n%2==0){
    for(int i=n;i>=1;i-=2){
      cout<<a[i]<<' ';
    }
    cout<<a[1]<<' ';
    for(int i=3;i<=n-1;i+=2){
      cout<<a[i];
      if(i!=n-1) cout<<' ';
    }
  }else{
    for(int i=n;i>=1;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=2;i<=n-1;i+=2){
      cout<<a[i];
      if(i!=n-1) cout<<' ';
    }
  }
  cout<<endl;
  return(0);
}


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

int main() {
	int n;
	cin >> n;
	int res = 100;
	for (int i = 1; i < n ; i++) {
		int suma = 0, sumb = 0;
		int s = i;
		while (s > 0) {
			suma += s % 10;
			s /= 10;
		}
		int j = n - i;
		while (j > 0) {
			sumb += j % 10;
			j /= 10;
		}
		res = min(res, suma + sumb);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000010000;

ll kai[100010];
ll bit[700010];

void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

ll H, A;

void solve() {
	cin >> H >> A;
	if (H % A == 0) {
		cout << H / A << endl;
	}
	else {
		cout << H / A + 1 << endl;
	}
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int answer(int h[],int n,int k)
{
    int dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        int minm=INT_MAX;
        for(int j=1;j<=k && (i-j)>=1;j++)
        {
            int a=dp[i-j]+abs(h[i-j]-h[i]);
            if(a<minm)
            minm=a;
        }
        dp[i]=minm;
    }
    return dp[n];
}
int main()
{
    int n,k;
    cin>>n>>k;
    int h[100000];
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    cout<<answer(h,n,k);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <string>

using namespace std;
int main(void){
  int i, n, num;
  char s[10000];
  string ans = "";
  string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cin >> n >> s;
  int len = strlen(s);
  for(i=0; i<len; ++i){
    num = al.find(s[i]); //アルファベットの順番
    //Zを超える時
    if (26 - (num + n) <= 0){
      ans += al[-1 * (26 - (num + n))];
    //それ以外
    }else{
      ans += al[num + n];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,t,a,mn=INT32_MAX,mni,h;
    cin >> n >> t >> a;
    a*=1000;
    rep(i, 1, n+1){
        cin >> h;
        ll k=1000*(t-h*0.006);
        if(mn>=abs(a-k)){
            mn=abs(a-k);
            mni=i;
        }
    }
    cout << mni << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 2010;
const int Mod = 1e9 + 7;

int n, k;
int dp[N][N], S[N][N];

int main(){
	scanf("%d%d", &n, &k);
	dp[1][n - k] = 1;
	For(i, 2, n){
		S[i - 1][0] = dp[i - 1][0];
		For(j, 1, n + 1) S[i - 1][j] = (S[i - 1][j - 1] + dp[i - 1][j]) % Mod;
		For(j, 0, n) dp[i][j] = S[i - 1][j + 1];
	}
	int ans = dp[n][0];
	For(i, 1, n - k - 1) ans = ans * 2 % Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 31744
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");

        int m = Integer.parseInt(input[0]);
        int f = Integer.parseInt(input[1]);
        int b = Integer.parseInt(input[2]);

        if (m + f < b) {
            System.out.println("NA");
        } else {
            System.out.println(m > b ? 0 : b - m);
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ans=0;
  int left=0;
  int right=N-1;
  while(left<right){
    while(s.at(left)!='W'){
      left++;
      if(left==N){
        cout << ans << endl;
        return 0;
      }
    }
    while(s.at(right)!='R'){
      right--;
      if(right==-1){
        cout << ans << endl;
        return 0;
      }
    }
    if(left>=right){
      break;
    }
    ans++;
    left++;
    right--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3724
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

int main(){
	Int r, D, x2000;
	cin>>r>>D>>x2000;
	Int x = x2000;
	for(int i = 2001;i<=2010;i++){
		x = r * x - D;
		cout<<x<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string m[7]={"null","one pair","two pair","three card","straight","full house","four card"};
int c[5],ans;
bool s1(){
	bool ok=false;
	for(int i=0;i<4;i++){
		if(c[i]==c[i+1])ok=true;
	}
	return ok;
}
bool s2(){
	bool ok=false;
	if(c[1]==c[2]&&c[3]==c[4])ok=true;
	if(c[0]==c[1]&&c[3]==c[4])ok=true;
	if(c[0]==c[1]&&c[2]==c[3])ok=true;
	return ok;
}
bool s3(){
	bool ok=false;
	for(int i=0;i<3;i++){
		if(c[i]==c[i+1]&&c[i]==c[i+2])ok=true;
	}
	return ok;
}
bool s4(){
	bool ok=true;
	for(int i=0;i<4;i++){
		if(c[i]+1!=c[i+1])ok=false;
	}
	int d[5]={1,10,11,12,13};
	bool A=true;
	for(int i=0;i<5;i++){
		if(c[i]!=d[i])A=false;
	}
	if(A)ok=true;
	return ok;
}
bool s5(){
	bool ok=true;
	if(c[0]!=c[1]||c[3]!=c[4])ok=false;
	if(c[1]!=c[2]&&c[3]!=c[2])ok=false;
	return ok;
}
bool s6(){
	bool ok=false;
	if(c[0]==c[1]&&c[0]==c[2]&&c[0]==c[3])ok=true;
	if(c[4]==c[1]&&c[4]==c[2]&&c[4]==c[3])ok=true;
	return ok;
}
int main(){
	char z;
	while(cin>>c[0]){
		for(int i=1;i<5;i++)cin>>z>>c[i];
		ans=0;
		sort(c,c+5);
		if(s1())ans=1;
		if(s2())ans=2;
		if(s3())ans=3;
		if(s4())ans=4;
		if(s5())ans=5;
		if(s6())ans=6;
		cout<<m[ans]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int A, B;

  cin >> A >> B;

  cout << (A + B) % 24 << endl;

  return 0;
}


Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

def check(n):
    if n >= 11:
        return 0
    elif n >= 6:
        return 1
    elif n >= 2:
        return 2
    else:
        return 3

N = list(get_input())

cntL = [0,0,0,0]
cntR = [0,0,0,0]

for lll in range(len(N)):
    l,r = [int(float(i)*10) for i in N[lll].split()]
    cntL[check(l)] += 1
    cntR[check(r)] += 1

for i in range(4):
    print(cntL[i],cntR[i])



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

typedef  long long ll;
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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    rep(i,n){
        cout<<s.at(i)<<t.at(i);
    }
    cout<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
static const double EPS = 1e-6;

struct road
{
  int node, len, limit;
  road() {}
  road(int x, int d, int c) : node(x), len(d), limit(c) {}
};

struct state
{
  int p, n, v;
  double c;
  state(int prev, int node, int velocity, double cost) : p(prev), n(node), v(velocity), c(cost) {}
  bool operator<(const state& that) const { return c > that.c; }
};

int main()
{
  int N, M;
  while (scanf("%d %d", &N, &M) != EOF && N != 0) {
    int S, G;
    scanf("%d %d", &S, &G);
    --S;  --G;
    vector<vector<road> > g(N);
    for (int i = 0; i < M; i++) {
      int x, y, d, c;
      scanf("%d %d %d %d", &x, &y, &d, &c);
      --x;  --y;
      g[x].push_back(road(y, d, c));
      g[y].push_back(road(x, d, c));
    }
    vector<vector<vector<double> > > dist(N, vector<vector<double> >(N, vector<double>(31, 1e7)));
    dist[S][S][0] = 0.0;
    priority_queue<state> q;
    q.push(state(S, S, 0, 0.0));
    double ans = 1e7;
    while (!q.empty()) {
      const int prev = q.top().p;
      const int n = q.top().n;
      const int v = q.top().v;
      const double cost = q.top().c;
      q.pop();
      if (n == G && v == 1) {
        ans = min(ans, cost);
        continue;
      }
      for (vector<road>::const_iterator it(g[n].begin()); it != g[n].end(); ++it) {
        if (it->node == prev) {
          continue;
        }
        for (int d = -1; d <= 1; d++) {
          if (v+d >= 1 && v+d <= it->limit) {
            const double c = cost + double(it->len) / (v+d);
            if (dist[prev][it->node][v+d] - c > EPS) {
              dist[prev][it->node][v+d] = c;
              q.push(state(n, it->node, v+d, c));
            }
          }
        }
      }
    }
    if (ans >= 1e7) {
      puts("unreachable");
    } else {
      printf("%.4f\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 1764
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=4000;
int n,k,wt[maxn+10][maxn+10],blk[maxn+10][maxn+10],ans;
char s[5];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		int x,y; scanf("%d%d",&x,&y); scanf("%s",s);
		x%=k*2; y%=k*2; ++x; ++y; if(s[0]=='W') ++wt[x][y]; else ++blk[x][y];
	}
	for(int i=1;i<=k*2;++i)
		for(int j=1;j<=k*2;++j){
			wt[i+k*2][j]=wt[i][j+k*2]=wt[i+k*2][j+k*2]=wt[i][j];
			blk[i+k*2][j]=blk[i][j+k*2]=blk[i+k*2][j+k*2]=blk[i][j];
		}
	for(int i=1;i<=k*4;++i)
		for(int j=1;j<=k*4;++j){
			wt[i][j]+=wt[i-1][j]+wt[i][j-1]-wt[i-1][j-1];
			blk[i][j]+=blk[i-1][j]+blk[i][j-1]-blk[i-1][j-1];
		}
	for(int i=0;i<k*2;++i)
		for(int j=0;j<k*2;++j){
			int t=wt[i+k][j+k]-wt[i][j+k]-wt[i+k][j]+wt[i][j];
			t+=wt[i+k*2][j+k*2]-wt[i+k][j+k*2]-wt[i+k*2][j+k]+wt[i+k][j+k];
			t+=blk[i+k*2][j+k]-blk[i+k][j+k]-blk[i+k*2][j]+blk[i+k][j];
			t+=blk[i+k][j+k*2]-blk[i][j+k*2]-blk[i+k][j+k]+blk[i][j+k];
			ans=max(ans,t);
		}
	printf("%d",ans); return 0;
}

Measured memory_bytes: 125696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int c;
  int d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  int l = a + b;
  int r = c + d;
  if(l > r){
    cout << "Left" << endl;
  }else if(l == r){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}
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() {
   int N, Q;
   cin >> N >> Q;
   string s;
   cin >> s;
   char t[Q], d[Q];
   for (int i = 0; i < Q; i++) {
      cin >> t[i] >> d[i];
   }
   int left = -1;
   int right = N;
   for (int q = Q - 1; q >= 0; q--) {
      if (d[q] == 'L' && t[q] == s[left + 1]) left++;
      if (left >= 0 && d[q] == 'R' && t[q] == s[left]) left--;
      if (d[q] == 'R' && t[q] == s[right - 1]) right--;
      if (right <= N - 1 && d[q] == 'L' && t[q] == s[right]) right++;
   }
   cout << max(right - left - 1, 0) << endl;
   return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int s = S.size();
  int countmax=0;
  
  for(int i=0; i<s; i++){
    int count = 0;
    int a=i;
    while(S[a] == 'A' || S[a] == 'T' || S[a] == 'G' || S[a] == 'C'){
      count++;
      a++;
      if(a==s) break;
    }
    countmax = max(countmax, count);
  }
  
  cout << countmax << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,x,y,z;
	cin>>a>>b>>c;
	int ans=0;
	while(1){
		if(a%2||b%2||c%2)break;
		x=(a+b)/2;
		y=(b+c)/2;
		z=(a+c)/2;
		a=x;
		b=y;
		c=z;
		ans++;
		if(ans>2e6){
			ans=-1;
			break;
		}
	}
	cout<<ans<<endl;

	
	return 0;
}


Measured memory_bytes: 256
from functools import reduce


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def graham_scan(points):
    points.sort(key=lambda p: (p.imag, p.real))
    lh = reduce(keep_left, points, [])
    uh = reduce(keep_left, reversed(points), [])
    lh.extend(uh[1:-1])
    return lh


def keep_left(hull, r):
    if hull:
        prev = hull.pop()
        while hull:
            p = hull[-1]
            if cross(prev - p, r - p) >= 0:
                hull.append(prev)
                break
            prev = hull.pop()
        else:
            hull.append(prev)
    if not hull or hull[-1] != r:
        hull.append(r)
    return hull


n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
result = graham_scan(points)
print(len(result))
for p in result:
    print(int(p.real), int(p.imag))

Measured memory_bytes: 24748
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var t = cin.next();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var u = cin.next();

            var sum = a + b;
            if(s == u)
            {
                Console.WriteLine(a-1 + " " + b);
            }
            else
            {
                Console.WriteLine(a + " " + (b-1));
            }

            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11220
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}
int solve(){
    int n;cin>>n;
    vector<int> a(n+1);
    rep(i, 1, n+1) { cin>>a[i]; }
    dump(a);

    vector<map<int, int>> dp0(n+1);
    vector<map<int, int>> dp1(n+1);
    rep(j, -5, 10){
        int v = - 3 + j;
        dp0[0][v] = -INF;
        dp1[0][v] = -INF;
    }

    dp0[0][0] = 0;

    rep(i, 1, n+1){
        rep(j, -5, 10){
            int v = i/2 - 3 + j;
            dp0[i][v] = -INF;
            dp1[i][v] = -INF;
        }
        rep(j, 0, 5){
            int v = i/2 - 3 + j;

            // toranai
            chmax(dp0[i][v], dp0[i-1][v]);
            chmax(dp0[i][v], dp1[i-1][v]);

            // toru
            chmax(dp1[i][v], dp0[i-1][v-1]+a[i]);
        }
    }
    rep(i, n+1){
        dump(dp0[i]);
        dump(dp1[i]);
    }
    cout << max(dp0[n][n/2], dp1[n][n/2]) << endl;

    return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
    std::ifstream in(infile);
    std::cin.rdbuf(in.rdbuf());
#endif
    solve();
    return 0;
} //}}}


Measured memory_bytes: 398676
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N ;
    int a[N];

    cin >> a[0]; 
    int high = a[0];
    int count = 1 ;
    for( int i = 0; i < N-1 ; i++){
        cin >>  a[i+1];
        if(a[i+1]>=high){
            count++;
            high=a[i+1];
        }

    }

    cout << count <<endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        String s=sc.next();
        if(s.charAt(2)==s.charAt(3) && s.charAt(5)==s.charAt(4)){
            System.out.println("Yes");
        }else System.out.println("No");


    }
    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: 21332
#include<stdio.h>
int main(void){
	long long int a,b,r,d;
	double f;
	scanf("%lld %lld", &a,&b);
	d = a/b;
	r = a % b;
	f = (double)a/b;
	printf("%lld %lld %.5lf\n",d,r,f);
	return 0;
}


Measured memory_bytes: 2728
n = int(input())
e = [list() for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    e[u-1] += [[v,w]]
    e[v-1] += [[u,w]]

visited = [-1]*n
stack = [0]
visited[0]=0
while stack:
    z = stack.pop()
    for v,w in e[z]:
        if visited[v-1]==-1:
            stack.append(v-1)
            if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
        else:
            continue
print(*visited,sep="\n") 

Measured memory_bytes: 47140
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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


Measured memory_bytes: 504
a, b, m = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
k = []
notDisc = min(As) + min(Bs)
k.append(notDisc)
for i in range(m):
    t1,t2,t3 = map(int, input().split())
    dis = As[t1-1] + Bs[t2-1] - t3
    k.append(dis)
print(min(k))

Measured memory_bytes: 18612
n, k, q = map(int, input().split())
a = list(map(int, input().split()))
ans = 10000000000000
for m in a:
    res = []
    l = []
    for x in a:
        if x < m and l:
            if len(l) >= k:
                l.sort()
                for p in l[:len(l) - k + 1]:
                    res.append(p)
            l = []
        elif x >= m:
            l.append(x)
    if l:
        if len(l) >= k:
            l.sort()
            for p in l[:len(l) - k + 1]:
                res.append(p)
    res.sort()
    if len(res) >= q:
        ans = min(ans, res[q - 1] - m)
if ans == 10000000000000:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 47324
#include <iostream>

using namespace std;

bool prime_table[100000];
int n;

void make_table() {
    for (int i = 0; i < 100000; i++) 
        prime_table[i] = true;

    prime_table[0] = false;
    prime_table[1] = false;

    for (int i = 2; i + i < 100000; i++) {
        if (prime_table[i]) {
            for (int j = i + i; j < 100000; j += i) {
                prime_table[j] = false;
            }
        }
    }
}

void solve() {
    int i;
    for (i = n-1; !prime_table[i]; i--);

    int j;
    for (j = n+1; !prime_table[j]; j++);
    cout << i << ' ' << j << endl;
}

int main() {
    make_table();
    while (cin >> n) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan =  null;
		try{
			scan = new Scanner(System.in);
			int n;
			while((n = scan.nextInt())!= 0){
				int A = 0,B = 0;
				for(int i = 0; i < n;i++){
					int a = scan.nextInt(),b = scan.nextInt();
					if(a < b)B += b+a;
					else if(a > b)A += b+a;
					else{
						A +=a;
						B +=b;
					}
				}
				System.out.printf("%d %d\n",A,B);
			}
		}finally{
			if(scan !=null)scan.close();
		}
	}
}

Measured memory_bytes: 53372
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
const int MAX = 4040404;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    long long sum = 0;
    for (int i = 0; i < N; ++i) cin >> A[i], sum += A[i];

    bitset<MAX> dp;
    dp[0] = 1;
    for (int i = 0; i < N; ++i) {
        dp |= (dp << A[i]);
    }
    long long res;
    for (res = (sum+1)/2; res < MAX; ++res) {
        if (dp[res]) break;
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

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


int main() {
	int i, j, k;
	int N, M, K;

	string S;
	cin >> N >> S;

	int a, b;
	a = b = 0;
	int c = 0;
	rep(i, 0, N) {
		if (S[i] == '(') {
			c++;
		}
		else {
			if (c > 0)
				c--;
			else
				b++;

		}
	}
	a = c;
	rep(i, 0, b)
		cout << '(';

	cout << S;
	rep(i, 0, a)
		cout << ')';


	return 0;

}


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

int main(){
  int n,t,a;
  cin>>n>>t>>a;
  double dan=10000;
  int ans=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(abs(a-t+x*0.006)<dan){
      dan=abs(a-t+x*0.006);
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    vi dp(n+10,INF);
    dp[0]=0;
    rep(i,n){
        chmin(dp[i+1],dp[i]+abs(v[i+1]-v[i]));
        chmin(dp[i+2],dp[i]+abs(v[i+2]-v[i]));
    }
    fin(dp[n-1]);
}


Measured memory_bytes: 1024
//============================================================================
// Name        : AtcoderDpJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 301;
int n, buf,
	c[4];
double dp[MAX][MAX][MAX];

double rec(int i, int j, int k){
	if(i == 0 && j == 0 && k == 0) return 0.;
	if(dp[i][j][k]) return dp[i][j][k];

	double tot = 1;

	if(i > 0) tot += rec(i - 1, j + 1, k) * ((double)i / n);
	if(j > 0) tot += rec(i, j - 1, k + 1) * ((double)j / n);
	if(k > 0) tot += rec(i, j, k - 1) * ((double)k / n);

	return dp[i][j][k] = tot / (1. - ((double)(n - i - j - k) / n));
}

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

	cin >> n;

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

	printf("%.12f\n", rec(c[3], c[2], c[1]));
}


Measured memory_bytes: 213248
S = str(input())

check = 0
for i in range(len(S)):
    if S[i] == 'L' or  S[i] ==  'R' or S[i] == 'U' or S[i] == 'D':
        check += 0
    else:
        check += 1

if 1 <= len(S) <= 100 and check==0:
    pass
else:
    print('EROOR')
    S = str(input())

RUD = 0
LUD = 0

for i in range(0,len(S),2):
    if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
        RUD += 0
    else:
        RUD += 1
        
for i in range(1,len(S),2):
    if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
        LUD += 0
    else:
        LUD += 1

if RUD == 0 and LUD == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int x; cin>>x;
  int ans = 1;
  for (int i=2; i<=x; i++) {
    for (int j=2; pow(i,j)<=x; j++) {
      ans = max(ans, (int)pow(i,j));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int res[112345];

struct edge
{
    int to;
    int id;
};

vector<edge> g[112345];

bool used[112345];

int c = 0;

void dfs(int s, int pre)
{
    used[s] = true;

    int color = 1;

    for (auto i : g[s])
    {
        if (used[i.to])
            continue;

        if (color == pre)
            color++;

        res[i.id] = color;

        c = max(c, color);

        dfs(i.to, color);

        color++;
    }
}

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

    int n, a[112345], b[112345];

    memset(used, 0, sizeof(used));

    cin >> n;
    REP(i, n - 1)
    {
        cin >> a[i] >> b[i];

        g[a[i]].push_back({b[i], i});
        g[b[i]].push_back({a[i], i});
    }

    dfs(1, 0);

    cout << c << endl;

    REP(i, n - 1)
    cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll int
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 300005
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}

void solve()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll gc;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        if (i)
            gc = __gcd(gc, a[i]);
        else
            gc = a[i];
    }
    bool f = 0;
    unordered_map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        ll tmp = a[i];
        ll check = 0;
        while (!(tmp % 2))
        {
            tmp = tmp / 2;
            if (mp[2] && check == 0)
            {
                f = 1;
            }
            mp[2]++;
            check = 1;
        }
        for (ll j = 3; j * j < tmp; j += 2)
        {
            check = 0;
            while (tmp % j == 0)
            {
                tmp = tmp / j;
                if (mp[j] && check == 0)
                {
                    //cout << j << endl;
                    f = 1;
                }
                mp[j]++;
                check = 1;
            }
        }
        if (tmp > 2)
        {

            if (mp[tmp])
            {
               // cout << tmp << endl;
                f = 1;
            }
           
            mp[tmp]++;
             tmp = tmp / tmp;
        }
    }
   // cout << f << endl;
    if (!f)
    {
        cout << "pairwise coprime" << endl;
    }
    else if (gc == 1)
    {
        cout << "setwise coprime" << endl;
    }
    else
    {
        cout << "not coprime" << endl;
    }
}

int main()
{

    speed;

    ll kk;
    kk = 1;
    // cin >> kk;
    while (kk--)
    {

        solve();
    }
    return 0;
}

Measured memory_bytes: 10448
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    vector<pair<ll, char>> v(m);
    rep(i, m) {
        ll s; char c; cin >> s >> c; s--;
        v[i] = {s, c};
    }

    for (ll i = (n != 1 ? (ll)pow(10, n - 1) : 0); i < (ll)pow(10, n); i++) {
        string j = to_string(i);
        bool isok = true;
        rep(k, m) {
            if (j[v[k].first] != v[k].second) {
                isok = false;
            }
        }

        if (isok) {
            cout << j << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256