akhauriyash/Code-Regression huggingface dataset:
def ume(s):
    while(len(s) <6):
        s = '0' + s
    return s

N, M = [int(i) for i in input().split()]

A = [[] for i in range(N+1)]
for i in range(M):
    P, Y = [int(i) for i in input().split()]
    A[P].append((Y, i))

ans = []
for i in range(1,N+1):
    A[i].sort()
    upper = ume(str(i))
    for j in range(1,len(A[i])+1):
        lower = ume(str(j))
        ans.append((A[i][j-1][1] ,upper+lower))

ans.sort()
for i in range(M):
    print(ans[i][1])


    


Measured memory_bytes: 42340
#include <cstdio>
#include <array>
using namespace std;

typedef array<int, 10001> v;

static inline int in()
{
    int c, n = 0;
    while ((c = getchar_unlocked()) >= '0' && c <= '9')
		n = 10 * n + (c - '0');
    return n;
}

int main()
{
	int n = in(), c = n;

	v b = {};

	while (n--)
		b[in()]++;

	bool f = true;
	for (int i = 0; c; i++)
		while (b[i]--)
			printf("%s%d", (f? f = false, "": " "), i), c--;
	puts("");
}



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

#define ull unsigned long long int
#define lli long long int
#define li long int
#define ld long double
#define ft first
#define sc second

#define mp make_pair
#define pb push_back

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;
const int MAX = 2e5+5;
const lli MOD = 1e9+7;

lli A[MAX], DP[MAX];
lli DPcolor[MAX];

int main() {
	// freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int N; cin >> N;
    int ind = 0;
    for(int i=0; i<N; i++) {
    	lli temp; sll(temp);
    	if(i>0 && temp == A[ind-1]) {
    		continue;
    	}
    	A[ind] = temp; ind++;
    }

    N = ind;

    DP[N] = 0; DP[N-1] = 1;
    DPcolor[A[N-1]] = 1;
    for(int i=N-2; i>=0; i--) {
    	DP[i] = DP[i+1];
    	//if(last[A[i]] != -1) {
    	DP[i] =  (DP[i] + DPcolor[A[i]]) % MOD;
    	//}
    	DPcolor[A[i]] = (DPcolor[A[i]] + DP[i+1]) % MOD;
    }

    cout << DP[0] << "\n";


	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for(int i=0;i<N;i++){
    cin>> x.at(i) >> u.at(i);
  }
  
  double ans=0;
  double BTC=380000.0;
  for(int i=0;i<N;i++){
    if(u.at(i) == "JPY"){
      ans += x.at(i);
    }else if(u.at(i) == "BTC"){
      ans += x.at(i)*BTC;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut sum = 0;
    let mut ans: Vec<usize> = Vec::new();
    for i in 1..(n + 1) {
        sum += i;
        ans.push(i);
        if sum >= n {
            break;
        }
    }

    if sum > n {
        ans.remove(sum - n - 1);
    }

    let mut result = String::new();
    for a in ans {
        result.push_str(&format!("{}\n", a));
    }
    return result.trim().to_string();
}


Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    // Your code here!
    int N,M,S;
    //int arr[100];
    int comp;
    vector<int> arr;
   
    cin >>N>>M>>S;
     if(M-N>0)comp=M;
    else comp = N;
    for(int i=1;i<comp+10;i++){
     if(N%i==0&&M%i==0){
    arr.push_back(i);
      }
    }
   sort(arr.begin(),arr.end(),greater<int>());
   cout<<arr[S-1]<<endl;
}

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

int arr[10][10];

void floyd() {
for (int k=0; k<=9; k++)
for (int i=0; i<=9; i++)
for (int j=0; j<=9; j++)
if (i!=j && j!=k && i!=k)
if (arr[i][k]+arr[k][j]<arr[i][j])
arr[i][j]=arr[i][k]+arr[k][j];
}�

int main() {
    int r,c;
    cin >> r >> c;
    
    int cost;
    long long cnt=0;
    for (int i=0;i<10;i++)
        for (int j=0;j<10;j++){
            cin >> arr[i][j];
        }
    
    floyd();
    
    for (int i=0;i<r;i++)
        for (int j=0;j<c;j++){
            cin >> cost;
            if (cost==-1)
                continue;
            cnt+=(long long)arr[cost][1];
        }
        
    cout << cnt << endl;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> d(n);
	for (auto& a : d) cin >> a;
	long long ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			ans += d[i] * d[j];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,k,i,a=1;
	scanf("%d",&n);
	scanf("%d",&k);
	for(i=0;i<n;i++) {
		if(a<=k) {
			a=a*2;
		} else {
			a=a+k;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a[5];
  int t[5];
  int sum=0;
  int min=700;
  for(int i=0;i<5;i++){
    cin>>a[i];
    t[i]=(10-a[i]%10)%10;
  }
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(i==j)continue;
      sum+=a[j]+t[j];
    }
    sum+=a[i];
    if(min>sum)min=sum;
    sum=0;
  }
  cout<<min<<endl;
  return 0;
}

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

using namespace std;

static int64_t dp[50][51][2501];

int64_t subsolve(const std::vector<int>& xs, int startPos, int count, int sum) {
  int64_t dpRet = dp[startPos][count][sum];
  if (dpRet >= 0) {
    return dpRet;
  }

  int64_t ret = 0;
  int const xn = xs.size();
  if (xn - startPos < count) {
    dp[startPos][count][sum] = ret;
    return ret;
  }
  if (startPos >= xn) {
    dp[startPos][count][sum] = ret;
    return ret;
  }

  if (count == 1) {
    if (sum > 50) {
      dp[startPos][count][sum] = ret;
      return ret;
    }
    for (int i = startPos; i < xn; i++) {
      if (xs[i] == sum) {
        ret++;
      }
    }
    dp[startPos][count][sum] = ret;
    return ret;
  }

  if (count == xn) {
    int64_t sumsum = 0;
    for (int i = startPos; i < xn; i++) {
      sumsum += xs[i];
    }
    if (sumsum == sum) {
      ret = 1;
    }
    dp[startPos][count][sum] = ret;
    return ret;
  }

  ret = subsolve(xs, startPos + 1, count - 1, sum - xs[startPos]) +
        subsolve(xs, startPos + 1, count, sum);
  dp[startPos][count][sum] = ret;
  return ret;
}

int64_t solve(int a, const std::vector<int>& xs) {
  int64_t ret = 0;
  for (int i = 1; i <= xs.size(); i++) {
    ret += subsolve(xs, 0, i, i * a);
  }
  return ret;
}

int main() {
  memset(dp, 0xFF, 50 * 51 * 2501 * sizeof(int64_t));
  int n, a;
  std::cin >> n >> a;
  std::vector<int> xs(n);
  for (auto& x : xs) {
    std::cin >> x;
  }
  std::cout << solve(a, xs) << std::endl;
  return 0;
}

Measured memory_bytes: 50048
#include <iostream>

const int MAXN = 1e5 + 5;

using namespace std;

int n,k,v[MAXN],dp[MAXN];

int main()
{
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        cin>>v[i];
        dp[i] = 2e9;
    }
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        for(int j = max(1,i - k); j <= i - 1; j++){
            dp[i] = min(dp[i],dp[j] + abs(v[j] - v[i]));
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
      	int b = scn.nextInt();
      	int c = scn.nextInt();
      	String ans = "NO";
      	if(b-a==c-b) ans = "YES";
      	System.out.println(ans);
	}
}

