akhauriyash/Code-Regression huggingface dataset:
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int X, A, B;
	std::cin >> X >> A >> B;
	std::cout << ((X-A)%B) << "\n";
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int q; cin >> q;
    multiset<int> L, R;
    ll tot = 0, totB = 0;
    
    while(q--){
        int t; cin >> t;
        if(t == 1){
            int a, b; cin >> a >> b;
            totB += b;
            L.insert(a); R.insert(a); 
            auto itl = L.end(); itl--;
            auto itr = R.begin();
            int l = *itl; int r = *itr;
            if(l > r){
                tot += l - r;
                L.erase(itl); L.insert(r);
                R.erase(itr); R.insert(l);
            }
            // cout << "totL, totR, totB = " << totL << ", " << totR << ", " << totB << endl;
        }else{
            ll l = *L.rbegin();
            cout << l << " " << tot + totB << endl;
        }
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 22292
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int oturi;
    for (int i = 0; i < 12; i++){
        int oturi = 1000*i - N;
        if (oturi > 0){
            cout << oturi << endl;
            return 0;
        }else if(oturi == 0){
            cout << 0 << endl;
            return 0;
        }
    }


    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll>A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        A[i] = (A[i] - 1) % K;
    }
    
    // 和が0 mod Kになる区間の個数
    // 区間の長さはK未満
    // multiset使うとTLE
    map<ll, int>mp;
    mp[0] = 0;
    vector<ll>sum(N+1, 0);
    for (int i = 1; i <= N; ++i) {
        sum[i] = sum[i-1] + A[i-1];
        sum[i] %= K;
        mp[sum[i]] = 0;
    }
    ll ans = 0;
    for (int i = 0; i < N+1; ++i) {
        ans += mp[sum[i]];
        mp[sum[i]]++;
        if(i >= K-1) {
            mp[sum[i-K+1]]--;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include<stdio.h>
int n,A[20];
int solve(int i,int m){
	int res=0;
	if(m==0){
		return 1;
	}else if(i>=n){
		return 0;
	}
	res=solve(i+1,m)||solve(i+1,m-A[i]);
	return res;
}
int main(){
	int q,m,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&m);
		if(solve(0,m)==1){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2096
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        final long A = s.nextLong();
        final double B = s.nextDouble();

        BigDecimal bdA = new BigDecimal(String.valueOf(A));
        BigDecimal bdB = new BigDecimal(String.valueOf(B));

        BigDecimal bdResult = bdA.multiply(bdB);

        System.out.println(bdResult.setScale(0, RoundingMode.DOWN));
    }
}

Measured memory_bytes: 29196
#include <stdio.h>

int main() {
	int a, b, c, d, e, k;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
	int dist = b - a;
	if(dist <= k){
		dist = c - a;
		if(dist <= k){
			dist = d - a;
			if(dist <= k){
				dist = e - a;
				if(dist <= k){
					dist = c - b;
					if(dist <= k){
						dist = d - b;
						if(dist <= k){
							dist = e - b;
							if(dist <= k){
								dist = d - c;
								if(dist <= k){
									dist = e - c;
									if(dist <= k){
										dist = e - d;
										if(dist <= k)
											printf("Yay!\n");
										else
											printf(":(\n");
									}
									else
										printf(":(\n");
								}
								else
									printf(":(\n");
							}
							else
								printf(":(\n");
						}
						else
							printf(":(\n");
					}
					else
						printf(":(\n");
				}
				else
					printf(":(\n");
			}
			else
				printf(":(\n");
		}
		else
			printf(":(\n");
	}
	else
		printf(":(\n");


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int X, N;
    cin >> X >> N;
    int p[101];
    int i;
    for (i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    bool flag1=0;
    bool flag2=0;
    for (i = 0;; i++)
    {
        flag1 = 0;
        flag2 = 0;
        for (int j = 0; j < N; j++)
        {
            if (X - i == p[j])
            {
                flag1 = 1;
            }
            if (X + i == p[j])
            {
                flag2 = 1;
            }
        }
        if (flag1 == 0 or flag2 == 0)
            break;
    }
    if (flag1 == 0)
        cout << X - i << "\n";
    else
        cout << X + i << "\n";
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int w,h,x,y,r;
    cin >> w;
    cin >> h;
    cin >> x;
    cin >> y;
    cin >> r;

    if(x-r<0||(x+r)>w)cout<<"No\n";
    else if((y-r)<0||(y+r)>h)cout<<"No\n";
    else cout<<"Yes\n";


    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (0<a && a<10 && 0<b && b<10) {
        cout << a*b <<endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++)
	{
		bool pos=0;
		for(int j=0;j<26;j++)
		{
			bool ps=1;
			for(int k=0;k<n-i;k++)
			{
				bool p=0;
				for(int l=k;l<=k+i;l++)
				{
					if(s[l]==j+'a')
					{
						p=1;
						break;
					}
				}
				if(!p) ps=0;
			}
			if(ps)
			{
				pos=1;
				break;
			}
		}
		if(pos)
		{
			cout<<i<<'\n';
			return 0;
		}
	}
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	map<llong, int> m;

	cin >> N;
	llong in;
	for(int i = 0; i < N; i++){
		cin >> in;
		m[in]++;
	}

	if(m.size()&1)
		cout << m.size() << endl;
	else
		cout << m.size()-1 << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main() {
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int count = 0;
    for(int i=0; i<=A; ++i){
        for(int j=0; j<=B; ++j){
            for(int k=0; k<=C; ++k){
                
                if(500*i + 100*j + 50*k == X){
                    ++count;
                }
                
            }
        }
    }
    
    cout << count << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort(a,a+3);

    if(a[2] == a[0]+a[1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	char S[64] = "";
	int sumipe = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%63s", S) != 1) return 1;
	for (i = 2; i < N && S[i] != '\0'; i++) {
		sumipe += S[i - 2] == 'A' && S[i - 1] == 'B' && S[i] == 'C';
	}
	printf("%d\n", sumipe);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] hist = new int[100];
		while(scan.hasNext()){
			hist[scan.nextInt()-1]++;
		}
		int max = 0;
		for(int i = 0;i < 100;i++){
			if(max < hist[i]){
				max = hist[i];
			}
		}
		for(int i = 0;i < 100;i++){
			if(max == hist[i]){
				System.out.println(i+1);
			}
		}
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    string s; cin >> s;
    ll n = s.size();
    if(n==5){
        if(s=="KIHBR"){
            puts("YES");
            return 0;
        }
    }else if(n==6){
        if(s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"){
            puts("YES");
            return 0;
        }
    }else if(n==7){
        if(s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"
           ||s=="KIHBARA"){
            puts("YES");
            return 0;
        }
    }else if(n==8){
        if(s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA"){
            puts("YES");
            return 0;
        }
    }else if(n==9){
        if(s=="AKIHABARA"){
            puts("YES");
            return 0;
        }
    }else{
        puts("NO");
        return 0;
    }
    puts("NO");
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    while(true)
    {
        int n,m,s1[100],s2[100];
        int sum1=0,sum2=0;

        cin>>n>>m;
        if(n==0 && m==0) break;

        REP(i,n) cin>>s1[i],sum1+=s1[i];
        REP(i,m) cin>>s2[i],sum2+=s2[i];

        int a=1e9,b=1e9;
        REP(i,n) REP(j,m){
            if(sum1-s1[i]+s2[j]==sum2+s1[i]-s2[j]){
                if(s1[i]+s2[j]<a+b) a=s1[i],b=s2[j];
            }
        }
        if(a==1e9) cout<<-1<<endl;
        else cout<<a<<" "<<b<<endl;
    }
}

Measured memory_bytes: 3112
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int N = S.size();

	int dp0 = 0;
	int dp1 = 1e9;
	for (int i = N - 1; i >= 0; i--) {
		int s = S[i] - '0';

		int tmp0 = dp0 + s;
		int tmp1 = dp1 + (9 - s);
		chmin(tmp0, dp1 + s + 1);
		chmin(tmp1, dp0 + (10 - s));

		dp0 = tmp0;
		dp1 = tmp1;
	}

	co(min(dp0, dp1 + 1));


	Would you please return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

class Node {
 public:
  int key;
  Node* parent;
  Node* left;
  Node* right;

  Node() {}
};

Node* NIL;
Node* root;

void Insert(const int& key) {
  Node* y = NIL;
  Node* x = root;
  Node* z = new Node();
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

Node* Find(Node* x, const int& value) {
  if (value == x->key) {
    return x;
  } else if (value < x->key && x->left != NIL) {
    return Find(x->left, value);
  } else if (value > x->key && x->right != NIL) {
    return Find(x->right, value);
  } else {
    return NIL;
  }
}

Node* TreeMin(Node* y) {
  if (y->left == NIL) {
    return y;
  } else {
    return TreeMin(y->left);
  }
}

void Delete(Node* z) {
  Node* target;  // delete target

  if (z->left != NIL && z->right != NIL) {
    target = TreeMin(z->right);
    z->key = target->key;
  } else {
    target = z;
  }

  Node* child;  // target's child
  if (target->left != NIL) {
    child = target->left;
  } else if (target->right != NIL) {
    child = target->right;
  } else {
    child = NIL;
  }

  if (child != NIL) {
    child->parent = target->parent;
  }

  if (target->parent == NIL) {
    root = child;
  } else {
    if (target == target->parent->left) {
      target->parent->left = child;
    } else {
      target->parent->right = child;
    }
  }
  delete target;
}

void PrintPreorder(const Node* node) {
  if (node == NIL) return;
  cout << " " << node->key;
  PrintPreorder(node->left);
  PrintPreorder(node->right);
}

void PrintInorder(const Node* node) {
  if (node == NIL) return;
  PrintInorder(node->left);
  cout << " " << node->key;
  PrintInorder(node->right);
}

int main() {
  root = NIL;
  int n;
  cin >> n;
  FOR(i, 0, n) {
    Node* node = new Node();
    string str;
    cin >> str;
    if (str == "insert") {
      int key;
      cin >> key;
      Insert(key);
    } else if (str == "find") {
      int value;
      cin >> value;
      if (Find(root, value) != NIL) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else if (str == "delete") {
      int value;
      cin >> value;
      Node* z = Find(root, value);
      Delete(z);
    } else if (str == "print") {
      PrintInorder(root);
      cout << endl;
      PrintPreorder(root);
      cout << endl;
    }
  }
  return 0;
}


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

ll INF = 1e+18;
int iINF = 1e9;

int 
main()
{

  ll N; cin >> N;

  vector<pair<ll, ll>> arr;
  ll ori = N;
  for(ll i = 2; i * i <= N; ++i){
    if(N % i != 0) continue;
    ll ex = 0;
    while(N % i == 0){
      ++ex;
      N /= i;
    }
    arr.push_back({i, ex});
  }
  if(N != 1) arr.push_back({N, 1});

  ll ans = 0;
  for(auto x: arr){
    ll count = 0;
    while(x.second > count){
      ++count;
      rep(i, 0, count) ori /= x.first;
      x.second -= count;
    }
    ans += count;
  }

  cout << ans << endl;

}

Measured memory_bytes: 3576
local n=io.read("n")
local maxz=math.mininteger
local minz=math.maxinteger
local maxw=math.mininteger
local minw=math.maxinteger
for i=1,n do
    local x,y=io.read("n","n")
    maxz=math.max(maxz,x+y)
    minz=math.min(minz,x+y)
    maxw=math.max(maxw,x-y)
    minw=math.min(minw,x-y)
end
print(math.max(maxz-minz,maxw-minw))

Measured memory_bytes: 2748
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int[] a=new int[N];
        int i;
        int max=0,min=1000;
        for(i=0;i<N;i++){
            a[i]=scan.nextInt();
            if(a[i]<min){
                min=a[i];
            }
            if(max<a[i]){
                max=a[i];
            }
        }
        System.out.println(max-min);

    }
}

Measured memory_bytes: 21972
#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
using namespace std;
const int N=2e5+5;
set<int>se[N];
typedef set<int>::iterator it;
int n,now,v[N],c[N],b[N],nex[N],head[N];
struct each{
	int a,id;
}a[N];
queue<int>que;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
int get(int x){
	int last=-1;
	it i=se[x].begin();
	for(;i!=se[x].end();++i)
		if(last+1==*i)	++last;
		else	break;
	return ++last;
}
int vis[N],tm[N],p[N];
int main(){
	//freopen("graph.out","w",stdout);
	//freopen("graph.in","r",stdin);

	n=read();
	for(register int i=1;i<=n;i++)
		++b[p[i]=read()];
	for(register int i=1;i<=n;i++)
		if(!b[i])	que.push(i);
	while(!que.empty()){
		int x=que.front(),k=get(x);
		que.pop(),se[p[x]].insert(k);
		if(!(--b[p[x]]))	que.push(p[x]);
	}
	int st;
	for(int i=1;i<=n;i++)
		if(b[i]){
			st=i,que.push(i);
			break;
		}
	while(!que.empty()){
		int x=que.front();
		que.pop(),tm[x]=get(x);
		if(se[p[x]].count(tm[x]))	vis[x]=1;
		se[p[x]].insert(tm[x]);
		if(p[x]==st){
			if(tm[x]==tm[st])	break;
			else{
				puts("POSSIBLE");
				return 0;
			}
		}
		que.push(p[x]);
	}
	for(int i=1;i<=n;i++)
		if(b[i]&&!vis[i])	se[p[i]].erase(tm[i]);
	int end=tm[st];
	que.push(st),se[st].insert(end);
	while(!que.empty()){
		int x=que.front();
		que.pop(),tm[x]=get(x);
		se[p[x]].insert(tm[x]);
		if(p[x]==st){
			if(tm[x]!=end)	break;
			else{
				puts("POSSIBLE");
				return 0;
			}
		}
		que.push(p[x]);
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 25984
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 30005
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll D, G;
    ll p[10], c[10];
    ll i, j;
    ll ans=INF;
    
    cin >> D >> G;
    for(i=1; i<=D; i++) {
        cin >> p[i] >> c[i];
    }
    
    for(i=0; i<1<<D; i++) {
        ll tmp=0;
        ll score=0;
        for(j=1; j<=D; j++) {
            if(1&i>>(j-1)) {
                tmp+=p[j];
                score+=p[j]*100*j+c[j];
            }
        }
        
        if(score>=G) {
            ans=min(ans, tmp);
        }else {
            for(j=D; j>=1; j--) {
                if(1&i>>(j-1)) continue;
                
                ll rem_sco=G-score;
                ll rem_cnt=(rem_sco+100*j-1)/(100*j);
                if(rem_cnt>=p[j]) continue;
                
                ans=min(ans, tmp+rem_cnt);
            }
        }
    }
    
    prin(ans);
}

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

int num[200010];

int main(){

    int x;
    cin >> x;
    vector<int> so;

    for(int i = 2;i < 200010;i++){
        if(num[i] == 0){
            so.push_back(i);
            for(int j = i+i;j < 200010;j+=i){
                num[j] = 1;
            }
        }
    }

    for(int i = 0;i < so.size();i++){
        if(so[i] >= x){
            cout << so[i] << endl;
            break;
        }
    }

    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b >> c >> d;
    MSG(max(a * b, c * d))
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

// Original Author : Ashishgup
struct Disjoint_Set_Union
{
#define V 101010
    int parent[V], size[V];
    Disjoint_Set_Union(int N = V-1)
    {
        init(N);
    }
    void init(int N)
    {
        for(int i=1;i<=N;i++)
        {
            parent[i]=i;
            size[i]=1;
        }
    }
    int Find(int K)
    {
        while(K!=parent[K])
        {
            parent[K]=parent[parent[K]];
            K=parent[K];
        }
        return K;
    }
    int getSize(int K)
    {
        return size[Find(K)];
    }
    void unite(int x, int y)
    {
        int u=Find(x), v=Find(y);
        if(u==v)
            return;
        if(size[u]>size[v])
            swap(u, v);
        size[v]+=size[u];
        size[u] = 0;
        parent[u] = parent[v];
    }
} dsu;
int n, m, k;
vector <int> fr[101010];
vector <int> blk[101010];
int sug[101010];
int32_t main()
{
    usecppio
    cin >> n >> m >> k;
    for (int i = 0; i<m; i++)
    {
        int a, b; cin >> a >> b;
        fr[a].push_back(b);
        fr[b].push_back(a);
        dsu.unite(a, b);
    }
    for (int i = 0; i<k; i++)
    {
        int c, d; cin >> c >> d;
        blk[c].push_back(d);
        blk[d].push_back(c);
    }
    for (int i = 1; i<=n; i++)
    {
        sug[i] = dsu.getSize(i)-fr[i].size()-1;
        for (auto it:blk[i])
        {
            if (dsu.Find(it)==dsu.Find(i))
                sug[i]--;
        }
    }
    for (int i = 1; i<=n; i++)
    {
        cout << sug[i] << ' ';
    }
}

Measured memory_bytes: 13048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int ans = 0;
		for(int i = A; i <= B; i++)
		{
			int[] d = new int[5];
			int tmp = i;
			for(int j = 0; j < 5; j++)
			{
				d[j] = tmp % 10;
				tmp /= 10;
			}
			if((d[0] == d[4]) && (d[1] == d[3]))
				ans++;
		}
		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 15312
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi a(n), b(n), c(n);
	vector<ll> B(n), C(n);
	rep(i, n) cin >> a[i]; sort(all(a));
	rep(i, n) cin >> b[i]; sort(all(b));
	rep(i, n) cin >> c[i]; sort(all(c));
	
	for(int i = 0, j = 0; i < n; i++){
		if(i) B[i] += B[i - 1];
		while(j < n && a[j] < b[i]){
			B[i]++; j++;
		}
	}
	ll ans = 0;
	for(int i = 0, j = 0; i < n; i++){
		if(i) C[i] += C[i - 1];
		while(j < n && b[j] < c[i]){
			C[i] += B[j++];
		}
		ans += C[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3072
#include<cstdio>
#include<cmath>
int main()
{
	long long n;
	int s = 0, ans;
	scanf("%lld",&n);
	for(int i = sqrt(n);i;i--)
		if(!(n % i))
		{
			ans = n / i;
			while(ans)
			{
				ans /= 10;
				s++;
			}
			printf("%d\n",s);
			return 0;
		}
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, k;
  cin >> n >> k;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  sort(xs.begin(), xs.end());
  int64 ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += xs[i];
  }
  cout << ans << endl;
}


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

int main() {

    int w, a, b;
    cin >> w >> a >> b;

    if (a < b) {
        
        if((a + w) < b)
            cout << b - (a + w);
        else
            cout << 0;
        
    } else if (a > b ) {

        if((b + w) < a)
            cout << a - (b + w);
        else
            cout << 0;
    } else 
        cout << 0;
    


    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l[101];
int a,n,i,j,k,s;
long long mx;
main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;

	for(i=1;i<=k;i++)
	{
		cin>>s;
		for(j=1;j<=s;j++)
		{
			cin>>a;
			l[a]=1;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(l[i]==0)
			mx++;
	}
	cout<<mx;
	
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	int J;
	int O;
	int I;
	int max;
	char t;
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String str = scan.nextLine();
			if(str.indexOf("J") < 0 || str.indexOf("O") < 0 || str.indexOf("I") < 0){
				System.out.println(0);
				continue;
			}
			J = 0;
			O = 0;
			I = 0;
			max = 0;
			for(int i = 0;i < str.length();i++){
				t = str.charAt(i);
				if(t == 'J'){
					if(I > 0){
						int a = (O > I)?0:Math.min(I,Math.min(O,J));
						max = (max < a)?a:max;
						J = 0;
						O = 0;
						I = 0;
					}else if(O > 0){
						J = 0;
						O = 0;
					}
					J++;
				}else if(t == 'O'){
					if(I > 0){
						int a = (O > I)?0:Math.min(I,Math.min(O,J));
						max = (max < a)?a:max;
						J = 0;
						O = 0;
						I = 0;
					}else if(J > 0){
						O++;
						if(J < O){
							J = 0;
							O = 0;
						}
					}
				}else if(t == 'I'){
					if(J > 0 && O > 0){
						I++;
					}else{
						J = 0;
						O = 0;
						I = 0;
					}
				}
			}
			if(I > 0){
				int a = (O > I)?0:Math.min(I,Math.min(O,J));
				max = (max < a)?a:max;
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 33332
H, W, A, B = map(int, input().split())
MAX = H + W
MOD = 10 ** 9 + 7
fac = [0 for _ in range(MAX)]
finv = [0 for _ in range(MAX)]
inv = [0 for _ in range(MAX)]
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def COM(n, k):
    global fac
    global finv
    global MOD
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def route(h, w):
    return COM(h + w - 2, h - 1)


ans = 0
for w in range(B + 1, W + 1):
    ans += route(H - A, w) * route(A, W - w + 1)
    ans %= MOD
print(ans % MOD)

Measured memory_bytes: 26904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i = 0;i<s.size();i++)
         if(s[i]==s[i+1])
         {
              cout<<"Bad";
              return 0;
         }  
     cout<<"Good";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);

        int ans = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                for (int k = j + 1; k < n; k++) {
                    // System.out.println(l[i] + " " + l[j] + " " + l[k]);
                    if (l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[i] + l[j]) {
                        ans++;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 26488
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc151_d():
    H, W = map(int, readline().strip().split())
    # 周辺埋め
    grid = [['#'] * (W+2)]
    for ln in read().split():
        grid.append(['#'] + [s for s in ln.decode('UTF-8')] + ['#'])
    else:
        grid.append(['#'] * (W+2))

    # 指定位置からBFSして距離最長を返す
    from collections import deque
    def bfs_max_dist(sx, sy):
        dist = [[-1] * (W+2) for _ in range(H+2)]
        dist[sx][sy] = 0
        que = deque([(sx, sy)])
        dmax = 0
        while que:
            r, c = que.popleft()
            for i, j in ((r-1, c), (r, c-1), (r, c+1), (r+1, c)):
                if grid[i][j] == '#': continue
                if dist[i][j] != -1: continue
                dist[i][j] = dist[r][c] + 1
                que.append((i, j))
                dmax = max(dist[r][c] + 1, ans)
        return dmax

    # スタート地点を全探索で試して、最長距離が最も大きいものを答えとする
    ans = 0
    for r in range(1, H+1):
        for c in range(1, W+1):
            if grid[r][c] == '#': continue
            ans = max(bfs_max_dist(r, c), ans)
    print(ans)

abc151_d()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,dp[105][100005],v[105],w[105],m;
int main(void){
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld%lld",w+i,v+i);
    for(int i=1;i<=n;i++){
        for(int j=m;j>=0;j--){
            if(j-w[i]>=0)dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    printf("%lld\n",dp[n][m]);
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int x=n%10;
  if(x==2 ||(x==4)||(x==5)||(x==7)||(x==9))
    cout<<"hon";
  else if(x==0 ||(x==1)||(x==6)||(x==8))
    cout<<"pon";
  else cout<<"bon";
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int dp[50][410][410];

int main()
{
	int n,ma,mb;
	cin >> n >> ma >> mb;
	vi a(n),b(n),c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];

	rep(i,50) rep(j,410) rep(k,410) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 410; j++){
			for(int k = 0; k < 410; k++){
				if(dp[i][j][k] != 1e5){
					dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
					dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
				}
			}
		}
	}

	/*nまでみたときのdpなのでnだけ回せば良い
	  WAの理由はi<nとなっていたため*/
	int ans = INF;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 410; j++){
			for(int k = 0; k < 410; k++){
				if(j == 0 && k == 0) continue;
				if(j*mb == k*ma) ans = min(ans,dp[i][j][k]);
			}
		}
	}
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 33024
#include <stdio.h>
#include <math.h>
 
int main()
{
    double x1, y1, x2, y2;
     
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    printf("%.8lf\n", hypot(x1-x2, y1-y2));
    return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n,m;
      cin>>n>>m;
      if(n>m)
      {
        for(int i=0;i<n;i++)
          cout<<m;
      }
      else
      {
        for(int i=0;i<m;i++)
          cout<<n;
      }
        
    }



Measured memory_bytes: 256
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Vikash Kumar @ Codechef/codeforces 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define ll                    long long int
#define ll_MAX                LLONG_MAX
#define ll_MIN                LLONG_MIN
#define pi                    3.14159265358979323846
#define count_1(n)            __builtin_popcountll(n)
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define mid(s,e)              (s+(e-s)/2)
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define print(a)        for (auto x : a) cout << x << " "; cout << endl

bool isT(ll a,ll b,ll c){
  if(a==b||b==c||a==c)return false;
  if(a+b>c && a+c>b && b+c>a)
    return true;
  return false;
}

inline void solve(){
  ll n;cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  ll cnt=0;
  for(ll i=0;i<=n-3;i++){
    for(ll j=i+1;j<=n-2;j++){
      for(ll k=j+1;k<=n-1;k++){
        if( isT(a[i],a[j],a[k]) ){
          //cout<<"a: "<<i+1<<" ,b: "<<j+1<<" ,c: "<<k+1<<"\n";
          cnt++;
        }
      }
    }
  }
  cout<<cnt<<"\n";
}

int main()
{
	cout<<fixed<<setprecision(12);
	fastio;ll  t=1,tc=1;
	#ifndef ONLINE_JUDGE
    	//freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);
	#endif
	//cin>>t;
	while(t--){solve();}return 0;
}

Measured memory_bytes: 3580
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    while True:
        w, h = map(int, input().split())
        if w==h==0:
            break
        c = [list(map(int, input().split())) for _ in range(h)]

        stk = []
        visited = [[False]*w for _ in range(h)]
        dir = ((0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1))

        ans = 0

        for i in range(h):
            for j in range(w):
                if c[i][j]==1 and not visited[i][j]:
                    stk.append((i, j))
                    while len(stk)>0:
                        a = stk.pop()
                        visited[a[0]][a[1]] = True
                        for d in dir:
                            ad = (a[0]+d[0], a[1]+d[1])
                            if 0<=ad[0]<h and 0<=ad[1]<w and c[ad[0]][ad[1]]==1 and not visited[ad[0]][ad[1]]:
                                stk.append(ad) 
                    ans += 1

        print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 6044
#include<stdio.h>
int main(){
  int a, b, c, cont = 0, i;
  scanf("%d %d %d", &a, &b, &c);
  for(i = a;i <= b;i++){
    if(c % i == 0)cont++;
  }
  printf("%d\n", cont);
  scanf("%d", &a);
  return 0;
}
 



Measured memory_bytes: 2136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num[]=new int[5];
		for(int i=0;i<5;i++) {
			num[i]=sc.nextInt();
			if(num[i]==0)
				System.out.println(i+1);
		}
		sc.close();
	}
}


Measured memory_bytes: 35864
using System;

namespace agc025_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long ret = long.MaxValue;
            for (int i = 0; i < n; i++)
            {
                int a = i; int b = n - i;
                if (Math.Min(a, b) <= 0) continue;
                string c = a.ToString(); string d = b.ToString();
                int now = 0;
                for (int j = 0; j < c.Length; j++) now += int.Parse(c[j].ToString());
                for (int j = 0; j < d.Length; j++) now += int.Parse(d[j].ToString());
                ret = Math.Min(ret, now);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 15296
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
typedef long long ll;
//#define N 100010
using namespace std;
void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<(a*b);
}

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	int t;
//	cin>>t;
//	while (t--) 
	solve();
	return 0;
}

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

using ll = long long;

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

    string s; cin >> s;
    if (s == "RRS" or s == "SRR") {
        printf("2\n");
        return 0;
    }
    if (s == "SSS") {
        printf("0\n");
        return 0;
    }
    if (s == "RRR") {
        printf("3\n");
        return 0;
    }
    printf("1\n");
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int i, N, *p, max = 0, sum = 0;
    if (scanf("%d%*c", &N) == -1) return -1;
    p = (int *)malloc(sizeof(int) * N);
    if (!p) return -1;
    for (i = 0; i < N; i++) {
        if (scanf("%d%*c", &p[i]) == -1) return -1;
        if (p[i] > max) max = p[i];
        sum += p[i];
    }
    sum -= max / 2;
    printf("%d\n", sum);
    free(p);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	vector<int> t(n + 2);
	vector<double> v(n + 2), va;
	for (int i = 1; i <= n; i++) cin >> t[i];
	for (int i = 1; i <= n; i++) cin >> v[i];
	for (int i = 1; i <= n; i++) t[i] += t[i - 1];
	for (int i = 0; i <= n; i++) t[i] *= 2;
	for (int i = 0; i <= t[n]; i++) {
		double s = i/2.;
		for (int j = 1; j <= n; j++) {
			if (t[j - 1] <= i && i <= t[j]) s = min(s, v[j]);
			else if (i < t[j - 1]) s = min(s, v[j] + abs(t[j - 1] - i)/2.);
			else if (t[j] < i) s = min(s, v[j] + abs(t[j] - i)/2.);
		}
		s = min(s, abs(t[n] - i) / 2.);
		va.push_back(s);
	}

	double ans = 0;
	for (int i = 0; i < (int)va.size() - 1; i++) {
		ans += 0.5*(va[i + 1] + va[i]) / 2.;
	}
	cout << fixed << setprecision(1000000) << ans << endl;
	return 0;
}

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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int i, int j, int h, int w, char tmp[][21])
{
    int ans[21][21] = {0};
    char c[21][21] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i<=h; i++){
        for(int j=0; j<=w; j++){
            c[i][j] = tmp[i][j];
        }
    }

        s.push(make_pair(i, j));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int a = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            a = max(a, ans[i][j]);
        }
    }

    return a;
}


int main()
{
    ll h, w;
    cin >> h >> w;

    char c[21][21] = {0};

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> c[i][j];
        }
    }

    int a = 0;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(c[i][j]=='#'){
                continue;
            }

            a = max(a, bfs(i, j, h, w, c));
        }
    }
    cout << a << endl;
    return 0;
}



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

