akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	int a[200000];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int b[200001]{ 0 };
	for (int i = 0; i < N; i++) {
		b[a[i]]++;
	}
	sort(b, b + N + 1, greater<int>());
	int sum{ 0 };
	for (int i = K; i < N; i++) {
		sum += b[i];
	}
    cout << sum << endl;
}

Measured memory_bytes: 1792
while True:
    try:
        weight = float(input())

        if(weight <= 48.00):
            print("light fly")
        elif(weight <= 51.00):
            print("fly")
        elif(weight <= 54.00):
            print("bantam")
        elif(weight <= 57.00):
            print("feather")
        elif(weight <= 60.00):
            print("light")
        elif(weight <= 64.00):
            print("light welter")
        elif(weight <= 69.00):
            print("welter")
        elif(weight <= 75.00):
            print("light middle")
        elif(weight <= 81.00):
            print("middle")
        elif(weight <= 91.00):
            print("light heavy")
        else:
            print("heavy")
    except:
        break;


Measured memory_bytes: 5568
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '?')s[i] = 'D';
    }
    cout << s << endl;
}

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

using namespace std;

#define ll long long
#define int ll
#define pb(x) push_back(x)
#define mp(x) make_pair(x)
#define fi first
#define se second
struct Trie
{
    Trie* next[26];
    bool last;
    Trie()
    {
        for(int i=0;i<26;i++)
        {
            next[i]=NULL;
        }
        last=false;
    }
};
Trie* head=new Trie();
int cnt=0;
void insert(string &s)
{
    Trie* ptr=head;
    for(int i=0;i<s.size();i++)
    {
        if(ptr->next[s[i]-'a']==NULL)
        {
            Trie* temp=new Trie();
            ptr->next[s[i]-'a']=temp;
        }
        ptr=ptr->next[s[i]-'a'];
    }
    if(ptr->last==false)
    {
        ptr->last=true;
        cnt++;
    }
    return;
}
int32_t main() {
    int t=1;
    //cin>>t;
    while(t--)
    {
        int N;
        cin>>N;
        for(int i=0;i<N;i++)
        {
            string s;
            cin>>s;
            insert(s);
        }
        cout<<cnt<<endl;
    }

    return 0;
    
}

Measured memory_bytes: 303420
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    deque<double> D,D1;
    D.clear(); D1.clear();
    for(int i=0;i<n;i++)
        D.push_back(a[i]);
    while(D.size()>1)
    {
        D.push_back((D[0]+D[1])/2);
        D.pop_front();
        D.pop_front();
        sort(D.begin(),D.end());
    }
    double ans=D[0];
    cout<<setprecision(6)<<fixed<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a;
    int b;
    int c;
    cin >> a;
    cin >> b;
    cin >> c;

    int tmp;
    int ans;
    tmp = a-b;
    if(tmp > c){
        ans = 0;
    }else{
        ans = c-tmp;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define int long long
using namespace std;
int n,m;
int a[100010];
int f[100010];
bool h[100010];
signed main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>a[i],h[a[i]]=1;
	f[0]=1;
	f[1]=(a[1]!=1);
	for(int i=1;i<=n;i++)if(!h[i]){
		f[i]=f[i-1]+f[i-2];
		f[i]%=MOD;
	}
	cout<<f[n]<<endl;
	return 0;
}


Measured memory_bytes: 1536
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
B = list(B)
if n%2:
  B = B[::-1]
print(*B)

Measured memory_bytes: 26360
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;

int mp[4][4];
int visited[4];