Measured memory_bytes: 35584
N = int(input())
h = list(map(int, input().split()))
dp = []

for i in range(N):
    if i == 0:
        dp.append(0)
    elif i == 1:
        dp.append(abs(h[i]-h[i-1]))
    else:
        dp.append(min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])))
        
print(dp[-1])

Measured memory_bytes: 13980
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        W: chars,
    }
    let mut map = BTreeMap::new();
    for w in W{
        *map.entry(w).or_insert(0) += 1;
    }
    let mut Ans = "Yes";
    for m in map{
        if m.1%2 != 0{
            Ans = "No";
            break;
        }
    }
    println!("{}", Ans);
}

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

namespace AtTest.ABC_134
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nd = ReadInts();
            int n = nd[0];
            int d = nd[1];
            int res = n / (d * 2 + 1);
            if (n % (d * 2 + 1) > 0) res++;
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char smax(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char smin(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I> inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 2e5 + 7;
const int P = 1e9 + 7;
const int Inv2 = (P + 1) / 2;

#define lowbit(x) ((x) & -(x))

int n, s, ans;
int a[N], b[N], sr[N], ss[N];

inline int smod(int x) { return x >= P ? x - P : x; }
inline void sadd(int &x, const int &y) { x += y; x >= P ? x -= P : x; }
inline int fpow(int x, int y) {
	int ans = 1;
	for (; y; y >>= 1, x = (ll)x * x % P) if (y & 1) ans = (ll)ans * x % P;
	return ans;
}

struct BIT {
	int s[N];
	inline void cls() { memset(s, 0, sizeof(*s) * (n + 1)); }
	inline void qadd(int x, int k) { /*dbg("qadd: x = %d, k = %d\n", x, k);*/ for (; x <= n; x += lowbit(x)) sadd(s[x], k); }
	inline int qsum(int x) {
		int ans = 0;
		for (; x; x -= lowbit(x)) sadd(ans, s[x]);
		return ans;
	}
	inline int qsum(int l, int r) { /*dbg("qsum: l = %d, r = %d\n", l, r);*/ return smod(qsum(r) + P - qsum(l - 1)); }
}sa, sb;

inline void ycl() {
	for (int i = n; i; --i) b[i] += b[i + 1];//, dbg("i = %d, b[i] = %d\n", i, b[i]);
	s = 1;
	for (int i = n; i; --i) { 
		ss[i] = b[i] - (n - i);
		s = (ll)s * ss[i] % P;
		if (i == n || ss[i + 1] == 1) sr[i] = i;
		else sr[i] = sr[i + 1];
		// dbg("i = %d, b[i] = %d, ss[i] = %d, sr[i] = %d\n", i, b[i], ss[i], sr[i]);
	}
	ss[0] = 1;
	for (int i = 1; i <= n; ++i)
		if (ss[i] == 1) ss[i] = ss[i - 1];
		else ss[i] = (ll)ss[i - 1] * (ss[i] - 1) % P * fpow(ss[i], P - 2) % P;
}

inline void work() {
	ycl();
	for (int i = n; i; --i) {
		sadd(ans, (ll)s * sa.qsum(a[i], sr[a[i]]) % P * fpow(ss[a[i]], P - 2) % P);
		// dbg("** i = %d, ans = %d, a[i] = %d, ss[i] = %d, %d %d\n", i, ans, a[i], ss[i], sa.qsum(a[i], sr[a[i]]), fpow(ss[a[i]], P - 2));
		sa.qadd(a[i], ss[a[i]]);
	}
	sa.cls();
	for (int i = 1; i <= n; ++i) {
		sadd(ans, (2ll * s * sb.qsum(a[i] + 1, n) + (ll)(P - s) * sa.qsum(a[i] + 1, sr[a[i]]) % P * fpow(ss[a[i]], P - 2)) % P);
		sa.qadd(a[i], ss[a[i]]), sb.qadd(a[i], 1);
		// dbg("***** i = %d, ans = %d, a[i] = %d, ss[i] = %d, %d, %d %d\n", i, ans, a[i], ss[i], sb.qsum(a[i] + 1, sr[a[i]]), sa.qsum(a[i], sr[a[i]]), fpow(ss[a[i]], P - 2));
	}
	ans = (ll)ans * Inv2 % P;
	printf("%d\n", ans);
}

inline void init() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]), ++b[a[i]];
}

