akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    query = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: x[1],
                   reverse=True)

    B = []
    for i in range(m):
        b, c = query[i]
        while b and len(B) != n:
            B.append(c)
            b -= 1
    B.sort(reverse=True)

    for i in range(len(B)):
        if A[i] < B[i]:
            A[i] = B[i]
    print(sum(A))


def resolve2():
    n, m = map(int, input().split())
    A = []
    for a in map(int, input().split()):
        A.append([1, a])

    for _ in range(m):
        b, c = map(int, input().split())
        A.append([b, c])
    A.sort(key=lambda x: x[1], reverse=True)

    num, res = 0, 0
    for a, b in A:
        if num + a <= n:
            res += a * b
            num += a
        else:
            res += (n - num) * b
            break
    print(res)


if __name__ == '__main__':
    resolve2()


Measured memory_bytes: 39652
/*

Code for problem A by cookiedoth
Generated 21 Mar 2020 at 02.55 PM


█▒▒▒▒▒▒▒▒▒
10%
███▒▒▒▒▒▒▒
30%
█████▒▒▒▒▒
50%
███████▒▒▒
70%
██████████
100%

¯\_(ツ)_/¯
^_^
-_-

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

void fast_io() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const int INF = 1e9 + 228;
const int mx = 110;
int h, w, dp[mx][mx];
vector<string> s;

int delta(char c1, char c2) {
	return (c1 == '.' && c2 == '#');
}

signed main() {
	fast_io();
	cin >> h >> w;
	s.resize(h);
	for (int i = 0; i < h; ++i) {
		cin >> s[i];
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = (s[0][0] == '#');
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (i < h - 1) {
				chkmin(dp[i + 1][j], dp[i][j] + delta(s[i][j], s[i + 1][j]));
			}
			if (j < w - 1) {
				chkmin(dp[i][j + 1], dp[i][j] + delta(s[i][j], s[i][j + 1]));
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 384
import math

a, b, h, m = map(int, input().split())

h_radius = 360 * h / 12 + 30 * m / 60
m_radius = 360 * m / 60

radius_diff = abs(h_radius - m_radius)

nagasa2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radius_diff))

print(math.sqrt(nagasa2))


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

int main() {
  int n;
  cin>>n;
  vector<int> vec(n);
  vector<int> answer(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int p=(n+1)/2;
  int m=0,sum=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      m+=vec.at(i);
    }
    sum+=vec.at(i);
  }
  answer.at(0)=2*m-sum;
  for(int i=1;i<n;i++){
    answer.at(i)=vec.at(i-1)*2-answer.at(i-1);
  }
  for(int i=0;i<n;i++){
    cout<<answer.at(i)<<" ";
  }
  cout<<endl;  
}

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

int main() {
    string s;
    cin >> s;
    char last = '\0';
    bool bad = false;
    for (auto c : s) {
        if (last && c == last) {
            cout << "Bad\n";
            bad = true;
            break;
        }
        last = c;
    }
    if (!bad)
        cout << "Good\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << (s.size()==2 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    static long lcm(int n, int m) {
        if (n == m) return n;
        long ans = 1;
        int div = 2;
        int max_kouyaku = Math.abs(m - n);
        while (div == 2) {
            if (n % 2 == 0 && m % 2 == 0) {
                n /= 2;
                m /= 2;
                ans *= div;
            } else div++;
        }
        for (div = 3; div <= Integer.min(n, m) && div <= max_kouyaku; div += 2) {
            if (m % div == 0 && n % div == 0) {
                m /= div;
                n /= div;
                ans *= div;
                div -= 2;
            }
        }
        return ans * m * n;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long lcm = lcm(N, M);
        int stepS = (int) (lcm / N);
        int stepT = (int) (lcm / M); //stepS,stepT刻みで入る
        int dupS = (int) (lcm(stepS, stepT) / stepS);
        int dupT = (int) (lcm(stepS, stepT) / stepT);
        //文字が一致しなくてはならないのはSの1+n(dupS)番目の文字とTの1+n(dupT)番目の文字
        String S = sc.next();
        String T = sc.next();
        for (int i = 0; i < N / dupS; i++) {
            if (S.charAt(i * dupS) != T.charAt(i * dupT)) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(lcm);
    }
}

Measured memory_bytes: 27732
s = input()
n = len(s)
x = [0] * n
fl = 1
if s[0] == 'A' or s[0] == 'T' or s[0] == 'C' or s[0] == 'G':
    x[0] = 1
        
for i in range(1,n):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        x[i] = x[i-1] + 1
    else:
        x[i] = 0

print(max(x))

Measured memory_bytes: 38384
function heron(a,b,c){
   var s=(a+b+c)/2;
   var S=Math.sqrt(s*(s-a)*(s-b)*(s-c));
   return S;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var I=0;I<Arr.length;I++){
   var arr=Arr[I].split(" ").map(Number);
   var x1=arr[0];var y1=arr[1];
   var x2=arr[2];var y2=arr[3];
   var x3=arr[4];var y3=arr[5];
   var xp=arr[6];var yp=arr[7];
   var d12=Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
   var d13=Math.sqrt(Math.pow(x1-x3,2)+Math.pow(y1-y3,2));
   var d23=Math.sqrt(Math.pow(x2-x3,2)+Math.pow(y2-y3,2));
   var dp1=Math.sqrt(Math.pow(xp-x1,2)+Math.pow(yp-y1,2));
   var dp2=Math.sqrt(Math.pow(xp-x2,2)+Math.pow(yp-y2,2));
   var dp3=Math.sqrt(Math.pow(xp-x3,2)+Math.pow(yp-y3,2));
   var S123=heron(d12,d13,d23);
   var s123=heron(d12,dp1,dp2)+heron(d13,dp1,dp3)+heron(d23,dp2,dp3);
   console.log((Math.abs(S123-s123)<0.0005)?"YES":"NO");
}

Measured memory_bytes: 8704
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <map>
#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    while(n) {
        int bit = n % 10;
        if(bit == 7) {
            cout << "Yes" << endl;
            return 0;
        }
       n /= 10;
    }
    cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 3624
#include<iostream>

int main(){

    int A,B,fee;
    std::cin>>A >>B;

    if(A > 12){
        fee = B;
    }
    else if(A > 5){
        fee =B/2;
    }
    else{
        fee =0;
    }
    std::cout<<fee<<std::endl;

}


Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
INFTY=sys.maxsize

def readinput():
    n=int(input())
    nList=[]
    for _ in range(n):
        nList.append([])
    for _ in range(n):
        l=list(map(int,input().split()))
        i=l[0]
        k=l[1]
        for j in range(k):
            v=l[2+j*2]
            c=l[2+j*2+1]
            nList[i].append([v,c])
    return n,nList

def dijkstra(s,n,nList):
    WHITE=0
    GRAY=1
    BLACK=2
    color=[WHITE]*n
    d=[INFTY]*n

    HQ=[]

    d[s]=0
    heappush(HQ,(d[s],s))

    while(len(HQ)>0):
        du,u=heappop(HQ)
        color[u]=BLACK

        if d[u]<du:
            continue

        for (v,vw) in nList[u]:
            if color[v]!=BLACK:
                if d[u] + vw < d[v]:
                    d[v] = d[u] + vw
                    color[v]=GRAY
                    heappush(HQ, (d[v], v))
    return d


def main(n,nList):
    d=dijkstra(0,n,nList)    
    for i in range(n):
        print('{} {}'.format(i,d[i]))

    return

if __name__=='__main__':
    n,nList=readinput()
    main(n,nList)

        


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int l, r, d;  cin >> l >> r >> d;
  cout << (r/d) - (l-1)/d << "\n";
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,a;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='?')
        {

                s[i]='D';

        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int R,G;
    cin>>R>>G;
    cout<<2*G-R<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
int main(void){
    int x[10],r,D,i;
    scanf("%d %d %d",&r,&D,&x[0]);
    for(i=0;10>i;++i){
        x[i+1]=r*x[i]-D;
        printf("%d\n",x[i+1]);
    }
    return 0;
}

Measured memory_bytes: 128
#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 vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vector<pii> > vvpii;

#define pb push_back
#define endl '\n'
#define INF (int)1e9
#define EPS 1e-9
#define MOD (int)1000000007
#define gcd __gcd
#define rs resize
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; } //for struct sorting

void printV(vector<int> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " " ;
	}
	cout << endl;
}

void print2V(vvi v){
	FOR(i, 0, v.size()){
		FOR(j, 0, v[i].size()){
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

int h, w, ways[2000][2000];
string grid[2000];

int cnt(int cur_i, int cur_j){
//	cout << "inside with: " <<  " " <<  cur_i << " " <<  cur_j << endl;
	if(cur_i == h && cur_j == w){
//		cout << "endpoint" << endl;
		return 1;
	}
	if( cur_i < 1 || cur_j < 1 || cur_i > h || cur_j > w || grid[cur_i-1][cur_j-1] == '#'){
//		cout << "out of bounds or wall" << endl;
		return 0;
	}
	if(ways[cur_i][cur_j] != -1){
//		cout << "already calculated" << endl;
		return ways[cur_i][cur_j];
	}
	int ans = 0;
	
	ans = (ans + cnt(cur_i+0, cur_j+1)%MOD)%MOD;
//	cout << "in: " << cur_i << " " << cur_j << endl;
//	cout << "for ways(" << cur_i+0 << " " << cur_j+1 << ")  ans is: " << ans << endl;
	ans = (ans + cnt(cur_i+1, cur_j+0)%MOD)%MOD;
//	cout << "in: " << cur_i << " " << cur_j << endl;
//	cout << "for ways(" << cur_i+1 << " " << cur_j+0 << ")  ans is: " << ans << endl;
	
	ways[cur_i][cur_j] = ans%MOD;
//	cout << "assigning ways(" << cur_i << " " << cur_j << ")  " << ans << endl; 
	
	return ways[cur_i][cur_j];
}

int main(){
	memset(ways, -1, sizeof ways);
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		cin >> grid[i];
	}	
	cout << cnt(1, 1);

/*
	cout << endl << endl;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cout << ways[i][j] << " ";
		}
		cout << endl;
	}
*/
}

