akhauriyash/Code-Regression huggingface dataset:
N = $stdin.gets.to_i
A = $stdin.gets.split.map {|i| i.to_i }
r = 1
0.upto(N - 1) do |i|
  if A[i] == 0
    puts "0"
    exit
  end
end
0.upto(N - 1) do |i|
  if (r *= A[i]) > 10 ** 18
    puts "-1"
    exit
  end
end
puts r


Measured memory_bytes: 21600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,time,c[1006],t[1006],mini = INT_MAX;
    bool flag = 1;
    cin>>n>>time;
    for(int i=0; i<n; i++)
    {
        cin>>c[i]>>t[i];
    }
    for(int i=0; i<n; i++)
    {
        if(t[i]<= time && c[i] < mini)
        {
            mini = c[i];
            flag =0;
        }
    }
    if(!flag)cout<<mini;
    else cout<<"TLE";
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a, b = n.times.map{gets.split.map(&:to_i)}.transpose
max_ab = -100000000000
min_ab = 100000000000
max_a_b = -100000000000
min_a_b = 100000000000
n.times do |i|
  max_ab = [max_ab,a[i]+b[i]].max
  min_ab = [min_ab,a[i]+b[i]].min
  max_a_b = [max_a_b,a[i]-b[i]].max
  min_a_b = [min_a_b,a[i]-b[i]].min
end
puts [max_ab-min_ab,max_a_b-min_a_b].max

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

int main() {
  int A;
  rep(i, 5){
    cin >> A;
    if(A==0){
      cout << i+1 << endl;
      break;
    }
  }
}
  

Measured memory_bytes: 3592
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

bool solvable(vector<int>& a, int to) {
    for (int elem: a)
        to += elem;

    if (to < 0 or to % 2 == 1)
        return false;
    to /= 2;
    
    vector<char> ok(to + 1);
    ok[0] = 1;
    
    for (int elem: a)
        for (int i = to - elem; i >= 0; --i)
            ok[i + elem] or_eq ok[i];
    return ok[to];
}

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    
    int mode = -1;
    int streak = 0;
    vector<int> X;
    vector<int> Y;

    string s = input<string>();
    int x = input<int>();
    int y = input<int>();
    
    for (char ch: s) {
        if (ch == 'T') {
            if (mode == -1)
                mode = 0;
            mode ^= 1, streak = 0;
        } else {
            if (mode == -1)
                x -= 1;
            else {
                ++streak;
                if (streak == 1)
                    (mode == 0 ? X : Y).push_back(1);
                else
                    (mode == 0 ? X : Y).back() += 1;
            }
        }
    }

    if (solvable(X, x) and solvable(Y, y))
        cout << "Yes\n";
    else 
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (s, t) = InputLine.to_sa
  (a, b) = InputLine.to_ia
  u = InputLine.to_s

  if s == u then
    puts [a - 1, b].map(&:to_s).join(' ')
  else
    puts [a, b - 1].map(&:to_s).join(' ')
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=100005;
const LL inf=(LL)1e15;

int n,cnt,root,last[N],size[N],f[N];
LL mn,dis[N],ans;
struct edge{int to,next,w;}e[N*2];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void addedge(int u,int v,int w)
{
	e[++cnt].to=v;e[cnt].w=w;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].w=w;e[cnt].next=last[v];last[v]=cnt;
}

void get_root(int x,int fa)
{
	size[x]=1;
	for (int i=last[x];i;i=e[i].next)
	{
		if (e[i].to==fa) continue;
		get_root(e[i].to,x);
		size[x]+=size[e[i].to];
		f[x]=max(f[x],size[e[i].to]);
	}
	f[x]=max(f[x],n-size[x]);
	if (!root||f[x]<f[root]) root=x;
}

void dfs(int x,int fa)
{
	if (fa) mn=min(mn,dis[x]);
	ans+=dis[x]*2;
	for (int i=last[x];i;i=e[i].next)
	{
		if (e[i].to==fa) continue;
		dis[e[i].to]=dis[x]+e[i].w;
		dfs(e[i].to,x);
	}
}

