akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int h, w;
char s[2000][2010];
int dp[2000][2010];
int main() {
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++)
		scanf("%s", s[i]);
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			s[i][j] = s[i][j] == '.';

	for (int i = 0; i < h; i++) {
		int car = 0;
		for (int j = 0; j < w; j++) {
			if (s[i][j])
				dp[i][j] += car++;
			else
				car = 0;
		}
		car = 0;
		for (int j = w - 1; 0 <= j; j--) {
			if (s[i][j])
				dp[i][j] += car++;
			else
				car = 0;
		}
	}
	for (int j = 0; j < w; j++) {
		int car = 0;
		for (int i = 0; i < h; i++) {
			if (s[i][j])
				dp[i][j] += car++;
			else
				car = 0;
		}
		car = 0;
		for (int i = h - 1; 0 <= i; i--) {
			if (s[i][j])
				dp[i][j] += car++;
			else
				car = 0;
		}
	}

	int maxs = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (s[i][j])
				maxs = max(maxs, dp[i][j] + 1);
	printf("%d\n", maxs);
}


Measured memory_bytes: 19840
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    if(abs(a-b)%2==0){cout<<"Alice"<<endl;}
    else{cout<<"Borys"<<endl;}
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def solve(N: int, K: int):
    if K<N:
        ans=min(N%K, abs(N%K-K))
    elif K<2*N:
        ans=K-N
    else:
        ans=N
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
rc, cc = map(int, input().split())
i = 0
r = []
c_sum = [0] * cc

while rc > i:
    r.append([int(s) for s in input().split()])
    r[i].append(sum(r[i]))
    j = 0
    while cc > j:
        c_sum[j] += r[i][j]
        j += 1
    i += 1

i, j = 0, 0
while rc > i:
    while cc + 1 > j:
        if cc != j:
            print("{} ".format(r[i][j]), end="")
        elif cc == j:
            print(r[i][j])
        j += 1
    i += 1
    j = 0

c_sum.append(sum(c_sum))
i = 0
while cc + 1 > i:
    if cc != i:
        print("{} ".format(c_sum[i]), end="")
    elif cc == i:
        print(c_sum[i])
    i += 1



