akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
	  int a=0;
	  Scanner sc = new Scanner(System.in);
	  String s = sc.next();
	  char [] str = s.toCharArray();
	    for(int i=1;i<str.length-1;i++) {
		  a++;
	    }
	  System.out.print(str[0]);
	  System.out.print(a);
	  System.out.print(str[str.length-1]);
	  sc.close();
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define itn int

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> adj(n);
    for (int i = 0; i < n - 1; i++) {
        itn a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    if (n == 1) {
        cout << "First" << endl;
        return 0;
    }
    if (n == 2) {
        cout << "Second" << endl;
        return 0;
    }
    vector<int> depth(n);
    function<void(int, int, int)> dfs = [&](int v, int p, int d) {
        depth[v] = d;
        for (int s : adj[v]) {
            if (s != p) {
                dfs(s, v, d + 1);
                
            }
        }
    };
    dfs(0, -1, 0);
    int k = max_element(depth.begin(), depth.end()) - depth.begin();
    dfs(k, -1, 0);
    int d = *max_element(depth.begin(), depth.end());
    cout << (d % 3 != 1 ? "First" : "Second") << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    //K個選ぶとき下限は0 + ... + K-1, 上限はN + ... + N-(K-1)
    ll ans = 0;
    for(ll i = K; i <= N+1; i++){
        ll dlim = (i-1)*i/2;
        ll ulim = (N + N-(i-1))*i/2;
        ans = (ans + (ulim-dlim+1)) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) cin >> a[i];

	vector<int> left(N + 1, 0), right(N + 1, 0);
	for (int i = 0; i < N; ++i) left[i + 1] = GCD(left[i], a[i]);
	for (int i = N - 1; i >= 0; --i) right[i] = GCD(right[i + 1], a[i]);

	int res = 0;
	for (int i = 0; i < N; ++i) {
		int l = left[i];
		int r = right[i + 1];

		chmax(res, GCD(l, r));
	}
	cout << res << endl;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7,inv2=5e8+4;
int n,m,a[3005];
ll f[3005][3005],ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	    if(a[i]>a[j])f[i][j]=1;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		for(int j=1;j<=n;j++)
		{
			if(j!=x&&j!=y)
			{
				f[x][j]=f[y][j]=(f[x][j]+f[y][j])*inv2%MOD;
				f[j][x]=f[j][y]=(f[j][x]+f[j][y])*inv2%MOD;
			}
		}
		f[x][y]=f[y][x]=(f[x][y]+f[y][x])*inv2%MOD;
	}
	for(int i=1;i<=n;i++)
	  for(int j=i+1;j<=n;j++)
	    ans+=f[i][j];
	ans%=MOD;
	for(int i=1;i<=m;i++)
	  ans=ans*2%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int n, k;
  cin >> n;
  k = log10(n);

  int odd = 0;
  for (int i = 0; i <= k; i++) {
    if (i%2==0 && i!=k){//odd digit and not top
      odd += (10 * pow(10, i)) -  (1 * pow(10, i));
      //cout << i+1 << " " << odd << endl;
    }if (i%2==0 && i==k) {//odd digit and top
      odd+= n - pow(10, i) + 1;
    }
  }

  cout << odd << endl;
  return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    println(0)
    var before = readInputLine()
    if (before.equals("Vacant")) {
        return
    }

    var l = 1
    var r = N
    
    while (l != r) {
        val mid = (l + r) / 2
        
        println(mid)
        val res = readInputLine()
        
        if (res.equals("Vacant")) {
            return
        }
        
        if (mid % 2 == 0) {
            if (res.equals(before)) {
                l = mid + 1
            } else {
                r = mid
            }
        } else {
            if (res.equals(before)) {
                r = mid
            } else {
                l = mid + 1
            }            
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main() {
  int N, X, L;
  cin >> N >> X;
  int D = 0, count = 1;
  
  while (D <= X && count < N + 1) {
    cin >> L;
    D += L;
    if (D > X)
      break;
    else
      count++;    
  }

    cout << count << endl;
    
}

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

int N, X[100100], tot4, tot1, tot2;

int main() {
    cin >> N;
    for (int i=1; i<=N; i++){
        cin >> X[i];
        if (X[i]%4==0){
            tot4++;
        }
        else if (X[i]%2==1){
            tot1++;
        }
        else {
            tot2++;
        }
    }
    if ((tot1-tot4==1)&&(tot2==0)){
        cout << "Yes" << endl;
    }
    else if (tot4>=tot1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No"<< endl;
    }
}

Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w, h;
		int map[][];
		int cnt[][];

		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}
			map = new int[h][w];
			cnt = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			for (int j = 0; j < w; j++) {
				if (map[h - 1][j] != 1) {
					cnt[h - 1][j] = 1;
				}
			}

			int sum;
			for (int i = h - 2; 0 <= i; i--) {
				for (int j = 0; j < w; j++) {
					sum = 0;
					if (map[i][j] == 0) {
						if (j + 1 < w && map[i + 1][j + 1] == 0) {
							sum += cnt[i + 1][j + 1];
						}
						if (0 <= j - 1 && map[i + 1][j - 1] == 0) {
							sum += cnt[i + 1][j - 1];
						}
						if (map[i + 1][j] != 1) {
							sum += cnt[i + 1][j];
						}
					} else if (map[i][j] == 2) {
						if (i + 2 < h) {
							sum += cnt[i + 2][j];
						} else {
							sum = 1;
						}
					}
					cnt[i][j] = sum;
				}
			}
			sum = 0;
			for (int j = 0; j < w; j++) {
				sum += cnt[0][j];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 21688
#include <stdio.h>

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    
    int a[n][m];
    int b[m], c[n];
    char x;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%c %d", &x, &a[i][j]);
        }
    }
    
    for(int i = 0; i < m; i++){
            scanf("%c %d", &x, &b[i]);
    }
    
    for(int i = 0; i < n; i++){
        c[i] = 0;
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
    }
    
    for(int i = 0; i < n; i++){
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
const int MOD = 1000000007;

int mul (int a, int b) {
    return (int64)a * b % MOD;
}

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

    int64 N, M;
    cin >> N >> M;

    vector<int64> A(N), B(M);

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

    for (int i = 0; i < M; i++)
        cin >> B[i];

    int64 result = 0;
    int64 column = 0;
    
    for (int i = 0; i < M - 1; i++) {
        int64 d = B[i + 1] - B[i];
        column += mul(mul (i + 1, M - (i + 1)), d);
        column %= MOD;
    }

    for (int i = 0; i < N - 1; i++) {
        result += mul(mul(column, mul(i + 1, N - (i + 1))), A[i + 1] - A[i]);
        result %= MOD;
    }

    cout << result << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)

