akhauriyash/Code-Regression huggingface dataset:
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll n,h[100005][3],i,j,k,l,dp[100005][3];
    cin>>n;
    rep(i,0,n-1)rep(j,0,2)cin>>h[i+1][j],dp[i+1][j]=0; 
    rep(i,1,n)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+h[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+h[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+h[i][2];
    }cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define ALL(n) begin(n), end(n)

int main()
{
  int N, res = 0, it;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);
  rep(i, N)
  {
    int big = 0;
    rep(j, N)
    {
      if (big < a.at(j))
      {
        big = a.at(j);
        it = j;
      }
    }
    a.at(it) = 0;
    res += pow(-1, i) * big;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
p = np.array(list(map(int, input().split())))
l = np.arange(1,n+1)
cnt = np.count_nonzero(l-p == 0)
ans = 0

if cnt == 0:
  print(ans)
else:
  for i in range(n-1):
    if p[i] == i+1:
      ans += 1
      p[i+1]=0
  else:
    if p[n-1] == n:
      ans += 1
    print(ans)
      

Measured memory_bytes: 23368
N = gets.to_i
arr = gets.split.map(&:to_i)

if N == 2
  puts arr.max - arr.min
  puts "#{arr.max} #{arr.min}"
else
  logs = []

  arr.sort!
  min = arr.shift
  max = arr.pop
  arr.each do |i|
    if i > 0
      logs.push([min, i])
      min -= i
    else
      logs.push([max, i])
      max -= i
    end
  end
  puts max - min
  logs.each { |log| puts "#{log[0]} #{log[1]}"}
  puts "#{max} #{min}"
end


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

int main() {
	int n,k;cin>>n>>k;
	long long ans=0;
	if(k%2){
		ans=n/k;
		ans=ans*ans*ans;
	}else{
		ans=n/k;
		ans=ans*ans*ans;
		n=n+k/2;
		long long ans2=0;
		ans2=n/k;
		ans2=ans2*ans2*ans2;
		ans+=ans2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>

using namespace std;

int main(void) {
    int N;
    vector<int> A(500010,0);
    vector<long long> S(500010,0), X(500010,0);
    cin >> N;
    for (int i=0;i<N;i++) cin >> A[i];
    S[0] = 0; X[0] = 0;
    for (int i=1;i<=N;i++) {
        S[i] = S[i-1] + A[i-1];
        X[i] = X[i-1] ^ A[i-1];
    }
#ifdef DEBUG
    for (int i=0;i<=N;i++) cout << S[i] << "\t";
    cout << endl;
    for (int i=0;i<=N;i++) cout << X[i] << "\t";
    cout << endl;
#endif

    long long ret = 0;
    int r = 0;
    for (int l = 0; l <= N; l++) {
        while (r <= N && (X[r]^X[l]) == S[r]-S[l]) {
            r++;
        }
#ifdef DEBUG
            cout << l << "," << r << endl;
#endif
        ret += r - l - 1;
        if (r == l) r++;
    }

//     for (int i=0;i<=N;i++) for (int j=i+2;j<=N;j++) {
//         if ((X[j]^X[i]) == S[j]-S[i]) {
//             ret++;
// #ifdef DEBUG
//             cout << i << "," << j << endl;
// #endif
//         }
//     }
    cout << ret << endl;

    return 0;
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    Fast
    int n;
    cin >> n;
    LL arr[n+1],Pow[n+1];
    FOR(i,0,n) cin >> arr[i];
    Pow[0]=1;
    FOR(i,1,n) Pow[i]=min((LL)1e18,Pow[i-1]+Pow[i-1]);
    LL leaf = 0,sum = 0;
    ROF(i,n,0){
    	LL lev = arr[i] + (leaf+1)/2;
    	sum += arr[i];
    	if(lev>Pow[i]){
    		cout << -1;
    		return 0;	
    	}
    	leaf = lev;
    }
    LL now = 1,ans = 0;
    FOR(i,0,n){
    	ans += min(now,sum);
    	sum -= arr[i];
    	now -= arr[i];
    	now = min(now+now,(LL)1e18);
    }
    cout << ans;
}


Measured memory_bytes: 5216
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b >> c;
	if (c > b && c - b > a) {
		cout << "dangerous" << "\n";
	}
	else if (c > b && c - b <= a) {
		cout << "safe" << "\n";
	}
	else {
		cout << "delicious" << "\n";
	}
	std::cin >> e;
}

Measured memory_bytes: 256
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    map <int,int> was;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        was[i + a[i]]++;
        ans += was[i - a[i]];
    }
    cout << ans << '\n';
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 27164
<?php
$n = int();
$a = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $n; $i++){
    echo $a[0][$i];
    echo $a[1][$i];
}
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
#include <iostream>
#include <queue>
#include <string>

using namespace std;

const int N_MAX = 5 * 1e3 + 10;

typedef struct cover {
    int first;
    int second;
    int len;
} Cover;

int checked[N_MAX][N_MAX] = {0};

int main() {
    int N;
    string S;

    cin >> N >> S;

    queue< Cover > que;

    for (int i = 0; i < S.length(); i++) {
        for (int j = i + 1; j < S.length(); j++) {
            if (S[i] == S[j]) {
                if (i == 0 || j == 0) {
                    que.push(Cover{i, j, 1});
                } else if (checked[i - 1][j - 1] == 0) {
                    que.push(Cover{i, j, 1});
                }
                checked[i][j] = 1;
            }
        }
    }

    int ans = 0;
    while (!que.empty()) {
        Cover c = que.front();
        que.pop();

        if (ans < c.len) ans = c.len;

        int nf = c.first + c.len;
        int ns = c.second + c.len;

        if (nf >= S.length()) continue;
        if (ns >= S.length()) continue;
        if (nf >= c.second) continue;

        if (S[nf] == S[ns]) {
            c.len += 1;
            que.push(c);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 125188
($N,$M)=glob<>;
/ /,${$`}{$'+0}=${$'+0}{$`}=1for<>;

sub f{
	my$c=$c[$_];
	for(keys%$_){
		if($c[$_]){
			if($c[$_]==$c){
				$e=1
			}
		}else{
			$g+=$-=$c[$_]=-$c;
			&f
		}
	}
}
f$_=$g=$c[1]=1;

print$e?$N*($N-1)/2-$M:$g*($N-$g)-$M


Measured memory_bytes: 104576
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	s, t := ReadString(), ReadString()
	ls, lt := len(s), len(t)
	dp := make([][]int, ls+1)
	for i := 0; i < ls+1; i++ {
		dp[i] = make([]int, lt+1)
	}
	for i := 1; i <= ls; i++ {
		for j := 1; j <= lt; j++ {
			dp[i][j] = dp[i-1][j]
			if dp[i][j] < dp[i][j-1] {
				dp[i][j] = dp[i][j-1]
			}
			if s[i-1] == t[j-1] && dp[i][j] < dp[i-1][j-1]+1 {
				dp[i][j] = dp[i-1][j-1] + 1
			}
		}
	}

	v := make([]byte, dp[ls][lt])
	i, j := ls, lt
	for i > 0 && j > 0 {
		if s[i-1] == t[j-1] && dp[i-1][j-1]+1 == dp[i][j] {
			v[dp[i-1][j-1]] = s[i-1]
			i--
			j--
			continue
		}
		if dp[i-1][j] == dp[i][j] {
			i--
		} else {
			j--
		}
	}
	fmt.Println(string(v))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 76936
N=int(input())
A=list(map(int,input().split()))
a=[[] for i in range(N)]
for i in range(N):
  a[i]=[i+1,A[i]]
a=sorted(a,key=lambda x:x[1])
for i in range(N):
  print(a[i][0],end='')
  print(' ',end='')

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  string s;
  cin >> s;
  set<char> se;
  rep(i,s.size()){
    if(se.count(s[i])==1){
      cout << "no" << endl;
      return 0;
    }
    else se.insert(s[i]);
  }
  cout << "yes" << endl;
  return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>


int main(void)
{
	char s[10+2], t[]="2018";

	while(scanf("%10[0-9/]\n", s)==1)
	{
		memcpy(s, t, 4);
		printf("%s\n", s);
	}

	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int a[n], ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] >= k)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    ll x = 1LL<<M;
    ll y = 1900LL * M + 100LL * (N-M);
    cout << x * y << endl;
    return 0;
}


Measured memory_bytes: 256
/********************
Author : MIHIR ARORA
********************
*/
#include <bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); 
#define input int n; scanf("%d",&n); int*arr = new int[n];  for(int i=0;i<n;i++) scanf("%d",&arr[i]);  
#define inputs int n; scanf("%d",&n); char str[n];   cin>>str;   
 
typedef long long int ll;
const int mod=1e9+7; 
ll add(ll a, ll b)
{
    return (a%mod+b%mod)%mod;
}
 
ll mul(ll a, ll b)
{
    return ((a%mod)*(b%mod))%mod;
}
 
ll sub(ll a, ll b)
{
    return ((a%mod) - (b%mod))%mod;
}
inline void solve()
{
 input; 
}
int main()
{ 
 int n ;
    cin>>n; 
    string str; 
    set<string>s; 
    for(int i=0;i<n;i++)
    {
        cin>>str; 
        s.insert(str); 
        
    }
    cout<<s.size(); 
}

Measured memory_bytes: 19228
#include<stdio.h>
#include<string.h>
int main()
{
	char seq[21];
	int x,i;
	scanf("%20s",seq);
	x=strlen(seq);
	for(i=x-1;i>=0;i--)
		printf("%c",seq[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int N, K, X, Y;
	CIN2(N, K);
	CIN2(X, Y);
	ll ans;
	ans = N * X;
	ans -= max(0, (N - K) * (X - Y));
	COUT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL a;
	cin>>a;
	LL sum = a + a*a + a*a*a;
	cout<<sum;

  	return 0;
}

Measured memory_bytes: 3644
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!(iter), parse!(iter))
    };
    ($iter: ident,3) => {
        (parse!(iter), parse!(iter))
    };
    ($iter: ident,4) => {
        (parse!(iter), parse!(iter))
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let _: usize = parse!(iter);
    let p: Vec<usize> = iter.map(|x| x.parse().unwrap()).collect();
    let mut m = 10000000;
    let mut res = 0;
    for pi in p {
        if m >= pi {
            res += 1;
            m = pi;
        }
    }
    println!("{:?}", res); // DEBUG
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
// #pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,i;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    for(i=0;i<2*n;i++)
    {
        if(i%2)
        {
            cout<<s2[(i-1)/2];
        }
        else
            cout<<s1[i/2];
    }


}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[2 * n];
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
sc.close();
Arrays.sort(arr);
int sum = 0;
for (int i = 0; i < arr.length; i += 2) {
sum += arr[i];
}
System.out.println(sum);


}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  rep(i,ty-sy) cout << "U";
  rep(i, tx-sx) cout << "R";
  rep(i,ty-sy) cout << "D";
  rep(i, tx-sx+1) cout << "L";
  rep(i,ty-sy+1) cout << "U";
  rep(i, tx-sx+1) cout << "R";
  cout << "DR";
  rep(i,ty-sy+1) cout << "D";
  rep(i, tx-sx+1) cout << "L";
  cout << "U\n";
}