Measured memory_bytes: 6228
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<typename A, size_t N, typename T>void Fill(A (&a)[N], const T &v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N=1e5;
int n, m, c[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  int a=0, p=0;
  FOR(i, 0, m){
    int b;
    string s;
    cin >> b >> s;
    b--;
    if(c[b]<0) continue;
    if(s[0]=='A'){
      p += c[b];
      a++;
      c[b] = -1;
    }else{
      c[b]++;
    }
  }
  cout << a << " " << p << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int A;
  cin>>A;
  int B;
  cin>>B;
  vector<ll>vec(B);
  vector<char>veco(B);
  for(ll i=0;i<B;i++){
    cin>>vec.at(i)>>veco.at(i);
  }
  ll c=-1;
  ll d=0;
  
  if(A>=2){
    d=1;
    for(int i=1;i<A;i++){
      d=d*10;
    }
    
  }
  ll e=10;
  e=max(e,10*d);
  
  if(B==0){
    cout<<d<<endl;
    return 0;
  }
    
  for(int i=d;i<e;i++){
    
    string b=to_string(i);
    for(ll j=0;j<B;j++){
      if(b.at(vec.at(j)-1)!=veco.at(j)){
        
        break;
      }
      if(j==B-1){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  cout<<c<<endl;
  return 0;
}
      
    



Measured memory_bytes: 3612
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static int nextInt () {return Integer.parseInt(sc.next());}

    public static void main(String[] args) {
        int N = nextInt();
        int M = nextInt();
        int[][] prefYears = new int[M][2];
        Map<Integer, List<Integer>> prefectureToYears = new HashMap<>();

        for (int i = 0; i < M; i++) {
            int p = nextInt();
            int y = nextInt();
            prefYears[i] = new int[] {p, y};
            if (!prefectureToYears.containsKey(p)) {
                prefectureToYears.put(p, new ArrayList<>());
            }
            List<Integer> ys = prefectureToYears.get(p);
            ys.add(y);
            prefectureToYears.put(p, ys);
        }

        for (Integer p : prefectureToYears.keySet()) {
            List<Integer> ys = prefectureToYears.get(p);
            Collections.sort(ys);
        }

        Map<Integer, Integer> yearToPosi = new HashMap<>();
        for (List<Integer> years : prefectureToYears.values()) {
            for (int i = 0; i < years.size(); i++) {
                yearToPosi.put(years.get(i), i+1);
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < M; i++) {
            int p = prefYears[i][0];
            int y = prefYears[i][1];

//            List<Integer> years = prefectureToYears.get(p);
//            int ans = Arrays.binarySearch(years.toArray(), y) + 1;
            sb.append(String.format("%06d%06d", p, yearToPosi.get(y)) );
            sb.append(System.getProperty("line.separator"));
        }

        System.out.println(sb);
    }
}


Measured memory_bytes: 120576
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct p
{
    int num;
    int p;
    int state[20];
} a[20];
int w[20],n,m,ans=0;
void check()
{
    int flag=1;
    for(int i=1;i<=m;i++)
    {
        int sum=0;
        for(int j=1;j<=a[i].num;j++)
            if(w[a[i].state[j]])
                sum++;
        if(sum%2!=a[i].p)
        {
            flag=0;
            break;
        }
    }
    if(flag)
        ans++;
}
void dfs(int x)
{
    if(x==n+1)
    {
        check();
        return ;
    }
    for(int i=0;i<=1;i++)
    {
        w[x]=i;
        dfs(x+1);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&a[i].num);
        for(int j=1; j<=a[i].num; j++)
            scanf("%d",&a[i].state[j]);
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i].p);
    dfs(1);
    printf("%d",ans);
    return 0;
}


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

struct SCC {
public:
    SCC(int n) : G(n), G_rev(n), comp(n, -1), visited(n) {}

    void add_edge(int u, int v) {
        G[u].push_back(v);
        G_rev[v].push_back(u);
    }

    void build() {
        for (int v = 0; v < G.size(); v++) dfs(v);
        reverse(order.begin(), order.end());
        int c = 0;
        for (int v : order) if (comp[v] == -1) rdfs(v, c++);
    }

    int operator[](int i) const {
        return comp[i];
    }

private:
    vector<vector<int>> G, G_rev;
    vector<int> comp, order;
    vector<bool> visited;

    void dfs(int u) {
        if (visited[u]) return;
        visited[u] = true;
        for (int v : G[u]) dfs(v);
        order.push_back(u);
    }

    void rdfs(int u, int c) {
        if (comp[u] != -1) return;
        comp[u] = c;
        for (int v : G_rev[u]) rdfs(v, c);
    }
};

struct TwoSat {
    bool satisfiable = true;

    TwoSat(int n) : n(n), scc(2 * n), val(n) {}

    void add_clause(int u, bool a, int v, bool b) {
        scc.add_edge(n * a + u, n * (!b) + v);
        scc.add_edge(n * b + v, n * (!a) + u);
    }

    void solve() {
        scc.build();
        for (int i = 0; i < n; i++) {
            if (scc[i] == scc[n + i]) {
                satisfiable = false;
                break;
            }
            val[i] = scc[i] > scc[n + i];
        }
    }

    bool operator[](int i) const {
        return val[i];
    }

private:
    int n;
    SCC scc;
    vector<bool> val;
};

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

    int N, D;
    cin >> N >> D;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    TwoSat sat(N);
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (abs(X[i] - X[j]) < D) {
                sat.add_clause(i, false, j, false);
            }
            if (abs(X[i] - Y[j]) < D) {
                sat.add_clause(i, false, j, true);
            }
            if (abs(Y[i] - X[j]) < D) {
                sat.add_clause(i, true, j, false);
            }
            if (abs(Y[i] - Y[j]) < D) {
                sat.add_clause(i, true, j, true);
            }
        }
    }
    sat.solve();
    if (sat.satisfiable) {
        cout << "Yes\n";
        for (int i = 0; i < N; i++) {
            if (sat[i]) cout << X[i];
            else cout << Y[i];
            cout << "\n";
        }
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 3848
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] A;

    private void solve() {
        N = nextInt();
        A = new int[N];

        for(int i = 0;i < N;i++) {
            A[i] = nextInt() - (i + 1);
        }

        Arrays.sort(A);

        int m = N / 2;
        long ans = 0;
        for(int i = 0;i < N;i++) {
            ans += Math.abs(A[i] - A[m]);
        }
        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 45192
#include <iostream>
#include <map>

using namespace std;
int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        cout << abs(a-b)/2 << endl;
        return 0;
    }
    long long t1 = b;
    long long t2 = n-a;
    if(t1<=t2){
        cout << (a+b-1)/2 << endl;
    }
    else cout << n-(b+a-1)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#include<bits/stdc++.h> 