using namespace std;
typedef long long ll;
ll INF = 1001001001;
ll gcd(int a, int b) {return b ? gcd(b, a%b):a;}
ll lcm(int a, int b) {return a*b/gcd(a, b);}
  vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  for(ll p=2; p*p <= n; p++) {
    if(n%p!=0) continue;
    int num = 0;
    while(n%p==0) {n /= p; ++num;}
      res.push_back(make_pair(p, num));
  }
   if (n != 1) res.push_back(make_pair(n, 1));
    return res; 
  
  }

long long gcd(ll a, ll b) {
      return b ? gcd(b, (a%b)) : a;
    }
    int main() {
      ll a, b;  cin >> a >> b;
      ll g = gcd(a, b);
      auto G =  prime_factorize(g);
      cout << G.size() + 1 << endl;
    }
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define ii pair<int,ll>
using namespace std;

int n;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;cin>>a>>b;
    int s = 1;
    int cnt = 0;
    while(s < b){
        s = (s-1)+a;
        cnt++;
    }
    cout<<cnt;
}

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

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

		while (true) {
			int N = Integer.parseInt(br.readLine());
			if (N <= 0)
				break;
			
			int[] sum = new int[N];

			for (int i = 0; i < N; i++) {
				String[] row = br.readLine().split(" ");
				int s = 0;
				
				for(int j=0;j<N;j++) {
					int tmp = Integer.parseInt(row[j]);
					
					sum[j] += tmp;
					s += tmp;
					
					fp(tmp);
				}
				fpln(s);
			}
			
			int s = 0;
			for (int i = 0; i < N; i++){
				fp(sum[i]);
				s += sum[i];
			}
			fpln(s);
		}
	}
	
	static String format(int i) {
		return String.format("%5d", i);
	}
	
	static void fpln(int i){
		System.out.println(format(i));
	}
	
	static void fp(int i){
		System.out.print(format(i));
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;

using ll=long long;
const ll mod=1000000007LL;

int l[90010];
ll dp[90010];

int main(void){
	int d,s;
	cin >> d;
	rep(i,d) cin >> l[i];
	cin >> s;
	
	dp[s]=1LL;
	rep(i,d) rep(j,s+1){
		if(j-l[i]>=0) dp[j-l[i]]+=mod-dp[j];
		dp[j]%=mod;
	}


	ll cut=0LL;
	rep(i,s+1){
		ll tmp=dp[i];
		rep(j,d) tmp=(tmp*i)%mod;
		cut=(cut+tmp)%mod;
	}

	cout << cut << endl;
	return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


string s;
int q;
int t[200001];
int f[200001];
string c[200001];
int cnt;


int main() {

	cin >> s >> q;

	rep(i, q) {
		cin >> t[i];
		if (t[i] == 2) {
			cin >> f[i] >> c[i];
			if ((cnt + f[i]) % 2 == 0)s += c[i];
			else s.insert(0, c[i]);
		}
		else {
			cnt++;
		}
	}

	if (cnt % 2 == 0) {
		cout << s << endl;
	}
	else {
		for (int i = s.size() - 1; i >= 0; i--) {
			cout << s[i];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  REP(i, n) {
    int x;
    cin >> x;
    q.push(x);
  }
  REP(i, m) {
    int x = q.top();
    q.pop();
    q.push(x / 2);
  }
  ll ans = 0;
  REP(i, n) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}

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

int main() {
  int a, b,c, d = 0;
  cin >> a >> b >>c;
  
  if (a != b)
    d++;
  if (a != c)
    d++;
  if (b != c)
    d++;
  if (d == 0)
    d++;
  cout << d<<endl;
}

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

using namespace std;

int dfs(int idx, const vector<int>& U, int currentCost, const vector<int>& C,
        const vector<vector<int>>& A, int N, int M, int X) {
    if (idx == N) {
        return -1;
    }

    vector<int> U_ = vector<int>(U);
    bool possible = true;
    for (int i = 0; i < M; i++) {
        U_[i] += A[idx][i];
        if (U_[i] < X) possible = false;
    }
    int cost_a;
    if (possible) {
        cost_a = currentCost + C[idx];
    } else {
        cost_a = dfs(idx + 1, U_, currentCost + C[idx], C, A, N, M, X);
    }

    int cost_b = dfs(idx + 1, U, currentCost, C, A, N, M, X);

    if (cost_a == -1 && cost_b == -1) {
        return -1;
    } else if (cost_a == -1) {
        return cost_b;
    } else if (cost_b == -1) {
        return cost_a;
    } else {
        return min(cost_a, cost_b);
    }
}

int main() {
    // Input
    int N, M, X;
    vector<int> C;
    vector<vector<int>> A;

    cin >> N >> M >> X;
    C = vector<int>(N);
    A = vector<vector<int>>(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) cin >> A[i][j];
    }

    // Process
    int ans = dfs(0, vector<int>(M, 0), 0, C, A, N, M, X);

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int mod = 1e9+7;
vector<int> g[100005];
int fin[100005];
vector<LL> pref[100005], suff[100005];
LL dp[100005];
void update(int u){
    for(int i=1;i<g[u].size();i++) pref[u][i] = (pref[u][i]*pref[u][i-1])%mod;
    for(int i=g[u].size()-2;i>=0;i--) suff[u][i] = (suff[u][i]*suff[u][i+1])%mod;
}
void dfs(int u, int p){
    dp[u] = 1;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(v == p){
            fin[u] = i;
            continue;
        }
        dfs(v, u);
        pref[u][i] = dp[v];
        suff[u][i] = dp[v];
        dp[u] = (dp[u]*dp[v])%mod;
    }
    if(fin[u] == -1) update(u);
    dp[u] = (dp[u] + 1)%mod;
}
void dfs2(int u){
    if(fin[u] == -1) return;
    int v = g[u][fin[u]];
    dfs2(v);
    LL p1 = 1, p2 = 1;
    int idx = lower_bound(g[v].begin(), g[v].end(), u) - g[v].begin();
    if(idx-1 >= 0) p1 = pref[v][idx-1];
    if(idx+1 < g[v].size()) p2 = suff[v][idx+1];

    pref[u][fin[u]] = (p1*p2 + 1)%mod;
    suff[u][fin[u]] = (p1*p2 + 1)%mod;
    fin[u] = -1;
    update(u);
}
int main(){
    memset(fin, -1, sizeof(fin));
    int n, a, b;
    scanf("%d%d", &n, &mod);
    if(n == 1){
        printf("1\n");
        return 0;
    }
    for(int i=1;i<=n-1;i++){
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        sort(g[i].begin(), g[i].end());
        pref[i].resize(g[i].size());
        suff[i].resize(g[i].size());
    }
    dfs(1, 0);
    for(int i=2;i<=n;i++) dfs2(i);
    for(int i=1;i<=n;i++) printf("%lld\n", (pref[i][pref[i].size()-1]+mod)%mod);
}

Measured memory_bytes: 24320
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

const int SIZE = 100010;

int num;
int A, B;

int enough(int a[],int t) {
	int count = 0;
	for (int i = 0; i < num; ++i) {
		int dummy = a[i] - B * t;
		if (dummy <= 0 || count > t) {
			break;
		}
		if (dummy % (A - B) == 0)
			count += dummy / (A - B);
		else
			count += 1 + dummy / (A - B);
	}
	if (t >= count)
		return 1;
	else
		return 0;
}

int main(){	
	int max, min, mid;
	int *enemy = new int[SIZE];

	cin >> num >> A >> B;
	for (int i = 0; i < num; ++i)
		scanf("%d", &enemy[i]);

	sort(enemy,enemy + num, greater<int>());
	max = enemy[0] / B + 1;
	min = enemy[num - 1] / A;
	mid = min + (max - min) / 2;

	while (min < max) {
		if (enough(enemy, mid) == 1) {
			max = mid;
		}
		else {
			min = mid + 1;
		}
		mid = min + (max - min) / 2;
	}

	cout << min << endl;
	

	return 0;
}

Measured memory_bytes: 640
N = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(N):
    b = b * a[i]
    if b > 10 ** 18:
      b = 'out'
      break

if b == 'out':
  print(-1)
else:
  print(b)


Measured memory_bytes: 21652
MOD = 10**9 + 7
inpl = lambda: list(map(int,input().split()))
def inv_mod(a, p=10**9+7):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

def comb_mod(n,k,p):
    ans = 1
    k = min(k,n-k)
    if k < 0:
        return 0
    for i in range(k):
        ans = ans * (n-i) * inv_mod(k-i,p) % p
    return ans

n, a, b = inpl()
ans = pow(2,n,MOD) - 1
ans -= comb_mod(n,a,MOD)
ans -= comb_mod(n,b,MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 42972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n, x, i;
    cin >> n;
    vector < pair < ll, ll > > v;
    for(i = 0; i < n; i++){
        cin >> x;
        v.emplace_back(x, i+1);
    }
    sort(v.begin(), v.end());
    for(auto it : v){
        cout << it.second << " ";
    }
    return 0;
}

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

using namespace std;

long long comb_max = 100;
vector<long long> comb = vector<long long>(comb_max * comb_max, -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[comb_max * (n - 1) + (r - 1)] != -1) return comb[comb_max * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[comb_max * (n - 1) + (r - 1)] = res;
		return res;
	}
}


inline int ceileing(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}


void D() {
	int N, M; cin >> N >> M;
	using work = pair<int, int>;
	auto works = vector<work>(N);
	for (size_t i = 0; i < N; i++) cin >> works[i].first >> works[i].second;
	sort(works.begin(), works.end(), [](work a, work b) {if (a.first == b.first)return a.second > b.second; else return a.first > b.first; });
	long long answer = 0;
	for (size_t i = 0; i < N; i++) {
		if (M >= works[i].first) {
			answer += works[i].second;
			--M;
		}
	}
	cout << answer << endl;
}

void C() {
	int N; cin >> N;
	auto ss = vector<string>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> ss[i];
		sort(ss[i].begin(), ss[i].end());
	}
	sort(ss.begin(), ss.end());
	long long answer = 0;
	int i = 1;
	string prev = ss[0];
	auto count = 1;
	while (i < N) {
		if (prev == ss[i]) {
			++count;
		} else {
			if (count > 1) {
				answer += combination(count, 2);
			}
			count = 1;
			prev = ss[i];
		}
		++i;
	}
	if (count > 1) 		answer += combination(count, 2);
	cout << answer << endl;
}


int main() {
	int K, X; cin >> K >> X;
	for (int i = 0; i < 2 * K-1; i++) {
		cout << (X - K + 1) + i << " ";
	}
	cout << endl;
}

Measured memory_bytes: 384
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,C,K=MI()
    T=LIN(N)
    T.sort()
    angry = inf
    now = 0
    ans = 0
    for t in T:
        if(angry < t or now == C):
            ans += 1
            angry = inf
            now = 0
        angry = min(angry,t+K)
        now += 1
        # print(t,ans,angry)
    ans += angry < inf
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 10000
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define srt(v) sort(v.begin(), v.end())
void sol()
{
	
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int co=0,ma=0;
    string aa;
    cin>>aa;
    f(i,0,aa.length())
    {
        if(aa[i]=='R')
        {
            co++;
        }
        else
        {
            co=0;
        }
        if(ma<co)
        {
            ma=co;
        }
    }
    cout<<ma;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(){


  long long n,a,b,c,cou = 0;

  cin  >> n;

  while(1){
    if(n == 0) break;
    b = n / 2;
    c = n % 2;
    cou++;
    if(b == 0) break;
    n = b;
  }
    cout << cou << endl;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
int main(){
  int p;
  cin >> p;
  int i,j,k,sum1 = 0;
  for (i = 1; i < p+1 ; i ++) {
    for (j = 1; j < p+1; j ++) {
      int temp1,more,less;
      if (i < j){
        more = j;
        less = i;
      }else{
        more = i;
        less = j;
      }
      while (more % less != 0){
        temp1 = less;
        less = more % less;
        more = temp1;
      }
      for (k = 1; k < p+1; k ++){
        int temp2,more1,less1;
        if (less < k){
          more1 = k;
          less1 = less;
        }else{
          more1 = less;
          less1 = k;
        }
        while(more1 % less1 !=0){
          temp2 = less1;
          less1 = more1 % less1;
          more1 = temp2;
        }
        sum1 += less1;
        
      }
    }
  }
  cout << sum1 << endl;

}


Measured memory_bytes: 3624
n = int(input())
h = [int(x) for x in input().split()]

ans = 0
tmp = 0

for i in range(n):
    if i == 0:
        pass
    elif h[i] <= h[i-1]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 14224
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    zeroCnt = 0
    oneCnt = 0

    for j in range(n):
        if (a[j] >> i) & 1 == 1:
            oneCnt += 1
        else:
            zeroCnt += 1
    ans += zeroCnt * oneCnt * pow(2, i, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 122936
import Foundation

private func readInt() -> [Int]{
    return readLine()!.split(separator: " ").map{Int($0)!}
}

func mainC() {
    let N = Int(readLine()!)!
    
    let S = (1...N).map { _ in readLine()! }
    
    print(Set(S).count)
}

mainC()


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

class A
{
public:
    A()
    {
        int n;
        std::cin >> n;

        std::vector<int> a(n);
        for(int i = 0; i < n; ++i)
        {
            std::cin >> a[i];
        }

        int cnt = bubbleSort(a, n);

        show(a);
        std::cout << cnt << std::endl;
    }

    const int bubbleSort(std::vector<int>& a,  const int n)
    {
        int cnt = 0;
        bool flag = true;

        while(flag)
        {
            flag = false;

            for(int i = n - 1; i >= 1; --i)
            {
                if(a[i] < a[i - 1])
                {
                    int v = a[i];
                    a[i] = a[i - 1];
                    a[i - 1] = v;

                    flag = true;
                    cnt++;
                }
            }
        }

        return cnt;
    }

    void show(const std::vector<int>& a)
    {
        for(int i = 0; i < a.size(); ++i)
        {
            std::cout << a[i] << (i + 1 == a.size() ? "\n" : " ");
        }
    }
};

class B
{
public:
    B()
    {
        int n;
        std::cin >> n;

        std::vector<int> a(n);
        for(int i = 0; i < n; ++i)
        {
            std::cin >> a[i];
        }

        const int cnt = selectionSort(a, n);

        for(int i = 0; i < n; ++i)
        {
            std::cout << a[i] << (i + 1 == n ? "\n" : " ");
        }

        std::cout << cnt << std::endl;
    }

    const int selectionSort(std::vector<int>& a, const int n)
    {
        int cnt = 0;

        for(int i = 0; i < n; ++i)
        {
            int min_j = i;

            for(int j = i; j < n; ++j)
            {
                if(a[j] < a[min_j])
                {
                    min_j = j;
                }
            }

            int v = a[i];
            a[i] = a[min_j];
            a[min_j] = v;

            if(i != min_j)
            {
                cnt++;
            }
        }

        return cnt;
    }
};

int main(void)
{
    B b;
    return 0;
}

Measured memory_bytes: 3096
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node [] L = new Node[n];
        for(int i=0;i<n;i++){
            int id = sc.nextInt();
            ArrayList<Integer> Child = new ArrayList<>();
            int left = sc.nextInt();
            int right = sc.nextInt();
            if(left!=-1) Child.add(left);
            if(right!=-1) Child.add(right);
            Node v = new Node();
            v.element(id,Child,-1,-1,Child.size(),0,0,"no");
            L[id] = v;
        }
        //finding the parent and slibing
        for(Node v:L){
            if(v.Child.size()==1) L[v.Child.get(0)].parent = v.id;
            else if(v.Child.size()==2){
                L[v.Child.get(0)].parent = v.id;
                L[v.Child.get(1)].parent = v.id;
                L[v.Child.get(0)].slibing = v.Child.get(1);
                L[v.Child.get(1)].slibing = v.Child.get(0);
            }
        }
        //finding the type of each node
        int root_id = 0;
        for(Node v:L){
            if(v.parent!=-1&&v.Child.size()>0) v.type="internal node";
            else if(v.parent!=-1&&v.Child.size()==0) v.type="leaf";
            else{
                v.type = "root";
                root_id = v.id;
            }
        }
        //depth
        depth(L,root_id,0);
        //height
        ArrayList<Integer> leaf = new ArrayList<>();
        for(Node v:L){
            if(v.type.equals("leaf"))height(L,v.id,0);
        }

        //output
        for(Node v:L){
            StringBuilder opt = new StringBuilder();
            opt.append("node "+v.id+": parent = "+v.parent+", sibling = "+v.slibing+", degree = "+v.degree+", depth = "+v.depth+", height = "+v.height+", "+v.type);
            System.out.println(opt);
        }

    }
    public static void depth(Node L[],int id,int depth){
        L[id].depth = depth;
        for(int i:L[id].Child) depth(L,i,depth+1);
    }
    public static void height(Node L[],int id,int height){
        if(L[id].height<height) L[id].height=height;
        if(L[id].parent!=-1)height(L,L[id].parent,height+1);
    }
    public static class Node{
        ArrayList<Integer> Child = new ArrayList<>();
        int id,parent,slibing,degree,depth,height;
        String type;
        public void element(int id,ArrayList<Integer> Child,int parent,int slibing,int degree,int depth,int height,String type){
            this.id = id;
            this.Child = Child;
            this.parent = parent;
            this.slibing = slibing;
            this.degree = degree;
            this.depth = depth;
            this.height = height;
            this.type = type;
        }
    }
}


Measured memory_bytes: 26476
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x = I()
    m = 100001
    dp = [0]*m
    dp[0] = 1
    for j in (100,101,102,103,104,105):
        for i in range(m):
            if dp[i]:
                k = i+j
                if k < m:
                    dp[k] = 1
    print(dp[x])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 41328
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll A10,B10,na,nb,tmp;
int A[101],B[101]; 
signed main(){
//	freopen("AGC015D.in","r",stdin);
//	freopen("mine.out","w",stdout);
	cin>>A10>>B10;
	na=nb=-1;
	if (A10==B10){
		puts("1");return 0;
	}
	tmp=A10;
	while (tmp){
		++na;
		if (tmp&1ll) A[na]=1;
		tmp/=2ll;
	}
	tmp=B10;
	while (tmp){
		++nb;
		if (tmp&1ll) B[nb]=1;
		tmp/=2ll;
	}
	na=nb;
	for (;A[na]==B[nb];na--,nb--);
	B10=A10=0;
	for (int i=na;~i;i--) B10=B10*2ll+B[i],A10=A10*2ll+A[i];
	ll tb1=nb,tb2=-1,ta1=-1;
	int tot=0;
	for (int i=na;~i;i--){
		if (B[i]==1){
			tot++;
			if (tot==2){
				tb2=i;break;
			}
		}
	}
	for (int i=na;~i;i--){
		if (A[i]==1){
			ta1=i;break;
		}
	}
	ll ansr=(1ll<<tb1)+(1ll<<(tb2+1))-1,ansl=A10;
	if (tb2>=ta1){
		printf("%lld\n",(1ll<<(tb1+1))-A10);
	}else{
		ll aansl=((1ll<<(tb1))+A10),aansr=(1ll<<(tb1+1))-1; 
		printf("%lld\n",(aansl<=ansr?aansr-ansl+1:aansr-aansl+1+ansr-ansl+1));
	}
    return 0;
}

Measured memory_bytes: 3732
import Control.Applicative
import Control.Arrow

main = do
  n <- getLine
  as <- map read . words <$> getLine :: IO [Int]

  print $ length $ solve as

  where
    solve [] = []
    solve xs = if length a >= length d then a : solve as else d : solve ds
      where
        (a,as) = aux xs 1
        (d,ds) = aux xs (-1)

    aux (x:[]) _ = ([x],[])
    aux (x:y:xs) 1 = if x<=y then first (x:) (aux (y:xs) 1) else ([x], y:xs)
    aux (x:y:xs) (-1) = if x>=y then first (x:) (aux (y:xs) (-1)) else ([x], y:xs)


Measured memory_bytes: 54652
// base: http://drken1215.hatenablog.com/entry/2019/09/16/014600

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return r;
}

// RollingHash with mod(2**64)
struct RollingHash {
  // Mod is 2**64 (max of ull + 1)
  static const ull base1 = 1000000007;
  vector<ull> _hash, _power;

  RollingHash(const string& S) { init(S); }
  void init(const string& S) {
    int n = S.size();
    _hash.resize(n+1);
    _power.assign(n+1, 1);
    rep(i, n) {
      _hash[i+1] = _hash[i] * base1 + S[i];
      _power[i+1] = _power[i] * base1;
    }
  }

  // get hash of S[left:right]
  inline ull get(int l, int r) const {
    ull res1 = _hash[r] - _hash[l] * _power[r-l];
    return res1;
  }
};

int N;
RollingHash rh("");

bool check(int d) {
  map<ull, int> ma;
  for (int i = 0; i + d <= N; ++i) {
    ull p = rh.get(i, i + d);
    if (ma.count(p)) {
      if (i - ma[p] >= d) { // no overlap
        return true;
      }
    } else {
      ma[p] = i; // set first i.
    }
  }
  return false;
}

int main(int argc, char** argv) {
  cin >> N;
  string S;
  cin >> S;

  rh.init(S);

  // Find the largest left by binary search.
  int left = 0;
  int right = N/2 + 1;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (check(mid)) {
      left = mid;
    } else {
      right = mid;
    }
  }

  cout << left << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
string s[200005];
bool have[1000005][26];

struct Trie{
	struct TrieNode{
		int num, next[26];
		int cnt[26];
		TrieNode(){
			num = 0;
			for(int i = 0; i < 26; i++) next[i] = -1, cnt[i] = 0;
		}
	};
	vector<TrieNode> vec;
	Trie(){
		init();
	}
	void init(){
		vec.clear();
		vec.push_back(TrieNode());
	}
	
	void insert(int id)
	{
		int p = 0;
		
		for(int i = 0; i < s[id].size(); i++){
			for(int j = 0; j < 26; j++){
				if(have[i][j]) vec[p].cnt[j]++;//, cout << i << " " << j << endl;
			}
			int c = s[id][i]-'a';
			if(vec[p].next[c] == -1){
				vec.push_back(TrieNode());
				vec[p].next[c] = (int)vec.size()-1;
			}
			p = vec[p].next[c];
		}
		//cout << p << endl;
	}
	
	llint get(int id)
	{
		int p = 0;
		for(int i = 0; i < (int)s[id].size()-1; i++){
			int c = s[id][i]-'a';
			//cout << c << endl;
			if(vec[p].next[c] == -1){
				vec.push_back(TrieNode());
				vec[p].next[c] = (int)vec.size()-1;
			}
			p = vec[p].next[c];
		}
		//cout << "!" << p << endl;
		char c = s[id][(int)s[id].size()-1];
		//for(int j = 0; j < 26; j++) cout << vec[p].cnt[j] << " "; cout << endl;
		return vec[p].cnt[c-'a'];
	}
};

Trie trie;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s[i];
		reverse(s[i].begin(), s[i].end());
		
		for(int j = 0; j < 26; j++) have[s[i].size()][j] = false;
		for(int j = (int)s[i].size()-1; j >= 0; j--){
			for(int k = 0; k < 26; k++){
				have[j][k] = have[j+1][k];
				have[j][s[i][j]-'a'] = true;
			}
		}
		/*for(int j = 0; j <= s[i].size(); j++){
			for(int k = 0; k < 26; k++){
				cout << have[j][k];
			}
			cout << endl;
		}*/
		
		trie.insert(i);
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) ans += trie.get(i), ans--;//, cout << ans << endl;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 252116
def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