int main() {
#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Measured memory_bytes: 4988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <set>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	ll k, n;
	cin >> k >> n;
	vector<ll> a(n + 1), d(n);

	for (ll i = 0; i < n; i++) cin >> a[i];
	a[n] = a[0] + k;

	for (ll i = 0; i < n ; i++)
	{
		d[i] = a[i + 1] - a[i];
	}

	sort(d.begin(), d.end());

	ll ans = 0;
	for (ll i = 0; i < n - 1; i++)
	{
		ans += d[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;



int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	int N,M;
	cin>>N;
	set<string> S;
	rep(i,N){
		string s;
		cin>>s;
		S.insert(s);
	}
	cin>>M;
	int open=0;
	rep(i,M){
		string s;
		cin>>s;
		if(!S.count(s))cout<<"Unknown "<<s<<endl;
		else{
			if(!open)cout<<"Opened by "<<s<<endl;
			else cout<<"Closed by "<<s<<endl;
			open^=1;
		}
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  vector<int> v[2];
  for(int i=1; i<=200; i++) {
    v[0].pb(i*(i+1)*(i+2)/6);
    v[i*(i+1)*(i+2)/6%2].pb(i*(i+1)*(i+2)/6);
  }
  int d[2][1000001];
  rep(i,2)rep(j,1000001) d[i][j]=MAX;
  d[0][0]=d[1][0]=0;
  rep(k,2) {
    rep(i,v[k].size()) {
      rep(j,1000001) {
	if(v[k][i]+j>1000001) break;
	d[k][v[k][i]+j]=min(d[k][v[k][i]+j],d[k][j]+1);
      }
    }
  }
  int n;
  while(R n && n) PR(d[0][n],d[1][n]);
  return 0;
}


Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll X, Y;
  cin >> X >> Y;
  ll n = X;
  ll ans = 0;
  while (n <= Y) {
    n = n * 2;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
//unordered_map
typedef long long ll;
//已AC 尝试去并查集 典型的权值并查集 再写一遍巩固并理解 
int n;
ll a[MAXN],sum[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
	    scanf("%lld",&a[i]);
	    sum[i]=sum[i-1]+a[i];
	    sum[i]%=mod;
	} 
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		ll summ=(a[i]%mod*(sum[n]-sum[i])%mod)%mod;
		ans=(ans+summ+mod)%mod;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		for(int i = 1; i < 3000; i++){
		    try {
			    input = br.readLine();
		        
		    } catch (IOException e) {
	    	}
	    	String[] xy = input.split(" ");
		    int x = Integer.parseInt(xy[0]);
		    int y = Integer.parseInt(xy[1]);
		    if(x > y){
		        int tem = x;
		        x = y;
		        y = tem;
		    }
	    	if(x == 0 && y == 0){
    		    break;
	    	}   
		    System.out.println(x + " " + y);
		}
	}
}



Measured memory_bytes: 26888
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
string S, T;
int ans;

int main() {
	cin >> N >> S >> T;
	
	for (int i = 0; i < N; i++) {
		cout << S[i] << T[i];
	}
	cout << endl;
	
	return 0;
}

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

int main(){
  int N ; 
  int T , A ; 
  cin >> N >> T >> A ; 
  vector<double> H(N) ; 
  double cnt = 1001000100 ; 
  int p = 0 ; 
  
  for(int i = 0 ; i < N ; i++) {
    cin >> H.at(i) ; 
    H.at(i) = T - H.at(i)*0.006 ; 
    
    if( abs(H.at(i) - A)  < cnt ){
      p = i ; 
      cnt = abs(H.at(i) - A);
    }
    
  }
  
  cout << p+1 << endl ; 
  
}

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
	static int dev(int[] a,int an){
		boolean flg = false;
		for(int i = 0;i < a.length;i++){
			if(a[i]%2 == 0){
				flg = true;
				a[i] /= 2;
				an++;
				break;
			}
		}
		if(flg)
			return dev(a,an);
		else
			return an;
	}
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int na[] = new int[n];
		for(int i = 0; i < n; i++)
			na[i] = sc.nextInt();
		
		System.out.println(dev(na,0));
		
	}
}

Measured memory_bytes: 42844
k = int(input())
a, b = [int(e) for e in input().split()]

import numpy as np

ab = np.zeros((b-a)+1)

ab[:] = a

for i in range(b-a):
    ab[i+1:] +=1

if (ab % k == 0).sum() > 0:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 27452
#'S', 'H', 'C', 'D'  1~13
n = int(input())
Slist = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Hlist = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Clist = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Dlist = [1,2,3,4,5,6,7,8,9,10,11,12,13]