using namespace std; 
  
// A utility function to add an edge in an 

// A utility function to print the adjacency list 
// representation of graph 

  
int32_t main()
{
    int n,k,ans=0;
    cin>>n>>k;
    vector<int> adj[n+1]; 
    int h[n+1]={};
    int a[n],i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<k;i++)
    {
        int b,c;
        cin>>b>>c;
        adj[b].push_back(c); 
        adj[c].push_back(b); 
        h[b]=1;
        h[c]=1;
    }
    for (int v = 1; v <=n; v++) 
    { 
        int flag=0;
        for (auto x : adj[v]) 
        {
            if(a[x-1]>=a[v-1])
            {
                flag=1;
            }
        }
        if(flag==0)
        {
            ans++;
            // cout<<"v "<<v<<endl;
        }

    } 
    cout<<ans;
    return 0;




    

}


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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    ll A, prevA;
    cin >> prevA;
    vector<ll> difA(N-1);
    for(int i=1;i<N;i++){
        cin >> A;
        difA[i-1] = A-prevA;
        prevA = A;
    }
    ll res = 0;
    ll cont = 0;
    for(int i=0;i<N-1;i++){
        if(cont==0){
            if(difA[i]<0) cont = -1;
            if(difA[i]>0) cont = 1;
        }else{
            if(cont*difA[i] < 0){
                res++;
                cont = 0;
            }
        }
    }
    res++;
    cout << res << endl;
    return 0;
}

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

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<long long> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    long long mn=9999999999999;
    for(int i=0,j=k-1;i<=n-k;i++,j++)
    {
        if(a[j]-a[i]<mn)
            mn=a[j]-a[i];
    }
    cout<<mn;
}


Measured memory_bytes: 1024
#include"stdio.h"
#include<string>
using namespace std;
#define MAX 25

class Node
{
public:
	enum TYPE { ROOT, INTERNAL_NODE, LEAF };
	Node(int ID, Node* PARENT)
	{
		id = ID;
		parent = PARENT;
	}
	~Node() {};
	Node* parent = 0;
	Node* sibling = 0;
	Node* left = 0;
	Node* right = 0;
	int id;
	int degree = 0;
	int depth = -1;
	int height = -1;
	TYPE type;
};

class Tree
{
public:
	Tree() { for (int i = 0; i < MAX; i++)nodes[i] = 0; }
	~Tree() { for (int i = 0; i < MAX; i++)if (nodes[i] != 0)delete nodes[i]; }
	void CreateNode(int ID, Node* PARENT) { nodes[ID] = new Node(ID, PARENT); }
	Node* nodes[MAX];
	Node* nodes_root;
	void SetRoot()
	{
		for (int i = 0; i < MAX; i++)
		{
			if (nodes[i] == 0)break;
			if (nodes[i]->parent == 0)
			{
				nodes[i]->type = Node::ROOT;
				nodes[i]->depth = 0;
				nodes_root = nodes[i];
				break;
			}
		}
	}
	void ShowPreoder(Node* NODE)
	{
		printf(" %d", NODE->id);
		if (NODE->left != 0) ShowPreoder(NODE->left);
		if (NODE->right != 0) ShowPreoder(NODE->right);
	}
	void ShowInoder(Node* NODE)
	{
		if (NODE->left != 0) ShowInoder(NODE->left);
		printf(" %d", NODE->id);
		if (NODE->right != 0) ShowInoder(NODE->right);
	}
	void ShowPostoder(Node* NODE)
	{
		if (NODE->left != 0) ShowPostoder(NODE->left);
		if (NODE->right != 0) ShowPostoder(NODE->right);
		printf(" %d", NODE->id);
	}

};