n,a,b = map(int,input().split())
mod = 10**9+7

ans = (pow(2,n,mod)-1) % mod


W = 1
X = 1
for i in range(a):

    W *= i + 1

    X *= n - i

    W %= mod
    X %= mod

ans -= X * inverse(W,mod)
ans %= mod

W = 1
X = 1
for i in range(b):

    W *= i + 1

    X *= n - i

    W %= mod
    X %= mod

ans -= X * inverse(W,mod)

print (ans % mod)

Measured memory_bytes: 41068
loop do
  a = gets.split(" ").map{|x| x.to_i}
  h = a[0]
  w = a[1]
  break if h + w == 0
  for i in 1..h do
    for j in 1..w do
      if i == 1 || i == h
        printf "#"
      elsif j ==1 || j == w
        printf "#"
      else
        printf "."
      end
    end
    puts
  end
  puts
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    vi d(4);
    REP(i, 4) {
        cin >> d[i];
    }
    sort(ALL(d));
    cout << (d == vi({1, 4, 7, 9}) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

// 動作環境 : C++14 AOJ
int main(){
    ll n;
    cin >> n;
    rep(i, 1, n + 1){
        ll x = i;
        if(!(i % 3)){
            cout << " " << i;
        }else if(i % 10 == 3){
            cout << " " << i;
        }else{
            while(x > 0){
                x /= 10;
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }

    cout << endl;

    return 0;
}



Measured memory_bytes: 3092
A, B ,M =map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = [list(map(int, input().split())) for k in range(M)]
ans = min(a) + min(b)
for k in range(M):
    cos = a[m[k][0]-1] + b[m[k][1]-1] - m[k][2]
    if ans > cos:
        ans = cos

print(ans)

Measured memory_bytes: 38560
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  swap(t[0], t[2]);
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) {
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi frist
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}



int main(){
	char s[10005];
	scanf("%s",s+1);
	printf("%c%c%c\n",s[1],s[2],s[3]);

	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,k;
  cin >> n >> k;
  ll a[n+1];
  a[0]=0;
  for(int i=0;i<n;i++)cin >> a[i+1];
  ll sum[n+1]={};
  sum[0]=0;
  vector<ll> v;
  for(int i=0;i<n;i++)sum[i+1]=sum[i]+a[i+1];
  for(int i=1;i<=n;i++){
    for(int j=0;j<=i-1;j++){
      v.push_back(sum[i]-sum[j]);
    }
  }
  ll ans=0;
  vector<ll> temp;
  for(int i=40;i>=0;i--){
    int cnt=0;
    temp.clear();
    for(int j=0;j<v.size();j++){
      if (v[j] & (1ll<<i)){
        cnt++;
        temp.push_back(v[j]);
      }
    }
    if(cnt>=k){
      ans+=(1ll<<i);
      v.swap(temp);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6384
#include<stdio.h>
char in[500010];
int a[500010][2];
int dp[500010][3];
int max(int a, int b) { return a > b ? a : b; }
int max(int a, int b, int c) { return max(max(a, b), c); }
int max(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); }
int main() {
	int n, N=1;
	scanf("%d%s", &n, in);
	for (int i = 0, k; i < n; N++, i=k) {
		a[N][0] = in[i]-'0';
		for (k = i; k < n && in[k] == in[i]; k++) a[N][1]++;
	}
	N--;
	int ans = 0;
	for (int i = (a[1][0]==1)?2:3; i <= N; i+=2) {
		dp[i][1] = dp[i][2] = dp[i][0] = max(dp[i - 2][1], dp[i - 2][2], dp[i - 2][0]);
		if (a[i][0] == 0 && a[i][1] == 1 && i+1 <= N) {
			dp[i][1] = max(dp[i][1],
				dp[i - 2][0] + a[i - 1][1],
				dp[i - 2][1] + a[i - 1][1] - 1);
			
			dp[i][2] = max(dp[i][2],
				dp[i - 2][0] + a[i + 1][1]);
			
			if(a[i-1][1]>=2)
				dp[i][2] = max(dp[i][2],
					dp[i - 2][1] + a[i + 1][1],
					dp[i - 2][2] + a[i + 1][1] - 1);
			
			ans = max(ans, dp[i][0], dp[i][1], dp[i][2]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10368
#include<cstdio>

int main(){
    char c[2][4];

    for(int i=0;i<2;i++){
        scanf("%s",c[i]);
    }

    if(c[0][0]==c[1][2] && c[0][1]==c[1][1] && c[0][2]==c[1][0]){
        printf("YES\n");
        return 0;
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
  if a[i]%2 == 0:
    if a[i]%3 == 0 or a[i]%5 == 0:
      continue
    else:
      print("DENIED")
      exit()
print("APPROVED")

Measured memory_bytes: 38408