Measured memory_bytes: 256
N=int(input())
X=[]
Y=[]
for i in range(N):
  x,y=map(int,input().split())
  X +=[x]
  Y +=[y]
L=0#全点同士の距離の合計
for i in range(N-1):
  for j in range(i+1,N):
    L+= (((X[i]-X[j])**2)+((Y[i]-Y[j])**2))**0.5
    
print(L*2/N)


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);//インタラクション問題には使用しないこと
	std::cout << std::fixed;
	std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL n,l,r,a[55]={};
	cin>>n>>l>>r;
	FOR(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	LD maxv=-1,val,minv=a[n-1];
	LL c=0,c2=upper_bound(a,a+n,a[n-1])-lower_bound(a,a+n,a[n-1]),c3=0;
	LL t=1;
	FORQ(i,l,r){
		val=0;
		c3=0;
		FOR(j,n-i,n){
			val+=a[j];
			if(minv==a[j])c3++;
		}
		val/=i;
		if(maxv==-1)maxv=val;
		if(minv==a[n-i]){
			LL t=1;
			int k=1;
			FORD(ii,c2+1,c2-c3+1){
				t*=ii;
				t/=k;
				k++;
			}
			//FORQ(ii,k,c3)t/=ii;
			c+=t;
			//cout<<"test i:"<<i<<" "<<c2<<" "<<c3<<" "<<t<<" "<<val<<endl;
		}else if(i==l){
			c3=0;
			FOR(j,n-i,n){
				val+=a[j];
				if(a[n-l]==a[j])c3++;
			}
			c2=upper_bound(a,a+n,a[n-l])-lower_bound(a,a+n,a[n-l]);
			LL t=1;
			int k=1;
			FORD(ii,c2+1,c2-c3+1){
				t*=ii;
				t/=k;
				k++;
			}
			//FORQ(ii,k,c3)t/=ii;
			c+=t;
			//cout<<"test i:"<<i<<" "<<c2<<" "<<c3<<" "<<t<<" "<<val<<endl;
		}else break;
	}

	cout<<maxv<<endl;
	std::cout << std::defaultfloat;
	cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int d;
    scanf("%d",&d);
    if(d==25)
        printf("Christmas\n");
    if(d==24)
        printf("Christmas Eve\n");
    if(d==23)
        printf("Christmas Eve Eve\n");
    if(d==22)
        printf("Christmas Eve Eve Eve\n");
    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  map<string,vector<pair<int,int>>> mp;
  int n;
  cin>>n;
  rep(i,n){
    string s;
    int p;
    cin>>s>>p;
    mp[s].emplace_back(100-p,i+1);
  }
  for(auto it : mp){
    sort(rng(it.se));
    for(auto it2:it.se){
      cout<<it2.se<<endl;
    }
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    int l = -1, r = n-1;
    while(r-l > 1){
        int m = (r+l)/2;
        ll s = 0;
        rep(i,m+1) s += a[i];
        bool can = true;
        int p = m+1;
        while(p < n){
            if(2*s >= a[p]){
                s += a[p];
                p++;
            } else {
                can = false;
                break;
            }
        }
        if(can) r = m;
        else l = m; 
    }
    cout << n-r << endl;
    return 0;
}

Measured memory_bytes: 1024
#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 if(B == C){
  cout << A << endl;}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=6e5+10;