int main()
{
	Tree T;
	int n;
	scanf("%d", &n);
	for (int o = 0; o < n; o++)
	{
		int id, l, r;
		scanf("%d%d%d", &id, &l, &r);
		if (T.nodes[id] == 0)T.CreateNode(id, 0);
		if (l != -1)
		{
			T.nodes[id]->degree++;
			if (T.nodes[l] == 0)T.CreateNode(l, T.nodes[id]);
			else T.nodes[l]->parent = T.nodes[id];
			T.nodes[id]->left = T.nodes[l];
		}
		if (r != -1)
		{
			T.nodes[id]->degree++;
			if (T.nodes[r] == 0)T.CreateNode(r, T.nodes[id]);
			else T.nodes[r]->parent = T.nodes[id];
			T.nodes[id]->right = T.nodes[r];
		}
		if (r != -1 && l != -1)
		{
			T.nodes[l]->sibling = T.nodes[r];
			T.nodes[r]->sibling = T.nodes[l];
		}
	}
	T.SetRoot();
	printf("Preorder\n");
	T.ShowPreoder(T.nodes_root);
	printf("\n");
	printf("Inorder\n");
	T.ShowInoder(T.nodes_root);
	printf("\n");
	printf("Postorder\n");
	T.ShowPostoder(T.nodes_root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2744
s = input()

counter_map = dict()
for i in range(4):
    if s[i] not in counter_map:
        counter_map[s[i]] = 1
    else:
        counter_map[s[i]] += 1

for i in counter_map.values():
    if i == 2:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 9028
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<string> s;
    for (int i = 0; i < n; i++)
    {
        string si;
        cin >> si;
        s.insert(si);
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 19256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int m=s.length();
int n=0,ss=0,w=0,e=0;
rep(i,0,m-1)
{
	if(s[i]=='N')
	n=1;
	else if(s[i]=='S')
	ss=-1;
	else if(s[i]=='W')
	w=1;
	else
	e=-1;
}

if((n+ss)==0&&(w+e)==0)
ol("Yes");
else
ol("No");
return 0;
}


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

using namespace std;

int sp, stk[100];
int main(void){
  string tmp;
  
  while (cin >> tmp){
    int t1,t2;
    if (tmp=="+"){
      t1 = stk[--sp]; t2 = stk[--sp];
      stk[sp++] = t1+t2;
    } else if (tmp=="-"){
      t1 = stk[--sp]; t2 = stk[--sp];
      stk[sp++] = t2-t1;
    } else if (tmp=="*"){
      t1 = stk[--sp]; t2 = stk[--sp];
      stk[sp++] = t1*t2;
    } else {
      sscanf(tmp.c_str(), "%d", &t1);
      stk[sp++] = t1;
    }
  }
  cout << stk[--sp] << endl;
  return 0;
}



Measured memory_bytes: 3312
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class Store implements Comparable<Store>{
		long a;
		long b;
		public Store(int a , int b) {
			this.a = a;
			this.b = b;
		}
		double value(){
			return a * 1.0 /(double) (b + 1);
		}
		@Override
		public int compareTo(Store o) {
			if(a == 0 && o.a == 0){
				return Long.compare(b, o.b);
			}
			return Double.compare(o.value(), value());
		}
	}
	static int solve(Store[] stores, long T){
		List<Store> nonzeroAStores = new ArrayList<Store>();
		List<Store> zeroAStores = new ArrayList<Store>();
		for(Store s : stores){
			if(s.a == 0){
				zeroAStores.add(s);
			}else{
				nonzeroAStores.add(s);
			}
		}
		int N = nonzeroAStores.size();
		long dp[] = new long[Math.min(30, N + 1)];
		Arrays.fill(dp , -1);
		dp[0] = 0;
		for(Store s : nonzeroAStores){
			long next[] = new long[dp.length];
			for(int k = 0 ; k < dp.length ; ++k){
				long ret = -1;
				if(dp[k] >= 0){
					ret = dp[k];
				}
				if(k > 0 && dp[k - 1] >= 0){
					long r2 = (dp[k - 1] + 1) * s.a + s.b + dp[k - 1] + 1;
//					long r2 = (s.a + 1) * dp[k - 1] + s.b + 1 + s.a;
					if(ret < 0){
						ret = r2;
					}else{
						ret = Math.min(ret, r2);
					}
				}
				if(ret >= T + 1){
					ret = -1;
				}
				next[k] = ret;
			}
			dp = next;
		}
		int ret = 0;
		for(int k = 0 ; k < dp.length ; ++k){
			long t = dp[k];
			if(t < 0){
				continue;
			}
			ret = Math.max(ret, k);
			for(int i = 0 ; i < zeroAStores.size(); ++i){
				Store s = zeroAStores.get(i);
				long nt = t + 1 + s.b;
				if(nt < T + 1){
					ret = Math.max(ret, k + i + 1);
				}
				t = nt;
			}
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		Store stores[] = new Store[N];
		for(int i = 0 ; i < N ; ++i){
			stores[i] = new Store(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(stores);
		System.out.println(solve(stores , T));
	}
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int n,k;
    cin>>n>>k;
    double ans=0.0;
    f1(i,1,n+1)
    {
        double temp=1.0/n;
        int j=i;
        while(j<k)
        {
            temp*=(1.0/2.0);
            j*=2;
        }
        ans+=temp;
    }
    cout<<setprecision(12)<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
	LL N, keta = 1, cc = 26;
	cin >> N;
	while(N > cc) {
		N -= cc;
		cc *= 26;
		++keta;
	}
	--N;
	string name('a', keta);
	REP(i, keta) {
		name[keta-1-i] = (char)('a' + N % 26);
		N /= 26;
	}
	cout << name.substr(0,keta) << endl;
}

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

int main(){
    string S,T;
    int ans;
    cin >> S>>T;
    ans = 0;
    for(int i= 0; i < 4; i++){
        if(S[i]==T[i]){
            ans++;
        }
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k = ni()
n = 50

a = k//n
b = k%n
c = n-1+a

ans = [str(c+n-b+1)]*b + [str(c-b)]*(n-b)

print(n)
print(' '.join(ans))


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
int sh,sm,ss,th,tm,ts,h,m,s,ks,ps,x,i;

for (i = 1;i <= 3;i++){

scanf("%d %d %d %d %d %d",&sh,&sm,&ss,&th,&tm,&ts);

ks = sh*60*60+sm*60+ss;
ps = th*60*60+tm*60+ts;

x=ps-ks;

h=x/3600;
m=(x-h*3600)/60;
s=x-h*3600-m*60;

printf("%d %d %d\n",h,m,s);

}
return 0;
}

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int N, a;
  cin >>N;
  int ANS[N+1];
  for(int i=1;i<N+1;i++){
    ANS[i]=0;
  }

  for(int x=1;x<101;x++){
    for(int y=1;y<101;y++){
      for(int z=1;z<101;z++){
        a = x*x + y*y + z*z + x*y + y*z + z*x;
        if(a > N){
          break;
        }
        ANS[a]++; 
      }
    }
  }
  
  for(int i=1;i<N+1;i++){
    cout << ANS[i] << endl;
  }
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3496
H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])

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

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

    map<string, int> count;
    for(int i = 0; i < n; i++)
    {
        count[s[i]]++;
    }

    cout << count.size();


    return 0;
}

Measured memory_bytes: 25456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ll a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+') {
        cout << (a + b) << endl;
    } else {
        cout << (a - b) << endl;
    }

    return 0;
}


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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