Measured memory_bytes: 17024
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

/*
 * ref. http://drken1215.hatenablog.com/entry/2018/06/08/210000
 *
 * usage:
 *
 * Combination *c;
 * 
 * const int MOD = 1000000007;
 * const int MAX_N = 100000;
 * 
 * int main(void) {
 *     int n, k;
 *     cin >> n >> k;
 *     c = new Combination(2 * MAX_N, MOD);
 *     cout << c->com(n + k - 1, k) << endl;
 *     delete(c);
 *     return 0;
 * }
 */
class Combination {
    public:
        const int max;
        const int mod;
        vector<ll> fac, finv, inv;

        Combination(int max, int mod) : max(max), mod(mod), fac(max), finv(max), inv(max) {
            init();
        }

        ll com(int n, int k) {
            if (n < k) return 0LL;
            if (n < 0 || k < 0) return 0LL;
            // return (fac[n] * ((finv[k] * finv[n - k]) % mod)) % mod;
            return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
        }

    private:
        void init() {
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < max; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }
};

Combination *c;

const int MOD = 1000000007;
const int MAX_N = 1000000;

int main(void) {
    int X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int n = (2 * Y - X) / 3;
    int m = (2 * X - Y) / 3;
    if (n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }
    // printf("n: %d, m: %d\n", n, m);

    c = new Combination(2 * MAX_N, MOD);
    cout << c->com(n + m, n) << endl;
    delete(c);

    return 0;
}