struct edge{int to,cost;};
vector< vector<edge> > g;
vector<ll> d;


void dfs(int s,ll dist,int pre= -1){
    d[s] = dist;
    for (auto nv:g[s]){
        if (nv.to == pre) continue;
        dfs(nv.to,dist+(ll)nv.cost,s);
    }
}

int main(){
    int n; cin >> n;
    g.resize(n);
    d.resize(n);
    rep(i,n-1){
        int x,y,c;
        cin >> x >> y >> c;
        edge e1 = {y-1,c};
        edge e2 = {x-1,c};
        g[x-1].push_back(e1);
        g[y-1].push_back(e2);
    }
    int q,k;
    cin >> q >> k;
    dfs(k-1,0);
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--;y--;
        cout << d[x]+d[y] << endl;
    }
    //rep(i,n) cout << d[i] << " ";
    //cout << endl;

    return 0;    
}


Measured memory_bytes: 12800
#include<iostream>
using namespace std;
int main(){
	int A;
	int B;
	int C;
	int D;
	cin>>A;
	cin>>B;
	cin>>C;
	cin>>D;
	int A1=A*B;
	int A2=C*D;
	if(A1>A2)
	cout<<A1;
	else if(A2>A1)
	cout<<A2;
	else
	cout<<A1;
	return 0;
}

Measured memory_bytes: 256
def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


N = int(input())
X = input()
p = X.count("1")
rem_plus = 0
rem_minus = 0
for i in range(N):
    k = N - i - 1
    if X[i] == "0":
        continue
    elif p > 1:
        rem_minus = (rem_minus + pow(2, k, p - 1)) % (p - 1)
    rem_plus = (rem_plus + pow(2, k, p + 1)) % (p + 1)
for i in range(N):
    k = N - i - 1
    if X[i] == "0":
        print(f((rem_plus + pow(2, k, p + 1)) % (p + 1)) + 1)
    elif p > 1:
        print(f((rem_minus - pow(2, k, p - 1)) % (p - 1)) + 1)
    else:
        print(0)


Measured memory_bytes: 9344