void go(){
	int n,a,b;cin>>n>>a>>b;
	if(n*a<b) cout << n*a;
	else cout << b;
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 0
    used = [-1] * N
    used[0] = 0
    cur = 0
    loop_cnt = 0
    start = 0
    for i in range(1, N+1):
        cur = A[cur] - 1
        if i == K:
            print(cur+1)
            sys.exit() 
        if used[cur] == -1:
            used[cur] = i
            continue
        else:
            loop_cnt = i
            start = cur
            break
    K -= loop_cnt
    loop_cnt -= used[start]
    x = K % loop_cnt
    for i in range(N):
        if used[i]-used[start] == x:
            print(i+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 91544
import math
from functools import reduce
from collections import deque,defaultdict
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,*A = get_all_int()

X = defaultdict(int)

ans = 0
for i in range(n):
    # log(i, A[i], X[i-A[i]])
    ans += X[i-A[i]]
    X[A[i] + i] += 1

# log(X)

print(ans)


Measured memory_bytes: 134688
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
int h,w,d;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<pair<int,pi> >arr;
	cin>>h>>w>>d;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			int num;
			cin>>num;
			arr.push_back(make_pair(num-1,pi(i,j)));
		}
	}
	sort(arr.begin(),arr.end());
	vector<int>psum(arr.size(),0);
	for(int i=0; i<arr.size(); i++){
		int previ = i-d;
		if(previ<0) continue;
		psum[i]+=psum[previ];
		int x = arr[previ].second.first-arr[i].second.first;
		int y = arr[previ].second.second-arr[i].second.second;
		psum[i]+=abs(x)+abs(y);
	}	
	int q;
	cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<psum[r-1]-psum[l-1]<<'\n';
	}
}