Measured memory_bytes: 47104
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	
	double weeks=0;
	double debit=100.0;
	
	
	cin >> weeks;
	
	for(int i=0; i<weeks;i++){
		debit=debit+debit*0.05;
		debit=ceil(debit);
	}
	
	int out =debit*1000;
	
	cout <<out<<endl;
	
	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a;
  for(int i = 1; i <= N; i++) {
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s, p, i));
  }
  sort(a.begin(), a.end());
  for(auto x : a) {
    cout << get<2>(x) << endl;
  }
  return 0;
}

Measured memory_bytes: 384
from math import factorial
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

if N > K:
    print(0)
else:
    print(factorial(K) * pow(factorial(N), MOD - 2, MOD) * pow(factorial(K - N), MOD - 2, MOD) % MOD)



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

int main(){
    long long n,d;
    cin >> n >> d;

    int count = 0;
    for (int i = 0; i < n; i++){
        long long x,y;
        cin >> x >> y;
        long long tmp = x*x + y*y;
        if (d*d >= tmp){
            count++;
        }
    }

    cout << count << "\n";
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+500;
int A[maxn],B[maxn];
int T,n;
map<string,int> mp;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(ceil(c*1.0/b)<=ceil(a*1.0/d)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

int main(){
	int H,W,flag;
	cin >> H >> W;
	
	vector<vector<char>> vec = vector<vector<char>>(H+2,vector<char>(W+2,'.'));
	
	for(int i=1; i<H+1; i++){
		for(int j=1; j<W+1; j++){
			cin >> vec.at(i).at(j);
		}
	}
	flag = 0;
	
	for(int i=1; i<H+1; i++){
		for(int j=1; j<W+1; j++){
			if(vec.at(i).at(j) == '#'){
				if((vec.at(i).at(j+1) == '#') || (vec.at(i+1).at(j) == '#') || vec.at(i-1).at(j) == '#' || vec.at(i).at(j-1) == '#'){
				
				
				}
				else {
					flag = 1;
					break;
				}
			}
		}
	}
	

	if(flag == 1) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	
}


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

int main(){
    int n;
    cin >> n;
    int i, num[n], check=0, count=0;
    for(i=0;i<n;i++){
        cin >> num[i];
    }
    while(check == 0){
        for(i=0;i<n;i++){
            if(num[i] % 2 != 0){
                check = 1;
                break;
            }
            else{
                num[i] /= 2;
            }
        }
        if(check == 0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int m=sc.nextInt();
        int ans=1;
        for (int i=1; i*i<=m ;i++ ) {            
            if(m%i==0 && 0<=m-i*n && (m-i*n)%i==0)ans=max(ans,i);          
            if(m%i==0 && 0<=m-((long)m/i)*n && (m-((long)m/i)*n)%(m/i)==0)ans=max(ans,m/i);
        }


        out.println(ans);
        out.flush();
        // out.println(ans);
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22484
#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()
{
    ll n;
    cin >> n;
    string ans;
    while (n)
    {
        n--;
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int n;
vector<double> x,y;

double distance1(){
	double sum=0.0;
	for(int i=0;i<n;i++){
		sum+=abs(x[i]-y[i]);
	}
	return sum;
}

double distance2(){
	double sum;
	for(int i=0;i<n;i++){
		sum+=(x[i]-y[i])*(x[i]-y[i]);
	}
	return sqrt(sum);
}

double distance3(){
	double sum;
	for(int i=0;i<n;i++){
		sum+=(x[i]-y[i])*(x[i]-y[i])*abs(x[i]-y[i]);
	}
	return cbrt(sum);
}

double distanceI(){
	double m=0;
	for(int i=0;i<n;i++){
		m=max(m,abs(x[i]-y[i]));
	}
	return m;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		double X;
		cin>>X;
		x.push_back(X);
	}for(int i=0;i<n;i++){
		double Y;
		cin>>Y;
		y.push_back(Y);
	}
	cout<<fixed;
	cout<<distance1()<<endl;
	cout<<distance2()<<endl;
	cout<<distance3()<<endl;
	cout<<distanceI()<<endl;
	return 0;
}



Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define vi vector<int>
#define vl vector<long long>
#define fio  cin.tie(nullptr); ios::sync_with_stdio(false); cout.tie(nullptr);
 
int main()
{
    fio;
    ll n;cin>>n;
    vi v(n);
    cin>>v[0];
    ll ans=v[0];
    loop(i,1,n,1)
    {
        cin>>v[i];
        ans = ans^v[i]; 
    }
    loop(i,0,n,1)
    {
        cout<<(ans^v[i])<<" ";
    }
    return 0;
}

Measured memory_bytes: 3956
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 998244353;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, a, b, k;
const ll M = 998244353;
vector<ll>
    fac(3000001);         //n!(mod M)
vector<ll> ifac(3000001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n)
{ //x^n(mod M)
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
//conbination
ll comb(ll a, ll b)
{ //aCb(mod M)
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b >> k;
    if(k==0)return cout<<1<<"\n",0;
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 3000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % M;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
    vector<ll> x, y;
    for (ll i = 0; i <= n; i++)
    {
        if ((k - a * i) % b == 0 && (k - a * i) / b > 0)
        {
            x.push_back(i);
            y.push_back((k - a * i) / b);
        }
    }
    //debug(x);
    //debug(y);
    ll ans = 0;
    rep(i, x.size())
    {
        if (x[i] <=n &&y[i] <= n)
        {
            ll temp = comb(n, x[i]);
            temp *= comb(n, y[i]);
            ans+=temp;
            ans%=MOD;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 57440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= (1000 / k); i++) {
			if (a <= i * k && b >= k * i) {
				ans++;
				break;
			}

		}
		if (ans == 1) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}

	}

}

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

using namespace std;

typedef long long ll;

const int N = 200200;
const ll Inf = 1e18;

int n;
int a[N];
ll Dp[N][3];

ll Rec(int i, int j)
{
    if(j < 0)   return -Inf;
    if(i >= n)  return j <= 1 ? 0 : -Inf;

    if(Dp[i][j] + 1)    return Dp[i][j];

    return Dp[i][j] = max(a[i] + Rec(i + 2, j), Rec(i + 1, j - 1));
}

int main()
{
    cin >> n;

    for(int i = 0; i < n; i++)  scanf("%d", a + i);

    memset(Dp, -1, sizeof(Dp));

    cout << Rec(0, n & 1 ? 2 : 1) << endl;
}


Measured memory_bytes: 15392
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	vi a;
	rep(i, 5){
		int x;
		cin >> x;
		a.pb(x);
	}
	int ans = 1e9;
	do{
		int res = 0;
		rep(i, 5){
			res = ((res + 9) / 10) * 10;
			res += a[i];
		}
		ans = min(ans, res);
	}while(next_permutation(all(a)));
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
LL a; 
int main()
{
	a=read();
	printf("%lld\n",a+a*a+a*a*a);
	return 0;
}


Measured memory_bytes: 3764
n = int(input())
a = list(map(int, input().split()))

negCnt = 0
absSum = 0
minAbs = float('inf')
for val in a:
    negCnt += val < 0
    absVal = abs(val)
    absSum += absVal
    minAbs = min(minAbs, absVal)
print(absSum - 2 * minAbs if negCnt & 1 else absSum)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,i,x;
    cin>>a;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='.')
        {
            s.erase(i,1);
        }
    }
  x=atoi(s.c_str());
  x=x*a/100;
    cout<<x<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int n;
  cin>>n;
  int pp[200005],pm[200005];
  rep(i,n){
    int x,y;
    cin>>x>>y;
    pp[i]=x+y;
    pm[i]=x-y;
  }
  sort(pp,pp+n);
  sort(pm,pm+n);
  cout<<max(pp[n-1]-pp[0],pm[n-1]-pm[0])<<endl;
  return 0;
}


Measured memory_bytes: 5184
s = gets.chomp

def year?(cs)
  v = cs.join.to_i
  v > 12 || v == 0
end

f = s.chars[0, 2]
b = s.chars[2, 2]

def calc(f, b)
  if year?(f)
    if year?(b)
      'NA'
    else
      'YYMM'
    end
  else
    if year?(b)
      'MMYY'
    else
      'AMBIGUOUS'
    end
  end
end
puts calc(f, b)


Measured memory_bytes: 1788
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))




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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  vll a(n + 1);
  vll b(n);
  ll num_mons = 0;
  REP(i, n + 1) {
    cin >> a[i];
    num_mons += a[i];
  }
  REP(i, n) {
    cin >> b[i];
  }
  REP(i, n) {
    ll mos = a[i] - b[i];
    if (mos < 0) {
      b[i] = b[i] - a[i];
      a[i] = 0;
    }
    else {
      a[i] = a[i] - b[i];
      b[i] = 0;
    }
    // COUTA(j, b);

    mos = a[i + 1] - b[i];
    if (mos < 0) {
      b[i] = b[i] - a[i + 1];
      a[i + 1] = 0;
    }
    else {
      a[i + 1] = a[i + 1] - b[i];
      b[i] = 0;
    }
    // COUTA(j, a);
  }

  REP(i, n + 1) {
    num_mons -= a[i];
  }
  // COUTA(i, a);
  COUT(num_mons);

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
2
3 5 2
4 5
*/


Measured memory_bytes: 4744
/**
 * @Author: harshkhajuria
 * @Date:   09-May-2020 05:39:30 pm
 * @Email:  khajuriaharsh729@gmail.com
 * @Filename: A - A?C.cpp
 * @Last modified by:   harshkhajuria
 * @Last modified time: 09-May-2020 05:44:02 pm
 */
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
		out << '(' << p.ff << ", " << p.ss << ')';
		return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
		int l = v.size();
		for (int i = 0; i < l - 1; i++)
				out << v[i] << ' ';
		if (l > 0)
				out << v[l - 1];
		return out;
}