card_list = []
for i in range(n):
    s,num = input().split()
    one_card = [str(s),int(num)]
    card_list.append(one_card)
    if(str(s) == 'S'):
        Slist.remove(int(num))
        #print(Slist)
    elif(str(s) == 'H'):
        Hlist.remove(int(num))
    elif(str(s) == 'C'):
        Clist.remove(int(num))
    elif(str(s) == 'D'):
        Dlist.remove(int(num))
while len(Slist) :
    for s in Slist:
        print('S {}'.format(s))
    break
while len(Hlist) :
    for s in Hlist:
        print('H {}'.format(s))
    break
while len(Clist) :
    for s in Clist:
        print('C {}'.format(s))
    break
while len(Dlist) :
    for s in Dlist:
        print('D {}'.format(s))
    break


Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static Scanner sc = new Scanner();
    public static void Main(){
        var x = sc.NextInt();
        var t = sc.NextInt();
        
        if(x<t){
            Console.WriteLine(0);
        }else{
            Console.WriteLine(x-t);
        }
    }
}

public class Scanner{
    private string line;
    private string[] token;
    private int cursole = 0;
    
    public string ReadLine(){
        line = Console.ReadLine();
        token = line.Split(' ');
        cursole = 0;
        return line;    
    }
    
    public string Next(){
        if(token == null) ReadLine();
        if(token.Length <= cursole) ReadLine();
        var ret = token[cursole];
        ++cursole;
        return ret;
    }

    public IEnumerable<double> NextDoubleList(){
        return NextList().Select(s => Double.Parse(s));
    }

    public int NextInt(){return Int32.Parse(Next());}
    
    public long NextLong(){return Int64.Parse(Next());}

    public double NextDouble(){return Double.Parse(Next());}

    public IEnumerable<string> NextList(){
        ReadLine();
        cursole = Int32.MaxValue;
        return token;
    }
    
    public IEnumerable<int> NextIntList(){
        return NextList().Select(s => Int32.Parse(s));
    }
}

public static class Extension{
    public static IEnumerable<int> To(this int from, int to){
        return Enumerable.Range(from, to);
    }

    public static void Times(this int times, Action<int> action){
        0.To(times).ToList().ForEach(x => action(x));
    }
}

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

const int MAX_N=1e4+10;

vector<int> connpos(const string &s,const string &t){
    vector<int> res(MAX_N,1);
    for (int i=0;i<s.size();++i)
        for (int j=0;i+j<s.size()&&j<t.size();++j)
            if (!(s[i+j]==t[j]||s[i+j]=='?'||t[j]=='?')) res[i]=0;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> S(3);
    vector<int> n(3);
    for (int i=0;i<3;++i) cin >> S[i],n[i]=S[i].size();
    vector<int> perm(3);
    iota(perm.begin(),perm.end(),0);
    int ans=MAX_N;
    do {
        vector<int> ab=connpos(S[perm[0]],S[perm[1]])
                    ,bc=connpos(S[perm[1]],S[perm[2]])
                    ,ac=connpos(S[perm[0]],S[perm[2]]);
        for (int i=0;i<=n[perm[0]];++i)
            for (int j=0;j<=max(n[perm[0]],n[perm[1]]);++j)
                if (ab[i]&&bc[j]&&ac[i+j])
                    ans=min(ans,max({n[perm[0]],i+n[perm[1]],i+j+n[perm[2]]}));
    } while(next_permutation(perm.begin(),perm.end()));
    cout << ans << '\n';
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int n;
  long a,sum[100000],cnt[2]={},b;
  scanf("%d",&n);
  scanf("%ld",&a);
  sum[0]=a;
  for(int i=1;i<n;i++){
    scanf("%ld",&a);
    sum[i]=sum[i-1]+a;
  }
  b=0;
  for(int i=0;i<n;i++){
    if(i%2==0&&sum[i]+b>=0){
      cnt[0]+=sum[i]+b+1;
      b-=sum[i]+b+1;
    }
    else if(i%2==1&&sum[i]+b<=0){
      cnt[0]-=sum[i]+b;
      cnt[0]++;
      b+=1-(sum[i]+b);
    }
    //printf("%ld\n",sum[i]+b);
  }
  b=0;
  for(int i=0;i<n;i++){
    if(i%2==0&&sum[i]+b<=0){
      cnt[1]-=sum[i]+b;
      cnt[1]++;
      b+=1-(sum[i]+b);
    }
    else if(i%2==1&&sum[i]+b>=0){
      cnt[1]+=sum[i]+b+1;
      b-=sum[i]+b+1;
    }
    //printf("%ld\n",sum[i]+b);
  }
  if(cnt[0]<cnt[1])
    printf("%ld\n",cnt[0]);
  else
    printf("%ld\n",cnt[1]);
}
    

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d,y,z;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	z=a*b;
	y=c*d;
	if(z>y){
		printf("%lld",z);
	
	}
else	if(y>z){
		printf("%lld",y);	
	
	}
else
	
		printf("%lld",z);
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#define INF 123456789
long long DATA[100001];
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int data[m];
	for (int i=0;i<m;i++) cin>>data[i];
	memset(DATA,INF,sizeof(DATA));
	for (int i=0;i<m;i++) DATA[data[i]]=1;
	DATA[0]=0;
	for (int i=1;i<=n;i++){
		for(int j=0;j<m;j++){
			DATA[i+data[j]]=min(DATA[i+data[j]],DATA[i]+1);
		}
	}
	cout<<DATA[n]<<endl;
	return 0;
}



Measured memory_bytes: 3868
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
x = [0 for _ in range(10**5+1)]
for ai in a:
  x[ai] += 1