Measured memory_bytes: 4908
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

enum COMMAND_TYPE {
  INSERT,
  DELETE,
  DELETE_FIRST,
  DELETE_LAST
};

static COMMAND_TYPE fetch(string& st) {
  const string CDF = "deleteFirst";
  const string CDL = "deleteLast";
  const string CD = "delete";
  const string CI = "insert";
  
  if (st.find(CI) != string::npos) {
    return INSERT;
  } else if (st.find(CDF) != string::npos) {
    return DELETE_FIRST;
  } else if (st.find(CDL) != string::npos) {
    return DELETE_LAST;
  } else {
    return DELETE;
  }
}

static void fetchCommand(list<int>& clist, int n) {
  COMMAND_TYPE type;
  string command;
  int number;
  list<int>::iterator p;
  char buf[50];
  for (int i = 0; i < n; i++) {
    memset(buf, sizeof buf, 0);
    fgets(buf, sizeof buf, stdin);
//    scanf("%s%d", buf, &number);
    command = buf;
    type = fetch(command);
 //   printf("n = %d, i = %d, command = %d.¥n", n, i, type);
    switch (type) {
      case INSERT:
        number = atoi(&buf[7]);
        clist.push_front(number);
        break;
      case DELETE:
        number = atoi(&buf[7]);
        p = find(clist.begin(), clist.end(), number);
        if (p != clist.end()) {
          clist.erase(p);
        }
        break;
      case DELETE_FIRST:
        clist.pop_front();
        break;
      case DELETE_LAST:
        clist.pop_back();
        break;
    }
   }
}

int main() {
  char buf[50] = {};
  fgets(buf, sizeof buf, stdin);
  int n = atoi(buf);

  list<int> commandList;
  fetchCommand(commandList, n);

  list<int>::iterator it = commandList.begin();
  bool first = true;
  while (it != commandList.end()) {
    if (first) {
      cout << *it;
      first = false;
    } else {
      cout << " " << *it;
    }
    it++;
  }
  cout << endl;  

  return 0;
}



Measured memory_bytes: 34408
#include<iostream>
#include<cstdio>
#define rg register
#define il inline
#define ll long long
#define maxn 500005
using namespace std;
il int read(){rg int x = 0 ,w = 1;char ch = getchar();while (ch < '0' || ch > '9'){if (ch == '-') w = -1;ch = getchar();}while (ch >= '0' && ch <= '9'){x = (x<<3) + (x<<1) + ch - '0';ch = getchar();}return x * w;}
struct edge{
	int to,next;	
}e[maxn << 1];
int head[maxn] , cnt , dis[maxn];
bool vis[maxn];
int main(){
	rg int a = read() , b = read();
	printf("%d",a - b + 1);
	return 0;	
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int par[N], rnk[N], sz[N];
int findroot(int node) {
  if (par[node] == node)
    return node;
  else {
    par[node] = findroot(par[node]);
    return par[node];
  }
}
void dounion(int x, int y) {
  if (rnk[x] > rnk[y]) {
    par[y] = x;
    sz[x] += sz[y];
  }
  else if (rnk[x] < rnk[y]) {
    par[x] = y;
    sz[y] += sz[x];
  }
  else {
    par[x] = y;
    sz[y] += sz[x];
    rnk[y]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    sz[i] = 1;
    par[i] = i;
  }
  pair<int, int> edg[m];
  for (int i = 0; i < m; i++) {
    cin >> edg[i].first >> edg[i].second;
    edg[i].first--;
    edg[i].second--;
  }
  long long ans[m], cnt = (n - 1LL) * n / 2;
  for (int i = m - 1; i >= 0; i--) {
    ans[i] = cnt;
    int x = findroot(edg[i].first);
    int y = findroot(edg[i].second);
    if (x != y) {
      cnt -= 1LL * sz[x] * sz[y];
      dounion(x, y);
    }
  }
  for (int i = 0; i < m; i++)
    cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 6312
#if 1

#include <bits/stdc++.h>
using namespace std;
double n,m;
double cnt,x;
double ans;

int main()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        x = i;
        cnt = 1;
        while(x < m)
        {
            x *= 2;
            cnt *= 2;
        }
        ans += (double)(1/n)*(1/cnt);
    }
    printf("%.20lf",ans);
}