struct oo{int x,y;};priority_queue<oo>q;
int n,a[maxn],b[maxn],flag;long long ans;
bool operator<(oo u,oo v){return u.y>v.y;}
int main(){
    read(n);
    for(rg int i=0;i<n;i++)read(a[i]);
    for(rg int i=0;i<n;i++)read(b[i]);
    for(rg int i=0;i<n;i++)
	if(b[i]>=b[(i+1)%n]+b[(i-1+n)%n])q.push((oo){i,b[i]});
    while(q.size()){
	int t,i=q.top().x,x=(i-1+n)%n,y=(i+1)%n,now=b[x]+b[y];
	ans+=(t=(b[i]-a[i])/now),b[i]-=t*now;q.pop();
	if(b[x]>=b[(x+1)%n]+b[(x-1+n)%n])q.push((oo){x,b[x]});
	if(b[y]>=b[(y-1+n)%n]+b[(y+1)%n])q.push((oo){y,b[y]});
    }
    for(rg int i=1;i<=n;i++)if(a[i]!=b[i])flag=1;
    printf("%lld\n",flag?-1:ans);
}


Measured memory_bytes: 4216
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int n;
int ac,wa,tle,re;
string s;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n){
        cin >> s;
        if(s == "AC") ac++;
        else if(s == "TLE") tle++;
        else if(s == "WA") wa++;
        else re++;
    }

    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__);