q = int(input())
for _ in range(q):
  b,c = map(int,input().split())
  xb = x[b]
  x[b] = 0
  s+= xb*(c-b)
  x[c] += xb
  print(s)
  
  
  

Measured memory_bytes: 83400
#include<bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define ll long long
#define sz size()
#define ft front
#define pu push
#define ty empty
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int m5=100042;
queue<ll>q;
int main(void)
{
	ll k;
	cin>>k;
	int i,j;
	for(i=1;i<=9;i++)
	{
		q.pu(i);
	}
	while(!q.ty())
	{
		ll opr=q.ft();
		q.pop();
		k--;
		if(k==0)
		{
			cout<<opr<<endl;
			break;
		}
		for(i=(opr%10)-1;i<=(opr%10)+1;i++)
		{
			if(i<0||i>9)
			{
				continue;
			}
			q.pu(opr*10+(ll)i);
		}
	}
    return 0;
}



Measured memory_bytes: 1792
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9,maxn=3e5+5;

int n,m,a[maxn],b[maxn],ra[maxn],dp[maxn];
struct edges{
	int to,nxt;
}ed[maxn<<1];
vector<int>son[maxn];
int head[maxn],ecnt=0,id[maxn],fa[maxn],c[maxn],sz[maxn];
void add(int x,int y){ed[++ecnt].to=y;ed[ecnt].nxt=head[x];head[x]=ecnt;}
int find(int x){return fa[x] == x?fa[x]:fa[x] = find(fa[x]);}
int cmp(int x,int y){return c[x] < c[y];}
void dfs1(int x){
	sz[x] += b[x];
	for(int i=0;i<son[x].size();i++){
		int u=son[x][i];
		dfs1(u);
		sz[x] += sz[u];
	}
}

void dfs2(int x){
	if(son[x].size() == 0){
		dp[x] = b[x] + c[x];
		return ;
	}
	dp[x] = 1e18;
	for(int i=0;i<son[x].size();i++){
		int u=son[x][i];
		dfs2(u);
		dp[x] = min(sz[x] - sz[u] + max(dp[u],c[x]),dp[x]);
	}
}

void init(){
	for(int i=1;i<=n;i++){
		int u=id[i];
		for(int j=head[u];~j;j=ed[j].nxt){
			int v=ed[j].to;int fv = find(v), fu = find(u);
			if(ra[fv] < ra[u] && fv != u){
				son[u].push_back(fv);
				fa[fv] = u;
			}
		}
	}
}

signed main(){
	memset(head,-1,sizeof head);
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i],&b[i]), fa[i]=i, id[i]=i, c[i] = max(a[i]-b[i],0ll);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%lld%lld",&x,&y);
		add(x,y);add(y,x);
	}
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++)ra[id[i]] = i;
//	for(int i=1;i<=n;i++)printf("%d ",c[i]);puts("");
//	for(int i=1;i<=n;i++)printf("%d ",id[i]);puts("");
	
	init();
	dfs1(id[n]);
	dfs2(id[n]);
	printf("%lld\n",dp[id[n]]);

	return 0;
}


Measured memory_bytes: 37504
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
long long cnt = 0;
void setsort(vector<int>&, int);
void shell(vector<int>&, int, int);
int main() {
	int n;
	vector<int> t(1000001, 0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> t[i];
	}
	setsort(t, n);
	for (int i = 0; i < n; ++i) {
		cout << t[i] << endl;
	}
	return 0;
}
void setsort(vector<int> &t, int n) {
	cnt = 0;
	long long m = 0, k = 0, num, h = 0;
	vector<int> g(n+1, 0);
	num = n - 1;
	for (int i = n / 2; i >= 1; i /= 2) {
		g[k++] = i;
		m++;
	}
	if (m == 0) {
		g[k++] = 1;
		m++;
	}
	for (int i = 0; i < m; ++i) {
		shell(t, n, g[i]);
	}
	cout << m << endl;
	for (int i = 0; i < m; ++i) {
		cout << (i == 0 ? "" : " ") << g[i];
	}


	cout << endl << cnt << endl;
	return;
}
void shell(vector<int> &t, int n, int g) {
	int v, j;
	for (int i = g; i < n; ++i) {
		v = t[i];
		j = i - g;
		while (j >= 0 && t[j] > v) {
			t[j + g] = t[j];
			j = j - g;
			cnt++;
			t[j + g] = v;
		}
	}
	return;
}


Measured memory_bytes: 10676
#include<iostream>
using namespace std;
int gcd(int a,int b){
  if(b>0){
    return gcd(b,a%b);
  }else{
    return a;
  }
}

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

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

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

int main () {
    string S;
    cin >> S;
    
    if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)){
        cout << "Bad" << endl;
    }

    else {
        cout << "Good" << endl;
    }
}

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;
using P = pair<ll, ll>;
using namespace std;

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

int main() {
    int A, B;
    cin >> A >> B;
    if (B%A == 0) {
        cout << A+B << endl;
    }
    else {
        cout << B-A << endl;
    }
}


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

int main(){
  int N;
  cin >> N;
  float ans;
  if(N%2==0){
  	ans=0.5f;
  }
  else{
  	ans  = (N+1)/2.0f/N;
  }
  cout << ans << endl;
}

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 pii = pair<int,int>;
using pil = pair<pii,int>;