#endif // 1++

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

int main(){
  ll n,i,j;
  ll b[4]={0};
  string a[4]={"AC","WA","TLE","RE"};
  string s;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    for(j=0;j<4;j++){
      if(s==a[j]){
        b[j]+=1;
        break;
      }
    }
  }
  for(i=0;i<4;i++){
    cout << a[i] << " x " << b[i] << endl;
  }
}

Measured memory_bytes: 3620
N = int(input())
a = [int(n) for n in input().split()]

colors = [0,0,0,0,0,0,0,0]
free = 0

for i in a:
    if i < 400:
        colors[0] = 1
    elif i < 800:
        colors[1] = 1
    elif i < 1200:
        colors[2] = 1
    elif i < 1600:
        colors[3] = 1
    elif i < 2000:
        colors[4] = 1
    elif i < 2400:
        colors[5] = 1
    elif i < 2800:
        colors[6] = 1
    elif i < 3200:
        colors[7] = 1
    else:
        free += 1

s = sum(colors)

print(str(max(s, 1)) + " " + str(s + free))


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

typedef long long ll;

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

	ll ans = (ll)1;
	if (H != 1 && W != 1) {
		int col = H / 2;
		ans = (ll)col * W;
		if (H % 2 == 1)
			ans += (ll)(W + 1) / 2;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = gcd(a[0], a[1]);
    for(int i = 2; i < n; i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

const long long int llinf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

#define Endl endl
#define pr(x) cout << x << endl
#define FOR(i,a,b) for(int i = a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define atcoder int(1e9) +7;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
#define all(x) x.begin,x.end();

int main() {

	ll a, b,x;
	cin >> a >> b >> x;
	ll ans = b / x - (a - 1) / x;
	if (a == 0 && x != 1)pr(ans+ 1);
	else pr(ans);

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)

N,X=map(int,raw_input().split())

height=[-1]*51
niku=[-1]*51
height[0]=1
niku[0]=1

for i in range(1, N+1):
    height[i]=2*height[i-1]+3
    niku[i]=2*niku[i-1]+1

def rec(l, x):
    if x==1:
        if l==0:
            return 1
        else:
            return 0
    
    if x < 1+height[l-1]+1:
        return rec(l-1, x-1)
    elif x == 1+height[l-1]+1:
        return 1 + niku[l-1]
    elif x <= height[l] - 1:
        return niku[l-1] + 1 + rec(l-1, x-height[l-1]-2)
    else:
        return 2*niku[l-1]+1
print(rec(N, X))



    



Measured memory_bytes: 2696
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,m,ans=0;
  string s,jam="";
  while(cin >> s){
    jam="";
    n=s.size();
    for(int i=n-1;i>=0;i--){
      jam=jam+s[i];
    }
    if(s==jam){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, a, b;
  scanf("%lld%lld%lld", &n, &m, &k);
  printf("%lld", n + m >= k - 1 ? (m + k) : n + m + 1 + m);
  return 0;
}

Measured memory_bytes: 128
import java.util.*; 

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin=new Scanner(System.in);
		
		int n = cin.nextInt();
		ArrayList<Integer> arr=new ArrayList<>();
		
		for(int i=0;i<n;i++){
			int x=cin.nextInt();
			arr.add(x);
		}
		
		Collections.reverse(arr);
		
		for(int i=0;i<n-1;i++){
			System.out.print(arr.get(i)+" ");
		}
		System.out.println(arr.get(n-1));
	}

}



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 0, 3*n) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    for (int i = n; i < 3 * n; i += 2)
        ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

const int mod = 1e9 + 7;
int N;
vector<int> v;

