akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using PLL = pair<ll, ll>;
using PPLL = pair<PLL, PLL>;
//#define endl '\n';

int main() {
    ll W = 5;
    while(true) {
        ll H;
        cin >> H;
        if(!H) break;
        VV<ll> board(H, V<ll>(W));
        ll sum = 0;
        for(auto &v : board) {
            for(ll &e : v) {
                cin >> e;
                sum += e;
            }
        }
        while(true) {
            bool update = false;
            VV<bool> used(H, V<bool>(W, false));
            for(ll h = 0; h < H; h++) {
                for(ll l = 0; l < 5; l++) {
                    for(ll r = W - 1; r - l + 1 >= 3; r--) {
                        bool is_same = true;
                        for(ll i = l; i <= r - 1; i++) {
                            if(board[h][i] == -1 || board[h][i + 1] == -1 || board[h][i] != board[h][i + 1]) is_same = false;
                        }
                        if(!is_same) continue;
                        update = true;
                        for(ll i = l; i <= r; i++) used[h][i] = true;
                    }
                }
            }
            if(!update) break;
            for(ll h = 0; h < H; h++) {
                for(ll w = 0; w < W; w++) {
                    ll nw = w + 1;
                    while(nw < W && used[h][nw]) nw++;
                    break;
                }
            }
            VV<ll> nb(H, V<ll>(W, -1));
            for(ll h = 0; h < H; h++) {
                for(ll w = 0; w < W; w++) {
                    ll b = board[h][w];
                    if(b == -1) continue;
                    if(used[h][w]) continue;
                    ll cnt = 0;
                    for(ll dh = 1; h + dh < H; dh++) if(used[h + dh][w]) cnt++;
                    nb[h + cnt][w] = b;
                }
            }
            board = move(nb);
        }
        for(const auto &v : board) for(ll e : v) if(e != -1) sum -= e;
        cout << sum << endl;
    }
    return 0;
}



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