int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int sum = 1;
    rep(i,n){
        if(sum > k) sum += k;
        else sum *= 2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

constexpr long long INF = (long long)1e18;

#define x first
#define y second

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


vector<pair<long double,long double>> in;
	
long double cal(long double X, long double Y){
	long double maximum = 0;
	
	for(int i = 0; i < in.size(); i++){
		maximum = max(maximum, (in[i].x - X) * (in[i].x - X) + (in[i].y - Y) * (in[i].y - Y));
	}
	
	return sqrt(maximum);
}
	
long double ternary_search2(long double X, long double l = -100, long double h = 1100){
	long double y1, y2, minimum = INF;
	
	for(int i = 0; i < 100; i++){
		y1 = (2 * l + h) / 3;
		y2 = (l + 2 * h) / 3;
		
		long double f1 = cal(X, y1);
		long double f2 = cal(X, y2);
		
		minimum = min(minimum, f1);
		minimum = min(minimum, f2);
		
		if(f1 < f2) {
			h = y2;
		} else {
			l = y1;
		}
	}
	
	return minimum;
}

long double ternary_search(long double l = -100, long double h = 1100){
	long double x1, x2, minimum = INF;
	
	for(int i = 0; i < 100; i++){
		x1 = (2 * l + h) / 3;
		x2 = (l + 2 * h) / 3;
		
		long double f1 = ternary_search2(x1);
		long double f2 = ternary_search2(x2);

		minimum = min(minimum, f1);
		minimum = min(minimum, f2);
		
		if(f1 < f2) {
			h = x2;
		} else {
			l = x1;
		}
	}
	
	return minimum;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].x>>in[i].y;
	}
	
	cout<<ternary_search()<<endl;
	
	return 0;
}

Measured memory_bytes: 256
from math import sqrt
N = int(input())
pts = []
for i in range(N):
    x,y = map(int,input().split())
    pts.append((x,y))
def fact(n):
    if n == 1:
        return 1
    return fact(n-1)*n
ans = 0
for i in range(N):
    for j in range(N):
        x1,y1 = pts[i]
        x2,y2 = pts[j]
        dx = x1-x2
        dy = y1-y2
        ans += fact(N-1)*(sqrt(dx**2+dy**2))
print(ans/fact(N))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  long long h,w,ans=0;
  cin >> h >> w;
  long long c[10][10],a[h][w];
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin >> c[i][j];
    }
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        c[j][k] = min(c[j][k], c[j][i]+c[i][k]);
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
      if(a[i][j]!=-1){
        ans+=c[a[i][j]][1];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int r, g, b, n, ans = 0;
  cin >> r >> g >> b >> n;
  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      if (n-r*i-g*j < 0) break;
      if ((n-r*i-g*j) % b == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <iterator>
#include <cstdint>

int main()
{
	std::array<std::int32_t, 5> numbers;
	for (std::int32_t& num : numbers) {
		std::cin >> num;
	}
	std::sort(numbers.begin(), numbers.end(),
			std::greater<std::int32_t>());
	std::copy(numbers.begin(), numbers.end() - 1,
			std::ostream_iterator<std::int32_t>(std::cout, " "));
	std::cout << numbers.back() << std::endl;
	return 0;
}

Measured memory_bytes: 1176
if __name__ == '__main__':

	k = int(input())

	# mod K 問題

	s = set()
	x = 7 % k
	i = 1
	cnt = -1
	while x not in s:
		if x == 0:
			cnt = i
			break
		s.add(x)
		x = (10 * x + 7) % k
		i += 1

	print(cnt)
	

Measured memory_bytes: 77904
// AOJ 3006: Chairs
// 2017.10.4 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX		100003
int p[MAX];
int sp[MAX], top;
int *q[MAX], hi[MAX];
int ans[MAX];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, a, i, j;
	
	n = in();
	for (i = 1; i <= n; i++) {
		p[i] = a = in();
		hi[a]++;
	}
	for (i = 1; i <= n; i++) q[i] = malloc(hi[i]*sizeof(int));
	memset(hi, 0, (n+1)<<2);
	for (i = 1; i <= n; i++) {
		a = p[i];
		q[a][hi[a]++] = i;
	}

	top = 0;
	for (j = 0; j < 2; j++) for (i = 1; i <= n; i++) {
		while (hi[i]) sp[top++] = q[i][--hi[i]];
		if (!ans[i] && top) ans[i] = sp[--top];
    }
   
	for (i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 7620
#include <stdio.h>

int main()
{
	int A, B, C, K;
	scanf("%d %d %d %d", &A, &B, &C, &K);
	if (A + B >= K) printf("%d\n", (A <= K)? A: K);
	else printf("%d\n", A - (K - A - B));
	fflush(stdout);
	return 0;
}

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

long long N, K;

// N 個の整数
vector<long long> A;

// 無限
const long long INF = (long long) (1e18)+1;

// x 未満を作ることができるペアが k 個未満か（true）否か（false）を返す
bool f(long long x) {

 // x 未満を作ることができるペアの数
 long long count = 0;
 for (int i = 0; i < N; i++) {
 
   if (0 <= A[i]) {

     // 全部 OK なら N - 1 個となる
     // 正の場合は、l が OK、r がダメ側
     int l = -1;
     int r = N;

     // border の範囲を二分探索で狭めていく
     while (l + 1 < r) {
       int border = (l + r) / 2;
       // 自分自身と自分自身のペアや、重複するペアも見る
       if (A[border] * A[i] < x) {
         l = border;
       } else {
         r = border;
       }
     }

     // 境界より左側
     count += r;
   } else {

     // 負の場合は、l がダメ側、r が OK
     int l = -1;
     int r = N;

     // border の範囲を二分探索で狭めていく
     while (l + 1 < r) {
       int border = (l + r) / 2;
       // 自分自身と自分自身のペアや、重複するペアも見る
       if (A[border] * A[i] < x) {
         r = border;
       } else {
         l = border;
       }
     }

     // 境界より右側
     count += N - r;
   }

   // 自分自身と自分自身のペアを引く
   if (A[i] * A[i] < x) {
     count--;
   }

 }

 // 半分は重複しているペアなので半分にする
 count /= 2;
 
 return count < K;
}

int main() {

 cin >> N >> K;

 A.resize(N);
 for (int i = 0; i < N; i++) {
   cin >> A[i];
 }

 sort(A.begin(), A.end());

 // 左端
 long long l = -INF;

 // 右端
 long long r = INF;

 // x の範囲を二分探索で狭めていく
 while (l + 1 < r) {

   long long x = (l + r) / 2;
   
   // x 未満を作ることができるペアが k 個未満か否か 
   bool flg = f(x);

   if (flg) {
     l = x;
   } else {
     r = x;
   }

 }

 cout << l << endl;

 return 0;
}

Measured memory_bytes: 1792
q=int(input())
m=10**6+3
f=[1]
for i in range(1,m):
    f.append(f[-1]*i%m)
for i in range(q):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,m))
    else:
        t=x*pow(d,m-2,m)%m
        if t==0 or t+n-1>=m:
            print(0)
        else:
            print(f[t+n-1]*pow(f[t-1],m-2,m)*pow(d,n,m)%m)

Measured memory_bytes: 43308
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout), freopen(s"log", "w", stderr)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 100010;