bool consistent(){
  sort(all(v));
  int beg;
  if(N&1){
    beg = 0;
    for(int i=0; i<N; ++i){
      if(i == 0){
        if(v[i] == 0){
           beg += 2;
           continue;
        }
        else
          return false;
      }
      if((i&1) && i >= 3)
        beg += 2;
      if(v[i] != beg)
        return false;
    }
  }
  else{
    beg = 1;
    for(int i=0; i<N; ++i){
      if(i != 0 && !(i&1))
        beg += 2;
       if(v[i] != beg){
         return false;
      }
    }
  }
  return true;
} 

long long power(long long b, int p){
 if(p == 0)
   return 1LL;
 return ((b%mod)*(power(b, p-1)%mod))%mod;
}

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N;
  v.resize(N);
  for(int i=0; i<N; ++i)
    cin >> v[i];
  long long res = 0LL;
  if(consistent()){
    res = power(2LL, N/2);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n,x;
set<int>a;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        a.insert(x);
    }
    if(a.size()==n){
        puts("YES");
    }
    else{
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 11136
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, M;
   cin >> N >> M;

   VI accepted(N), penalty(N);

   REP(m, M) {
      int id;
      string verdict;
      cin >> id >> verdict;
      --id;
      if (verdict == "AC") {
         accepted[id] = true;
      }
      else {
         if (!accepted[id])
            penalty[id]++;
      }
   }

   int naccepted = 0, npenalty = 0;
   REP(id, N) {
      if (accepted[id]) {
         ++naccepted;
         npenalty += penalty[id];
      }
   }
   
   cout << naccepted << ' ' << npenalty << endl;

   return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[100010],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a,a+n+1);
	cout<<a[n/2+1]-a[n/2];
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

typedef long long i64; 
typedef vector< int > vi;
typedef vector< i64 > vi64;
typedef pair< int, int > pi;
typedef vector< pair< int, int > > vpi;

void crypt() {
	int a, b, h; cin >> a >> b >> h;
	int ans = ((abs(a-b) * h) / 2) + min(a, b) * h;
	cout << ans << "\n";
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	cout << fixed;
	int t = 1; 
//	cin >> t;
	while (t--) crypt();
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n : usize,
        m : usize,
    }
    let ans = n * m;
    println!("{}\n",ans);
}


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

const int N = 2003;

bitset <N * N> bag;
int n;

int main() {
  bag[0] = 1;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 1, a; i <= n; i ++) {
    scanf("%d", &a);
    sum += a;
    bag |= bag << a;
  }
  for (int i = (sum + 1) / 2; ; i ++)
    if (bag[i]) {
      printf("%d\n", i); return 0;
    }
  return 0;
}

Measured memory_bytes: 1664
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt), *,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt), *) => {
            let ($($name, )*) = {
                let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
                $(let $name = _read_value!(_scanned, $t);)*
                ($($name, )*)
            };
            $(let _ = &$name;)*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt), *)) => {
            ($(_read_value!($scanned, $t)), *)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _index) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    #[derive(Default)]
    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf).unwrap();
            // if buf.last() != Some(&b'\n') {
            //     buf.push(b'\n');
            // }
            // assert!(buf.iter().all(|&b| b <= 0x7f));
            Scanned { buf: buf, pos: 0 }
        }

        #[inline]
        pub fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
        }
    }
}

#[allow(dead_code)]
mod output {
    use std::io::{self, BufWriter, StdoutLock, Write as _Write};

    pub fn with_stdout<F: FnMut(&mut BufWriter<StdoutLock>)>(mut f: F) {
        let stdout = io::stdout();
        let mut stdout = BufWriter::new(stdout.lock());
        f(&mut stdout);
        stdout.flush().unwrap();
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::Write;
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, thread, u16, u32, u64, u8};

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
    }
    let mut v = vec![a, b, c];
    v.sort();
    let r = 10 * v[2] + v[1] + v[0];
    println!("{}", r);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

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

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

int main() {
	int N;
	char S[100];
	char T[100];
	int a = 0;
	char ans[200];

	scanf("%d", &N);
	scanf("%s %s", S, T);

	for (int i = 0; i < N; i++) {
		ans[a] = S[i];
		a = a + 1;
		ans[a] = T[i];
		a = a + 1;
	}

	for (int i = 0; i < a; i++) {
		putchar(ans[i]);

	}


	return 0;
}

Measured memory_bytes: 128