int main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read(),z=read();
		addedge(x,y,z);
	}
	get_root(1,0);
	mn=inf;dfs(root,0);
	if (n%2==0&&f[root]==n/2)
	{
		for (int i=last[root];i;i=e[i].next)
			if (f[e[i].to]==n/2) {ans-=e[i].w;break;}
	}
	else ans-=mn;
	printf("%lld",ans);
	return 0;
}

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

typedef pair<int,int > pp;
typedef long long ll;

int const N=2e5+10,oo=1e9,M=64;
ll const OO=1e18;
int mod=oo+7;
double const eps=1e-4,PI=acos(-1);

int aa[2],cnt[2];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(aa[0]==0||aa[0]==a){
            aa[0]=a;
            cnt[0]++;
        }else if(aa[1]==0||aa[1]==a){
            aa[1]=a;
            cnt[1]++;
        }else{
            cout<<"No\n";
            return 0;
        }
    }
    if(cnt[0]==n){
        if(aa[0]==n-1||aa[0]*2<=n||aa[0]==1)cout<<"Yes\n";
        else cout<<"No\n";
        return 0;
    }
    if(abs(aa[1]-aa[0])>1){
        cout<<"No\n";
        return 0;
    }
    if(aa[1]>aa[0])swap(aa[1],aa[0]),swap(cnt[0],cnt[1]);
    aa[0]-=cnt[1];
    n-=cnt[1];
    if(aa[0]*2<=n&&aa[0]>0)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    char a;
    cin >> a;
    if(isupper(a)) cout << 'A' << endl;
    else cout << 'a' << endl; 
} 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    long long N, K, n;
    long long ans = 99999999999;
    cin >> N >> K;
    vector<long long> h;
    for(int i = 0; i < N; i++){
        cin >> n;
        h.push_back(n);
    }
    K -= 1;

    sort(h.begin(), h.end());

    for(int i = K; i < N; i++){
        ans = min(h[i] - h[i - K], ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

class SCC{
    public:
        int V;  //????????°
        vector<vector<int>> G,rG;   //??£??\??????????????°????????¨????????????????????°??????
        vector<int> vs;     //??°?????????????????????
        vector<bool> used;
        vector<int> cmp;    //?±????????????£????????????????????????????????????

        SCC(int N):V(N),G(N),rG(N),used(N,false),cmp(N){}

        void add_edge(int from,int to){
            G[from].push_back(to);
            rG[to].push_back(from);
        }

        void dfs(int v){
            used[v]=true;
            for(int nv:G[v]){
                if(!used[nv]) dfs(nv);
            }
            vs.push_back(v);
        }

        void rdfs(int v,int k){
            used[v] = true;
            cmp[v] = k;
            for(int nv:rG[v]){
                if(!used[nv]) rdfs(nv,k);
            }
        }

        int scc(){
            for(int v=0;v<V;v++){
                if(!used[v]) dfs(v);
            }
            used.assign(V,false);
            int k=0;
            for(int i=vs.size()-1;i>=0;i--){
                if(!used[vs[i]]) rdfs(vs[i],k++);
            }
            return k;
        }

};

int main(){
    int v,e;
    cin>>v>>e;
    SCC sc(v);
    rep(i,e){
        int s,t;
        cin>>s>>t;
        sc.add_edge(s,t);
    }
    sc.scc();
    int q;
    cin>>q;
    rep(i,q){
        int u,v;
        cin>>u>>v;
        if(sc.cmp[u]==sc.cmp[v]) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 4412
from collections import Counter

N,K = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
A2 = dict(Counter(A))
i=0
r = [v for k,v in sorted(A2.items(),key=lambda x:-x[1])]
print(N- sum(r[0:K]))


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

const size_t MAX_N = (size_t) 1e5 + 5;
typedef long long ll;

ll a[MAX_N];

namespace BLESS_ME {
    int main() {
        ll n, k, gcd, mx;
        cin >> n >> k;
        for (int i = 0; i < n; i++) cin >> a[i];
        gcd = mx = a[0];
        for (int i = 1; i < n; i++) gcd = __gcd(gcd, a[i]), mx = max(mx, a[i]);
        if (k % gcd || k > mx) return cout << "IMPOSSIBLE", 0;
        cout << "POSSIBLE";
        return 0;
    }
}

int main() {
    return BLESS_ME::main();
}

Measured memory_bytes: 1024
#include <stdio.h>

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	if(x >= y)
		printf("%d\n",calc(x,y));
	else{
		printf("%d\n",calc(y,x));
	}
}




 



Measured memory_bytes: 2768
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int> (n - 1));

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n - 1; j++) {
      cin >> a[i][j];  
      a[i][j]--;
    }
  }

  vector<int> idxs(n, 0);
  int ans = 1;
  
  set<int> st;
  set<int> end;
  for(int i = 0; i < n; i++) st.insert(i); 
  
  while(1) {

    if(st.size() == 0){

      cout << -1 << endl;
      return 0;
    }
    set<int> nxtst;
    
    for(auto x : st) {
      
      int player = x;
      int pid = idxs[player];
      if(pid >= n - 1) continue;
      int oponent = a[player][pid];
      int oid = idxs[oponent];

      if(nxtst.find(player) != nxtst.end()) continue;
      if(nxtst.find(oponent) != nxtst.end()) continue;
      if(oid >= n - 1) continue;
      if(player == a[oponent][oid]){
        
        
        idxs[player]++;
        idxs[oponent]++;

        if(idxs[player] == n - 1) end.insert(player);
        if(idxs[oponent] == n - 1) end.insert(oponent);

        nxtst.insert(player);
        nxtst.insert(oponent);
      }
    }
  
    if(end.size() == n) break;
    ans++;

    st.clear();
    st = nxtst;
    nxtst.clear();
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;



signed main(){
	string s;
	cin >> s;
	int ta = 0;
	char mu = 'A';
	for (int i = 0; i < s.size(); i++) {
		if (mu != s[i]) {
			ta++;
			mu = s[i];
		}
	}
	cout << ta - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
										//can this add const??
void dfs(int root, vector<int> &color, vector<vector<int> > &G, int color_id){
	//unordered_map<int, bool> visited; 
	color[root] = color_id;
	int v_size = G[root].size();
	for(int i = 0; i < v_size; i++){
		if(color[G[root][i]] == -1) dfs(G[root][i],  color, G, color_id);
	}
	//cout << "DEBUG2" << color_id << endl;
}


int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<int> > G(n);//adj list
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	//cout << "DEBUG" << endl;
	//assign color
	vector<int> color(n, -1);
	int color_id = 0;
	for(int u = 0; u < n; u++){
		if(color[u] == -1) dfs(u, color, G, color_id++);
	}
	//cout << "DEBUG1" << endl;
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int u, v;
		cin >> u >> v;
		if(color[u] == color[v]) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 14952
#include <stdio.h>
#include <string.h>
int main(void){
    char s[101],p[101],obj[201];
    scanf("%s",s);
    scanf("%s",p);
    obj[0]='\0';strcat(obj,s);strcat(obj,s);
    printf ("%s\n",(strstr(obj,p)!=NULL)? "Yes":"No"); 
    return 0;
}


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

int main() {
  int64_t N,K;
  cin >> N >> K;
  if(N<=K){
    cout << min(K-N, N) << endl;
    return 0;
  }
  
  cout << min(N - K*(N/K), K-(N - K*(N/K))) << endl;
  
}


// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    int n,a,b,maxx=0,x=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(maxx<=a)
        {
            maxx=a;x=b;
        }
       
    }
     cout<<maxx+x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;

  int na = 0;
  int nb = 0;

  for (auto c : s) {
    if (c == 'A') ++na;
    if (c == 'B') ++nb;
  }

  if (na == 2 || nb == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 760
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		int H = cin.nextInt();
		
		int a[] = new int[N];
		int b[] = new int[N];
		
		for (int i=0; i<N; i++) {
			a[i] = cin.nextInt();
			b[i] = cin.nextInt();
		}
		cin.close();
		
		Arrays.sort(a);
		Arrays.sort(b);
		
		int index_a = a.length-1;
		int index_b = b.length-1;
		int attack = 0;
		
		while (true) {
			if (index_b >=0 && b[index_b] > a[index_a]) {
				H = H - b[index_b];
				index_b--;
			} else {
				H = H - a[index_a];
			}
			
			attack++;
			if (H <= 0) break;
		}
		
		System.out.println(attack);
	}

}