int a[MAXN];
int res[MAXN];
int ans[MAXN];
int deg[MAXN];
vector<int>to[MAXN];

inline void cmp(int n) {
	for(int i = 1; i <= n; i++)
		if(ans[i] < res[i]) {
			for(int j = i; j <= n; j++)
				res[j] = ans[j];
			return ;
		} else if(res[i] < ans[i]) return ;
}

inline void Solve(int b[], int N, int n) {
	int p = 0, v = 0;
	for(int i = 1; i <= N; i++) {
		int x = a[i], sz = deg[x];
		for(auto u : to[x])
			if(u == a[i - 1] || u == a[i + 1])
				--sz;
		b[p + sz + 1] = ++v;
		while(sz--) b[++p] = ++v;
		++p;
	}
}

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri;
	for(int i = 1; i < n; i++) {
		int u = ri, v = ri;
		to[u].push_back(v);
		to[v].push_back(u);
		deg[u]++, deg[v]++;
	}

	int jsq = 0, x = 0, y = 0;
	for(int i = 1; i <= n; i++) {
		if(deg[i] == 1) continue;
		int cnt = 0;
		for(auto u : to[i])
			cnt += deg[u] > 1;
		if(cnt > 2) return puts("-1"), 0;
		if(cnt == 1) (x ? y : x) = i;
		else if(cnt == 0) x = i;
	}

	if(!y) {
		printf("1");
		for(int i = 3; i < n; i++) printf(" %d", i);
		printf(" 2 %d\n", n);
		return 0;
	} else {
		int p, q;
		for(auto u : to[x]) if(deg[u] == 1) p = u;
		for(auto u : to[y]) if(deg[u] == 1) q = u;
		int N = 0;
		a[++N] = p;
		while(x != y) {
			a[++N] = x;
			for(auto u : to[x])
				if(deg[u] != 1 && a[N - 1] != u) {
					x = u;
					break;
				}
		} a[++N] = y, a[++N] = q;

		Solve(res, N, n);
		reverse(a + 1, a + 1 + N);
		Solve(ans, N, n), cmp(n);
		for(int i = 1; i <= n; i++) printf("%d%c", res[i], " \n"[i == n]);
	}

	return 0;
}

Measured memory_bytes: 11020
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define BR cout<<endl;
#define LEN(s) s.length();
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];

    rep(i,n){
        if(a[i]%2 == 0){
            if(!(a[i]%3==0 or a[i]%5==0)){    
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}



Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 100010
#define MO 1000000007
#define LL long long
int x[MAXN],n,m;
bool vis[MAXN];
void task1()
{
	static int dp[100010][3];
	dp[0][0]=1;
	for(int i=1;i<=m;i++)
		vis[x[i]]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0];
		dp[i][1]=(dp[i-1][0]+dp[i-1][1])%MO;
		dp[i][2]=((dp[i-1][0]+dp[i-1][1])%MO+(dp[i-1][1]+dp[i-1][2])%MO)%MO;
		if(!vis[i-1])
		{
			dp[i][0]=(dp[i][0]+dp[i-1][2])%MO;
			dp[i][1]=(dp[i][1]+dp[i-1][2])%MO;
			dp[i][2]=(dp[i][2]+dp[i-1][2])%MO;
		}
	}
	printf("%d\n",dp[n][2]);
}
struct node
{
	LL a[3][3];
}A,C,a,b,c,tmp;
void Mul(node &ret,node X,node Y)
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			tmp.a[i][j]=0;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				tmp.a[i][j]=(tmp.a[i][j]+X.a[i][k]*Y.a[k][j]%MO)%MO;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			ret.a[i][j]=tmp.a[i][j];
}
void Pow(int X)
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			c.a[i][j]=C.a[i][j];
	while(X)
	{
		if(X&1) Mul(a,a,c);
		Mul(c,c,c);
		X>>=1;
	}
}
int f[3],g[3];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&x[i]);
	memset(A.a,0,sizeof A.a);
	memset(C.a,0,sizeof C.a);
	A.a[0][0]=A.a[1][1]=A.a[2][2]=A.a[1][2]=A.a[0][2]=1;
	A.a[0][1]=2;
	C.a[0][2]=C.a[1][0]=C.a[1][1]=C.a[1][2]=C.a[2][0]=C.a[2][2]=1;
	C.a[0][0]=C.a[0][1]=2;
	f[0]=1;
	x[++m]=n;
	for(int l=1,pos=0;l<=m;l++)
	{
		int k=x[l]-pos-1;
		memset(b.a,0,sizeof b.a);
		memset(a.a,0,sizeof a.a);
		for(int i=0;i<3;i++)
			a.a[i][i]=1;
		if(k) Pow(k);
		Mul(b,a,A);
		for(int i=0;i<3;i++)
		{
			g[i]=0;
			for(int j=0;j<3;j++)
				g[i]=(g[i]+f[j]*b.a[j][i]%MO)%MO;
		}
		for(int i=0;i<3;i++)
			f[i]=g[i];
		pos=x[l];
	}
	printf("%d\n",f[2]);
}


