akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll s[n + 1];
    s[0] = 0;
    rep(i, n)
    {
        s[i + 1] = s[i] + a[i];
    }
    ll ans = (1ll << 60);
    rep(i, 1, n + 1)
    {
        ll llen = s[i];
        ll rlen = s[n] - s[i];
        if (llen == rlen)
        {
            ans = 0;
            break;
        }
        //cerr << i << " " << s[i] << " " << llen << " " << rlen << " " << abs(llen - rlen) << " " << ans << endl;
        ans = min(ans, abs(llen - rlen));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3968
n, m = map(int, input().split())
lst = []
for i in range(n):
  tmplst = [int(i) for i in input().split()]
  tmp = 0
  for item in tmplst[1:]:
    tmp |= 1 << item
  lst.append(tmp)
ret = lst[0]
for item in lst[1:]:
  ret &= item
if ret:
  s = sum(map(int, bin(ret)[2:]))
  print(s)
else:
  print(0)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<long long> v(n);
  for(int i=0;i<n;i++){
	cin>>v[i];
  }
  sort(v.begin(),v.end(),greater<long long>());
  long long sum=0;
  long long ex=0;
  long long count=0;
  for(int i=0;i<a;i++){
	sum+=v[i];
  }
  int first,last;
  for(int i=0;i<n;i++){
	if(v[a-1]==v[i]){
      if(i==0){
		first=i;
	  }else if(v[i-1]!=v[i]){
		first=i;
	  }
	  if(i==n-1){
		last=i;
	  }else if(v[i+1]!=v[i]){
		last=i;
	  }
	}
  }
  long long ans2=0;
  for(int j=a;j<=b;j++){
	long long r=last-first+1;
	long long k=j-1-first+1;
	if(r<k)continue;
	long long anst=1;
	for(int i=0;i<k;i++){
      anst*=r-i;
	  anst/=i+1;
	}
	ans2+=anst;
	if(first!=0)break;
  }
  double ans=double(sum)/a;
  cout<<setprecision(10)<<ans<<endl<<ans2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int main() {
    int x;
    while(cin>>x){
        cout<<"ABC"<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int x,n;
    cin >> x >> n;
    unordered_map<int,int> mp;
    for (int i = 0; i < n; ++i) {
        int c;
        cin >> c;
        mp[c] = 1;
    }

    if (mp[x] != 1) {
        cout << x;
        return 0;
    }   
    for (int i = 1; i < x + 1; i++) {
        int a1 = x + (-1)*i;
        int a2 = x + (1)*i;
        if (mp[a1] != 1) {
            cout << a1;
            return 0;
        } 
        if (mp[a2] != 1) {
            cout << a2;
            return 0;
        }
    }


    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include "math.h"


using namespace std;

int main()
{/*
	int n = 0;
	cin >> n;
	int* ike = new int[n+1];
	for (int i = 0; i < n; i++) {
		cin >> ike[i+1];
	}
	int ima = 1;
	int doredake = 0;
	for (int i = 1; i < n+1; i++) {
		ima = ike[ima];
		if (ima == 2) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
	*/
	int n;
	int m;
	long long int nka = 1;
	long long int mka = 1;
	long long int ans = 0;
	long long int moder = 1000000007;
	cin >> n >> m;
	for (int i = 1; i < n+1; i++) {
		nka = (nka * i) % moder;
	}
	for (int i = 1; i < m+1; i++) {
		mka = (mka * i )% moder;
	}
	long long int tyousei = 2;
	if (n != m) {
		tyousei = abs(n - m);
	}
	if (abs(n - m) > 1) {
		tyousei = 0;
	}
	ans = ((((nka * mka)% moder) * tyousei) % moder);
	cout << ans << endl;

	/*
	int n = 0;
	int a = 0;
	int b = 0;
	cin >> n >> a >> b;
	if (0 <= (a - b)) {
		cout << "delicious" << endl;
		return 0;
	}
	if (abs((a - b)) > n) {
		cout << "dangerous" << endl;
		return 0;
	}
	cout << "safe" << endl;
	return 0;*/
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define mod 1000000007
#define MN 201000

int n, a, b, c;
int fac[MN], inv[MN];

int qpow(int x, int p)
{
	int ans = 1;
	while(p)
	{
		if(p & 1) ans = 1ll * ans * x % mod;
		x = 1ll * x * x % mod; p >>= 1;
	}
	return ans;
}

int C(int a, int b) {return 1ll * fac[a] * inv[b] % mod * inv[a - b] % mod;}

int main()
{
	scanf("%d%d%d%d", &n, &a, &b, &c);

	int N = 2 * n; fac[0] = 1;
	for(int i = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[N] = qpow(fac[N], mod - 2);
	for(int i = N - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	int P = qpow(a + b, mod - 2);
	a = 1ll * a * P % mod;
	b = 1ll * b * P % mod;
	int w = 100ll * qpow(100 - c, mod - 2) % mod;
	
	int ans = 0;
	for(int i = n; i < N; i++)
	{
		int p1 = 1ll * qpow(a, n) * qpow(b, i - n) % mod;
		ans = (ans + 1ll * p1 * C(i - 1, n - 1) % mod * i) % mod;
		
		int p2 = 1ll * qpow(a, i - n) * qpow(b, n) % mod;
		ans = (ans + 1ll * p2 * C(i - 1, n - 1) % mod * i) % mod;
	}
	
	printf("%lld\n", 1ll * ans * w % mod);
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 62)

string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

int main(int argc, char* argv[])
{
	for (;;) {
		ll N, K;
		cin >> N >> K;
		if (cin.fail()) break;
		string sN = to_s(N);

		bitset<10> b;
		while (K--) {
			char c;
			cin >> c;
			b[c - '0'] = true;
		}
		vector<char> D;
		for (char i = 9; i >= 0; i--) {
			if (!b[i]) D.push_back(i + '0');
		}

		string S = string(sN.size(), D.front());
		ll X = to_ll(S);
		ll R;
		if (X < N) {
			auto it = D.rbegin();
			if (*it == '0') {
				R = to_ll(string(1, *++it) + string(sN.size(), '0'));
			} else {
				R = to_ll(string(sN.size() + 1, *it));
			}
		} else {
			ll K = 1;
			for (ull i = 1; i < S.size(); i++) K *= 10;
			
			R = 0;
			while (K > 0) {
				X /= 10;
				char d_ = D.front();
				for (auto d : D) {
					if (R + (d - '0') * K + X < N) break;
					d_ = d;
				}
				R += (d_ - '0') * K;
				K /= 10;
			}
		}

		printf("%lld\n", R);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int canEat = c > a + b ? a + b * 2 + 1 : b + c;
		System.out.println(canEat);

		sc.close();
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;
using namespace std;

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

    int n, m;
    cin >> n >> m;


    vector<int> l(m), r(m);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        l[i] = a;
        r[i] = b;
    }

    int cnt = 0;

    for (int i = 0; i < m; i++) {
        int mp[n][n];
        for (int a = 0; a < n; a++) {
            for (int b = 0; b < n; b++) {
                mp[a][b] = INT32_MAX / 2;
            }
        }
        for (int a = 0; a < m; a++) {
            if (a == i) continue;
            mp[l[a]][r[a]] = 1;
            mp[r[a]][l[a]] = 1;
        }

        for (int a = 0; a < n; a++) {
            for (int b = 0; b < n; b++) {
                for (int c = 0; c < n; c++) {
                    mp[b][c] = min(mp[b][a] + mp[a][c], mp[b][c]);
                }
            }
        }
        bool reachable = true;
        for (int a = 0; a < n && reachable; a++) {
            for (int b = 0; b < n && reachable; b++) {
                if (mp[a][b] > INT32_MAX / 3) {
                    reachable = false;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int g = 0;
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                g = gcd(g, a);
            }
            out.println(g);
        }

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

    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}



Measured memory_bytes: 35800
def abc175_a_1():
    def solve():
        # そもそも3文字しか入力ないんだから長い順にチェックしてしまえば問題ない？
        if s.count('RRR'):
            return 3
        if s.count('RR'):
            return 2
        if s.count('R'):
            return 1
        return 0

    s = input()
    print(solve())

if __name__ == '__main__':
    abc175_a_1()

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

//< ave , a(time), b(manzoku) >
typedef tuple<double, int, int> A;

int main() {
    int n;
    cin >> n;
    vector<int> vs(n);

    rep(i, n) {
        int v;
        cin >> v;
        vs[i] = v;
    }


    rep(i, n) {
        int c;
        cin >> c;
        vs[i] -= c;
    }

    sort(vs.rbegin(), vs.rend());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (vs[i] < 0) {
            break;
        } else {
            ans += vs[i];
        }
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.chars
sc = s.count
a = []
b = []
(n-1).times do |i|
  a << s[0..i]
  b << s[i+1..sc]
end
res = []
tmp_s = s.sort.uniq
ma = a.map(&:uniq)
mb = b.map(&:uniq)
ma.zip(mb).each do |i, j|
  val = 0
  i.each do |k|
    val += 1 if j.include?(k)
  end
  res << val
end
puts res.max

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    int H, W;
    cin>>H>>W;

    cout<<H-W+1<<endl;
    return 0;
    
}

Measured memory_bytes: 256
S = input()
N = len(S)

zeros = [0,0] # even, odd
flg = 0
for s in S:
    if s=='0':
        zeros[flg] += 1
    flg = (flg+1)%2

ones = [(N+1)//2-zeros[0], N//2-zeros[1]]
ans = min(zeros[0]+ones[1], zeros[1]+ones[0])
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int a,b,c;
    string str;cin>>str;
    if(str.size()==1 or str.size()%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    rep(i,str.size()){
        if(i%2==0){
            if(str[i]!='h'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(str[i]!='i'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math


a,b,x = map(int,input().split())


if x/a >= b*a/2:

    y = 2*(b - x/(a*a))
    
    print(math.degrees(math.atan(y/a)))

else:
    
    y= 2*x/(a*b)

    print(math.degrees(math.atan(b/y)))
    


Measured memory_bytes: 3060
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
int n, a[N], b[N], aa[N], bb[N];
int vo[11111], ve[11111];
LL odd, even;
int main(){
    //IN;
    //OUT;
    II(n);
    FF(i, 1, n) SC(a[i]);
    FF(i, 1, n){
        if(i & 1){
            if(a[i] > 0){
                odd += a[i];
                vo[i] = 1;
            }
        }else {
            if(a[i] > 0){
                even += a[i];
                ve[i] = 1;
            }
        }
    }
    if(even > odd){
        odd = even;
        FF(i, 1, n) vo[i] = ve[i];
    }
    vector<int> ans;
    if(odd == 0){
        int mn = -INF;
        int pos = 0;
        FF(i, 1, n){
            if(a[i] > mn){
                mn = a[i];
                pos = i;
            }
        }
        PR(mn);
        PR(n - 1);
        FF(i, 1, pos - 1) PR(1);
        int ii = pos - 1;
        FF(i, pos + 1, n){
            PR(n - ii);
            ++ii;
        }
    }
    else {
    int ii = 0;
    int i = 1;
    while(i <= n && vo[i])++i;
    for(; i <= n;){
        int j = i;
        while(j <= n && vo[j] == 0) ++j;
        if(i == 1){
            for(int k = 1; k <= j - i; ++k){
                ans.PB(i - ii);
            }
            ii += j - i;
        }else if(j == n + 1){
            for(int k = 1; k <= j - i; ++k){
                ans.PB(n - ii);
                ++ii;
            }
        }else {
            for(int k = 1; k <= (j - i) / 2; ++k){
                ans.PB(i + 1 - ii);
            }
            ans.PB(i - ii);
            ii += j - i + 1;
        }
        i = j;
        while(i <= n && vo[i])++i;
    }
    cout << odd << endl;
    PR(ans.size());
    for(int i : ans) PR(i);
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n; cin >> n; ll oddcnt,cnt2,cnt4; 
  oddcnt = 0; cnt2 = 0; cnt4 = 0; 
  
  for(ll i=0; i < n; i++){
    ll x; cin >> x;
    if(x % 4 == 0){
      cnt4++;
      continue;
    }
    
    else if(x % 2 == 0) cnt2++;
    
    else oddcnt++;

  }
  
  if((cnt2 == 0 && cnt4 + 1 >= oddcnt ) || (cnt4 >= oddcnt)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

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

		StringTokenizer st = new StringTokenizer(str," ");

		int ar[] = new int[3];

		for (int i=0;i<3;i++){
			 ar[i] = Integer.parseInt(st.nextToken());
		}
		
		Arrays.sort(ar);			
		System.out.println(ar[0] +" "+ar[1]+" "+ar[2] );
	}
}

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

using namespace std;
 
int main() {
  int num;
  cin >> num;
  
  int result;
  cin >> result;
  for(int i = 1; i < num; ++i)
  { 
    int tmp;
    cin >> tmp;
    result = __gcd(result,tmp);
  }

  cout << result << endl;
}

Measured memory_bytes: 256
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<long long> comb = vector<long long>(100 * 100,-1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}


int main() {
	string odd, even;
	cin >> odd >> even;
	for (size_t i = 0; i < even.size(); i++) {
		cout << odd[i]<<even[i];
	}
	if (odd.size() > even.size())cout << odd[odd.size() - 1];
	cout << endl;
}


Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N;
    while(cin >> N, N != -1) {
        int money = 0;
        money += 1150, N -= min(N, 10LL);
        money += min(N, 10LL) * 125, N -= min(N, 10LL);
        money += min(N, 10LL) * 140, N -= min(N, 10LL);
        money += 160 * N;

        cout << 4280 - money << endl;
    }
    return 0;
}



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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;
    int l[n], r[n];
    rep(i, n) { cin >> l[i] >> r[i]; }
    // check
    // rep(i, n) {
    //     if (i > 0) cout << " ";
    //     cout << l[i] << " " << r[i];
    // }

    // 処理
    int sum = 0;
    rep(i, n) { sum += r[i] - l[i] + 1; }
    // 出力
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

const double PI=4*atan(1.0);

//#define RED_FILE

#ifdef RED_FILE
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

int dp[101][321];

int main(){

    int t;
    cin>>t;
    while(t--){
        memset(dp,0,sizeof(dp));
        int n;
        cin>>n;
        int a[101];
        for(int i = 0; i < n; i++)
            cin>>a[i];
        if(n==1){
            cout<<a[0]<<endl;
            continue;
        }
        dp[0][a[0]]=a[1];
        for(int i = 1; i < n-1; i++){
            for(int j = 0; j < 321; j++){
                // ツ遷ツ暗堋つウツつケツづゥ
                if(dp[i-1][j]-1>=0)
                    dp[i][dp[i-1][j]-1]=max(dp[i][dp[i-1][j]-1],j+a[i+1]);
                // ツ遷ツ暗堋つウツつケツづ按つ「
                dp[i][dp[i-1][j]]=max(dp[i][dp[i-1][j]],a[i+1]);
            }
        }
        int maxNum=0;
        for(int i = 0; i < 321; i++){
            maxNum=max(dp[n-2][i],maxNum);
        }

        cout<<maxNum<<endl;
    }
    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0, n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3836
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, m = li()
inf = float('inf')

a = []
b = []
c = []
for _ in range(m):
    ai, bi = li()
    ci = list(li_())
    a.append(ai)
    b.append(bi)
    state = 0
    for cij in ci:
        state += pow(2, cij)
    c.append(state)


dp = [inf]*(1<<n)
dp[0] = 0

for state in range(1<<n):
    for i in range(m):
        dp[state | c[i]] = min(dp[state] + a[i], dp[state | c[i]])

print(dp[-1] if dp[-1] != inf else -1)

Measured memory_bytes: 43100
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std ;

int n ;
string s ;

void input ( ) {
    cin >> s ;
    n = s.size ( ) ;
}

void solve ( ) {
    for ( int i = 0 ; i < n ; ++ i ) {
        if ( ( i % 2 ) == 0 && s[ i ] == 'L' ) { cout << "No\n" ; return ; }
        if ( ( i % 2 ) == 1 && s[ i ] == 'R' ) { cout << "No\n" ; return ; }
    }
    cout << "Yes\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
int po26[500005];
int po31[500005];
int ipo26[500005];
int ipo31[500005];
const int MOD=1000000007;
int add(int x, int y)
{
	return (x + y) % MOD;
}

int sub(int x, int y)
{
	return add(x, MOD - y);
}

int mul(int x, int y)
{
	return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
	int z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}

int inv(int x)
{
	return binpow(x, MOD - 2);
}
vector<vector<int>>vals;


main() {
	po26[0]=1;
	po31[0]=1;
	for(int i=1; i<=500000; i++){
		po26[i]=mul(26, po26[i-1]);
		po31[i]=mul(31, po31[i-1]);
	}
	for(int i=0; i<=500000; i++){
		ipo26[i]=inv(po26[i]);
		ipo31[i]=inv(po31[i]);
	}
	int n;
	cin>>n;
	vals.resize(n);
	for(int i=0; i<n; i++){
		vals[i].resize(30);
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<30; j++){
			vals[i][j]=0;
		}
	}
	int a[n];
	int b[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		cin>>b[i];
	}
	for(int bit=0; bit<30; bit++){
		
		vector<int>a1;
		vector<int>a2;
		vector<int>a3;
		for(int j=0; j<n; j++){
			if(((1<<bit)&(b[j]))!=0){
				a1.pb(1);
			}
			else{
				a1.pb(0);
			}
			if(((1<<bit)&(a[j]))!=0){
				a2.pb(1);
				a3.pb(0);
			}
			else{
				a2.pb(0);
				a3.pb(1);
			}
		}
		vector<int>a2c;
		vector<int>a3c;
		for(auto u:a2){
			a2c.pb(u);
		}
		for(auto u:a3){
			a3c.pb(u);
		}
		for(auto u:a2c){
			a2.pb(u);
		}
		for(auto u:a3c){
			a3.pb(u);
		}
		
		int p11[n+1];
		int p12[n+1];
		p11[0]=0;
		p12[0]=0;
		for(int i=1; i<=n; i++){
			p11[i]=(p11[i-1]+po26[i-1]*(1+a1[i-1]))%MOD;
			p12[i]=(p12[i-1]+po31[i-1]*(1+a1[i-1]))%MOD;
		}
		int p21[2*n+1];
		int p22[2*n+1];
		int p31[2*n+1];
		int p32[2*n+1];
		p21[0]=0;
		p22[0]=0;
		p31[0]=0;
		p32[0]=0;
		for(int i=1; i<=2*n; i++){
			p21[i]=(p21[i-1]+po26[i-1]*(1+a2[i-1]))%MOD;
			p22[i]=(p22[i-1]+po31[i-1]*(1+a2[i-1]))%MOD;
			p31[i]=(p31[i-1]+po26[i-1]*(1+a3[i-1]))%MOD;
			p32[i]=(p32[i-1]+po31[i-1]*(1+a3[i-1]))%MOD;
		}
		for(int i=0; i<n; i++){
			int h1=mul(sub(p21[n+i], p21[i]), ipo26[i]);
			int h2=mul(sub(p22[n+i], p22[i]), ipo31[i]);
			if(h1==p11[n] && h2==p12[n]){
				vals[i][bit]=1;
			}
			int h3=mul(sub(p31[n+i], p31[i]), ipo26[i]);
			int h4=mul(sub(p32[n+i], p32[i]), ipo31[i]);
			if(h3==p11[n] && h4==p12[n]){
				vals[i][bit]=1;
			}
		}
	}
	vector<int>pos;
	
	for(int i=0; i<n; i++){
		int num=0;
		for(int j=0; j<30; j++){
			num+=vals[i][j];
		}
		if(num==30){
			pos.pb(i);
		}
	}
	for(auto u:pos){
		cout<<u<<" "<<(a[u]^b[0])<<endl;
	}
	return 0;
}

Measured memory_bytes: 109408
import sys
inf = 10**15
mod = 10**9+7
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
bi = []
bii = []
for i in range(n):
    bi.append(t-h[i]*0.006)
    bii.append([t-h[i]*0.006, i+1])
bi.sort()
import bisect
ind = bisect.bisect_left(bi, a)
tmp = 0
if ind == n:
    tmp = bi[n-1]
else:
    if abs(bi[ind]-a) > abs(bi[ind-1]-a):
        tmp = bi[ind-1]
    else:
        tmp = bi[ind]
for i in range(n):
    if tmp == bii[i][0]:
        print(bii[i][1])
        sys.exit()

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;

int main()
{
    int A,B,K;
    cin >> A >> B >> K;

    for (int i = 0; i < K; i++) {
        if (i % 2 == 0){
            if (A % 2 == 1) {A--;}
            B += A/2;
            A /= 2;
        }
        else {
            if (B % 2 == 1) {B--;}
            A += B/2;
            B /= 2;
        }
    }

    cout << A << ' ' << B << endl;
}


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

int main(){
    int n, i, j, k, count = 0;
    cin >> n;
    int l[n];
    for(i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l, l+n);
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            for(k=j+1; k<n; k++){
                if(l[k] < l[i]+l[j] && l[i] < l[k]+l[j] && l[j] < l[i]+l[k]) count++;
            }
        }
    }
    cout << count;
    return 0;
}

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

int main() {
	int x[10010];
	int n = 0;

	while (1) {
		cin >> x[n];
		if (x[n] == 0) break;
		++n;
	}

	for (int i = 0; i < n; ++i) printf("Case %d: %d\n", i + 1, x[i]);
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
string s;
int len,cnt;
stack<char>st;
int main()
{
	cin>>s;
	len=s.length();
	for(int i=0;i<len;i++)
	{
		if(st.size()==0)
			st.push(s[i]);
		else
		{
			if(s[i]==49)
			{
				if(st.top()==48)
				{
					st.pop();
					cnt+=2;
				}
				else st.push(s[i]);
			}
			else if(s[i]==48)
			{
				if(st.top()==49)
				{
					st.pop();
					cnt+=2;;
				}
				else st.push(s[i]);
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define  lowbit(x) (x&(-x))
#define  ll long long
#define  ull unsigned long long
#define  max(a,b) (a>b?a:b)
#define  min(a,b) (a>b?b:a)
#define  PI acos(-1.0)
#define  fir first
#define  sec second
#define  SZ(x) (x.size())
#define  inf 0x3f3f3f3f
#define  PB push_back
#define  MP make_pair
#define  all(x) (x).begin(),(x).end()
#define  PII pair<int,int>
#define  E 2.7182818284590452353602874713527
using namespace std;

/**********************************************Head-----Template****************************************/
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//const ll mod = 10000019;
//const ll phi_mod_prime=mod-1;
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
ll phi(ll n){ ll rea=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ rea=rea-rea/i;while(n%i==0) n/=i;}}if(n>1) rea=rea-rea/n;return rea;}
//a^(b%modhi(mod)+phi(mod))%mod;
void exgcd(int a,int b,int &x,int &y,int &d){if(!b){x=1;y=0;d=a;}else exgcd(b,a%b,y,x,d),y-=a/b*x;}
inline int inv(int a,int mod){int x,y,d;exgcd(a,mod,x,y,d);x=(x%mod+mod)%mod;return x;}
/********************************Head----Template**********************************************/


ll a[1000000];

ll sum[1000000];

int main(){
    ll w,h,x,y;cin>>w>>h>>x>>y;
    ll  s1=max((h-y)*w,y*w);
    //cout<<s1<<endl;
    ll s2=max((w-x)*h,x*h);

    double s3=w*h*1.0/2;
    //cout<<s3<<endl;
    if((x==0&&y==h)||(x==w&&y==0)||(x==w&&y==h)||(x==0&&y==0)) printf("%.11f 0\n",w*h*1.0/2);
    else if(w==2ll*x&&h==2ll*y) printf("%.9f 1\n",1.0*s3);//,cout<<999<<endl;
    else printf("%.9f 0\n",s3);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;



int main()
{
	int n;
	cin >> n;
	int m;
	cin >> m;
	vector <vector<int>> G(n);
	vector <int> color(n);

	rep(i,m)
	{
		int foo,fooo;
		cin >> foo >> fooo;
		//Sif(foo>fooo)swap(foo,fooo);
		G[foo].push_back(fooo);
		G[fooo].push_back(foo);
	}
	rep(i,n) color[i] = -1;
	queue<int> Q;
	rep(iii,n)
	{
		int v=-1;
		if(color[iii]==-1)v=iii;
		else continue;
		//cout<<v<<endl;
		color[v]=v;
		if(v!=-1)Q.push(v);
		while(!Q.empty())
		{
			int u = Q.front();
			color[u]=v;
			Q.pop();
			rep(i,G[u].size())
			{
				if(color[G[u][i]]==-1)Q.push(G[u][i]);
			}
		}
	}
	//rep(i,n)cout<<color[i]<<endl;
	int k;
	cin >> k;
	rep(i,k)
	{
		int foo,fooo;
		cin >> foo >> fooo;
		if(color[foo]==color[fooo])cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 8660
#include <bits/stdc++.h>
#define ll long long int 
using namespace std;
bool isprime(ll x)
{
    for(ll i=2;i*i<=x;i++)
    {
        if(x % i == 0)
            return false;
    }
    return true;
}
int main() 
{
  ll x;
  cin>>x;

  for(int i=x;i<=100003;i++)
  {
      if(isprime(i))
      {
          cout<<i;
          break;
      }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<vector<ll>> dist(n, vector<ll>(n));

    for (ll i = 0; i < n;i++){
        for (ll j = 0; j < n;j++){
            dist[i][j] = 0;
        }
    }
    vector<ll> ans(n - 1);
    for (ll i = 0; i < n; i++) {
        for (ll j = i+1; j < n;j++){
            if (i == j) continue;
            dist[i][j] = min({abs(j-i), abs(i-x) + 1 + abs(y-j), abs(j-x) + 1 + abs(i-y)});
            ans[dist[i][j] - 1]++;
        }
    }
    for (auto i : ans) cout << i << endl;
}


Measured memory_bytes: 31616
#include<stdio.h>
#define INF 1000000
int main(){
    while(true){
        int e,ans=INF;
        scanf("%d",&e);
        if(e==0) return 0;
        for(int z=0;z*z*z<=e;z++){
            for(int y=0;y*y+z*z*z<=e;y++){
                if(ans>e-y*y-z*z*z+y+z) ans=e-y*y-z*z*z+y+z;
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 1028
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = i32;
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

fn dfs(g: &Graph, from: usize, visit: &mut Vec<bool>) {
    if visit[from] {
        return;
    }
    visit[from] = true;
    for e in g[from].iter() {
        dfs(g, e.dest, visit);
    }
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut g = graph_new(n);
    let mut index = 0;
    for _i in 0..m {
        let x = read::<usize>() - 1;
        let y = read::<usize>() - 1;
        let z = read::<Weight>();
        add_bi_edge(&mut g, &mut index, x, y, z);
    }
    let mut visit = vec![false; n];
    let mut ans = 0;
    for i in 0..n {
        if visit[i] {
            continue;
        }
        dfs(&g, i, &mut visit);
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 25340
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    vector<pair<string,ll>>st(n);
    for(int i=0;i<n;++i){
        string s;cin>>s;
        st[i]={s,in()};
    }
    string x;cin>>x;
    ll ans=0;
    bool f=false;
    for(int i=0;i<n;++i){
        if(f)ans+=st[i].second;
        f|=st[i].first==x;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#define Re register int

char S[3005],T[3005],ans[3005];
int lenS,lenT,f[3005][3005],len;

inline int max(int a,int b) {return a>b?a:b;}
int main(int argc, char const *argv[])
{
	scanf("%s%s",S,T);
	lenS=strlen(S),lenT=strlen(T);
	for (Re i=1; i<=lenS; ++i)
		for (Re j=1; j<=lenT; ++j)
		{
			f[i][j]=max(f[i-1][j],f[i][j-1]);
			if (S[i-1]==T[j-1]) f[i][j]=max(f[i][j],f[i-1][j-1]+1);
		}
	while (lenS&&lenT)
	{
		if (f[lenS][lenT]==f[lenS-1][lenT]&&lenS) --lenS;
		else if (f[lenS][lenT]==f[lenS][lenT-1]&&lenT) --lenT;
			else ans[++len]=S[lenS-1],--lenS,--lenT;
	} for (Re i=len; i; --i) printf("%c",ans[i]);
	return 0;
}

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



int main()
{
int N;
cin>>N;
vector<double>v(N);
for(int i=0;i<N;i++)
{cin>>v[i];}
sort(v.begin(),v.end());
double answer=v[0]+v[1];
answer/=2;
for(int i=2;i<N;i++)
{answer=(answer+v[i])/2;}
cout<<answer<<endl;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    if n % n
        .to_string()
        .chars()
        .map(|x| x.to_string().parse::<i64>().unwrap())
        .sum::<i64>() == 0
    {
        "Yes"
    } else {
        "No"
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "12" => "Yes",
    test2: "101" => "No",
    test3: "999999999" => "Yes",
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < long , long >
# define pDD pair < D , D >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(1,1);
const D tpie = 2*pie;

string vow = "aeiou";

void solve( int test_case )
{
    int n;
    cin >> n;

    vi v ( n );
    for ( int i=0 ; i<n ; i++ ) cin >> v[i];

    sort ( all(v) );

    cout << v[n/2] - v[(n-1)/2];
    line
}

int main()
{
    fast
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


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

struct dyse{

    vector<int> x = {0,0,0,0,0,0};

    void set_dyse(){
        rep(i,6) cin >> x.at(i);
    }

    void ido(char dir){
        if(dir == 'N'){
            int tmp = x.at(0);
            x.at(0) = x.at(1);
            x.at(1) = x.at(5);
            x.at(5) = x.at(4);
            x.at(4) = tmp;
        }else if(dir == 'S'){
            int tmp = x.at(0);
            x.at(0) = x.at(4);
            x.at(4) = x.at(5);
            x.at(5) = x.at(1);
            x.at(1) = tmp;
        }else if(dir == 'W'){
            int tmp = x.at(0);
            x.at(0) = x.at(2);
            x.at(2) = x.at(5);
            x.at(5) = x.at(3);
            x.at(3) = tmp;
        }else if(dir == 'E'){
            int tmp = x.at(0);
            x.at(0) = x.at(3);
            x.at(3) = x.at(5);
            x.at(5) = x.at(2);
            x.at(2) = tmp;
        }
    }

    void ue(){
        cout << x.at(0) << endl;
    }

    void solve_migi(int jou, int zen){
        vector<int> umsu(4);
        for(umsu.at(0) =0;;umsu.at(0)++){
            if(x.at(umsu.at(0)) == jou) break;
        }
        for(umsu.at(1) =0;;umsu.at(1)++){
            if(x.at(umsu.at(1)) == zen) break;
        }
        umsu.at(2) = 5-umsu.at(0);
        umsu.at(3) = 5-umsu.at(1);
        
        rep(i,4){
            if(umsu.at(i) == 0 && umsu.at((i+1)%4) == 1){cout << x.at(2) << endl;break;}
            else if(umsu.at(i) == 1 && umsu.at((i+1)%4) == 0){cout << x.at(3) << endl;break;}
            else if(umsu.at(i) == 1 && umsu.at((i+1)%4) == 2){cout << x.at(0) << endl;break;}
            else if(umsu.at(i) == 2 && umsu.at((i+1)%4) == 1){cout << x.at(5) << endl;break;}
            else if(umsu.at(i) == 2 && umsu.at((i+1)%4) == 0){cout << x.at(1) << endl;break;}
            else if(umsu.at(i) == 0 && umsu.at((i+1)%4) == 2){cout << x.at(4) << endl;break;}
        }
        return;
    }
};

int main(){
    dyse d;
    d.set_dyse();

    int q,jou,zen;
    cin >> q;
    rep(i,q){
        cin >> jou >> zen;
        d.solve_migi(jou,zen);
    }

}   


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int insertionSort(int* A, const int n, const int g);
void shellSort(int* A, const int n);

int main(){
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	int* A = new int[n];
	for(int i = 0; i < n; ++i){
		cin >> A[i];
	}

	shellSort(A, n);

	for(int i = 0; i < n; ++i){
		cout << A[i] << endl;
	}

	delete[] A;

	return 0;
}

int insertionSort(int* A, const int n, const int g){
	int count = 0;
	for(int i = g; i < n; ++i){
		int v = A[i];
		int j = i - g;
		while(0 <= j && A[j] > v){
			A[j + g] = A[j];
			j -= g;
			count++;
		}
		A[j + g] = v;
	}
	return count;
}

void shellSort(int* A, const int n){
	int cnt = 0;
	int tmp = 1;
	int m = 1;

	while(n >= 3 * tmp + 1){
		tmp = 3 * tmp + 1;
		m++;
	}

	cout << m << endl;
	int* G = new int[m];

	for(int i = 0; i < m; ++i){
		G[i] = tmp;
		tmp /= 3;
		cout << G[i] << (m - 1 == i ? "\n" : " ");
	}

	for(int i = 0; i < m; ++i){
		cnt += insertionSort(A, n, G[i]);
	}

	cout << cnt << endl;
	delete[] G;
}



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

using namespace std;

using P = pair<int, int>;

bool dfs(vector<vector<int>>& G, vector<int>& match, vector<int>& used, int v){
    used[v] = 1;
    for(auto u : G[v]){
        int w = match[u];
        if(w < 0 || !used[w] && dfs(G, match, used, w)){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int main(void){
    int N;
    cin >> N;
    vector<P> V(2*N);
    for(auto& it : V) cin >> it.first >> it.second;
    vector<vector<int>> G(2*N, vector<int>());
    for(int r=0;r<N;r++){
        for(int b=N;b<2*N;b++){
            if(V[r].first < V[b].first && V[r].second < V[b].second){
                G[r].push_back(b);
                G[b].push_back(r);
            }
        }
    }

    vector<int> match(2*N, -1);
    vector<int> used(2*N, 0);

    int ans = 0;
    for(int i=0;i<2*N;i++){
        if(match[i] < 0){
            for(auto& x : used) x = 0;
            if(dfs(G, match, used, i)) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256