Measured memory_bytes: 72364
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	cin >> N;
	auto box = s.find("222");
	for (int i = 0; i < N; i++) {
		string t;
		cin >> t;
		t += t;
		if (t.find(s)!=box)M++;
	}
	cout << M << endl;
	return 0;
} 


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    int S, W;

    cin >> S >> W;

    if (S > W) {
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007LL
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int r,g;
    cin >> r >> g;
    cout << 2*g - r;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
//---------------------------------------
bool check_sosu(int x);  //sosu = ?´???°(not?????°!!)
//---------------------------------------

int main(void)
{
	int num;
	int num_sosu = 0;
	
	cin >> num;
	
	for(int i = 0; i < num; i++){
	 int a;
	 cin >> a;
	 if(check_sosu(a)){  //check_sosu(a)????´???°??????true
	 	num_sosu++;
	 }
	}
	
	cout << num_sosu << endl;
	 
	return 0;
}
//--------------------------------------------
bool check_sosu(int x)
{
	if(x == 1){
		return false;
	}
	for(int i = 2; i <= sqrt(x); i++){
		int amari = x % i;
		if(!amari){
			return false;
		}
	}
	return true; //2~3???????????????2???????????????for?????????????????????true
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    string s;
    cin>>s;
    int cnt=0;
    char bef=s[0];
    REP(i,1,sz(s)){
        if(bef!=s[i]){
            cnt++;
            bef=s[i];
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll x;
    cin >> x;
    cout << ll(x / 500) * 1000 + ll((x % 500) / 5) * 5 << endl;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

s = input()
ans = 'x'*len(s)
print(ans)

Measured memory_bytes: 4084
def mx(ls,m):
	global n
	sum = 0
	for i in range(m):
		sum += (n-i)*ls[-i-1]
	return sum

def mn(ls,m):
	global n
	sum = 0
	for i in range(m):
		sum += (n-i)*ls[i]
	return sum
	
def f(ls,m,s):
	global n
	count = 0
	if m > 0:
		vmx,vmn = mx(ls,m),mn(ls,m)
		if vmx < s or vmn > s: return 0
		elif vmx == s or vmn == s: return 1
		for i in range(len(ls)):
			lls = ls[:]
			a = (n-m+1)*lls.pop(i)
			if s-a < 0:	break
			else: count += f(lls,m-1,s-a)
		return count
	else:
		return 1 if s == 0 else 0
			
ls = [i for i in range(10)]
while True:
	try:
		n,s = map(int, raw_input().split())
                if mx(ls,n) > 330:
                    print 0
		else: print f(ls,n,s)
	except:
		break

Measured memory_bytes: 4272
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
   int n;
    cin>>n;
    int c=0;
    int f=1;
  int a[n];
    for(int i=0;i<n;i++)
    {
       cin>>a[i];
    }
    while(true)
    {
        for(int i=0;i<n;i++)
    {
       if(a[i]%2==0)
           a[i]=a[i]/2;
            else
            {
                f=0;
                break;
            }
        }
            if(f==0)
                break;
            else
                c++;
    }
    
    cout<<c;
    return 0;
}

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



double rec(int x, double p) {
	if (x % 2)
		return p * rec(x - 1, p) + (1 - p) * rec(x + 1, p) + 1;
	
	return x / p / 2;
}
//-----------------------------------------------------------------
int main() {
	int x, p;
	cin >> x >> p;
	double ans = rec(x, p / 100.0);
	printf("%.10f\n", ans);
}

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

class Node:
    def __init__(self):
        self.count = 0
        self.check = False
        self.link = []

def main():
    # N = int(input())
    N, Q = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input().strip()
    
    nodes = [Node() for i in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        nodes[a].link.append(nodes[b])
        nodes[b].link.append(nodes[a])
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        nodes[p].count += x
    
    q = deque()
    q.append([nodes[0], 0])
    while len(q) > 0:
        node, cost = q.popleft()
        node.check = True
        node.count += cost
        cost = node.count
        for nex in node.link:
            if not nex.check:
                q.append([nex, cost])
    
    for i in range(N-1):
        print(nodes[i].count, end=" ")
    print(nodes[-1].count)


if __name__ == "__main__":
    main()

Measured memory_bytes: 88428
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int check(ll a,ll b,ll k){
	ll val=(b+k);
	if(val>=a*b)
		return 0;
	val=k*(b+1);
	if(val>=a*b)
		return 0;
	if(b+k+1>=2*k){
		return 1; 
	}
	if((b+k+1)*(b+k+1)-4*a*b<0)
		return 1;
	return 0;

}
int main(){
    std::ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--){
    	ll a,b;
    	cin>>a>>b;
    	if(a<b){
    		swap(a,b);
    	}
    	ll bigg=b-1;
    	ll  low=1;
    	ll  mid,high=a-1,ans=0;
    	while(low<=high){
    		mid=(low+high)/2;
    		if(check(a,b,mid)){
    			ans=mid;
    			low=mid+1;
    		}
    		else{
    			high=mid-1;
    		}

    	}
    	//cout<<ans<<endl;
    	bigg+=ans;
    	cout<<bigg<<endl;
    }
    return 0;  
    
}



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

using namespace std;
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
typedef int64_t ll;

int main()
{
	int n;
	cin >>n;
	int frq[6]={};
	const double lmt[] ={165, 170, 175, 180, 185, 99999};
	rep(i,n){
		double s;
		cin >>s;
		rep(j,6){
			if(s < lmt[j]){frq[j]++; break;}
		}
	}
	
	rep(i, 6){
		printf("%d:%s\n" ,i+1 ,string(frq[i], '*').c_str());
	}
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<lli> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
int n;

vector<vector<lli>> multiply(vvi &a, vvi &b){
	vvi c(n,vi(n,0));
	for(int i=0; i < n; i++){
		for(int j=0; j < n; j++){
			for(int k =0; k < n; k++){
				c[i][j]= (c[i][j] + (a[i][k] * b[k][j])%mod)%mod;
			}
		}
	}
	return c;
}

vvi modpow(vvi a, lli b){
	vvi ans(n,vi(n,0));
	for(int i=0; i <n; i++)
		for(int j=0; j < n; j++) if(i == j) ans[i][j] = 1ll;
	
	while(b){
		if(b&1ll) ans = (multiply(a,ans));
		b>>=1ll;
		a = multiply(a,a);
	}

	return ans;
}

int main(){__
	lli k;
	cin >> n >> k;
	vvi mat(n,vi(n));
	for(int i=0; i<n; i++){
		for(int j=0; j<n;j++){
			cin >> mat[i][j];
		}
	}

	vvi ans = (modpow(mat,k));
	lli res =0ll;
	for(int i=0; i < n; i++){
		for(int j=0; j < n; j++){
			res = (res + ans[i][j]) % mod;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int main(void){
  char s[1001] , t[1001];

  scanf("%s %s",s,t);

  int len_s = strlen(s) , len_t = strlen(t);
  int min = 100000 , count = 0;

  for(int i = 0;i < len_s - len_t+1;i ++){
    for(int j = 0;j < len_t;j ++){
      if(s[i+j] != t[j]){
        count ++;
      }
    }
    //printf("%d\n",count);
    if(count < min){
      min = count;
    }
    count = 0;
  }

  printf("%d\n",min);

  return 0;
}

Measured memory_bytes: 1728
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()
#define BASE 100

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, a[maxN];

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);

    int ans = 0;
    fto(i, 1, n) {
        if (a[i] == i) {
            ++ans;
            ++i;
        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 768
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int group(int n){
	if(n == 2) return 1;
	if(n == 4 || n == 6 || n == 9 || n == 11) return 2;
	return 3;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int x, y;
	cin >> x >> y;
	if(group(x) == group(y)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  vector<string> a = {"dream", "dreamer", "erase", "eraser"};
  int m = a.size();
  string s;
  cin >> s;
  reverse(all(s));
  int n = s.size();
  REP(i,m) reverse(all(a[i]));
  int ok = 1;
  for (int i=0; i<n;) {
    int ok2 = 0;
    REP(j,m) {
      if (s.substr(i,a[j].size()) == a[j]) {
        ok2 = 1;
        i += a[j].size();
      }
    }
    if (!ok2) {
      ok = 0;
      break;
    }
  }
  puts(ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> dp(10, vector<int>(10, 0));
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> dp[i][j];
        }
    }
    for(int k = 0; k < 10; k++) {
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                if (dp[i][k] + dp[k][j] < dp[i][j])
                    dp[i][j] = dp[i][k] + dp[k][j];
            }
        }
    }
    ll ans = 0, val = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> val;
            if (val != -1)
                ans += dp[val][1];
        }
    }
    cout << ans << endl;
    return 0;
}




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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define nl '\n'
#define all(x) (x).begin(), (x).end()
#define int_max numeric_limits<int>::max()
#define int_min numeric_limits<int>::min()
#define ll_max numeric_limits<ll>::max()
#define ll_min numeric_limits<ll>::min()

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

// custom sort example
//sort(all(a), [ ]( const auto& c, const auto& d) {
	//if (c.fi.se != d.fi.se) {
		//return c.fi.se < d.fi.se; // lower first
	//}
	//if (c.fi.fi != d.fi.fi) {
		//return c.fi.fi > d.fi.fi; // higher first
	//}
	//return c.se > d.se; // higher first
//});

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n;
	ll ft = ll_max, fd = ll_max, st = ll_max, sd = ll_max, pom = (1000000000 - 1);
	cin >> n;
	for (int z = 0; z < n; z++) {
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		ft = min(ft, x + y);
		fd = min(fd, x + (pom - y));
		st = min(st, (pom - x) + y);
		sd = min(sd, (pom - x) + (pom - y));
	}
	debug() << im(ft) im(fd) im(st) im(sd);
	ll res = 0;
	res = max(res, pom + pom - ft - sd);
	res = max(res, pom + pom - fd - st);
	res = max(res, pom - ft - fd);
	res = max(res, pom - st - sd);
	res = max(res, pom - ft - st);
	res = max(res, pom - fd - sd);
	cout << res << nl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> alt;
    rep(i, N) alt.pb(A[i]);
    sort(all(alt));
    rep(i, N) {
        int it = lower_bound(all(alt), A[i]) - alt.begin();
        A[i] = it;
    }
    vector<int> nums(N);
    for (int i = 1; i < N; i += 2) {
        nums[i]++; nums[A[i]]++;
    }
    int res = 0;
    for (int i = 1; i < N; i += 2) {
        if (nums[i] == 2) res++;
    }
    cout << N / 2 - res << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int n, i, ans;
	scanf("%d", &n);
	if(n <= 9) ans = n;
	if(n >= 10 && n <= 99) ans = 9;
	if(n >= 100 && n <= 999) ans = 9+(n-99);
	if(n >= 1000 && n <= 9999) ans = 909;
	if(n >= 10000 && n <= 99999) ans = 9+900+(n-9999);
	if(n == 100000) ans = 90909;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  vector<int> a{0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a[x]==a[y]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int long long
#define mod 1000000007
#define maxN 1000005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pip pair<int,pii>
#define vi vector<int>
#define vpi vector<pii >
#define endl "\n"
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define repr(a,b,c) for(int(a) = b;a>=c;a--)
#define rep(i,n) for(int(i) = 0;i<n;i++)
#define fir first
#define sec second
#define beg begin()
#define e end()
#define len length()
using namespace std;
using namespace __gnu_pbds;
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;


int32_t main()
{
   fastIO;
   int k,x;
   cin>>k>>x;
   int low = max(-1000000ll,x-k+1);
   int hi = min(1000000ll,x+k-1);
   FOR(i,low,hi)cout<<i<<' ';

   return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  map<string,ll> mp;
  rep(i,n) {
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  for (auto x: mp)
    ans += (x.second)*(x.second - 1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 13968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var pqr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            pqr = pqr.OrderBy(x => x).ToArray();
            Console.WriteLine(pqr[0] + pqr[1]);
        }
    }
}


Measured memory_bytes: 13396
N=int(input())
X=list(map(int,input().split()))
a=min(X)
b=max(X)
dis=10**18
for k in range(a,b+1):
    D=0
    for i in range(N):
        D+=(X[i]-k)**2
    dis=min(dis,D)

print(dis)

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

int main(){
  int n;
  cin>>n;
  
  list<int> L;

  char com[20];
  //string com;
  int key;
  rep(i,n){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&key);
      L.push_front(key);
    }
    else if(com[6]=='F')L.pop_front();
    else if(com[6]=='L')L.pop_back();
    else if(com[0]=='d'){
      scanf("%d",&key);
      for(list<int>::iterator it=L.begin();it!=L.end();it++){
        if(*it==key){
          L.erase(it);
          break;
        }
      }
      
    }
  }

  int i=0;
  for(list<int>::iterator it=L.begin();it!=L.end();it++){
    if(i++)printf(" ");
    printf("%d",*it);
  }
  printf("\n");

  return 0;
 
} 


Measured memory_bytes: 34388
#include <iostream>

using namespace std;

char dx[] = {-1,1,0,0};
char dy[] = {0,0,-1,1};
int b[20][20];
int w, h, ans;

void dfs(int x, int y, int step){
	for(int i=0;i<4;i++){
		if(step == ans) return;
		int nx = x, ny = y;
		if(!(0<=nx+dx[i]&&nx+dx[i]<w&&0<=ny+dy[i]&&ny+dy[i]<h&&b[ny+dy[i]][nx+dx[i]]!=1)) continue;
		while(0<=nx+dx[i]&&nx+dx[i]<w&&0<=ny+dy[i]&&ny+dy[i]<h){
			if(b[ny+dy[i]][nx+dx[i]] == 3) { ans = step; break; }
			if(b[ny+dy[i]][nx+dx[i]] == 1) {
				b[ny+dy[i]][nx+dx[i]] = 0;
				dfs(nx,ny,step+1);
				b[ny+dy[i]][nx+dx[i]] = 1;
				break;
			}
			nx += dx[i], ny += dy[i];
		}
	}
}

int main(){
	int t;
	while(cin >> w >> h){
		if(!w) break;
		int sx, sy;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> t;
				if(t == 2) sx = j, sy = i, b[i][j] = 0;
				else       b[i][j] = t;
			}
		}
		ans = 11;
		dfs(sx,sy,1);
		cout << (ans != 11 ? ans : -1) << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

ll dp[52][52][2510];

int main() {
    int n, a; cin >> n >> a;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(i,n) rep(j,n) rep(k,a*n+1) {
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
    }
    ll ans = 0;
    repf(j,1,n+1) {
        ans += dp[n][j][a*j];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 53248
#include<stdio.h>
int main(void){
	int n,a,b,c[101],i,j,p,m=0,o=0;
	int t;
	scanf("%d %d %d %d",&n,&a,&b,&p);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	for(i=1;i<n;i++){
		for(j=n;j>i;j--){
			if(c[j]>c[j-1]){
				t=c[j];
				c[j]=c[j-1];
				c[j-1]=t;
			}
		}
	}
	for(i=1;i<=n;i++){
		t=p;
		t=t+o+c[i];
		o=t-p;
		if(m<t/(a+b*i)){
			m=t/(a+b*i);
		}
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 596
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();
		
		if(A>=K) {
			System.out.println(K);
		}
		if(A<K) {
			if((K-A)<=B) {
				System.out.println(A);
			}
			if((K-A)>B) {
				System.out.println(A-(K-(A+B)));
			}
		}
	}
}

Measured memory_bytes: 35616
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  cout<<max({a*c,a*d,b*c,b*d});
  
  return 0;
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string l;
    cin >> l;
    ll s = (ll)l.size();
    vvll dp(s,vll(2,0));
    dp[0][1]=1;
    for(int i=1;i<s;i++){
        if(l[i]=='1'){
            dp[i][1] = dp[i-1][1]*2;
            dp[i][0] = dp[i-1][1]+dp[i-1][0]*3;
            dp[i][0]++;
        }else{
            dp[i][1] = dp[i-1][1];
            dp[i][0] = dp[i-1][0]*3;
            dp[i][0]++;
        }
        dp[i][0] %= mod;
        dp[i][1] %= mod;
    }
    ll ans = dp[s-1][0]+dp[s-1][1];
    ans*=2;
    ans++;
    ans%=mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5840