Measured memory_bytes: 512
def bubble_sort(numbers, n):
    """bubble sort method

    Args:
        numbers: a list of numbers to be sorted by bubble sort
        n: len(list)

    Returns:
        sorted list
    """
    flag = True
    counter = 0
    while flag:
        flag = False
        for index in range(n - 1, 0, -1):
            if numbers[index] < numbers[index - 1]:
                numbers[index], numbers[index - 1] = numbers[index - 1], numbers[index]
                flag = True
                counter += 1
    return numbers, counter


n = int(raw_input())
numbers = [int(x) for x in raw_input().split()]
numbers, swapped_numbers = bubble_sort(numbers, n)

print(" ".join([str(x) for x in numbers]))
print(swapped_numbers)

Measured memory_bytes: 6428
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println(800 * N - 200 * (N / 15));
        }
    }
}


Measured memory_bytes: 21076
#include<iostream>
using namespace std;
int main()
{
  char as[8], bs[8], cs[16];
  int a;
  scanf("%s %s", as, bs);
  sprintf(cs, "%s%s", as, bs);
  sscanf(cs, "%d", &a);
  
  for(int i=1; i<=317; ++i){
    if(i*i == a){
      printf("Yes", a);
      return 0;
    }
  }
  printf("No", a);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long ans[2007];

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
    long long n,x,y;
    cin >> n >> x >> y;
    for(long long i = 1;i <= n;i++){
        for(long long j = i+1;j <= n;j++){
            ans[min(j-i, min(abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1))]++; 
        }
    }
    for(long long i = 1;i <= n-1;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;
long long ans;
long long N;
bool solve() {
  scanf("%d", &N);
  if(N < 4) {
    return false;
  } else {
    for(int i = 0; i <= 100; i++) {
      for(int j = 0; j <= 100; j++) {
        if((4*i)+(7*j)==N) {
          return true;
        }
      }
    }
  return false;
  }
}

int main(int arg, char* argv[]) {
  if(solve()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define pb  emplace_back
#define X   first
#define Y   second

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

#define lch		i << 1
#define rch     i << 1 | 1

struct Node {
	ll  Max;
	ll  Min;
	
	Node() : Max(1e18), Min(1e18)	{}
}	tr[N << 2];

Node operator + (const Node&a,const Node&b) {
	Node c;
	c.Max = min(a.Max,b.Max);
	c.Min = min(a.Min,b.Min);
	return  c;
}
void upd(int i,int l,int r,int p,ll  v) {
	if (l > p)  return;
	if (r < p)  return;
	if (l == r) {
		if (tr[i].Max > v + l)
			tr[i].Max = v + l;
		if (tr[i].Min > v - l)
			tr[i].Min = v - l;
		
		return;
	}
	int m = (l + r) / 2;
	
	upd(lch,l,m,p,v);	++m;
	upd(rch,m,r,p,v);
	
	tr[i] = tr[lch] + tr[rch];
}
Node get(int i,int l,int r,int L,int R) {
	if (l > R)	return  Node();
	if (L > r)	return  Node();
	if (L <= l && r <= R)
		return tr[i];
	
	int m = (l + r) / 2;
	
	return  get(lch,l,m,L,R) + get(rch,m + 1,r,L,R);
}

int main()  {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n, q;	cin >> n >> q;
	int A, B;   cin >> A >> B;
	
	int L;	cin >> L;
	
	upd(1,1,n,A,abs(B - L));
	upd(1,1,n,B,abs(A - L));
	
	ll  val = 0;
	
	for(int i = 1 ; i < q ; ++i)	{
		int x;	cin >> x;
		ll  nxt = 1e18;
		nxt = min(nxt,get(1,1,n,1,x).Min + x);
		nxt = min(nxt,get(1,1,n,x,n).Max - x);
		
		upd(1,1,n,L,nxt - abs(x - L));
		val += abs(x - L);
		L = x;
	}
	ll  Ans = 1e18;
	
	for(int i = 1 ; i <= n ; ++i)
		Ans = min(Ans,get(1,1,n,i,i).Min + i);
	
	cout << Ans + val << endl;
}

Measured memory_bytes: 12800
n= int(input())
a = list(map(int , input().split()))
b = list(map(int , input().split()))
c = list(map(int , input().split()))
ans = sum(b)
for i in range(1,n):
    if a[i] == a[i-1] + 1:
        ans += c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064