int main(){
	int n;
	cin >>n;
	vector<int> a(n);
	int ave=0;
	for(int i =0; i< n; i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave /= n;
	int mini=9999999;
	int cost;
	for(int i = max(ave-10, -100); i<= min(ave+10, 100);i++) {
		cost = 0;
		for(int j=0; j<n;j++) {
			cost += (a[j] - i)*(a[j] - i);
		}
		if(mini > cost)
			mini = cost;
	}
	cout << mini << endl;
	
}


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

struct edge
{
	int from; int to; long long cost;
};

int const MAX_E = 2005;
int const MAX_V = 1005;
long long const MAX = 1000000000000000;

edge e[MAX_E];
long long dist[MAX_V];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int sss, t, r;
		cin >> sss >> t >> r;
		e[i] = { sss,t,-r };
	}
	for (int i = 1; i <= n; i++) {
		dist[i] = MAX;
	}
	dist[1] = 0;
	for (int i = 1; i <= n - 1; i++) {
		for (int j = 1; j <= m; j++) {
			int fr = e[j].from;
			int too = e[j].to;
			int cos = e[j].cost;
			if (dist[fr] != MAX && dist[fr] + cos < dist[too]) {
				dist[too] = cos + dist[fr];
			}
		}
	}
	long long ans = dist[n];
	for (int i = 1; i <= n - 1; i++) {
		for (int j = 1; j <= m; j++) {
			int fr = e[j].from;
			int too = e[j].to;
			int cos = e[j].cost;
			if (dist[fr] != MAX && dist[fr] + cos < dist[too]) {
				dist[too] = cos + dist[fr];
			}
		}
	}
	if (ans != dist[n]) {
		cout << "inf" << endl;
	}
	else {
		cout << -ans << endl;
	}
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

	int H,W;
	int[] DX = {0,0,1,1,1,-1,-1,-1};
	int[] DY = {1,-1,0,1,-1,0,1,-1};
	boolean[][] used;
	char[][] spells;
	HashMap<String,Integer> map;

	public String dfs(int h,int w,int dy,int dx){

		if(used[h][w])return "";
		used[h][w] = true;


		String ret = "";
		int nh = (h + dy + H) % H;
		int nw = (w + dx + W) % W;

		ret = spells[h][w] + dfs(nh,nw,dy,dx);

		used[h][w] = false;
		map.put(ret, map.containsKey(ret)  ? map.get(ret) + 1 : 1);
		return ret;
	}


	public void solve() {
		while(true){
			H = nextInt();
			W = nextInt();
			if(H + W == 0)break;
			map = new HashMap<String,Integer>();
			spells = new char[H][];

			for(int i = 0;i < H;i++){
				spells[i] = next().toCharArray();
			}

			used = new boolean[H][W];

			for(int i = 0;i < H;i++){
				for(int j = 0;j < W;j++){
					for(int k = 0;k < DX.length;k++){
						dfs(i,j,DY[k],DX[k]);
					}
				}
			}

			String ans = "";
			for(String key : map.keySet()){
				if(map.get(key) >= 2 && key.length() >= 2){

					if(ans.length() < key.length()){
						ans = key;
					}else if(ans.length() == key.length() && ans.compareTo(key) >= 1){
						ans = key;
					}
				}
			}

			out.println(ans.length() == 0 ? 0 : 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[2048];
	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: 272516
n = gets.to_i
hash = Hash.new(0)
1.upto(101) do |x|
  1.upto(101) do |y|
    1.upto(101) do |z|
      hash[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1
    end
  end
end
1.upto(n) do |i|
  puts hash[i]
end


Measured memory_bytes: 16700
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	vi DIJ(int s){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int n;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		ll x,y,z;
		cin>>x>>y>>z;
		if(x==0) break;
		pll p={INF,INF};
		ll a,b;
		for(int i=0;i<100005;i++){
			if((x*i+z)%y==0){
				ll c=i,d=(x*i+z)/y;
				pll q={c+d,c*x+d*y};
				if(q<p){
					p=q;
					a=c,b=d;
				}
			}
		}
		swap(x,y);
		for(int i=0;i<100005;i++){
			if((x*i+z)%y==0){
				ll c=i,d=(x*i+z)/y;
				pll q={c+d,c*x+d*y};
				if(q<p){
					p=q;
					b=c,a=d;
				}
			}
		}
		swap(x,y);
		for(int i=0;x*i<z;i++) if((z-i*x)%y==0){
			ll c=i,d=(z-i*x)/y;
			pll q={c+d,c*x+d*y};
			if(q<p){
				p=q;
				a=c,b=d;
			}
		}
		cout<<a<<' '<<b<<endl;
	}
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;	
	for(int i=start;i<to;i++)		
	       for(int j=i+1;j<=to;j++) {res[i][j]=index;
		  		}	
	int mid=(start+to)>>1;	
	dfs(start,mid,index+1),dfs(mid+1,to,index+1);
	}
	int main(){	
	cin>>n;	
	dfs(1,n,1); 	
	for(int i=1;i<n;i++)        
	for(int j=i+1;j<=n;j++)	
	cout<<res[i][j]<<" ";
}



Measured memory_bytes: 1536
#include <iostream>
 
using namespace std;
 
int main()
{
    double tmp;
     
    while(cin >> tmp){
        if(tmp <= 48.0){
            cout << "light fly" << endl;
        } else if(tmp <= 51.0){
            cout << "fly" << endl;
        } else if(tmp <= 54.0){
            cout << "bantam" << endl;
        } else if(tmp <= 57.0){
            cout << "feather" << endl;
        } else if(tmp <= 60.0){
            cout << "light" << endl;
        } else if(tmp  <= 64.0){
            cout << "light welter" << endl;
        } else if(tmp <= 69.0){
            cout << "welter" << endl;
        } else if(tmp <= 75.0){
            cout << "light middle" << endl;
        } else if(tmp <= 81.0){
            cout << "middle" << endl;
        } else if(tmp <= 91.0){
            cout << "light heavy" << endl;
        } else {
            cout << "heavy" << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
typedef long long ll;
using namespace std;
int n,x[100005],y[100005],d[100005];
char ch[]="RLUD";
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
const unsigned int mo=1e9+7;
double ans=9e99;
bool tra(long double t,int md){
	double max=x[0]+t*dx[d[0]],mix=max,may=y[0]+t*dy[d[0]],miy=may;
	ll nmax=0,nmix=0,nmay=0,nmiy=0;
	for(int i=1;i<n;++i){
		long double X=x[i]+t*dx[d[i]],Y=y[i]+t*dy[d[i]];
		if(X>max)nmax=i,max=X;
		if(X<mix)nmix=i,mix=X;
		if(Y>may)nmay=i,may=Y;
		if(Y<miy)nmiy=i,miy=Y;
	}
	//cout<<max<<may<<mix<<miy<<endl;
	ans=min(ans,(max-mix)*(may-miy));
	int p;
	if(md&4) md-=4,p=dx[d[nmax]]-dx[d[nmix]];
	else p=dy[d[nmay]]-dy[d[nmiy]];
	return p<md-1;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		char tp;
		scanf("%d%d %c",x+i,y+i,&tp);
		for(int j=0;j<4;++j){
			if(ch[j]==tp){
				//cout<<j<<endl;
				d[i]=j;break;
			}
		}
	}
	for(int mode=0;mode<8;++mode){
		long double l=0,r=2e8;
		for(int i=0;i<70;++i){
			double mid=(l+r)/2;
			//printf("%.39lf\n",mid);
			if(tra(mid,mode))l=mid;
			else r=mid;
			//printf("%.39lf\n",(double)ans);
		}
	}
	printf("%.17lf\n",ans);
	return 0;
} 
/*
3
-1000 0 U
1000 0 L
-1900 0 R
*/

Measured memory_bytes: 1536
#include<stdio.h>
#include<algorithm>
int*it,shop[100001],n,m,d,i;
int main(){
	for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
		for(;--i;)
			scanf("%d",shop+i);
		for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] ))
			scanf("%d",&d),
			it = std::upper_bound( shop, shop+n, d );
	}
}

Measured memory_bytes: 1148
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int a[1<<19];
int MOD;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
int Deal(int l,int r)
{
    int mx=0;
    while(l<=r)
        mx=max(mx,add(a[l],a[r])),++l,--r;
    return mx;
}
int n;
bool Ch(int lim)
{
    lim=n-lim;
    int l=(lim<<1)+1,r=n<<1;
    while(l<=r){
        if(a[l]+a[r]<MOD)return 0;
        ++l,--r;
    }
    return 1;
}
int main()
{
    scanf("%d%d",&n,&MOD);
    for(int i=1;i<=(n<<1);i++)
        scanf("%d",&a[i]);
    sort(a+1,a+(n<<1)+1);
    int als=2100000000;
    int l=0,r=n;
    while(l<=r){
        int mid=(l+r)>>1;
        if(Ch(mid))l=mid+1;
        else r=mid-1;
    }
    int fin=n-r;
    printf("%d",max(Deal(1,fin<<1),Deal((fin<<1)+1,n<<1)));
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> G(100);
vector<pair<int,int>> D(100);
bool visited[100];
int elapse = 1;
void dfs(int x){
    if(visited[x]) return;
    visited[x] = true;
    D[x].first = elapse;
    elapse++;
    for(auto &a:G[x]) dfs(a);
    D[x].second = elapse;
    elapse++;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;++j){
            int v;
            cin>>v;
            G[u-1].push_back(--v);
        }
    }
    for(int i=0;i<N;++i) dfs(i);
    for(int i=0;i<N;++i) cout<<i+1<<' '<<D[i].first<<' '<<D[i].second<<endl;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int x,y;
    cin>>x>>y;
    cout<<(x-y<0?0:x-y)<<endl;
    return 0;
}

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

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

    vector<int> ABC = {A,B,C};
    sort(ABC.begin(), ABC.end());

    for(int i = 0; i < K; i++) {
        ABC.at(2) *= 2;
    } 

    int total = ABC.at(0) + ABC.at(1) + ABC.at(2);
    cout << total << endl;

}