int main(){

    for(int i = 0;i < 3;i++){
        int a,b;
        cin >> a >> b;
        visited[a-1]++;
        visited[b-1]++;
    }

    int odd = 0,even = 0;
    for(int i = 0;i < 4;i++){
        if(visited[i] % 2 == 1){
            odd++;
        }else{
            even++;
        }
    }
    if(odd == 2 || even == 4){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    

    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>;


int main(){
    ll n; cin >> n;
    string ans = "";
    while(n > 0){
        n--;//10進数における0がないことに対応
        char c = 'a' + n % 26;
        n /= 26;
        ans = c + ans;
    }
    cout << ans << endl;
}

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

int main(){
    string N;
    cin>>N;
    sort(N.begin(),N.end());
    if(N=="000"){
        cout<<'0'<<endl;
    }else if(N=="001"){
        cout<<'1'<<endl;
    }else if(N=="011"){
        cout<<'2'<<endl;
    }else{
        cout<<'3'<<endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {

	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int H = sc.nextInt();
			final int W = sc.nextInt();
			
			final int SIZE = 10;
			int[][] adj = new int[SIZE][SIZE];
			for(int i = 0; i < SIZE; i++){
				for(int j = 0; j < SIZE; j++){
					adj[i][j] = sc.nextInt();
				}
			}
			
			for(int k = 0; k < SIZE; k++){
				for(int i = 0; i < SIZE; i++){
					for(int j = 0; j < SIZE; j++){
						adj[i][j] = Math.min(adj[i][j], adj[i][k] + adj[k][j]);
					}
				}
			}
			
			long answer = 0;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					final int a = sc.nextInt();
					if(a < 0){ continue; }
					
					
					answer += adj[a][1];
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 25428
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

#define MAX_P 2000010
int fact[MAX_P]; //n! mid p

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}
int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
//n! = a p^e -> a mod p
void make_fact()
{
    fact[1] = 1;
    for (int i = 2; i < MAX_P; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    return;
}
int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0)
        return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}
//nCk mod p
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    int n = (x + y) / 3;
    x -= n;
    y -= n;
    make_fact();
    cout << mod_comb(x + y, x, mod) << endl;
}


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

using lint = long long;

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};
using P = Point<double>;

vector<P> pts;

double distance(double x, double y) {
	double furthest = 0.0;
	for (int i = 0; i < pts.size(); ++i) {
		double d = (x - pts[i].x) * (x - pts[i].x) + (y - pts[i].y) * (y - pts[i].y);
		furthest = max(furthest, d);
	}	
	return furthest;
}

double ts(double x) {
	double left = -1000, right = 1000;
	for (int i = 0; i <= 100; ++i) {
		double lmid = (2*left + right)/3.0;
		double rmid = (left + 2*right)/3.0;
		if (distance(x, lmid) > distance(x, rmid)) left = lmid;
		else right = rmid;
	}
	return distance(x, left);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    pts.resize(n);
    for (int i = 0; i < n; ++i) 
    	cin >> pts[i].x >> pts[i].y;
    double left = -1000, right = 1000;
    for (int i = 0; i <= 100; ++i) {
    	double lmid = (2*left + right)/3.0;
    	double rmid = (left + 2*right)/3.0;
    	if (ts(lmid) > ts(rmid)) left = lmid;
    	else right = rmid;
    }
    cout << setprecision(15) << fixed << sqrt(ts(left)) << '\n';
}

Measured memory_bytes: 384
import math

a, b = map(int, input().split())
a_origin = math.ceil(a*100/8)
b_origin = b*10

while True:
    if a_origin == b_origin:
        result = a_origin
        break;
    if a_origin < b_origin:
        a_origin += 1
    else:
        b_origin += 1

    if a_origin >= (a+1) * 100/8 or b_origin >= (b+1) * 10:
        result = -1
        break

print(result)


Measured memory_bytes: 3060
#?§???§????????????????????????hour miniute s ??§??¨???

TIMER = 60

time = gets.to_i

hour = 0
miniute = 0


if time >= 3600 then
	hour = time/TIMER/TIMER
	temp = time%3600
else 
	temp = time
end

if temp > 59 then
	miniute = temp/TIMER
	temp = temp%TIMER
end

if time <= 59 then
	temp = time
end


second = temp

puts "#{hour.floor}:#{miniute.floor}:#{second}"

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

using namespace std;




int main(){
	int k,i,j,t;
	string s;
	cin>>k>>s;
	if(s.size()<=k)cout<<s;
	else {
		for(i=0;i<k;i++)cout<<s[i];
		cout<<"...";
	}



    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vi h(n);
  rep(i,n) cin >> h[i];
  bool ok =true;
  rep(i,n-1){
    if(h[i]<=h[i+1]-1) h[i+1]--;
  }
  rep(i,n-1){
    if(h[i]>h[i+1]) ok =false;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n;
vector<int>V[114514];
int d[114514], d2[114514];
bool used[114514], used2[114514];
void dfs(int x) {
	used[x] = true;
	rep(i, V[x].size()) {
		if (!used[V[x][i]]) {
			d[V[x][i]] = d[x] + 1;
			dfs(V[x][i]);
		}
	}
}
void dfs2(int x) {
	used2[x] = true;
	rep(i, V[x].size()) {
		if (!used2[V[x][i]]) {
			d2[V[x][i]] = d2[x] + 1;
			dfs2(V[x][i]);
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	dfs(0); dfs2(n - 1);
	int ans1 = 0, ans2 = 0;
	rep(i, n) {
		if (d[i] > d2[i])ans2++;
		else ans1++;
	}
	if (ans1 > ans2) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}
}


Measured memory_bytes: 12544
#include <stdio.h>
int main()
{
	int h, w;
	int i, j;
	while (1){
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)break;
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if ((i%2 == 0 && j%2 == 0)||(i%2 == 1 && j%2 == 1)){
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <string>
using namespace std;
int ans;
int main(){
  int n;
  char s;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=='Y') ans++;
  }
  if(ans>0){
    cout <<"Four" << endl;
  }
  else{
    cout <<"Three" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N){
  if (N == 2) {
    std::cout << 1 << std::endl;
    return;
  }
  long long f = 2;
  for (long long i = 2; i*i <= N; ++i) {
    if ((N-1)%i == 0){
      f++;
      if ((N-1)/i != i) {
        f++;
      }
    } else {
      long long M = N;
      while (M >= i) {
        if (M%i == 0) M/=i;
        else M%=i;
      }
      if (M==1) f++;
    }
  }
  std::cout << f << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};


signed main(){
  Int n;
  cin>>n;
  vector<string> va(n);
  vector<Int> vx(n);
  for(Int i=0;i<n;i++) cin>>va[i]>>vx[i];

  map<string, Int> idx;
  for(Int i=0;i<n;i++) idx[va[i]]=i;

  Int m;
  cin>>m;
  vector<vector<Int> > G(n);
  for(Int i=0;i<m;i++){
    string s,t;
    cin>>s>>t;
    G[idx[s]].emplace_back(idx[t]);
    G[idx[t]].emplace_back(idx[s]);
  }

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<n;i++) vp.emplace_back(vx[i],i);
  sort(vp.begin(),vp.end());

  vector<Int> used(n,-1);
  for(auto p:vp){
    if(~used[p.second]) continue;
    queue<Int> que;
    used[p.second]=p.second;
    que.emplace(p.second);

    while(!que.empty()){
      Int v=que.front();que.pop();
      for(Int u:G[v]){
	if(~used[u]) continue;
	used[u]=used[v];
	que.emplace(u);
      }
    }
  }

  Int ans=0;
  for(Int i=0;i<n;i++) ans+=vx[used[i]];
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4016
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
char ns[100010] = {0};
int main()
{
    scanf("%s",ns);
    int len = strlen(ns);
    int l,r;
    int ans;
    char j = '1';
    ans = len/2;
    if(len%2)
    {
        ans++;
        l = len/2-1;
        r = l+2;
        if(ns[len/2] == '1')
            j = '0';
    }
    else
    {
        r = len/2;
        l = r-1;
        if(ns[l]=='1' && ns[r]=='1')
            j = '0';
    }
    while(l>=0 && r<len && ns[l]!=j && ns[r]!=j)
    {
        l--;
        r++;
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
<?php

fscanf(STDIN,"%s", $str);
$array = str_split($str);

$map= [];
foreach($array as $value){
    if(!isset($map[$value])){
        $map[$value] = 1;
    }else{
        $map[$value]++;
    }
}
sort($map);

$ans = 1;
$count = count($map);

for($i=0;$i<$count-1;$i++) {
    $tmp = 0;
    for ($j = $i + 1; $j < $count; $j++){

    $tmp += $map[$i] * $map[$j];
    }
    $ans += $tmp;
}
echo $ans;


Measured memory_bytes: 19064
import bisect
N,M=(int(x) for x in input().split())
As=sorted([int(x) for x in input().split()])
BC=[]

result=0
for _ in range(M):
    BC.append([int(x) for x in input().split()])

BC=sorted(BC, key=lambda x: x[1],reverse=True)
now=0
for b,c in BC:
    if now+b-1<=len(As)-1:
        if As[now+b-1]<=c:
            result+=c*b
            now+=b
        else:
            pos=bisect.bisect_left(As[now:],c)
            result+=c*pos
            now+=pos
            break
    else:
        if As[-1]<=c:
            result+=c*(N-now)
            As=[]
        else:
            pos=bisect.bisect_left(As[now:],c)
            result+=c*pos
            now+=pos
        break
        
print(result+sum(As[now:]))




Measured memory_bytes: 83864
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define f first
#define s second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<pair<int,int>> vii;
typedef vector<pair<ll,ll>> vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

ll ppow(ll x,ll y,ll mod) {
    ll res=1;
    while(y) {
        if(y&1) res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

const int N=105;

char a[N][N];
int dp[N][N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m; cin >> n >> m;
    for (int i=1;i<=n;++i) {
        for (int j=1;j<=m;++j) {
            cin >> a[i][j];
        }
    }
    for (int i=0;i<=n;++i)
        for (int j=0;j<=m;++j)
            dp[i][j]=1000;
    dp[1][1]=a[1][1]=='#';
    for (int i=2;i<=m;++i) {
        dp[1][i]=dp[1][i-1]+(a[1][i] != a[1][i-1]);
    }
    for (int i=2;i<=n;++i) {
        dp[i][1]=dp[i-1][1]+(a[i][1] != a[i-1][1]);
    }
    for (int i=1;i<=n;++i) {
        for (int j=1;j<=m;++j) {
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(a[i][j]=='.'&&a[i+1][j]=='#'));
            dp[i][j+1]=min(dp[i][j+1],dp[i][j]+(a[i][j]=='.'&&a[i][j+1]=='#'));
        }
    }
    cout << dp[n][m];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100 + 10;
int vis[maxn][maxn][2];
int deg[maxn][maxn][2];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(false);
    int n,a,b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2){
        cout << "Borys" << endl;
    }else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
#define f(i,a,b) for(ll i=a;i<b;i++)
 

int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int x,y,z;
cin>>x>>y>>z;
swap(x,y);
swap(x,z);
cout<<x<<" "<<y<<" "<<z<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <iterator>
using namespace std;

void func_b(int N) {
	int a = 0, b = 0, c = 0;
	a = N < 10 ? N : 9;
	if (100 <= N) {
		if (N < 1000)
			b = N - 100 + 1;
		else
			b = 900;
	}
	if (10000 <= N) {
		if (N < 100000)
			c = N - 10000 + 1;
		else
			c = 100000 - 10000;
	}
	cout << a + b + c << endl;
}

int main()
{
	int N;
	cin >> N;
	func_b(N);
}


Measured memory_bytes: 256
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    k,s = map(int,input().split())
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            if s-i-j<=k and s-i-j>=0:
                ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


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



int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL) ; 
	
	ll a  ; double b ; 
	cin >> a>> b ; 
	ll ans = a * (int)b ;
	//cout << ans ;
	string s = to_string(b) ; 
	string t = s.substr(2,2) ; 
	// << t; 
	ll fac = (stoll(t))* a ; 
	string sf = to_string(fac) ;
	if(sf.size() > 2) 
	{ 	sf.pop_back() ; 
		sf.pop_back() ; 
		ll add = (stoll(sf)) ; 
		cout << ans + add ; 
	}
	else 
		cout<<ans ; 
	



	return 0 ;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int x;
    cin>>x;
    cout<<48-x<<endl;
    return 0;
}



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

int main()
{
    string str1, str2;
    int num;
    cin >> num;
    int point[2] = {0,0};

    for(int i=0; i<num; i++)
    {
        cin >> str1 >> str2;
        if(str1 > str2) point[0] += 3;
        else if(str2 > str1) point[1] += 3;
        else point[0]++, point[1]++;
    }
    cout << point[0] << ' ' << point[1] << endl;

    return 0;
}


Measured memory_bytes: 3156
#coding:utf-8

while True:
	buff = input().split()
	h = int(buff[0])
	w = int(buff[1])
	if w == h == 0:
		break
	for i in range(h):
		if i == 0 or i == h-1:
			for j in range(w):
				print("#", end = "")
		else:
			for j in range(w):
				if j == 0 or j == w-1:
					print("#", end = "")
				else:
					print(".", end = "")
		print()
	print()

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

int main() 
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if (L > R) cout << "Left" << endl;
  else if (L == R) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int main()
{
  int n; cin>>n;
  rep(i,n){
    double x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    x2-=x1,y2-=y1;
    x4-=x3,y4-=y3;

    bool ok=abs(x2*y4-x4*y2)<EPS;
    cout<<(ok?"YES":"NO")<<endl;
  }
  return 0;
}

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

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

  vector<vector<char>> B(H + 2, vector<char>(W + 2, '0'));
  vector<vector<char>> A(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
      if (A.at(i).at(j) == '#') {
        for (int k = i; k < i + 3; k++) {
          for (int l = j; l < j + 3; l++) {
            B.at(k).at(l)++;
          }
        }
      } 
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') {
        B.at(i + 1).at(j + 1) = '#';
      }
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cout << B.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
        char N[4];
        int i;
        scanf("%s", N);

        for(i = 0; i < 3; i++) {
                if(N[i] == '7') {
                        printf("Yes\n");
                        return 0;
                }
        }
        printf("No\n");
        return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 1;
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for(int i=0; i<N-1; i++){
   if(vec.at(i) > vec.at(i+1))
     sum++;
  }
  
  cout << sum << endl;
  
}


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

using namespace std;


int main(){
  int n,m;
  cin>>n>>m;
  int h[100001];
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  vector<int> G[100001];
  while(m--){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int mx=0;
    for(auto e:G[i]){
      mx=max(mx,h[e]);
    }
    ans+=h[i]>mx;
  }
  cout<<ans<<endl;
}


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

//Minimum Macros
using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define rep(_i,_n) for(ll _i = 0; _i < _n; ++_i)
#define rep2(_i,_s,_n) for(ll _i = _s; _i < _n; ++_i)
#define elif else if
//Vector Macros
#define vec vector
#define append(_x) push_back(_x)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecL(_name, _n) vec<long> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecLL(_name, _n) vec<ll> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecUL(_name, _n) vec<ul> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecULL(_name, _n) vec<ull> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define maxIdx(_name) distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";
//Graph Macros
using Graph = vec<vec<long>>;
inline vec<long> BFS(Graph _g, long start){
  vec<long> _ans(_g.size(), -1); _ans[start] = 0; queue<long> _que; _que.push(start);
  while(!_que.empty()){
    long _target = _que.front(); _que.pop();
    for(long _towhere : _g[_target]){
      if(_ans[_towhere] == -1){
        _ans[_towhere] = _ans[_target] + 1; _que.push(_towhere);
      }
    }
  }
  return _ans;
}

ll N, M, X;
int Lrate[12];
int Lrate2[12];
long price[12];
long A[12][12];
ll minprice = -1;

void assess(){
  ll pricebuf = 0;
  rep(j, M){
    Lrate2[j] = 0;
  }
  rep(i, N){
    if(Lrate[i] == 1){
      pricebuf += price[i];
      rep(j, M){
        Lrate2[j] += A[i][j];
      }
    }
  }
  bool ok = true;
  rep(j, M){
    if(Lrate2[j] < X){
      ok = false;
      break;
    }
  }
  if(ok){
    if(minprice == -1 || minprice > pricebuf){
      minprice = pricebuf;
    }
  }
}

int main()
{
  cin >> N >> M >> X;
  rep(i, N){
    cin >> price[i];
    rep(j, M){
      cin >> A[i][j];
    }
  }
  rep(i0, 2){
    Lrate[0] = i0;
    rep(i1, 2){
      Lrate[1] = i1;
      rep(i2, 2){
        Lrate[2] = i2;
        rep(i3, 2){
          Lrate[3] = i3;
          rep(i4, 2){
            Lrate[4] = i4;
            rep(i5, 2){
              Lrate[5] = i5;
              rep(i6, 2){
                Lrate[6] = i6;
                rep(i7, 2){
                  Lrate[7] = i7;
                  rep(i8, 2){
                    Lrate[8] = i8;
                    rep(i9, 2){
                      Lrate[9] = i9;
                      rep(i10, 2){
                        Lrate[10] = i10;
                        rep(i11, 2){
                          Lrate[11] = i11;
                          assess();
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << minprice << endl;
  return 0;
}


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

using namespace std;
#define mx 200000
#define ll long long
int main()
{

   ll x;
   cin>>x;

   for(int j=1;j<=x;j++){

     double p =(double)j * 1.08;

     ll pd= p;
    // if(j==1000)cout<<p<<endl;
     if(pd==x){cout<<j<<endl;
     return 0;
     }
   }
   cout<<":("<<endl;

    return 0;
}



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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
// gcd : O(logN)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

#define uniq(v) (v).erase(unique(ALL((v))), (v).end());

// area of (0, 0)(a, b)(c, d)
double area(double a, double b, double c, double d){
    return abs(a * d - b * c) / 2.0;
}

const int PREC = 10;
#define coutf(val) cout << fixed << setprecision(PREC) << (val) << endl;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make2(int, N, K);

    vector<int> As(N);
    int ok_left_ind = -1;
    int ok_right_ind = -1;
    REP(i, N) {
        make(int, A);
        As.at(i) = A;

        if (A == 1) {
            ok_left_ind = i;
            ok_right_ind = i;
        }
    }

    int ans = 0;
    // まず左方向に伸ばす
    while(ok_left_ind > 0) {
        ok_left_ind -= (K - 1);
        ans++;
    }

    // 余ったぶんは右に伸ばすために使う
    if (ok_left_ind < 0) {
        ok_right_ind += abs(ok_left_ind);
        ok_left_ind = 0;
    }

    // 右方向に伸ばす
    while(ok_right_ind < (N-1)) {
        ok_right_ind += (K - 1);
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3660
a, b = map(int, input().split())
c = input()
d = "1234567890"
for i in range(a):
    if c[i] not in d:
        print("No")
        exit()
for i in range(len(c)-1, len(c)-1-b, -1):
    if c[i] not in d:
        print("No")
        exit()
if c[a] != "-":
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3060
n, m = map(int, input().split())
a, b = [], []

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


Measured memory_bytes: 6012
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int n;
ll c;

ll calc(vector<ll> &x, vector<ll> &v) {
  x[n + 1] = c;
  vector<ll> v_sum(n + 1);
  for (int i = 1; i <= n; ++i) {
    v_sum[i] = v_sum[i - 1] + v[i];
  }
  vector<ll> f(n + 1), g(n + 1);
  for (int i = 1; i <= n; ++i) {
    f[i] = v_sum[i] - x[i];
    g[i] = max(g[i - 1], f[i]);
  }
  ll res = 0;
  for (int i = n + 1; i >= 1; --i) {
    ll oa = g[i - 1];
    ll ob = v_sum[n] - v_sum[i - 1] - 2 * (c - x[i]);
    res = max(res, oa + ob);
  }
  return res;
}

int main() {
  cin >> n >> c;
  vector<ll> x(n + 2), v(n + 2);
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> v[i];
  }
  ll ans = 0;
  ans = max(ans, calc(x, v));
  reverse(ALL(x));
  reverse(ALL(v));
  for (int i = 0; i <= n; ++i) {
    x[i] = c - x[i];
  }
  ans = max(ans, calc(x, v));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4176
s = list(input())
ans = abs(753 - int(s[0] + s[1] + s[2]))
for i in range (len(s) - 2):
  num = s[i] + s[i+1] + s[i+2]
  if ans > abs(int(num)-753):
    ans = abs(int(num)-753)
print(ans)

Measured memory_bytes: 3188
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = 0
b = 0
ans = 0
t = sum(A)
temp = 0
if t <= K:
    ans = N
j = 0
ans2 = 0
for i in range(0,N+1):
    if i != 0:
        t -= A[-i]
    while t < K and j < len(B):
        if t + B[j] <= K:
            ans2 += 1
            t += B[j]
            j += 1
        else:
            break
    if t <= K:
        ans = max(ans,len(A)-i+ans2)
print(ans)


Measured memory_bytes: 40444
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n),b(n);
  vector<pair<int,int>> c(n);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    c[i]=make_pair(a[i],b[i]);
  }
  sort(c.begin(),c.end());
  long long cnt=0;
  int ans;
  for(int i=0;i<n;i++){
    cnt+=c[i].second;
    if(cnt>=k){
      ans=c[i].first;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a ^ b ^ c) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N; cin >> N;
	int S[1000], F[1000], C[1000];

	for (int i = 0;i < N-1;i++){
		cin >> C[i] >> S[i] >> F[i];
	}

	for (int i = 0;i < N;i++){
		int t = 0;
		for (int j = i;j < N-1;j++){
			if(t < S[j]) t = S[j]+C[j];
			else t = ((t-1)/F[j] + 1)*F[j]+C[j];
		}
		cout << t << endl;
	}


	return 0;

}


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

int main() {
    int64_t n, m, ans;
    cin >> n >> m;
    if (n > m/2) {
        ans = m/2;
    }
    else {
        ans = (2*n + m) / 4;
    }
    cout << ans << endl;
}



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

int allon(int m, vector<int>&switches, int pattern, vector<int>&bulbs) {
	for(int i = 0; i < m; i++) {
		bitset<10> on (pattern & switches[i]);
		if(on.count() % 2 != bulbs[i])
			return 0;
	} return 1;
}

int main() {
	int n, m, num, ret = 0;
	cin >> n >> m;
	vector<int> switches (m);
	vector<int> bulbs(m);
	for(int i = 0; i < m; i++) {
		cin >> num;
		int sw, flag = 0;
		for(int j = 0; j < num; j++) {
			cin >> sw;
			flag |= (1 << (sw - 1));
		} switches[i] = flag;
	}
	for(int i = 0; i < m; i++) {
		cin >> bulbs[i];
	}
	for(int i = 0; i < (1 << n); i++) {
		ret += allon(m, switches, i, bulbs);
	}
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int kai(int x)
{
    if(x==1) 
    {
        return 1;
    }

    else
    {
        return 10*kai(x-1);
    }
    
}

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

   int p,q;

   p=a;
   q=b;

   int A=0;
   int B=0;

   while (p>0)
   {
       A+=b*kai(p);
       p--;
   }

   while (q>0)
   {
       B+=a*kai(q);
       q--;
   }

   if(A>B) printf("%d",A);
   else printf("%d",B);

   int k;

   
    return 0;

}



Measured memory_bytes: 128
#include"iostream"
#include"cstdio"

#define MAXN
using namespace std;

int n;

bool check(int x)
{
	int cnt = 0;
	for(int i = 1; i <= x; i += 2)
		if(x % i == 0)
			cnt++;
	if(cnt == 8)
		return true;
	else
		return false;
}

int main()
{
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(check(i))
			ans++;
	cout << ans << endl;
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  ll g=0,p=0;
  ll ans = 0;
  REP(i,s.length()){
    if(s[i]=='g'){
      if(p<g){
        p++;
        ans++;
      }else{
        g++;
      }
    }else{
      if(p<g){
        p++;
      }else{
        g++;
        ans--;
      }
    }
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 512
#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;
    for (int i=1; i<=9; ++i)
    if (n%i == 0 and n/i < 10)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
  int n;
  int field[255][255];
  int d;
  string tmp;

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      cin >> tmp;
      for(int j=0;j<n;j++)field[i][j] = tmp[j]-'0';
    }

    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(field[i][j]){
	  d = 1;
	  while(i+d<n &&  j-d>=0 && field[i+d][j-d])d++;
	  ans = max(ans,d);

	  d = 1;
	  while(i+d<n && field[i+d][j])d++;
	  ans = max(ans,d);

	  d = 1;
	  while(i+d<n && j+d<n && field[i+d][j+d])d++;
	  ans = max(ans,d);

	  d = 1;
	  while(j+d<n && field[i][j+d])d++;
	  ans = max(ans,d);

	}
      }
    }

    cout << ans << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    string s,t; cin >> s >> t;
    vector<set<char>> tmp1(26);
    vector<set<char>> tmp2(26);
    rep(i, s.size()) {
        tmp1[s[i]-'a'].insert(t[i]);
        tmp2[t[i]-'a'].insert(s[i]);
    }

    rep(i, 26) {
        //cout << tmp[i].size() << endl;
        if(tmp1[i].size() > 1 || tmp2[i].size() > 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
program main
	implicit none
	integer(8):: A,B,C,N,i,j,t,k,D,E
	read *, A,B,C,D,E
	
   	if(A==0)	print'(I0)',1
   	if(B==0)	print'(I0)',2
   	if(C==0)	print'(I0)',3
   	if(D==0)	print'(I0)',4
   	if(E==0)	print'(I0)',5
   	
	
end program main

Measured memory_bytes: 2888
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5)
#define INFL LLONG_MAX
#define NINFL LLONG_MIN
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
	FIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		ll a,b;
		cin >> a >> b;
		cout << (a*3 + b)/2 << "\n";
	}


	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    int n; 
    cin >> n; 
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = INT_MAX; 
    for (int i = -100; i <= 100; ++i) {
        int sum = 0; 
        for (int j = 0; j < n; ++j) {
            sum += (a[j] - i) * (a[j] - i); 
        }
        ans = min(ans, sum); 
    }   
    cout << ans << endl; 
    return 0; 
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int n;cin>>n;
    int ans=0;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }

    for (int i=n-1;i>0;i--) {
        if(a[i]==a[i-1]){
            a[i-1]=0;
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //入力
        int n = Integer.parseInt(sc.next());
        int[] list = new int[n];
        for(int i=0; i<n; i++){
            list[i] = Integer.parseInt(sc.next());
        }
        
        //ソート
        for(int i=0; i<n; i++){
            int v = list[i];
            int j = i-1;
            while(j>=0 && list[j] > v){
                list[j+1] = list[j];
                j--;
                list[j+1] = v;
            }
            //出力
            for(int k=0; k<n; k++){
                System.out.print(list[k]);
                if(k != n-1){
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
    }

}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

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

int n;

void solve() {
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    sort(a, a+n);
    double h = 1. * a[n-1] / 2;
    int op = 0;
    rep(i,n-1) {
        if (abs(op - h) > abs(a[i] - h)) {
            op = a[i];
        }
    }
    cout << a[n-1] << " " << op << endl;
}

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


Measured memory_bytes: 640
n = int(input())
t, a = map(int, input().split())
h = [int(i) for i in input().split()]

check = float('inf')
ans = 0
for i in range(n):
    if check > abs(a - t + 0.006 * h[i]):
        ans = i + 1
        check = abs(a - t + 0.006 * h[i])
print(ans)

Measured memory_bytes: 3064