int main(){
    dcl(n);
    int ans=0;
    vi p(n);
    rep(i,n)get(p[i]);
    rep(i,n){
        if(p[p[i]-1]-1==i)ans++;
    }
    cout<<ans/2<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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 Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	int a[110];
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = Inf;
	for (int B = -100; B <= 100; B++) {
		int tmp = 0;
		for (i = 0; i < n; i++) {
			tmp += pow(B - a[i], 2);
		}
		ans = min(ans, tmp);
	}
	cout << ans;
	return(0);
}

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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n,x,y;
        cin>>n>>x>>y;
        int a[n+1];
        memset(a,0,sizeof a);
        loop(i,1,n-1)
        {
            loop(j,i+1,n)
            {
                int len=j-i;
                len=min(len,abs(i-x)+abs(j-y)+1);
                a[len]++;
            }
        }
        loop(i,1,n-1)
        {
            cout<<a[i];
            nl;
        }

    }
    return 0;
}


Measured memory_bytes: 3648
n,m=map(int,input().split())
h=list(map(int,input().split()))
road=[[] for i in range(n)]
f=0
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b)
    road[b-1].append(a)
for i in range(n):
    if all(h[i-1]>h[road[i-1][j]-1] for j in range(len(road[i-1]))):
           f+=1
print(f)