Measured memory_bytes: 256
from operator import itemgetter
def main():
  n, m = map(int, input().split())
  bridge = 0
  ab = []
  for _ in range(m):
    a, b = map(int, input().split())
    ab.append((a,b))
  ab = sorted(ab, key=itemgetter(1))
  count = 0
  for a, b in ab:
    if not a <= bridge <= b:
      count += 1
      bridge = b-1
  print(count)

main()



Measured memory_bytes: 59104
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;

    set<string> st;
    string command, str;
    for (int i = 0; i < n; i++) {
        cin >> command >> str;
        if (command == "insert") {
            st.insert(str);
        } else {
            if (st.find(str) != st.end()) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int containAB = 0;
  int beginB = 0;
  int endA = 0;
  int beginBendA = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    auto pos = s.find("AB");
    while (pos != string::npos) {
      containAB++;
      pos = s.find("AB", pos + 2);
    }
    if (s[0] == 'B') beginB++;
    if (s[s.size() - 1] == 'A') endA++;
    if (s[s.size() - 1] == 'A' && s[0] == 'B') beginBendA++;
  }
  if (beginBendA == beginB && beginBendA == endA && beginBendA)
    cout << beginBendA - 1 + containAB << endl;
  else
    cout << min(beginB, endA) + containAB << endl;
  return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3052
use std::io;
use std::cmp::min;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let mut mini:i32 = 700;
	for i in 0..(s.len()-2) {
		let x = &s[i..(i+3)];
		let xi:i32 = x.parse().ok().unwrap();
		mini = min(mini, (753 - xi).abs());
	}
	println!("{}", mini);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int cnt=0;
	char c;
	cin>>s;
	int i;
	int o=0;
	int z=s.size();
	for(i=0;i<26;i++){
		c=i+97;
		for(int k=0;k<z;k++){
			if(s[k]==c){
				cnt++;
			}
		}
		if(cnt%2==1){
			o++;
			break;
		}
		cnt=0;
	}
	if(o!=0){
		cout<<"No"<<endl;
	}
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
N_n_osatsu, Y_sum_money = map(int, input().split())

rest_money = Y_sum_money
rest_n_osatsu = N_n_osatsu
n_each_osatsu_list = [] # 万札、五千円札、千円札の枚数の2重リスト

def skip_search(rest_money, rest_n_osatsu):  # 明らかに無理な場合、処理をスキップ
    if rest_n_osatsu*1000 > rest_money or rest_n_osatsu*10000 < rest_money:
        return True

def is_answer(n_10000, n_5000, n_1000):
    if n_10000 + n_5000 + n_1000 == N_n_osatsu and n_10000*10000 + n_5000*5000 + n_1000*1000 == Y_sum_money:
        print(n_10000, n_5000, n_1000)
        exit()

for n_10000 in range(int(Y_sum_money/10000 +1)): # 万札枚数。0枚からスタート
    is_answer(n_10000, 0, 0)
    rest_money = Y_sum_money - 10000*n_10000
    rest_n_osatsu = N_n_osatsu - n_10000
    if skip_search(rest_money, rest_n_osatsu):
        break

    for n_5000 in range(int(rest_money/5000 + 1)): # 万札枚数決定後に5000円の枚数を探索。5000円0枚からスタート
        is_answer(n_10000, n_5000, 0)
        rest_money = Y_sum_money - 10000*n_10000 - 5000*n_5000
        rest_n_osatsu = N_n_osatsu - n_10000 - n_5000
        if skip_search(rest_money, rest_n_osatsu):
            break
        n_1000 = int(rest_money/1000)
        is_answer(n_10000, n_5000, n_1000)

print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}

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