template <typename T> void trace(const char* name, T&& arg1) {
		cout << name << " : " << arg1 << endl;
}

template <typename T, typename ... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
		const char* comma = strchr(names + 1, ',');
		cout.write(names, comma - names) << " : " << arg1 << " | ";
		trace(comma + 1, args ...);
}

/*Input*/
/*Input*/

int main()
{
		//ios::sync_with_stdio(false);
		//cin.tie(0);
		//cout.tie(0);
		clock_t tStart = clock();
		int test;
		test = 1;
		// cin >> test;
		while (test--) {
				string s;
				cin >> s;
				if(s == "ARC") cout << "ABC\n";
				else cout << "ARC\n";
		}
#ifdef LOCAL_DEFINE
		printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
		return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main() {
	int i, j, f, a[8][8];
	char name[10];
	while(1) {
		f=0;
		for( i=0; i<8; i++) {
			for( j=0; j<8; j++) {
				if (scanf("%1d", &a[j][i])==EOF) {
					f=1;
					break;
				}
			}
		}
		if (f==1) break;
		name[0]='\0';
		for( i=0; i<8; i++) {
			for( j=0; j<8; j++) {
				if (a[j][i]) {
					if (j<=4) {
						if ( (a[j+1][i])&&(a[j+2][i])&&(a[j+3][i]) ) 
								name[0]='C';
					}
					if (j<=5) {
						if (i<=6) {
							if ( (a[j+1][i])&&(a[j+1][i+1])&&(a[j+2][i+1]) )
								name[0]='E';
						}
					}
					if (j<=6) {
						if (i<=5) {
							if ( (a[j][i+1])&&(a[j+1][i+1])&&(a[j+1][i+2]) )
								name[0]='F';
						}
						if (i<=6) {
							if ( (a[j+1][i])&&(a[j][i+1])&&(a[j+1][i+1]) )
								name[0]='A';
							if (j>=1) {
								if( (a[j+1][i])&&(a[j][i+1])&&(a[j-1][i+1]) )
									name[0]='G';
							}
						}
					}
					if (j<=7) {
						if (i<=4) {
							if ( (a[j][i+1])&&(a[j][i+2])&&(a[j][i+3]))
								name[0]='B';
						}
						if ( (j>=1)&&(i<=5) ) {
							if ( (a[j][i+1])&&(a[j-1][i+1])&&(a[j-1][i+2]) )
								name[0]='D';
						}
					}
					name[1]='\0';
					break;
				}
			}
		}
		printf("%s\n",name);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<time.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
#define INF (1<<30)
#define INFLL (1LL << 60)
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }


class UF
{
	vector<int> par;
public:
	UF(int n) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;	//頂点iの親を格納する
	}
	int root(int x) {
		if (x == par[x]) return x;
		else return par[x] = root(par[x]);	//経路圧縮
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		par[x] = y;
		return true;
	}
};
struct Edge {
	int from, to, cost;
	Edge(int f, int t, int c) { from = f; to = t; cost = c; }
};

ll kruskal(vector<Edge> edges, int vnum)
{
	sort(edges.begin(), edges.end(), [](Edge a, Edge b) {
		return a.cost < b.cost;
		});
	UF uf = UF(vnum);
	ll sum = 0;
	for (Edge e : edges) {
		if (uf.unite(e.from, e.to)) sum += e.cost;
	}
	return sum;
}

int main()
{
	int N; cin >> N;
	vector<pair<int, int>> xy(N), xi(N), yi(N);
	rep(i, N) {
		int x, y; cin >> x >> y;
		xy[i] = make_pair(x, y);
		xi[i] = make_pair(x, i);
		yi[i] = make_pair(y, i);
	}
	sort(xi.begin(), xi.end());
	sort(yi.begin(), yi.end());

	//辺の構築
	vector<Edge> es;
	rep(i, N - 1) {
		es.emplace_back(Edge(xi[i].second, xi[i + 1].second, xi[i + 1].first - xi[i].first));
		es.emplace_back(Edge(yi[i].second, yi[i + 1].second, yi[i + 1].first - yi[i].first));
	}
	cout << kruskal(es, N) << endl;
	return 0;
}


Measured memory_bytes: 11140
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    //バケット法
    //値とインデックスを対応させる.
    vector<int> bucket(n+1);
    rep(i,n) ++bucket.at(a.at(i));

    //ソート
    sort(bucket.begin(),bucket.end());
    reverse(bucket.begin(),bucket.end());
    // rep(i,n) cout<<bucket.at(i)<<endl;

    //変える必要があるか？
    int group=0;
    int ans=0;
    rep(i,n){
        if(bucket.at(i)!=0) ++group;
    }
    if(group<=k){
        cout<<0<<endl;
        return 0;
    }
    else{
        int del_group = 0;
        del_group = group - k;
        reverse(bucket.begin(),bucket.end());

        int t;
        rep(i,n){
            if(bucket.at(i)!=0){
                ans += bucket.at(i);
                ++t;
                if(t==del_group) break;
            }
        }

    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()

using namespace std;

//long a, b, c, d, i, j, k, n;

int64_t dfs(int64_t val , int64_t n);


int main(){
//////////////////////////////////////////////////////

    uint64_t n;
    cin >> n;

    //cout << "n:" << n << endl;

    // vector<long> input(n);
    // for (int i = 0 ; i < n ; i ++ )
    // {
    //     cin >> input[i];
        // cout << "input[" << i << "]=" << input[i] << endl;
    // }

    // sort(input.begin() , input.end());

    // uint64_t max = numeric_limits<uint64_t>::max();



    // long sum = 0;
    // for ( int i = 0 ; i < n ; i ++ )
    // {
    //     sum += i;
    // }






    cout <<   dfs( 0, n)   << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


int64_t dfs(int64_t val , int64_t n)
{
    if ( val > n )
    {
        return 0;
    }

    string s = to_string(val);
    int64_t cnt = 0;

    if (s.find("7") != string::npos && s.find("5") != string::npos && s.find("3") != string::npos )
    {
        cnt++;//これ自身が753数であったら．
    }

    cnt += dfs(val * 10 + 3 , n);
    cnt += dfs(val * 10 + 5 , n);
    cnt += dfs(val * 10 + 7 , n);

    return cnt;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cin(string, s);
    
    vc<vc<int>> dp(n+1, vc<int>(n+1, 0));
    dp[0][0] = 1;
    For(i, n) For(j, n+1){
        dp[i+1][j] = (dp[i][max(j-1, 0)] + 2*dp[i][min(j+1, n)] % MOD) % MOD;
    }
    Cout(dp[n][s.size()]);
}




Measured memory_bytes: 98176
# -*- coding: utf-8 -*-
N = int(input())
L = map(int, input().split())
sumL = 0
maxL = -1
for Li in L:
    sumL += Li
    if Li > maxL:
        maxL = Li
    
sumL -= maxL

if maxL < sumL:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template <class T>
class CumulativeSum{
public:
    vector<T>sum;
    T e;
    
    CumulativeSum(vector<T>v,T e) : sum(v.size()),e(e){
        copy(v.begin(),v.end(),sum.begin());
        T past = 0;
        for(auto && itr : sum){
            itr += past;
            past = itr;
        }
    }
    //[l,r)
    auto query(int l, int r){
        if(r > 0) return (sum[r - 1] - (l == 0 ? 0 : sum[l - 1]));
        else return e;
        
    }
};

signed main(){
    int n; cin >> n;
    int sum = 0;
    string s; cin >> s;
    int b = 0, w = 0;
    for(auto c : s) if(c == '#')++b; else ++w;
    s.push_back('W');
    vector<int>bv,wv;
    int cnt = 1; char now = s.front();
    for(int i = 1; i < s.size(); ++i){
        if(s[i] == now){
            ++cnt;
        } else {
            if(now == '#'){
                bv.push_back(cnt);
                wv.push_back(0);
            } else {
                bv.push_back(0);
                wv.push_back(cnt);
            }
            cnt = 1;
            now = s[i];
        }
    }
    auto wsum = CumulativeSum<int>(wv,0LL);
    auto bsum = CumulativeSum<int>(bv,0LL);
    int ans = min(b,w);
    for(int i = 0; i < bv.size();++i){
        cmin(ans,bsum.query(0,i) + wsum.query(i,bv.size()));
    }
    cout << ans << endl;
}




Measured memory_bytes: 8268
#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 n, d, x;
int chocolate(int a) {
	return (d - 1) / a + 1;
}
int main() {
	cin >> n >> d >> x;
	int ans = x;
	rep(i, n) {
		int a; cin >> a;
		ans += chocolate(a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $N, $M);
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
sort($A);

//累積和を作る
$AS[-1] = 0;
foreach($A as $i => $a){
    $AS[$i] = ($AS[$i-1] ?? 0) + $a;
}
//二分探索 -- $k以上の値の個数がMを超えるなかで最大のkを求める
//めぐる式二分探索
$ok = 0; 
$ng = 10**5*2+1;
while(abs($ok - $ng) > 1){
    $mid = intdiv($ok+$ng, 2);
    $sum = 0;
    $count = 0;
    if(isOK($mid)){
        $ok = $mid;
    }else{
        $ng = $mid;
    }
}
echo $sum - $ok * ($count - $M);
function isOK($bound){
    global $M, $A, $AS, $N, $sum, $count;
    foreach($A as $a){
        $i = lower_bound($A, $bound - $a);
        $ok = $N - $i;
        $count += $ok;
        $sum += $AS[$N - 1] - $AS[$i - 1] + $a * $ok;
    }
    return $count >= $M;
}
function lower_bound($array, $key){
    global $N;
    global $memo;
    if(!isset($memo[$key])){
        $min = -1;
        $max = $N;
        while($max - $min > 1){
            $c = intdiv($min + $max, 2);
            if($array[$c] >= $key){
                $max = $c;
            }else{
                $min = $c;
            }
        }
        $memo[$key] = $max;
    }
    return $memo[$key];
}


Measured memory_bytes: 27636
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        int count = 1;
        for(int i=0; i<input.length; i++){
            if(i !=0 && input[i-1] == input[i]){
                count++;
            } else if(i != input.length-1){
                count = 1;
            }
        }

        if(count >= 3){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

typedef struct tt{
  char name[100];
  int t;
}A;
A Q[100000];
int head=0,tail,n;
void enqueue(A x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t=x.t;
  tail++;
  if(tail==100000){
    tail=0;
  }
}
int main(){
  int elaps = 0;
  int i,q;
  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  tail=n;
  while(tail!=head){
    if(Q[head].t>q){
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);
    }else{
      elaps += Q[head].t;
      printf("%s %d\n",Q[head].name,elaps);
    }
    head++;
    if(head==100000){
      head = 0;
    }
  }
  return 0;
}

Measured memory_bytes: 11848
#include <iostream>
#include <string>
#include <deque>
using namespace std;
int main(void){
    bool inversion = false;
    string S = "";
    cin >> S;
    int sLength = S.length();
    deque<string> work(sLength);
    for (int i = 0; i < sLength; ++i) {
        work[i] = S[i];
    }
    
    int Q = 0;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int queryType = 0;
        cin >> queryType;
        
        if (queryType == 1) {
            inversion = !inversion;
            continue;
        }
        
        int F = 0;
        string C = "";
        cin >> F >> C;
        if (!inversion) {
            if (F == 1) {
                work.push_front(C);
            } else {
                work.push_back(C);
            }
        } else {
            if (F == 1) {
                work.push_back(C);                
            } else {
                work.push_front(C);
            }
        }
    }

    if (!inversion) {
        for (auto itr = work.begin(); itr != work.end(); itr++) {
            cout << *itr;
        }
    } else {
        for (auto itr = work.rbegin(); itr != work.rend(); itr++) {
            cout << *itr;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
string s[100];
int main(){
	int n,l;
	cin>>n;
	cin>>l;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	for(int k=0;k<n;k++){
		cout<<s[k];
	}
}
//超有名な"伊勢田数" １番目の数は"２７"　二番目の数は"４８"


Measured memory_bytes: 256