Measured memory_bytes: 29332
import numpy as np

def main():
    n, k = map(int, input().split())
    a = list(map(lambda x: int(x)-1, input().split()))
    foot = [0]
    is_loop = False
    ed = np.zeros([n], dtype=int)
    ed[0] = 1

    for i in range(1,k):
        go = a[foot[-1]]
        foot.append(go)
        if ed[go] == 1:
            st_i = foot.index(foot[-1])
            lo_size = len(foot)-1 - st_i

            k -= st_i
            k %= lo_size
            
            print(foot[st_i+k]+1)
            is_loop = True
            break
        ed[go] = 1
    
    if not is_loop:
        print(a[foot[-1]]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51068
lines = readlines.map(&:chomp).map{|line| line.split.map(&:to_i)}
lines.each do |line|
    break if line == [0, 0]
    line[0].times do |i|
        line[1].times do |j|
            if i.odd?&&j.odd? || i.even?&&j.even? then
                print "#"
                next
            end
            if i.odd?&&j.even? || i.even?&&j.odd? then
                print "."
                next
            end
        end
        puts
        end
    puts
end


Measured memory_bytes: 6876
#include <iostream>
using namespace std;
#define NIL -1

struct node {
  int parent;
  int left;
  int right;
};

node T[10000];
int H[10000];

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL) {
    h1 = setHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = setHeight(T[u].right) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int main() {
  int n, id, l, r, root;
  cin >> n;
  for (int i = 0; i < n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }
  for (int i = 0; i < n; i++) {
    cin >> id >> l >> r;
    T[id].left = l;
    T[id].right = r;
    if (l != -1) {
      T[l].parent = id;
    }
    if (r != -1) T[r].parent = id;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }
  setHeight(root);

  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", sibling = ";
    if (T[i].parent != NIL) {
      if (T[T[i].parent].left == i) {
        cout << T[T[i].parent].right;
      } else {
        cout << T[T[i].parent].left;
      }
    } else {
      cout << -1;
    }
    cout << ", degree = ";
    if (T[i].left != NIL && T[i].right != NIL) {
      cout << 2;
    } else if (T[i].left != NIL || T[i].right != NIL) {
      cout << 1;
    } else {
      cout << 0;
    }
    cout << ", depth = ";
    int d = 0, p = i;
    while (T[p].parent != NIL) {
      d++;
      p = T[p].parent;
    }
    cout << d << ", height = " << H[i] << ", ";
    if (T[i].parent == NIL) {
      cout << "root";
    } else if (T[i].left == NIL && T[i].right == NIL) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }
    cout << endl;
  }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << round( ( a + b ) / 2.0 ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007; // 10^9 + 7

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

  int N, Y; cin >> N >> Y; Y /= 1000;
  for (int b = 0; b <= min((10 * N - Y) / 5, (Y - N) / 4); b++) {
    if ((10 * N - Y - 5 * b) % 9 > 0) continue;
    int c = (10 * N - Y - 5 * b) / 9;
    cout << N - b - c << " " << b << " " << c << endl;
    return 0;
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	set<int>a,b;
	map<int,ll>cnta,cntb;
	rep(i,n){
		int h;
		cin>>h;
		int ite=i+1;
		if(ite>=h){
			cntb[ite-h]++;
		}
		if(ite+h<=2e5){
			cnta[ite+h]++;
		}
		a.insert(ite+h);
	}
	ll ans=0;
	for(auto i=a.begin(); i!=a.end();i++){
		int t=*i;
		ans+=(ll)cnta[t]*cntb[t];
	}
	cout<<ans<<endl;
}

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


Measured memory_bytes: 37920
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc102_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            n = (n % 2 == 0) ? n : n*2;
            WriteLine(n);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#define ll long long
#define N 100010
using namespace std;
priority_queue<ll,vector<ll>,less<ll> >lf;
priority_queue<ll,vector<ll>,greater<ll> >rf;
ll l[N],r[N],len[N];
ll deltl,deltr,L,R,ans;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%lld%lld",&l[i],&r[i]),len[i]=r[i]-l[i];
	lf.push(r[1]),rf.push(r[1]);
	for(int i=2;i<=n;i++)
	{
		deltl-=len[i-1];
		deltr+=len[i];
		L=lf.top()+deltl;
		R=rf.top()+deltr;
		if(r[i]>=L && r[i]<=R)
		{
			lf.push(r[i]-deltl);
			rf.push(r[i]-deltr);
		}
		else if(r[i]>R)
		{
			ans+=r[i]-R;
			rf.pop();
			lf.push(R-deltl);
			rf.push(r[i]-deltr);
			rf.push(r[i]-deltr);
		}
		else
		{
			ans+=L-r[i];
			lf.pop();
			rf.push(L-deltr);
			lf.push(r[i]-deltl);
			lf.push(r[i]-deltl);
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define LiangJiaJun main
#define INF 1999122700
using namespace std;
int n,k,a[200004],cnt=0;
int LiangJiaJun(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(a[x]==0)++cnt;
        a[x]++;
    }
    if(cnt<=k)return puts("0"),0;
    cnt-=k;
    sort(a+1,a+200000+1);
    int ans=0;
    for(int i=1;i<=200000;i++){
        if(a[i]!=0)ans+=a[i],--cnt;
        if(cnt<=0)break;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)==2)
    {
        if(b%a==0)
        {
            cout<<a+b<<endl;
        }
        else
        {
            cout<<b-a<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int k,input;
  while(cin>>k && k){
    int sum=0;
    for(int i=0;i<k*(k-1)/2;i++){
      cin>>input;
      sum+=input;
    }
    cout<<sum/(k-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  char *s = (char *) calloc (200000 + 1, sizeof (char));
  scanf ("%s", s);
  i32 n = strlen (s);
  s[n] = 'B';
  i64 ans = 0;
  for (i32 i = 0, a = 0; i < n; ++i) {
    if (s[i] == 'A') {
      a++;
    } else if (s[i] == 'B' && s[i + 1] == 'C') {
      ans += a;
      i++;
    } else {
      a = 0;
    }
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def list_duplicate(l, m):
    if len(l) <= len(m):
        l1 = l
        l2 = m
    else:
        l1 = m
        l2 = l
    ret = []
    for v in l1:
        if v in l2:
            ret.append(v)
            l2.remove(v)
    return ret

n = int(readline())
l = list(readline().decode().rstrip())
for _ in range(n - 1):
    m = list(readline().decode().rstrip())
    l = list_duplicate(l, m)
l.sort()

print("".join(l))

Measured memory_bytes: 9168
module m1
  implicit none
  type :: edge
     integer ix
     integer,allocatable :: v(:)
  end type edge
  integer ans,v0
  logical,allocatable :: visited(:)
end module m1

program agc033c
  use m1
  implicit none
  integer a, b, i, n
  integer,allocatable :: v1(:), v2(:), cnt(:)
  type(edge),allocatable :: e(:)

  read *, n
  allocate(v1(n-1),v2(n-1),cnt(n),e(n),visited(n))

  v1 = 0
  v2 = 0
  cnt = 0
  visited = .false.

  do i = 1,n-1
     read *, a,b
     v1(i) = a
     v2(i) = b
     cnt(a) = cnt(a) + 1
     cnt(b) = cnt(b) + 1
  end do

  do i = 1,n
     e(i)%ix = 1
     allocate(e(i)%v(cnt(i)))
  end do

  do i = 1,n-1
     e(v1(i))%v(e(v1(i))%ix) = v2(i)
     e(v2(i))%v(e(v2(i))%ix) = v1(i)
     e(v1(i))%ix = e(v1(i))%ix + 1
     e(v2(i))%ix = e(v2(i))%ix + 1
  end do

  ans = 0
  v0 = 1

  call visit(1,0)
  call visit(v0,0)

  if (mod(ans,3) == 1) then
     print *, 'Second'
  else
     print *, 'First'
  end if

contains

  recursive subroutine visit(vertex,distance)
    integer,intent(in) :: vertex,distance
    integer i

    visited(vertex) = .true.

    do i = 1,size(e(vertex)%v)
       if (.not.visited(e(vertex)%v(i))) then
          call visit(e(vertex)%v(i),distance+1)
       end if
    end do

    visited(vertex) = .false.

    if (ans < distance) then
       ans = distance
       v0 = vertex
    end if
  end subroutine visit
end program agc033c


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

vvi v;
vi color;

bool dfs(int now,int c) {
  color[now]=c;
  for(int x:v[now]) {
    if(color[x]==c) return false;
    if(!color[x]&&!dfs(x,-c)) return false;
  }
  return true;
}

int main() {
  ll N,M;
  cin >> N >> M;
  v=vvi(N);
  color=vi(N);
  vi A(M),B(M);
  rep(i,M) {
    cin >> A[i] >> B[i];
    A[i]--;B[i]--;
    v[A[i]].push_back(B[i]);
    v[B[i]].push_back(A[i]);
  }
  
  if(dfs(0,1)) {
    int count=0;
    rep(i,N) {
      if(color[i]==1) count++;
    }
    cout << count*(N-count)-M << endl;
  }
  else cout << N*(N-1)/2-M << endl;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

//Node treeMinimum(Node x){


//}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

//Node treeSuccessor(Node x){


//}

//void treeDelete(Node z){
//Node y; // node to be deleted
//Node x; // child of y



//}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL) preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  //else if ( com[0] == 'd' ){
  //  scanf("%d", &x);
  //  treeDelete(treeSearch(root, x));
  //}
  }
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int MAXLOG = 30; 
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, a[MAXN], b[MAXN], c[MAXN];
int getcnt(int x, int y) {
	return lower_bound(c + 1, c + n + 1, y + 1) - lower_bound(c + 1, c + n + 1, x);
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	for (int i = 1; i <= n; i++)
		read(b[i]);
	int ans = 0;
	for (int p = 1; p <= MAXLOG; p++) {
		int tmp = 1 << p, tnp = 1 << (p - 1);
		for (int i = 1; i <= n; i++)
			c[i] = b[i] % tmp;
		sort(c + 1, c + n + 1);
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			int now = a[i] % tnp;
			if (a[i] & tnp) cnt += n - getcnt(tnp - now, tmp - 1 - now);
			else cnt += getcnt(tnp - now, tmp - 1 - now);
		}
		ans += (cnt & 1) * tnp;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans {1};
    char buf = ' ';
    for(auto c : s){
        if (buf == ' ') buf = c;
        else if(buf != c){
            ans++;
            buf = c;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
l=list(input().split())
l=l[::-1]
stack=[]
while len(l)>0:
  n=l.pop()
  if n in ["+","-","*"]:
    a=int(stack.pop())
    b=int(stack.pop())
    if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
  else:
    stack.append(n)
print(stack[-1])


Measured memory_bytes: 5600
import math, fractions


def num_prime_factor(n):
    
    ret = 0

    for i in range(1, int(math.sqrt(n)) + 2):

        composite = False

        if n % i == 0:
            ret += 1
            n = n / i

            if i != 1:
                while n % i == 0:
                    n = n / i

            if n == 1:
                break

            for j in range(2, int(math.sqrt(n)) + 2):
                if n % j == 0:
                    composite = True
                    break

            if not composite:
                ret += 1
                break

    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(num_prime_factor(n))

Measured memory_bytes: 64492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 1e11 + 7;
const int maxn = 2e5+5;
#include<atcoder/dsu>
using namespace atcoder;
void solve() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    f(m) {
        int op, x, y;
        cin >> op >> x >> y;
        if (!op) {
            d.merge(x, y);
        }
        else {
            cout << d.same(x, y) << '\n';
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pi acos(-1)

using namespace std;

int main() {
    nl // Bazzi - Paradise

    string s; cin >> s;

    bool a = 0;

    for(auto x : s) {
        if(x == '9') a = 1;
    }
    cout << (a ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3588
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

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

int main(){
    ll n,x;
    cin>>n>>x;
    cout<<3*(n-gcd(n,x))<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256