int main() {
  char c;
  cin >>c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout <<"vowel" <<endl;
  }
  else{
    cout <<"consonant" <<endl;
  }
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSlimes solver = new CSlimes();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSlimes {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            String st = n();
            int i = 0;
            char last = st.charAt(0);
            StringBuffer str = new StringBuffer();
            str.append(last);
            for (i = 1; i < n; i++) {
                if (st.charAt(i) == last)
                    continue;
                else {
                    str.append(st.charAt(i));
                    last = st.charAt(i);
                }
            }
            pn(str.toString().length());

        }

        String n() {
            return in.next();
        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

int N;

string S,T,U;
int A,B;

int main(){
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(U==S)A--;
    if(U==T)B--;
    cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int n;
cin>>n;
int h[n];
for(int i=0;i<n;i++){
    cin>>h[i];
}
int cnt=1;

for(int i=1;i<n;i++){
    int x=0;
    for(int j=0;j<i;j++){
        if(h[j]>h[i]){
            x=1;
        }
    }
    if(x==0)cnt+=1;

}
cout<<cnt<<endl;


return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    vector<vector<int>> cnt(9,vector<int>(9));
    int n,f,b;cin>>n;string s;
    for(int i=1;i<=n;i++){
        s=str(i);
        f=s[0]-'0';b=s[s.size()-1]-'0';
        if(f==0||b==0)continue;
        cnt[f-1][b-1]++;
    }
    lint ans=0;
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3708
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
    int n,m,i,j,k,l,s=0;
    cin>>n>>m;
    map<int,int> m1;
    for(i=1;i<=n;i++)
    {
      cin>>k;
      m1[k]++;
    }
    map<int,int>::reverse_iterator it;
    for(i=1;i<=m;i++)
    {
      it=m1.rbegin();
      j=(it->first);
      m1[j/2]++;
      m1[j]--;
      if(m1[j]==0)
       m1.erase(j);
    }
    for(auto it=m1.begin();it!=m1.end();it++)
     {
       j=(it->first),k=(it->second);
       s+=j*k;
     }
     cout<<s;
  }

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main()
{
int arr[3];
cin>>arr[0]>>arr[1]>>arr[2];
sort(arr,arr+3);
if((arr[0]==arr[1]&&arr[0]!=arr[2])||(arr[1]==arr[2]&&arr[0]!=arr[1]))
cout<<"Yes\n";
else
cout<<"No\n";
}


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

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;

// (a + b + c)^3 >= 27abc

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

    double L;

    cin >> L;
    printf("%.9lf",L*L*L/27);

    return 0;
}


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

