akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


typedef double ld;
const int N=1010;
int x[N],y[N],r[N],n,vis[N];
ld dis[N][N],d[N];


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>x[1]>>y[1]>>x[2]>>y[2]>>n;n+=2;
	for(int i=3;i<=n;++i)cin>>x[i]>>y[i]>>r[i];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)if(i!=j)dis[i][j]=max(0.,hypot(x[i]-x[j],y[i]-y[j])-r[i]-r[j]);
	for(int i=1;i<=n;++i)d[i]=INFINITY;d[1]=0;
	for(int i=1;i<=n;++i){
		ld mn=INFINITY;int id=0;
		for(int j=1;j<=n;++j)if(!vis[j]&&d[j]<mn)mn=d[j],id=j;
		if(id==2){
			cout<<fixed<<setprecision(10)<<mn<<'\n';
			return 0;
		}
		vis[id]=1;
		for(int j=1;j<=n;++j)if(j!=id)d[j]=min(d[j],mn+dis[id][j]);
	}
	return 0;
}


Measured memory_bytes: 8192
using System;

class Program
{
	static void Main(string[] args)
	{
		var inputValues = Console.ReadLine().Split(' ');
    var A = int.Parse(inputValues[0]);
    var B = int.Parse(inputValues[1]);
    var T = int.Parse(inputValues[2]);
	
		var biscuit = 0;
		var sec = 1;
		while(A * sec <= T)
		{
			biscuit += B; 
			sec++;
		}
		Console.WriteLine(biscuit);
	}
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<ll> a(n);
	for (auto &i : a) cin >> i;

	ll s = accumulate(a.begin(), a.end(), 0LL), cur = 0;
	ll ans = numeric_limits<ll>::max();
	for (auto i : a)
	{
		cur += i;
		if (cur != s)
			ans = min(ans, llabs(cur - (s-cur)));
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
#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 int mod = 1e9+7;
const int maxn = 100005;
int dp[21][1<<21];
void go() {
	int n;
	cin >> n;
	int m[21][21] = {};
	f(n) {
		fr(j,0,n) {
			cin >> m[i][j];
		}
	}	
	f(n) {
		if (m[0][i]) {
			dp[0][1<<i] = 1;
		}
	}
	f1(n-1) {
		fr(j,0,1<<n) {
			if (__builtin_popcount(j) != i + 1) {
				continue;
			}
			fr(k,0,n) {
				if (m[i][k] &&(j & (1<<k))) {
					dp[i][j] += dp[i - 1][j ^ (1<<k)];
					dp[i][j] %= mod;
				}
			}
		}
	}
	cout << dp[n-1][(1<<n) - 1] << '\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--) {
        go();
    }
    
}

Measured memory_bytes: 93656
import math

A, B, H, M = list(map(int, input().split()))

h = H * 30 + M * 0.5
m = M * 6
rad = min(h - m, m - h)

ans = (A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(rad))) ** 0.5
print(ans)


Measured memory_bytes: 9568
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22)cout << "bust";
    else cout << "win";
}

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

namespace _0107
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int[] items = RIntAr();
                if (items.Sum() == 0) break;

                Array.Sort(items);
                int widthSqar = items[0] * items[0] + items[1] * items[1];

                int n = RInt();
                for (int i = 0 ; i < n ; i++) Console.WriteLine(widthSqar < Math.Pow(RInt() * 2, 2) ? "OK" : "NA");
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16200
#include <iostream>
#include <algorithm>

using namespace std;

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

    sort(A, A+n);
    A[n-1] /= 2;
    for(int i = 0; i < n; i++) sum += A[i];
    cout << sum << '\n';
}

Measured memory_bytes: 256
def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

N = n_in()
P = l_in()
Q = l_in()


kaijo = [1]

[kaijo.append((i+1)*kaijo[i]) for i in range(8)]


i = N-1
res = 0
lis = list(range(1, N+1))
for p in P[:N-1]:
    res += lis.index(p)*kaijo[i]
    lis.remove(p)
    i -= 1;

i = N-1
res2 = 0
lis = list(range(1, N+1))
for p in Q[:N-1]:
    res2 += lis.index(p)*kaijo[i]
    lis.remove(p)
    i -= 1;

print(abs(res-res2))



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N;
    cin >> N;

    cout << (1 + N) * N / 2 << endl;

    return 0;
}

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

using namespace std;