int main() {
  auto forecast = [](const std::string& w) {
    if (w == "Sunny")
      return "Cloudy";
    else if (w == "Cloudy")
      return "Rainy";
    else
      return "Sunny";
  };

  std::string weather;
  std::cin >> weather;
  std::cout << forecast(weather) << std::endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]

mod=10**9+7

dp=[[0]*w for i in range(h)]
dp[0][0]=1

for i in range(h):
 for j in range(w):
  if i==j==0:
   continue
  if l[i][j]=='#':
   dp[i][j]==0
   continue

  if i-1>=0 and l[i-1][j]=='.':
   dp[i][j]+=dp[i-1][j]
  if j-1>=0 and l[i][j-1]=='.':
   dp[i][j]+=dp[i][j-1]

  dp[i][j]%=mod

print(dp[-1][-1])

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

signed main(void)
{
	string s;
	int k, now, tmp;

	cin >> s >> k;
	now = 0;
	while (now < s.size())
	{
		tmp = ('a' - s[now] + 26) % 26;
		if (tmp <= k)
		{
			k -= tmp;
			s[now] = 'a';
		}
		now++;
	}
	rep(i, k)
	{
		if (s[now - 1] == 'z')
			s[now - 1] = 'a';
		else
			s[now - 1]++;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf=1000000007;
const ll maxinput=25;
const ll mod=998244353;
#define mp make_pair
const int maxinput2=(1<<21)+5;
ll n,mat[21][21];
vector <int> adj[maxinput];
int dp[25][maxinput2];
int ways(int pos,int mask)
{
    if(pos==n)
        return(1);

    if(dp[pos][mask]!=-1)
        return(dp[pos][mask]);
    int temp=0;
    int j;
    for(int j=0;j<adj[pos].size();j++)
    {
        if(((1<<adj[pos][j])&mask)==0)
            temp+=(ways(pos+1,mask|(1<<adj[pos][j])))%inf,temp%=inf;
    }
    return(dp[pos][mask]=temp%inf);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>mat[i][j];
            if(mat[i][j]==1)
                adj[i].push_back(j);
        }
    }

    cout<<(ways(0,0)+inf)%inf; //current position,mask
}

Measured memory_bytes: 205056
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b;
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
	int flag = 0;
	scanf("%d", &n);
	for(int i = 1; i < 10; i++){
		if(n % i == 0 && (n / i) < 10){
			printf("Yes\n");
			flag++;
			break;
		}
	}
	if(flag == 0){
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1656
a, b, m = map(int, input().split())
ref = list(map(int, input().split()))
rnj = list(map(int, input().split()))
ans = min(ref) + min(rnj)
for i in range(m):
    x, y, c = map(int, input().split())
    ans = min(ref[x-1] + rnj[y-1] - c, ans)
print(ans)

Measured memory_bytes: 18736
import sys
from collections import deque
input = sys.stdin.readline

def main():
    while True:
        w, h = map(int, input().split())
        if w == 0:
            break
        board = [list(map(int, input().split())) for i in range(h)]
        tmp = list(map(int, input().split()))
        p_cost = [tmp[2], tmp[3], tmp[0], tmp[1]]
        INF = int(1e5)
        mincost = [[[INF] * 4 for i in range(w)] for j in range(h)]
        q = deque()
        q.append((0, 0, 0, 3))
        while len(q) > 0:
            x, y, cost, from_ = q.popleft()
            # コストなしで進める方向
            if board[y][x] == 0:# 直進: (from_ + 2) % 4
                no_cost = (from_ + 2) % 4
            elif board[y][x] == 1:# 右折: (from_ + 3) % 4
                no_cost = (from_ + 3) % 4
            elif board[y][x] == 2:# 反転: from_
                no_cost = from_
            elif board[y][x] == 3:# 左折: (from_ + 1) % 4
                no_cost = (from_ + 1) % 4
            else:# 停止: なし
                no_cost = -1
            for i, (nx, ny) in enumerate([(x, y-1), (x+1, y), (x, y+1), (x-1, y)]):
                if i == no_cost:
                    next_cost = cost
                else:
                    next_cost = cost + p_cost[(i+4-from_)%4]
                if mincost[y][x][i] > next_cost:# 最小値を更新
                    mincost[y][x][i] = next_cost
                    # マスが存在する場合はqに入れる
                    if 0 <= nx and nx < w and 0 <= ny and ny < h:
                        q.append((nx, ny, next_cost, (i + 2) % 4))
        # print(mincost)
        print(min(mincost[h-2][w-1][2], mincost[h-1][w-2][1]))



if __name__ == "__main__":
    main()


Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(q);
  rep(i,q){
    cin >> a.at(i);
    a.at(i)--; // 0-indexedにする
  }

  vector<int> p(n,k-q); //n人分のポイントを管理する配列　初期値はk-q
  //正解者の得点を増やしていく
  rep(i,q){
    p.at(a.at(i))++;
  }
  //勝ち抜け者を出力していく
  rep(i,n){
    if(p.at(i)>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, K;
vector<int> A;
const int MAX_K = 100010;
int dp[MAX_K][2];

int memo(int k, int turn)
{
    if (k == 0)
    {
        return !turn;
    }
    if (dp[k][turn] != -1)
    {
        return dp[k][turn];
    }
    int &res = dp[k][turn];
    res = !turn;
    for (int i = 0; i < N; i++)
    {
        if (k - A[i] >= 0)
        {
            int tmp = memo(k - A[i], !turn);
            if (tmp == turn)
            {
                res = turn;
                return res;
            }
        }
    }
    return res;
}
int main()
{
    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    memset(dp, -1, sizeof(dp));
    int res = memo(K, 0);
    if (res == 0)
    {
        cout << "First" << endl;
    }
    else
    {
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int bar[N];
  for(int i=0;i<N;i++){cin >> bar[i];}
  sort(bar,bar+N,greater<int>());
  int output = 0;
  for(int i=0;i<K;i++){output+=bar[i];}
  cout << output << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

bool cmp(const pair<int,char> &a,const pair<int,char> &b){
	return a.first > b.first;
}
int main(){
	int x,y;
	while(cin >> x >> y , x){
		int ans = 0;
		if(y>x)swap(x,y);
		while(y){
			x = x%y;
			swap(x,y);
			ans++;
		}
		cout << x << " " << ans << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

long long int a, b;
int main() {
	cin >> a >> b;
	long long int ret;
	if (a == 1 || b == 1) {
		if (a == 1 && b == 1) {
			ret = 1;
		} else {
			ret = max(a - 2, b - 2);
		}
	} else if (a == 2 || b == 2) {
		ret = 0;
	} else {
		ret = (a - 2)*(b - 2);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
s = int(input())

ls = [False for _ in range(1000001)]
ls[s] = True

count = 1
while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if ls[s]:
        break
    ls[s] = True
    count += 1
print(count + 1)

Measured memory_bytes: 10904
#include <stdio.h>
int main()
{
  int a,b,x,y,d,r;
  scanf("%d%d",&x,&y);
  if(x>=y)
    {
      r=x%y;
      for(d=r;d>=1;d--)
	{
	  a=y%d;
	  b=r%d;
	  if(a==0&&b==0)break;
	}
    }
  if(y>=x)
    {
      r=y%x;
      for(d=r;d>=1;d--)
	{
	  a=x%d;
	  b=r%d;
	  if(a==0&&b==0)break;
	}
    }
  if(x==y)
    {
      d=x;
      a=x%d;
      b=y%d;
    }
  printf("%d",d);
  printf("\n");
  return 0;
}




Measured memory_bytes: 2124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int>>
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long>>
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
    DRII(x,y);
    cout<<y*2-x;
    return 0;
}


Measured memory_bytes: 256
<?php
class Line {
    protected $lineData;
    protected $pointer;
    public function __construct(array $line)
    {
        $this->lineData = $line;
        $this->pointer = 0;
        $this->count = count($line);
    }

    public function next()
    {
        if ($this->count > $this->pointer) {
            return $this->lineData[$this->pointer++];
        }
        return false;
    }

    public function getData()
    {
        return $this->lineData;
    }
}

class IOW {
    /**
     * @return Line
     */
    public static function nl()
    {
        $str = trim(fgets(STDIN));
        return new Line(explode(' ', $str));
    }

    public static function out($data)
    {
        print_r ($data . PHP_EOL);
    }
}


$line = IOW::nl();
$cardCount = $line->next();
$action = $line->next();
$list = IOW::nl();
$candidate = array_count_values($list->getData());

// harumekisanのやつ
// keyに数を使うのが思いつかなった。領域を減らせる
for ($i = 0; $i < $action; $i++) {
    $change = IOW::nl();
    $newCount = $change->next();
    $number = $change->next();
    if (isset($candidate[$number])) {
        $candidate[$number] += $newCount;
    } else {
        $candidate[$number] = $newCount;
    }
}

krsort($candidate);
$total = 0;
foreach ($candidate as $num => $count) {
    $addCount = min ($cardCount, $count);
    $total += $num * $addCount;
    $cardCount -= $addCount;
    if($cardCount == 0) {
        break;
    }
}
IOW::out($total);

Measured memory_bytes: 23540
N,M = map(int,input().split())
A = list(map(int,input().split()))

test = [0]*N

A = list(map(lambda x: x*(-1) ,A))

import heapq

heapq.heapify(A)

for i in range(M):
    temp = ( heapq.heappop(A) * (-1) ) // 2 * (-1) 
    heapq.heappush(A,temp)
    if A == test:
        break

total = sum(A) * (-1)
print(total)


Measured memory_bytes: 14100
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N) {
  double ans = 0;
  double BTC = 380000.0;
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * BTC;
    }
  }
  printf("%f\n", ans);
}

int main() {
  int N;
  cin >> N;
  solve(N);
  return 0;
}

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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    if(A*N>B){
        printf("%d\n",B);
    }else{
        printf("%d\n",A*N);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double n;
  while(cin >>n){
    double ans = n;
    for(int i=2; i<=10; i++){
      if(i%2 == 0) n*=2;
      else n/=3;
      ans+=n;
    }
    printf("%.8lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

int main(){
  char line[100], pre[100], c = 'A';
  int count=0, max=0;
  int N;
  array<int, 26> s1{0};
  array<int, 26> s2{0};

  scanf("%d", &N);
  scanf("%s", line);

  for(int d=1; d<N-1; d++){
   for(int i=0; i<d; i++){
      s1[line[i]-'a'] += 1;
    }
   for(int i=d; line[i] != '\0'; i++){
      s2[line[i]-'a'] += 1;
   }
   for(int i=0; i<26; i++){
    if(s1[i] != 0 && s2[i] != 0){count++;}
   }
  if(count > max){ max=count;}
  count = 0; 
  s1.fill(0);
  s2.fill(0);
  }
  printf("%d\n", max);
 }


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
t = 0
for a in A[2:]:
    t ^= a
s = sum(A[:2])
if s < t or (s ^ t) & 1:
    print(-1)
    exit()
 
u = (s - t) // 2
a = A[0]
n = 0
for i in range(40)[::-1]:
    b, c = (t >> i) & 1, (u >> i) & 1
    if b == c == 1:
        print(-1)
        exit()
    if b == 0 and c == 1:
        n += 1 << i
for i in range(40)[::-1]:
    b, c = (t >> i) & 1, (u >> i) & 1
    if b == 1 and c == 0:
        if n + (1 << i) <= a:
            n += 1 << i
 
if n > a or n == 0:
    print(-1)
else:
    print(a - n)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main()
{
	map<int,int> m;
	int N;
	cin>>N;
	int a;
	for(int i=0;i<N;i++){
		cin>>a;
		m[a]++;
		if(m[a]!=1){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
using System;
using static System.Console;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int H, W, h, w;
            string[] input;
            input = ReadLine().Split(' ');
            H = int.Parse(input[0]);
            W = int.Parse(input[1]);
            input = ReadLine().Split(' ');
            h = int.Parse(input[0]);
            w = int.Parse(input[1]);

            int ans = (H - h) * (W - w);
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
int main(){
  int i,a,r=0,s=0,n;
  for(i=0;i<5;i++){
    scanf("%d",&a);
    n=10-a%10;
    if(n==10)n-=10;
    s+=a+n;
    if(r<n&&n!=0)r=n;
  }
  printf("%d",s-r);
  return 0;
}

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

map<ll, char>have;

inline int read() {
  int s = 0, t = 1; char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * t;
}

const int N = 100001;

ll n, m;
char s[N], t[N], ans[N << 2];

int main() {
  n = read();
  m = read();
  scanf ("%s", s + 1);
  scanf ("%s", t + 1);
  ll GCD = __gcd(max(m, n), min(m, n));
  ll LCM = n * m / GCD;
  ll poss = LCM / n, post = LCM / m, nows = 1, nowt = 1;
  for (int i = 1; i <= n; i++) {
    have[nows] = s[i];
    nows += poss;
  }
  for (int i = 1; i <= m; i++) {
    if (have[nowt] == 0) have[nowt] = t[i];
    else {
      if (have[nowt] != t[i]) {
        cout<<-1<<endl;
        return 0;
      }
    }
    nowt += post;
  }
  cout<<LCM<<endl;
  return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> war(m);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        war[i] = {b,a};
    }
    sort(war.begin(),war.end());
    int nowend = war[0].first;
    int ans = 1;
    for(int i = 0; i < m; i++){
        if(war[i].second >= nowend){
            ans++;
            nowend = war[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int64,int64>;

int main() {
    int n;
    cin >> n;
    vector a(n,0LL);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());

    priority_queue<int64> pq;
    pq.emplace(a[0]);

    int64 ans = 0;
    for (int i=1; i<n; i++) {
        ans += pq.top(); pq.pop();
        pq.emplace(a[i]);
        pq.emplace(a[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6456
n,m,x=map(int,input().split())
a=[]
num=[]
for i in range(n):
    inp=list(map(int,input().split()))
    a.append(inp[1:])
    num.append(inp[0])
ans=10**12
flag=0
for i in range(2**n):
    f=0
    s=0
    cnt=[0]*m
    for j in range(n):
        if (i>>j & 1):
            for k in range(m):
                cnt[k]+=a[j][k]
            s+=num[j]
    for l in range(len(cnt)):
        if cnt[l]<x:
            f=1
    if f==0:
        ans=min(ans,s)
        flag=1
if flag==1:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 8952
($t[0],$t[1])=glob<>;
@l=map{[glob<>]}(0..2);
@p=sort{$$b[1]<=>$$a[1]}map{$c=$_;map{[$c,$_]}@{$l[$c]}}(0..2);
$a=$t[1]+$t[0];
for(;0<$a;$i++){
  ($e,$f)=@{$p[$i]};
  (2-$e)&&($t[$e]?$t[$e]--:next);
  $d+=$f;$a--;
}
print$d

Measured memory_bytes: 112004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int c = 1;
  rep(i, N - 1) {
    if(vec.at(i) < vec.at(i + 1)) {
      c++;
    }
  }
  cout << c << endl;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a >> b >> c;
    if ((10*b+c)%4 == 0)
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 2e5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n, m;
    cin >> n >> m;
    ll a[n], acc[n], ans = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i < n; i++)
        acc[i] = a[i] + (i ? acc[i - 1] : 0);
    int low = 2, high = 2e5, mid;
    while(low <= high)
    {
        mid = (low + high) / 2;
        ll val = 0, shakes = 0;
        for (int i = 0; i < n; i++)
        {
            int low2 = 0, high2 = i, mid2, len = -1;
            while(low2 <= high2)
            {
                mid2 = (low2 + high2) / 2;
                if (a[i] + a[mid2] >= mid)
                    high2 = mid2 - 1, len = i - mid2 + 1;
                else
                    low2 = mid2 + 1;
            }
            if (~len)
            {
                shakes += (len * 2 - 1);
                val += (a[i] * (len * 2 - 2));
                val += 2 * (acc[i] - (i >= len ? acc[i - len] : 0));
            }
        }
        if (shakes < m)
            high = mid - 1;
        else
        {
            low = mid + 1;
            ans = val - mid * (shakes - m);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
n=int(input());l=[0,1];a=0;b=c=1;p=998244353
for i in range(2,n):
 l+=[l[p%i]*(p-int(p/i))%p]
for i in range(n,n//2,-1):
 a+=b*c%p;b=2*b%p;c=c*i*l[n+1-i]%p
print((pow(3,n,p)-2*a+p)%p)

Measured memory_bytes: 193148
# coding: utf-8
# Your code here!
import sys
ans = input().split("/")
for i in range(3):
    ans[i] =int(ans[i])

if ans[0]<=2019:
    if ans[1]>=5:
        print("TBD")
    else:
        print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){


	int n, i, h, R;
	char M;
	int flag[4][13];
	
	//?????°????????????
		for(i = 0; 4 > i; i++){
			for(h = 0; 13 > h; h++){
				flag[i][h] = 0;
			}
		}

	scanf("%d", &n);
	
	//??????????????\???????´?
	for(i = 0; n > i; i++){
		scanf(" %c %d", &M, &R);

		if(M == 'S')
			flag[0][R-1] = 1;
		if(M == 'H')
			flag[1][R-1] = 1;
		if(M == 'C')
			flag[2][R-1] = 1;
		if(M == 'D')
			flag[3][R-1] = 1;

	}


	//????´???????????????????????????¢??????????????????
		for(i = 0; 4 > i; i++){
			for(h = 0; 13 > h; h++){
				if(flag[i][h] == 0){
					if(i == 0)
						printf("S %d\n", h+1);
					if(i == 1)
						printf("H %d\n", h+1);
					if(i == 2)
						printf("C %d\n", h+1);
					if(i == 3)
						printf("D %d\n", h+1);
				}
			}
		}

	return 0;
	
}

Measured memory_bytes: 596