int main() {
	int tmp, N, ans = 0;
	vector<int> L;
	cin >> N;
	for(int i=0;i<2*N;i++) {
		cin >> tmp;
		L.push_back(tmp);
	}
	sort(L.begin(), L.end());
	for(int i=0;i<2*N;i+=2) {
		int a = L[i], b = L[i+1];
		ans += min(a, b);
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

// A - 0
// G - 1
// C - 2
// T - 3
const ll mod = 1000000007;

inline bool check(int a, int b, int c){
	return a == 0 && b == 1 && c == 2;
}

inline int getState(int mask, int nc){
	vector<int> vec;
	for(int i = 0; i < 3; i++){
		vec.push_back(mask%4);
		mask /= 4;
	}
	reverse(vec.begin(), vec.end());
	vec.push_back(nc);
	if(check(vec[0], vec[1], vec[2]))return -1;
	if(check(vec[1], vec[2], vec[3]))return -1;
	if(check(vec[1], vec[0], vec[2]))return -1;
	if(check(vec[0], vec[2], vec[3]))return -1;
	if(check(vec[0], vec[2], vec[1]))return -1;
	if(check(vec[2], vec[1], vec[3]))return -1;
	if(check(vec[0], vec[1], vec[3]))return -1;
	if(check(vec[1], vec[3], vec[2]))return -1;
	return vec[1]*16 + vec[2]*4 + vec[3];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<vector<ll> > dp(n + 1, vector<ll>(64, 0));
	dp[0][63] = 1;
	for(int i = 1; i <= n; i++){
		for(int mask = 0; mask < 64; mask++){
			for(int j = 0; j < 4; j++){
				int nmask = getState(mask, j);
				if(nmask == -1)continue;
				dp[i][nmask] += dp[i - 1][mask];
				if(dp[i][nmask] >= mod)dp[i][nmask] -= mod;
			}
		}
	}
	ll ans = 0;
	for(int mask = 0; mask < 64; mask++){
		ans += dp[n][mask]; if(ans >= mod)ans -= mod;
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(li[n-1])

Measured memory_bytes: 38384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    if (n > k) {
      System.out.println(k * x + (n - k) * y);
    } else {
      System.out.println(n * x);
    }
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M;
  cin>>N>>M;
  priority_queue<ll> que;
  for(ll i=0;i<N;i++){
    ll x;
    cin>>x;
    que.push(x);
  }
  for(ll i=0;i<M;i++){
    ll tmp=que.top();
    que.pop();
    que.push(tmp/2);
  }
  ll ans=0;
  for(ll i=0;i<N;i++){
    ans+=que.top();
    que.pop();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;


public class Main {

	Scanner sc;
	
	int solve(int n){
		if(n==1) return 0; else return 1+(n%2==0 ? solve(n/2) : solve(n*3+1));
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		while(true){
			int n=ni();
			if(n==0) break;
			System.out.println(solve(n));
		}
		sc.close();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

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

ll l1[51][51];
ll dir[8][2]={{1,0},{0,1},{0,-1},{-1,0},{-1,1},{-1,-1},{1,-1},{1,1}};
map<ll,ll>di;

vector<ll>adj[51];
ll visited[51];

void bfs(int s,int n)
{
    //for(int i=0;i<n;i++)visited[i]=0;
    queue<int>Q;
    Q.push(s);
    visited[s]=1;cout<<"->"<<s<<endl;///visited starting node.
    while(!Q.empty()){
        int u=Q.front();
        Q.pop();
        for(int i=0;i<adj[u].size();i++){

            if(visited[adj[u][i]]==0){
                int v=adj[u][i];
                visited[v]=1;
                cout<<"->"<<v<<endl;///visited nodes.
                Q.push(v);
            }
        }
    }
}


int main()
{
    ll n,k,m,a,b,s=0;
    cin>>n>>m;
    ll l1[n+1],l2[m+1];
    for(int i=1;i<=m;i++){
        cin>>a>>b;di[a]++;di[b]++;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    //bfs(1,n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(di[j]==1){
                di[j]-=1;s++;
                for(int k=0;k<adj[j].size();k++){
                    di[adj[j][k]]-=1;
                }
            }
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
// D.

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef pair<int, int> II;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<II> b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		b[i] = II(a[i], i);
	}
	sort(b.begin(), b.end());
	int bi = abs(b.back().first) > abs(b.front().first) ? b.back().second : b.front().second;
	vector<II> ans;
	for (int i = 0; i < n; ++i) {
		if (i != bi) {
			ans.push_back(II(bi + 1, i + 1));
			a[i] += a[bi];
		}
	}
	if (a[0] >= 0) {
		for (int i = 1; i < n; ++i) {
			ans.push_back(II(i, i + 1));
		}
	} else {
		for (int i = n - 1; i > 0; --i) {
			ans.push_back(II(i + 1, i));
		}
	}
	cout << ans.size() << endl;
	for (auto kv : ans) {
		cout << kv.first << " " << kv.second << 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 P = pair<int, int>;

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

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main(){
    int N, Q;
    string s;
    char t[200000];
    char d[200000];
    cin >> N >> Q;
    cin >> s;
    for(int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    int l = -1;
    int r = N;
    for(int i = Q-1; i >= 0; i--){
        if(l == -1){
            if(t[i] == s[0] && d[i] == 'L') l = 0;
        }else{
            if(t[i] == s[l] && d[i] == 'R') l--;
            if(t[i] == s[l+1] && d[i] == 'L') l++;
        }
    }
    for(int i = Q-1; i >= 0; i--){
        if(r == N){
            if(t[i] == s[N-1] && d[i] == 'R') r = N-1;
        }else{
            if(t[i] == s[r] && d[i] == 'L') r++;
            if(t[i] == s[r-1] && d[i] == 'R') r--;
        }
    }
    //cout << l << ' ' << r << endl;
    if(l >= r) cout << 0 << endl;
    else cout << r-l-1 << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(a>=6) cout << b/2 << endl;
    else cout << "0" << endl;

    return 0;
}

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

int main()
{
    int n, x;
    while (true) {
        scanf("%d %d", &n, &x);
        if (n == 0 and x == 0) break;
        
        int ans = 0;
        for (int a = 1; a <= n; a++) {
            for (int b = a + 1; b <= n; b++) {
                for (int c = b + 1; c <= n; c++) {
                    if (a + b + c == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3204
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	PriorityQueue<Integer> A = new PriorityQueue<>();
    	for(int i=0; i<N; i++) {
    		A.add(sc.nextInt());
    	}
    	Set[] set = new Set[M];
    	for(int i=0; i<M; i++) {
    		set[i] = new Set(sc.nextInt(), sc.nextInt());
    	}
    	Arrays.sort(set, (a, b) -> b.C - a.C);
    	for(int i=0; i<M; i++) {
    		for(int j=0; j<set[i].B; j++) {
    			int x = A.poll();
    			if(x >= set[i].C) {
    				A.add(x);
    				break;
    			} else {
    				A.add(set[i].C);
    			}
    		}
    	}
    	long sum = 0;
    	for(int i=0; i<N; i++) {
    		sum += (long)A.poll();
    	}
    	System.out.println(sum);
    }

    static class Set {
    	int B;
    	int C;
		public Set(int b, int c) {
			B = b;
			C = c;
		}
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 50648
N=int(input())
A,B,C=[sorted(map(int,input().split())) for i in range(3)]
ans=a=c=0
for i in B:
    while a<N and A[a]<i:
        a+=1
    while c<N and C[c]<=i:
        c+=1
    if c==N:break
    ans+=a*(N-c)
print(ans)

Measured memory_bytes: 23328
#include <iostream>
#include <string>
#include <set>
using namespace std;


int main(void){
    int  n;
    std::string input;
    std::set<std::string> a;
    
    cin >> n;
    
    for (int i = 1; i <= n ; i ++) {
        
        cin >> input;
        a.insert(input);
        
    }
    
    cout << a.size() << endl;
}


Measured memory_bytes: 19212
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    string s;
    cin >> N >> s;
    int sz = (int)s.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    dp[0][0] = 1;
    rep(i, N){
        rep(j, N + 1){
            (dp[i + 1][max(j - 1, 0)] += dp[i][j]) %= mod;
            (dp[i + 1][j + 1] += 2 * dp[i][j]) %= mod;
        }
    }
    
    ll div = inv_mod(pow_mod(2, s.size(), mod), mod);
    
    ll ret = dp[N][sz] * div % mod;
    output(ret, 0);
    
    return 0;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
int main(){
   int k; cin >> k;
   vector<ll> a(k);
   rep(i,k) cin >> a[i];
   ll mn=2; ll ma=2;
   if(a[k-1]>2){
       cout << -1 << endl;
       return 0;
   }
   for(int i=k-1; i>=0; i--){
       mn=a[i]*((mn-1)/a[i]+1);
       ma=((ma/a[i])+1)*a[i]-1;
       //mn=((mn-1)/a[i]+1)*a[i];
       //ma=(ma/a[i])*a[i]+a[i]-1;
       //cout << ma << endl;
       //cout << mn << ' ' << ma << endl;
       if(mn>ma){
           cout << -1 << endl;
           return 0;
       }
   }
 
   cout << mn << ' ' << ma << endl;
return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
char a[52],b[52];
int main()
{
cin>>a;
cin>>b;
int la=strlen(a),lb=strlen(b);
int l=min(la,lb),ll=max(la,lb);
for(int i=0;i<=l-1;i++)
cout<<a[i]<<b[i];
if(la>lb)
for(int i=l;i<=ll-1;i++)
cout<<a[i];
else for(int i=l;i<=ll-1;i++)
cout<<b[i];
return 0;
}

Measured memory_bytes: 256
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-04-26 20:03:22
 * @LastEditTime: 2020-04-26 20:08:09
 * @FilePath: \VSC\C++\Practice\AC abc164 B.cpp
 */
#include<bits/stdc++.h>
using namespace std;

int a,b,c,d;
signed main(){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int x=c/b;
    int y=a/d;

    if(c%b) ++x;
    if(a%d) ++y;

    puts(x<=y?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3764
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a::Array{Int,1},x::Int)
	l,r = 0, length(a)+1
	while r-l>1
		m = (r+l)>>1
		if a[m]<x
			l = m
		else
			r = m
		end
	end
	r
end

function calc(a::Array{Int,1},b::Array{Int,1},t)
	c = 0
	for i in a
		c += bsearch(b,2t-i)-bsearch(b,t-i)+bsearch(b,4t-i)-bsearch(b,3t-i)
	end
	c%2
end

are(a::Array{Int,1},x::Int)=Int[i%x for i in a]

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = readline() |> split |> parseMap
	r = 29
	s = 0
	for i in 1:r
		c = are(b,2^i)
		c = sort(c)
		s += calc(are(a,2^i),c,2^(i-1))*(2^(i-1))
	end
	println(s)
end

main()

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

int main() {
	int N; 
	cin >> N;
	int T[N];
	for (int i=0; i<N; i++) cin >> T[i];
	int M;
	cin >> M;
	vector <vector <int>> drink(M, vector <int> (2));
	for (int i=0; i<M; i++){
	    cin >> drink[i][0] >> drink[i][1];
	}
	int total;
	for (int i=0; i<N; i++) total+=T[i];
	int ans;
	for (int i=0; i<M; i++){
	    ans=total-T[drink[i][0]-1]+drink[i][1];
	    cout << ans << endl;
	}
}


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

using namespace std;

const double EPS = 1e-7;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(p.y, -p.x); } // 時計回りに90度回転 
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;
    if (cross(b, c) > EPS) return +1;      // a,b,cの順に反時計周り
    if (cross(b, c) < -EPS) return -1;     // a,b,cの順に時計周り
    if (dot(b, c) < 0) return +2;          // c--a--b 直線
    if (norm(b) < norm(c)) return -2;      // a--b--c 直線
    return 0;                              // a--c--b 直線
}



struct Line {
    Point a, b;
    Line() {}
    Line(const Point& a, const Point& b) : a(a), b(b) {}
};
bool contains(const Line& l, const Point& p) { return ccw(l.a, l.b, p) % 2 == 0; }
bool parallel(const Line& s, const Line& t) { return abs(cross(s.b - s.a, t.b - t.a)) < EPS; }
bool orthogonal(const Line& s, const Line& t) { return abs(dot(s.b - s.a, t.b - t.a)) < EPS; }
bool equals(const Line& s, const Line& t) { return parallel(s, t) && contains(s, t.a); }
istream& operator>>(istream& is, Line& l) { return is >> l.a >> l.b; }

Point crosspoint(const Line& s, const Line& t) {
    double d = cross(t.b - t.a, s.b - s.a);
    assert(abs(d) >= EPS);
    return s.a + (s.b - s.a) * cross(t.b - t.a, t.b - s.a) / d;
}

int main() {
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        Line s, t; cin >> s >> t;
        Point p = crosspoint(s, t);
        cout << fixed << setprecision(12) << p.x << " " << p.y << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll n,p;
  cin>>n>>p;
  ll ans = 1;
  for(ll x=2; x*x<=p; x++)if(p%x==0){
    int cnt = 0;
    while(p%x==0)p/=x, cnt++;
    cnt /= n;
    while(cnt--)ans *= x;
  }
  if(p>1){
    ll x = p;
    int cnt = 0;
    while(p%x==0)p/=x, cnt++;
    cnt /= n;
    while(cnt--)ans *= x;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int dist[210][210];

int main(){
    bool flag=false;
    ll ans=INF,sum=0;

    int n,m,r;
    cin >>n>>m>>r;
    vector<int> dst(r),od(r);

    rep(i,n)rep(j,n)dist[i][j]=INF;
    
    rep(i,r){
        cin>>dst[i];
        od[i]=i;
    }

    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;

        dist[a][b]=c;
        dist[b][a]=c;
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                chmin(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    do{
        int ttdist=0;
        rep(i,r-1){
            int frm=dst[od[i]]-1;
            int to=dst[od[i+1]]-1;
            //db2(frm,to);cout<<"-";

            ttdist += dist[frm][to];
        }
        //db(ttdist);ln;
        chmin(ans,ttdist);
    }while(next_permutation(all(od)));

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int z=1,y=0,x=0,ans=0;
		while(z<=N){
			y=z;
			while(true){
				x+=y%10;
				y/=10;
				if(y==0)
					break;
			}
			if(A<=x&&B>=x)
				ans+=z;
			x=0;
			z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    vi a(3);
    cin >> a;
    sort(RALL(a));
    cout << (a[0] * 10 + a[1] + a[2]) << endl;
    return (0^_^0);
}



Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

struct Node{
    int k;
    Node *p,*l,*r;
};

Node *root;

void insert(int k){
    Node *y=NULL;
    Node *x=root;
    Node *z;
    z=(Node*)malloc(sizeof(Node));
    z->k=k;
    z->l=NULL;
    z->r=NULL;
    while(x!=NULL){
        y=x;
        if(z->k<x->k){
            x=x->l;
        }
        else{
            x=x->r;
        }
    }
    z->p=y;
    if(y==NULL){
        root=z;
    }
    else if(z->k<y->k){
        y->l=z;
    }
    else{
        y->r=z;
    }
}

Node *find(Node *v,int k){
    while(v!=NULL&&k!=v->k){
        if(k<v->k)v=v->l;
        else v=v->r;
    }
    return v;
}

Node *treeMinimum(Node *x){
    while(x->l!=NULL)x=x->l;
    return x;
}

Node *treeSuccessor(Node *x){
    if(x->r!=NULL)return treeMinimum(x->r);
    Node *y=x->p;
    while(y!=NULL&&x==y->r){
        x=y;
        y=y->p;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y,*x;
    if(z->l==NULL||z->r==NULL)y=z;
    else y=treeSuccessor(z);
    
    if(y->l!=NULL){
        x=y->l;
    }
    else{
        x=y->r;
    }
    
    if(x!=NULL){
        x->p=y->p;
    }
    
    if(y->p==NULL){
        root=x;
    }
    else{
        if(y==y->p->l){
            y->p->l=x;
        }
        else{
            y->p->r=x;
        }
    }
    if(y!=z){
        z->k=y->k;
    }
    
    free(y);
}

void inorder(Node* v){
    if(v==NULL)return;
    inorder(v->l);
    cout<<" "<<v->k;
    inorder(v->r);
}

void preorder(Node* v){
    if(v==NULL)return;
    cout<<" "<<v->k;
    preorder(v->l);
    preorder(v->r);
}

void run(){
    int n;
    cin>>n;
    rep(i,n){
       string s;
       cin>>s;
       if(s=="insert"){
           int k;
           cin>>k;
           insert(k);
       }
       else if(s=="find"){
           int k;
           cin>>k;
           cout<<(find(root,k)!=NULL?"yes":"no")<<endl;
       }
       else if(s=="print"){
           inorder(root);
           cout<<endl;
           preorder(root);
           cout<<endl;
       }
       else{
           int k;
           cin>>k;
           treeDelete(find(root,k));
       }
   }
}


Measured memory_bytes: 21948
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll a,b;
    cin>>a>>b;
    ll i;
    ll ans=-1;
    for(i=1;i<=100000;i++)
    {

        ll x = (i*(0.08));
        ll y = (i*(0.1));



        if(x==a && y==b)
        {
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lf long double
#define INF 10000000000000000
#define MAX 300001
#define M 998244353
using namespace std;

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

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int sum=0;
    for(int i=1;i<n-1;i++){
      if(a[i-1]<a[i] && a[i]<a[i+1]){
        sum++;
      }else if(a[i+1]<a[i] && a[i]<a[i-1]){
        sum++;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 22612
n = int(input())
adj = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    if l[1] == 0:
        continue 
    else:
        for j in range(2,len(l)):
            adj[l[0]-1][l[j]-1] = 1

color = ['white' for _ in range(n)]
d = [-1 for _ in range(n)]
color[0] = 'grey'
d[0] = 0
Q = [1]
while Q:
    u = Q.pop(0)
    color[u-1] = 'black'
    for v in range(1, n+1):
        if adj[u-1][v-1] == 1 and color[v-1] == 'white':
            Q.append(v)
            color[v-1] = 'grey'
            d[v-1] = d[u-1] + 1  

for i in range(n):
    print(' '.join([str(i+1), str(d[i])]))
    
        


Measured memory_bytes: 5700
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)


Measured memory_bytes: 18608
if __name__ == "__main__":
    n,k = (int(x) for x in input().split())
    choice = [int(x) for x in input().split()]

    #print(n,k,choice)

    win = [False] * (k+1)
    for i in range(k+1):
        for x in choice:
            if i-x>=0 and not win[i-x]:
                win[i] = True
                break

    print("First" if win[k] else "Second")


Measured memory_bytes: 9656
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    char s[6];
    scanf("%s",s);
    if(s[2]==s[3]&&s[4]==s[5]){
        printf("Yes\n");
    }
    else{printf("No\n");}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lb long double
#define eps 1e-9
using namespace std;
struct Po{lb x,y;}p1,p2,x,np;
int t; 
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
lb operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
lb operator ^(Po x,Po y){return x.x*y.x+x.y*y.y;}
lb le2(Po x){return x.x*x.x+x.y*x.y;}
int main(){
	get(p1);get(p2);np=p2-p1;
	scanf("%d",&t);
	while (t--){
		get(x);
		Po nx=x-p1;
		lb cj=nx*np;
		if (cj>eps)puts("CLOCKWISE");
		if (cj<-eps)puts("COUNTER_CLOCKWISE");
		if (fabs(cj)<eps){
			if ((nx^np)<-eps)puts("ONLINE_BACK");
			else if (le2(nx)<le2(np)+eps)puts("ON_SEGMENT");else puts("ONLINE_FRONT");
		}
	}
	return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>
#include <vector>
#include <string.h>

#pragma warning(disable:4996)
int main(void) {
	int r, D, x2000;
	scanf("%d %d %d", &r, &D, &x2000);
	int x = x2000;
	for (int i = 1; i <= 10; ++i) {
		x = r * x - D;
		printf("%d\n", x);
	}
	return 0;
}

Measured memory_bytes: 256
module Main where

-- import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
-- import Data.Array
import Data.Array.IO
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

solve :: Int -> [Int] -> IO [Int]
solve n l = iter (newListArray (0, n) (minBound:l)) (div n 2) where
    iter :: IO (IOUArray Int Int) -> Int -> IO [Int]
    iter ar 0 = ar >>= getElems >>= (\x -> return (drop 1 x)) 
    iter ar i = iter (maxHeapify ar i) (i-1) where
        maxHeapify ar i = do
            a <- ar
            iv <- readArray a i              
            lv <- readArray a l
            rv <- readArray a r
            if iv > lv
                then if iv > rv then return a
                                else swap a i iv r rv
                else if lv > rv then swap a i iv l lv 
                                else swap a i iv r rv where
                swap :: IOUArray Int Int -> Int -> Int -> Int -> Int -> IO (IOUArray Int Int)
                swap a i iv m mv = do
                    writeArray a i mv
                    writeArray a m iv
                    maxHeapify (return a) m
                l = if 2*i <= n then 2*i else 0
                r = if 0 < l && l < n then l+1 else 0

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' :: [Int] -> IO()
print' [] = putStrLn "" 
print' (x:xs) = do 
    putStr $ ' ':show x 
    print' xs

{-
printIOUArray :: IOUArray Int Int -> IO ()
printIOUArray ioa = do
    l <- getElems ioa
    print l
 -}

main :: IO() 
main = do
    n <- readIntLn
    l <- readIntList
    r <- solve n l 
    print' r



Measured memory_bytes: 102688
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 924844033;
double PI = 4*atan(1);

int siz = 0, par[2001];
ll ans[2001], temp[2001], fac[2001];
int N,K; 

ll inv(ll x) {
	ll po = MOD-2, ans = 1;
	while (po) {
		if (po & 1) ans = (ans*x) % MOD;
		x = (x*x) % MOD;
		po /= 2;
	}
	return ans;
}

ll combo(int a, int b) {
	ll ans = (fac[a]*inv(fac[b])) % MOD;
	ans = (ans*inv(fac[a-b])) % MOD;
	return ans;
}

void comb(int sz) {
	for (int i = siz; i >= 0; --i) FOR(j,1,sz+1) 
		ans[i+j] = (ans[i+j]+ans[i]*temp[j]) % MOD;	
	siz += sz;
}

void gen() {
	cin >> N >> K;
	fac[0] = ans[0] = 1;
	FOR(i,1,2001) fac[i] = (i*fac[i-1]) % MOD;
	FOR(i,1,min(N,K)+1) {
		int co = 0;
		for (int j = i; j <= N; j += K) co ++;
		F0R(i,co/2+1) temp[i] = combo(co-i,i);
		comb(co/2);
		comb(co/2);
	}
}

int main() {
	gen();
	
	ll fin = 0;
	F0R(i,N+1) {
		if (i % 2 == 0) fin = (fin+ans[i]*fac[N-i]) % MOD;
		else fin = (fin-ans[i]*fac[N-i]) % MOD;
		fin = (fin+MOD) % MOD;
		// cout << i << " " << fin << "\n";
	}
	cout << fin;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int m,f,r,ten;
	while(1){
	scanf("%d %d %d",&m,&f,&r);
	if(m==-1 && f==-1 && r==-1){
		break;
	}
	ten = m+f;
	if(m == -1 || f == -1){
		printf("F\n");
	}else if(ten >= 80){
		printf("A\n");
	}else if(ten>=65 && ten<80){
		printf("B\n");
	}else if(ten>=50 && ten<65){
		printf("C\n");
	}else if(ten>=30 && ten<50){
		if(r>=50){
			printf("C\n");
		}else{
			printf("D\n");
		}
	}else if(ten<30){
		printf("F\n");
	}
	}
}
		

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

int main() {
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0; i<n; i++){
    cin >> s.at(i);
  }
  
  sort(s.begin(),s.end());
  
  for(int i=0; i<n; i++){
    cout << s.at(i);
  }
  
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void reverse(char str[])
{
    static int i=0;
    int len=(int)strlen(str);
    char tmp;
    if(i>=len/2) return;
    tmp=str[i];
    str[i]=str[len-1-i];
    str[len-1-i]=tmp;
    i++;
    reverse(str);
}

char *divide[4]={"maerd","remaerd","esare","resare"};
char d[8],cpy[8];
int main(void)
{
    char S[100000];
    scanf("%s",S);
    reverse(S);//文字列反転
   
    int can=1;
    for(int k=0;S[k]!='\0';){
        int can2=0;
        for(int j=0;j<4;j++){
            strncpy(cpy,S+k,strlen(divide[j]));
            cpy[strlen(divide[j])]='\0';
            if(strcmp(cpy,divide[j])==0){
                can2=1;
                k+=strlen(divide[j]);
            }
        }
        if(can2==0){
            can=0;
            break;
        }
    }
    if(can==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
	int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    
    if(A==B&&A==C&&B==C)
    	printf("No\n");
    else if(A!=B&&A!=C&&B!=C)
      	printf("No\n");
  	else
      	printf("Yes\n");
 
        
    return 0;
}

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

#define len_MAX 5000000
int A[len_MAX+1];

void Z_algorithm(string S){
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
    }
}

int main(){
    //input
    string S,T;
    cin >> S >> T;

    //calc
    int n=S.length(), m=T.length();
    string S_ext,U;
    while(S_ext.length()<m){
        S_ext += S;
    }
    S_ext += S_ext;
    U += T;
    U += '_';
    U += S_ext;
    Z_algorithm(U);
    bool in[n], out[n], visited[n];
    int i,j;
    for(i=0; i<n; i++){
        in[i]=0;
        out[i]=0;
        visited[i]=0;
    }
    for(i=0; i<n; i++){
        if(A[i+(m+1)]==m){
            out[i]=1;
            in[(i+m)%n]=1;
        }
    }
    //dfs
    int ans=0, val;
    for(i=0; i<n; i++){
        if(out[i]==1&&in[i]==0){
            visited[i]=1;
            val=1;
            j = (i+m)%n;
            while(out[j]==1){
                visited[j]=1;
                val++;
                j = (j+m)%n;
            }
            ans=max(ans,val);
        }
    }
    bool loop=0;
    for(i=0; i<n; i++){
        if(visited[i]==0&&out[i]==1){
            loop=1;
        }
    }

    //output
    if(loop==1){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 21748
type ary=array[1..100010] of int64;
var n,k,i:int64;
    d:ary;
procedure sort(p,q :int64; var d:ary);
  var i, j, k, w :int64;
begin i := p; j := q; k:=d[(p+q) div 2];
  repeat
    while d[i] < k do i := i+1;
    while k < d[j] do j := j-1;
    if i <= j then begin
      w := d[i]; d[i] := d[j]; d[j] := w;
      i := i+1;  j := j-1
    end
  until i > j;
  if p < j then sort(p,j,d);
  if i < q then sort(i,q,d)
end;
begin
read(n);
for i := 1 to n do read(d[i]);
sort(1,n,d);
write(d[(n div 2)+1]-d[n div 2])
end.
    



Measured memory_bytes: 896
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
P, Q = [0]*(N+1), [0]*(M+1)
for i in range(N):
  P[i+1] = P[i]+A[i]
for i in range(M):
  Q[i+1] = Q[i]+B[i]
j, result = M, 0
for i in range(N+1):
  if P[i]>K:
    break
  if K-P[i]>=Q[j]:
    result = max(result, i+j)
  else:
    while 0<j and K-P[i]<Q[j-1]: j -= 1
    result = max(result, i+j-1)
print(result)

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

const int mod = (int)1e9+7;

long long modpow(long long a, long long b){
	if(b == 0) return 1;
	if(b & 1) return a*modpow(a, b-1) % mod;

	long long work = modpow(a, b/2);
	return (work*work) % mod;
}

long long comb(long long a, long long b){
	long long faca=1, facb=1;
	for(int i=1; i<=a; ++i){
		if(i > a-b) faca = (faca * i) % mod;
		if(i <= b) facb = (facb * i) % mod;
	}

	return faca * modpow(facb, mod-2) % mod;
}

int main(){
	long long N, M; cin >> N >> M;

	map<int, int> fac;
	int a = 2;
	while(M >= a){
		if(M % a == 0){
			++fac[a];
			M /= a;
		}else{
			++a;
		}
	}

	long long ans = 1;
	for(auto& x : fac){
		ans = (ans * comb(x.second+N-1, x.second)) % mod;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<usize>();
    let mut alice = 0;
    let mut bob = 0;
    a.sort();
    a.reverse();
    for i in 0..n {
        if i % 2 == 0 {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }
    let ans = alice - bob;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>


int main() {


	//出力
	int sx, sy, tx, ty;
	std::cin >> sx >> sy >> tx >> ty;


	//処理
	int w, h;//sとtの差
	w = tx - sx;
	h = ty - sy;
	std::string ans = "";
	for (int i = 0; i < w; i++)ans += 'R';
	for (int i = 0; i < h; i++)ans += 'U';
	for (int i = 0; i < w; i++)ans += 'L';
	for (int i = 0; i < h; i++)ans += 'D';


	ans += 'D';

	for (int i = 0; i < w + 1; i++)ans += 'R';
	for (int i = 0; i < h + 1; i++)ans += 'U';

	ans += 'L';
	ans += 'U';
	for (int i = 0; i < w + 1; i++)ans += 'L';
	for (int i = 0; i < h + 1; i++)ans += 'D';

	ans += 'R';


	//出力
	std::cout << ans;
	


	return 0;


}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[5], ans;

int main()
{
	scanf("%d%d%d", &a[1], &a[2], &a[3]);
	sort(a + 1, a + 4);
	for (int i = 2; i <= 3; i++)
		ans += a[i] - a[i - 1];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128