akhauriyash/Code-Regression huggingface dataset:
// darksta5's template v2.0

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

class DisjointSet
{
private:
  int _sz, _numSets;
  vector<int> _par, _setSz, _rank;

public:
  DisjointSet(int sz)
  {
    _sz = sz;
    _numSets = sz;
    _setSz.assign(sz, 1);
    _rank.assign(sz, 0);
    _par.assign(sz, 0);
    for (int i = 0; i < sz; i++)
    {
      _par[i] = i;
    }
  }

  int sz()
  {
    return _sz;
  }

  int numSets()
  {
    return _numSets;
  }

  int setSz(int i)
  {
    return _setSz[find(i)];
  }

  int find(int i)
  {
    int x = i;
    while (x != _par[x])
    {
      x = _par[x];
    }

    return _par[i] = x;
  }

  bool isSame(int i, int j)
  {
    return find(i) == find(j);
  }

  void uni(int i, int j)
  {
    if (!isSame(i, j))
    {
      _numSets--;
      int x = find(i);
      int y = find(j);
      if (_rank[x] < _rank[y])
      {
        _par[x] = y;
        _setSz[y] += _setSz[x];
      }
      else
      {
        _par[y] = x;
        _setSz[x] += _setSz[y];
        if (_rank[x] == _rank[y])
        {
          _rank[x]++;
        }
      }
    }
  }
};

ll make_key(int x, int y)
{
  return (ll)x * 200050LL + (ll)y;
}

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

  int n, r1, r2;
  cin >> n >> r1 >> r2;
  DisjointSet ds1(n), ds2(n);

  for (int i = 0; i < r1; i++)
  {
    int x, y;
    cin >> x >> y;
    ds1.uni(x - 1, y - 1);
  }

  for (int i = 0; i < r2; i++)
  {
    int x, y;
    cin >> x >> y;
    ds2.uni(x - 1, y - 1);
  }

  unordered_map<ll, int> cnt;
  for (int i = 0; i < n; i++)
  {
    ll key = make_key(ds1.find(i), ds2.find(i));
    cnt[key]++;
  }

  for (int i = 0; i < n; i++)
  {
    ll key = make_key(ds1.find(i), ds2.find(i));
    if (i < n - 1)
    {
      cout << cnt[key] << " ";
    }
    else
    {
      cout << cnt[key] << endl;
    }
  }
}

Measured memory_bytes: 12872
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++ ) {
        cin >> v[i];
    }
    int res = 0x3f3f3f3f;
    for (int i = -100; i <= 100; i++) {
        int c = 0;
        for (int j = 0; j < n; j++) {
            c += pow(i - v[j], 2);
        }
        res = min(res, c);
    }
    cout << res << endl;
}


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

int main()
{
  long long a,b,k;
  cin >> a;
  cin >> b;
  cin >> k;
  
  if(a>=k)
  {
    a=a-k;
  }
  else 
  {
    
    k=k-a;
    a=0;
    if(b>=k)
    {
      b=b-k;
    }
    else
    {
      b=0;
    }
  }
   cout << a <<" "<< b <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int a=0,b=0,n;
	for(int i=0;i<4;i++){
		cin>>n;
		a=a+n;
	}
	for(int i=0;i<4;i++){
		cin>>n;
		b=b+n;
	}
	if(a>b){
		cout<<a<<endl;
	}
	else{
		cout<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <cstring>
#include <iostream>
using namespace std;
 
int main()
{
    int b;
    cin>>b;
    char a[b];
    cin>>a;
    int contador =0;
    for (int i=0; i<b-2; i++){
        if ( a[i]=='A' && a[i+1]=='B' &&a[i+2]=='C' ){
            contador += 1;
        }
    }
    cout<<contador;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,arr[105];
    double s,sum1,sum2;
    cin>>n;
    s=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        s+=arr[i];
    }

    sum1=floor(s/n);
    sum2=ceil(s/n);
    //cout<<sum1<<" "<<sum2;
    double r1,r2,t;
    //cout<<sum;
    r1=r2=0;
    for(int i=0;i<n;i++)
    {
        r1+=((arr[i]-sum1)*(arr[i]-sum1));
        r2+=((arr[i]-sum2)*(arr[i]-sum2));
    }
    //cout<<r1<<" "<<r2<<endl;
    t=min(r1,r2);
    cout<<t<<endl;
    return 0;

}


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

using namespace std;

long long maxValueFrom(int curr, const vector<int>& w, const vector<long long>& v, int outstandingCapacity
    , vector<vector<long long> >& memo) {
    int N = w.size();
    if (curr == N) {
        return 0LL;
    }
    if (memo[curr][outstandingCapacity] > 0) {
        return memo[curr][outstandingCapacity];
    }

    long long skipThis = maxValueFrom(curr + 1, w, v, outstandingCapacity, memo);
    int thisWeight = w[curr];
    long long ret = 0LL;
    if (outstandingCapacity - thisWeight < 0) {
        ret = skipThis;
    }
    else {
        long long takeThis = maxValueFrom(curr + 1, w, v, outstandingCapacity - thisWeight, memo) + v[curr];
        ret = max(takeThis, skipThis);
    }

    memo[curr][outstandingCapacity] = ret;
    return ret;
}

void Main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N, 0);
    vector<long long> v(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    vector<vector<long long> > memo(N, vector<long long>(W + 1, -1LL));
    long long ans = maxValueFrom(0, w, v, W, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 79488
#include <stdio.h>

int binarySearch(int);

int data[100000],n;

int main(){
  int i,a,b,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
      }

  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b);
    if(binarySearch(b)){
      c++;
    }
  }
  printf("%d\n",c);

  return 0;
}

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  
  while(left<right){
    mid=(left+right)/2;
  if(data[mid]==key){
    return mid;
  }
  if(data[mid]>key){
    right=mid;
  }
  if(data[mid]<key){
    left=mid+1;  
}
  }
  return 0;
  }



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	int n;
  	cin>>n;
  	string s,r,t;
  	cin>>r>>s>>t;
  	int ans=0;
  	For(i,n)
  	{
  		if(s[i]==r[i] && r[i]==t[i])continue;
  		if(s[i]==r[i] || r[i]==t[i] || s[i]==t[i])ans++;
  		else ans+=2;
  	}
  	cout<<ans<<endl;
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100000;
ll N,K,h[MAX_N];

int main(){
  cin>>N>>K;
  for(ll i=0;i<N;i++){
    cin>>h[i];
  }
  sort(h,h+N);
  ll ans=inf;
  for(ll i=0;i+K-1<N;i++){
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
int tc;
const int N=3e5+5,M=3e5+5,MOD=1e9+7,OO=1e9;

int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	//file();
 	
 	int n;
 	string a;
 	cin>>n>>a;

 	if(n%2)cout<<"No\n";
 	else{
 		string wa1 = a.substr(0,n/2);
 		string wa2 = a.substr(n/2,n/2);

 		if(wa1==wa2)cout<<"Yes\n";
 		else cout<<"No\n";
 	}
}


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

int main() {
  
  int A=0, B=0,C=0;
  
  cin >> A >> B >> C;
  
  if(A==B) {
    
    cout << C << endl;
    
  } else if(A==C) {
    
    cout << B << endl;
    
  } else if(B==C) {

    cout << A << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input = input.split("\n");
var N = parseInt(input[0]);
var A = input[1].split(" ").map(function(e){ return parseInt(e,10)});

var count = 0;
for(var i = 0; i < N; i++){
  var range = A.slice(i);
  var min = Math.min.apply(null,range);
  var rangeIndexMin = range.indexOf(min);
  var AIndexMin = rangeIndexMin + i;
  if(i < AIndexMin){
    A[AIndexMin] = A[i];
    A[i] = min;
    count++;    
  };
}
console.log(A.join(" "));
console.log(count);


Measured memory_bytes: 15216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int x = 0; x < W; x++) {
                System.out.print('#');
            }
            System.out.println();
            for (int y = 1; y < H - 1; y++) {
                System.out.print('#');
                for (int x = 1; x < W - 1; x++) {
                    System.out.print('.');
                }
                System.out.print('#');
                System.out.println();
            }
            for (int x = 0; x < W; x++) {
                System.out.print('#');
            }
            System.out.println();
            System.out.println();
        }
    }
}


Measured memory_bytes: 36312
#include <bits/stdc++.h>
using namespace std;
void readtxt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
int main()
{
	//readtxt();
    int a, b, c , d;
    cin >> a >> b >> c >> d;
    int count=0;
    while(a>0 && c > 0)
    {
    	if(count%2==0)
    	{
    		c = c-b;
    	}
    	else
    	{
    		a = a - d;
    	}
    	++count;
    }
    if(count %2 == 0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
//file_name:ABC89_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='Y'){
            puts("Four");
            return 0;
        }
    }


    puts("Three");
    return 0;
}



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

int getResult(double x){
  if(x >= 1.1) return 0;
  if(x >= 0.6) return 1;
  if(x >= 0.2) return 2;
  return 3;
}

int main(){
  double L, R;
  int l[4] = {0};
  int r[4] = {0};

  while(cin >> L >> R){
    l[getResult(L)]++;
    r[getResult(R)]++;
  }

  for(int i = 0; i < 4; i++){
    cout << l[i] << " " << r[i] << endl;
  }
}

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

using namespace std;

int main()
{
  int n;
  vector<int> v;
  double acc;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int v1;
    cin >> v1;
    v.push_back(v1);
  }

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

  acc = v[0];
  for (int i = 1; i < n; i++) {
    acc = 0.5*(acc + v[i]);
  }

  cout << acc << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<ll, ll> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   ll A[N][N];
   ll dp[N][N];
   vector<ipair> log;
   map<int, ipair> LUT;
   int id = 0;
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         cin >> A[i][j];
         dp[i][j] = A[i][j];
         if (i < j) {
            log.push_back(ipair(id, A[i][j]));
            LUT[id] = ipair(i, j);
            id++;
         }
      }
   }
   sort(log.begin(), log.end(), lessPair);

   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            dp[i][j] = llmin(dp[i][j], dp[i][k] + dp[k][j]);
         }
      }
   }
   ll ans = 0;
   for (auto it = log.begin(); it != log.end(); it++) {
      int ID = it->first;
      int s = LUT[ID].first;
      int e = LUT[ID].second;
      ll dis = dp[s][e];
      ll tmp = it->second;
      // cout << LUT[ID].first << " " << LUT[ID].second << " " << dis << " " << tmp << endl;
      if (dis < tmp) {
         cout << -1 << endl;
         return 0;
      } else if (dis > tmp) ans += tmp;
      else {
         bool flg = false;
         for (int k = 0; k < N; k++) {
            if (k != s && k != e && tmp == dp[s][k] + dp[k][e]) {
               flg = true;
               continue;
            }
         }
         if (!flg) ans += tmp;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 5108
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int h, w;
char a[22][22];
int d[22][22];
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int dfs(int s, int t, int pp, int q) {
	queue<P>que;
	rep(i, h) { rep(j, w)d[i][j] = -1; }
	que.push(P(s, t));
	d[s][t] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == pp && p.second == q)break;
		rep(i, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx >= 0 && nx < h && ny >= 0 && ny < w && d[nx][ny] == -1 && a[nx][ny] != '#') {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[pp][q];
}
signed main() {
	cin >> h >> w;
	rep(i, h) { rep(j, w)cin >> a[i][j]; }
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			rep(k, h) {
				rep(l, w) {
					if (a[i][j] != '#' && a[k][l] != '#') {
						ans = max(ans, dfs(i, j, k, l));
					}
				}
			}
		}
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
  cin >> vec.at(i);
}
for (int i = 0; i < 5; i++) {
  if (vec.at(i) == 0) {
    cout << i + 1 << endl;
  }
}
  
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(){
	int N;
	char S[100],S2[26],S3[26];
	int i,j,k,a;
	int max,max2=0;

	char alp[] = "abcdefghijklmnopqrstuvwxyz";
    int alpnum[26];

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

	for(i=0;i<N;i++){
        for(a=0;a<26;a++){
            S2[a]=0;
            S3[a]=0;
        }
        max=0;

        for(j=0;j<i;j++){
            for(a=0;a<26;a++){
                if(S[j]==alp[a]){
                    S2[a]=1;
                }
            }
        }
        for(k=j;k<N;k++){
            for(a=0;a<26;a++){
                if(S[k]==alp[a]){
                    S3[a]=1;
                }
            }
        }
        for(a=0;a<26;a++){
            if(S2[a]==1 && S3[a]==1){
                max++;
            }
        }
        if(max2<max){
            max2=max;
        }

	}
	printf("%d",max2);


	return 0;
}

Measured memory_bytes: 128
(defstruct const s c)

(defun solve (N M lst)
  (loop named outer 
        for i from (if (= N 1) 0 (expt 10 (1- N)))
        to (1- (expt 10 N)) do
        (loop for x in lst
              with vec = (concatenate 'vector (princ-to-string i))
              unless (eq (aref vec (const-s x))
                         (const-c x))
              return nil
              finally (return-from outer i))
        finally (return-from outer -1)))


(let ((N (read))
      (M (read)))
     (princ (solve N M
                   (loop repeat M
                         collect (make-const :s (1- (read)) :c (read-char))))))

Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>food(N);
  for(int i=0;i<N;i++) {
    cin>>food[i];
   food[i]--;
  }
  vector<int> sat(N);
  for(int i=0;i<N;i++) cin>>sat[i];
  vector<int> C(N-1);
  for(int i=0;i<N-1;i++) cin>>C[i];
  int S=0;
  for(int i=0;i<N;i++){
    S+=sat[food[i]];
	if(i!=0&&food[i]==food[i-1]+1) S+=C[food[i-1]];
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

/*bool operator<(const data &d)const{
	return hoge;
}*/
 
const int dx[]={0,1,1,-1,-1,0};
const int dy[]={1,1,0,0,-1,-1};
set<char>vowel={'a','i','u','e','o'};


 
signed main(){
	IOS();
	int N;
	vector<int>ans;
	while(cin>>N,N){
		int t[N][N+1];
		rep(i,0,N){
			rep(j,0,N+1)cin>>t[i][j];
		}
		int dp[1ll<<N];
		rep(i,0,1ll<<N)dp[i]=INF;
		dp[0] = 0;
		rep(i,0,1ll<<N){
			if(dp[i]==INF)continue;
			rep(j,0,N){
				if(i&(1ll<<j))continue;
				int mi = t[j][0];
				rep(k,0,N){
					if((i&(1ll<<k))==0)continue;
					chmin(mi,t[j][k+1]);
				}
				chmin(dp[i^(1ll<<j)],dp[i]+mi);
			}
		}
		ans.push_back(dp[(1ll<<N)-1]);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> bal(n);
    rep(i,n){
        cin >> bal[i];
    }
    vector<vector<ll>> bn(n, vector<ll>(2));
    rep(j,n){
        bn[bal[j]-1][0]++;
    }
    rep(k,n){
        bn[k][1] = bn[k][0] * (bn[k][0] - 1) / 2;
    }
    ll ans = 0;
    rep(a,n){
        ans += bn[a][1];
    }
    rep(s,n){
        cout  << ans + 1 - bn[bal[s] - 1][0] << endl;
    }
}

Measured memory_bytes: 15104
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n;
  cin>>n;
  int t[n+1],x[n+1],y[n+1];
  t[0]=0; x[0]=0; y[0]=0;
  rep1(i,n+1){
    cin>>t[i]>>x[i]>>y[i];
  }
  int dec=1;
  rep(i,n){
    int time=t[i+1]-t[i];
    int distance=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(time%2!=distance%2 || time<distance){
      dec=0;
    }
  }
  if(dec){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<string.h>
 
using namespace std;
 
int main()
{
    char s[4];
    int count = 0;
    cin.getline(s, 4);
 
    for(int i=0; s[i]!='\0'; ++i)
    {
        if(s[i] == 'R')
        {
            count++;
        }
 
        else if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R')
        {
            count = 0;
        }
        else if(s[0] == 'S' && s[1] == 'R' && s[2] == 'S')
        {
            count = 1;
        }
        else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'R')
        {
            count = 0;
        }
        else
        {
            count = count;
            break;
        }
    }
 
    cout << count << endl;
 
 
 
 
}

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
////////////////////////////////////////////////////////////

int main(){
	vector<long> v(10);
	rep(i,0,10)
		cin >> v[i];
	rvsort(v);
	rep(i,0,3){
		P(v[i]);
	}
	ret 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=300009;
const int md=1000000007;
int fac[N],iv[N];
int h,w,n;
pair <int,int> v[3009];
int f(int a,int n){
	if(n==0)return 1;
	if(n==1)return a%md;
	int x=f(a,n/2);
	x=(x*x)%md;
	if(n%2)
		x=(x*a)%md;
	return x;
}
int C(int n, int k){
    int x =fac[n] * iv[k] % md * iv[n-k] % md;
    return x;
}
int cal(int x,int y){
	int a=(v[x].f-v[y].f);
	int b=(v[x].s-v[y].s);
	if(a*b==0)return 1;
	if(a<1 or b<1)return 0;
	return C(a+b,a);
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	fac[0] = 1;
	for (int i = 1; i <= N; i++){
    	fac[i] = fac[i - 1] * i % md;
    	iv[i]=f(fac[i],md-2);
	}
	cin >> h >> w >> n;
	for(int i=0;i<n;i++)
		cin >> v[i].f >> v[i].s;
	v[n].f=h,v[n].s=w,n++;
	v[n].f=1,v[n].s=1;
	int dp[n];
	sort(v,v+n);
	for(int i=0;i<n;i++){
		dp[i]=cal(i,n);
		for(int j=0;j<i;j++)
			dp[i]=(dp[i]-(cal(i,j)*dp[j])%md+md)%md;
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 4992
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    res = 0
    a, b = map(int, r.split())
    if a > b:
        print(a-1)
    else:
        print(a)

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;}
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

/* }}} */

#define sq(x) ((x) * (x))

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

  while (n--){
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double d = sqrt(sq(xa - xb) + sq(ya - yb));

    if (d < ra - rb){
      print("2");
    } else if (d < rb - ra){
      print("-2");
    } else if (d <= ra + rb){
      print("1");
    } else {
      print("0");
    }
  }

  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#define rep(i,n) for(i = 0;i < n;i++)
using namespace std;

int w;

int main(){
	int i;
	int sum;

	while( cin >> w ){
		sum = 1150;
		if( w == -1 )
			break;
		w -= 10;
		if( w > 0 ){
			sum += 125*w;
			w -= 10;
		}
		if( w > 0 ){
			sum += 15*w;
			w -= 10;
		}
		if( w > 0 ){
			sum += 20*w;
		}
		cout << 4280-sum << endl;
	}
	return 0;
}

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

int main(){
  int N,S;
  cin >> N;
  S = 0;
  bool answer;
  answer = true;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  for(int i=1;i<N;i++){
    S += L.at(i);
  }
  if(L.at(0) < S)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	while(true){
	    int a=sc.nextInt();
	    int b=sc.nextInt();
	    if(a==0 && b==0) break;
	    for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
		    System.out.printf("#");
		}
		System.out.printf("\n");	
	    }
	    System.out.printf("\n");
	}
    }
}

Measured memory_bytes: 48180
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    char s[111];
    cin >> s;
    int a[30] = {};
    for (int i = 0; i < strlen(s); i++)
    {
        a[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (a[i] % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int sort_strings(int N, int L, char **String) {
	int i, j;
	int sorted;
	char *temp;
	char a[128], b[128];

	sorted = 0;
	while(sorted < N - 1) {
		sorted = 0;
		for(i = 0; i < N - 1; i += 1) {
			for(j = 0; j < L; j += 1) {
				if(String[i][j] > String[i + 1][j]) {
					//switch
					temp = String[i];
					String[i] = String[i + 1];
					String[i + 1] = temp;
					break;
				} else if(String[i][j] == String[i + 1][j]) {
					if(j == L - 1) {
						sorted += 1;
					}
					continue;
				} else {
					sorted += 1;
					break;	
				}
			}
		}
	}
	return 0;
}

int main(void) {
	int i;
	int N, L;
	char **String = NULL;
	char *result;
	char buf[128], *ch;
	FILE *file;
	//file = fopen("input.txt", "r");

	fgets(buf, sizeof(buf), stdin);
	//fgets(buf, sizeof(buf), file);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	L = atoi(ch);

	String = (char **)calloc(N, sizeof(char *));
	result = (char *)calloc(N * (L + 8), sizeof(char));

	for(i = 0; i < N; i += 1) {
		String[i] = (char *)calloc(L, sizeof(char));
	}

	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		//fgets(buf, sizeof(buf), file);
		sprintf(String[i], "%s", strtok(buf, " "));
	}

	sort_strings(N, L, String);

	for(i = 0; i < N; i += 1) {
		sprintf(&(result[i * L]), "%s", String[i]);
	}
	printf("%s\n", result);

	for(i = 0; i < N; i += 1) {
		free(String[i]);
		String[i] = NULL;
	}
	free(String);
	String = NULL;
	free(result);
	result = NULL;
	//fclose(file);
	return 0;
}


Measured memory_bytes: 2036
N = int(input())
S = input()
white = S.count(".")
if white == 0:
    print(0)
    exit()
if S[0] == "#":
    B = [1]*N
    W = [white]*N
else:
    B = [0]*N
    W = [white-1]*N
for i in range(1,N):
    if S[i] == "#":
        B[i] = B[i-1] + 1
        W[i] = W[i-1]
    else:
        B[i] = B[i-1]
        W[i] = W[i-1] - 1
#print(B)
#print(W)
Ans = [B[i]+W[i] for i in range(N)]
print(min(min(Ans),white,N-white))


Measured memory_bytes: 20964
#include<vector>
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include<algorithm>
#include<random>
#include<map>
#include<set>

using namespace std;

//int mod = 998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<vector<int>>vvi;
typedef vector<vector<ll>>vvl;
typedef vector< pair<ll, ll>>vpll;
typedef vector< pair<ld, ld>>vpld;
typedef pair<ld, ld>pld;
#define mp make_pair
#define pb push_back

int mod;
int sum(int a, int b)
{
	int c = a + b;
	if (c >= mod)
	{
		c -= mod;
	}
	return c;
}
int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)
	{
		c += mod;
	}
	return c;
}
int mlt(int a, int b)
{
	ll c = a * 1LL * b;
	return c % mod;
}
int ibit(int n, int i)
{
	return ((n >> i) & 1);
}
void mlt1(vi &pol, int a)
{
	//cerr << a << endl;
	vi newv(pol.size());
	for (int i = 0; i < pol.size(); i++)
	{
		//cerr << pol.size()<<' '<<i << endl;
		int cur = 0;
		if (i >= a)
		{
			cur = newv[i - a];
		}
		cur = sum(cur, pol[i]);
		newv[i] = cur;
	}
	//cerr << "Here" << endl;
	pol = newv;
}
int solve_vec(vi &mlts, int maxn)
{
	vi cur(maxn);
	cur[0] = 1;
	for (int i = 0; i < mlts.size(); i++)
	{
		mlt1(cur, mlts[i]);
	}
	int ans = 0;
	//cerr << "There" << endl;
	for (int i = 0; i < maxn; i++)
	{
		int bt = mlt(maxn - i, cur[i]);
		//cerr << "dds" << endl;
		ans = sum(ans, bt);
	}
	//cerr << "Here" << endl;
	return ans;
}
void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;
	cin >> n >> mod;
	vector<int>v;
	if (n % 2 == 0)
	{
		for (int i = 0; i < n / 2; i++)
		{
			v.pb(i + 1);
		}
		for (int i = 0; i < n / 2-1; i++)
		{
			v.pb(n/2-i);
		}
	}
	else
	{
		for (int i = 0; i < n / 2; i++)
		{
			v.pb(i + 1);
		}
		for (int i = 0; i < n / 2; i++)
		{
			v.pb(n / 2 +1- i);
		}
	}
	cout << solve_vec(v, n) << endl;
}
int main()
{
	solve();
	int n;
	cin >> n;
}

Measured memory_bytes: 384
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main() {

    int K, X; cin>>K>>X;
    if(K*500>=X){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <sstream>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

void dfs(int cur, int m, int n, const vector<vector<int>> &var, int &val_max, vector<int> &a) {
  if (a.size() < n) {
    for (int i = cur; i <= m; ++i) {
      a.push_back(i);
      dfs(i, m, n, var, val_max, a);
      a.pop_back();
    }
  }
  int val = 0;
  for (int j = 0; j < var.size(); ++j) {
    if (a[var[j][1]] - a[var[j][0]] == var[j][2]) {
      val += var[j][3];
    }
  }

  val_max = max(val_max, val);

}

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m, q;
  cin >> n >> m >> q;

  vector<vector<int>> var(q, vector<int>(4));
  for (int i = 0; i < q; ++i) {
    cin >> var[i][0] >> var[i][1] >> var[i][2] >> var[i][3];
    var[i][0]--, var[i][1]--;
  }

  int val_max = 0;
  vector<int> a;

  dfs(1, m, n, var, val_max, a);

  cout << val_max << endl;

  return 0;
}


Measured memory_bytes: 3148
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 2e5 + 10;
const int INF = 1e9 + 10;
int A, B, C, D, E, F;

int main(){
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	int a, b;
	a = b = 0;
	double maxn = 0;
	for(int i = 0; i <= F / (100 * A); ++i) {
		for(int j = 0; j <= F / (100 * B); ++j) {
			if(A * i * 100 + B * j * 100 > F)	break;
			for(int k = 0; k <= F / C; ++k) {
				if(A * i * 100 + B * j * 100  + k * C > F)	break;
				for(int l = 0; l <= F / D; ++l) {
					if(A * i * 100 + B * j * 100  + k * C + l * D > F)	break;
					int water = A * i * 100 + B * j * 100;
					int suger = k * C + l * D;
					int watersu = water + suger;
					int maxsuger = (A * i + B * j) * E;
					if(suger > maxsuger)	continue;
					if(suger * 1.0 / watersu >= maxn) {
						maxn = suger * 1.0 / watersu;
						a = watersu, b = suger;
					}
				}
			}
		}
	}
	printf("%d %d\n", a, b);
	return 0;
}

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

using namespace std;

int main (void)
{
	while (1) {
		int n; cin >> n;
		vector<string> step;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			step.push_back(str);
		}
		bool up = false;
		bool down = false;
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (step[i] == "ru" || step[i] == "lu") {
				// 片足がdownしてない，かつupしている状態
				if (!down && up) {
					count++;
					up = false;
				}
				// どっちもdown
				else if (!down && !up) {
					up = true;
				}
				else if (down) {
					down = false;
				}
			}
			if (step[i] == "rd" || step[i] == "ld") {
				// 片足がupしてない，かつdownしている状態
				if (down && !up) {
					count++;
					down = false;
				}
				// どっちもup
				else if (!down && !up) {
					down = true;
				}
				else if (up) {
					up = false;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    VEC(ll, a, n + 1);
    reverse(ALL(a));
    vector<P> p;
    ll l, r;
    rep(i, n + 1){
        if(i == 0){
            p.emplace_back(a[i], a[i]);
            l = a[i], r = a[i];
        }
        else {
            l = (l + 1) / 2;
            p.emplace_back(l + a[i], r + a[i]);
            l = l + a[i], r = r + a[i];
        }
    }
    reverse(ALL(p));
    reverse(ALL(a));
    ll res = 0, now = 1;
    rep(i, n + 1){
        if(p[i].first > now){
            cout << -1 << endl;
            return 0;
        }
        res += min(now, p[i].second);
        if(now > p[i].second)now = p[i].second;
        else {
            now -= a[i];
            now *= 2;
        }
      //cout << p[i].first << " " << p[i].second << endl;
    }
    cout << res << endl;
}

Measured memory_bytes: 5740
import bisect


def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    a = sorted(a)
    m = a.pop(-1)
    if len(a)==1:
        left,right = 0,0
    else:
        left = bisect.bisect_left(a,m/2)
        right = max(left-1,0)
    
    if abs(m-2*a[left])<=abs(m-2*a[right]):
        print(m,end=" ")
        print(a[left])
    else:
        print(m,end=" ")
        print(a[right])
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 62704
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

ll long_search(const int start, const int N, const vvll& E, vll& dp){
  if(dp[start]>=0) return dp[start];

  ll ans = 0;
  for(auto end : E[start]){
    ans = max(ans, long_search(end, N, E, dp)+1);
  }

  return dp[start] = ans;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N >> M;
  vvll E(N+1);
  rep(i, 0, M){
    ll x, y;
    cin >> x >> y;
    E[x].push_back(y);
  }

  vll dp(N+1, -1);
  ll ans=0;
  rep(i, 0, N+1){
    ans = max(ans, long_search(i, N, E, dp));
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 9984
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True

def insu(num):
    from collections import defaultdict
    div_prime = [d for d in make_divisors(num) if is_prime(d)]
    res = defaultdict(int)
    for d in div_prime:
        while num % d == 0:
            num //= d
            res[d] += 1
    return res
ins = insu(N)
ans = 0
for v in ins.values():
    counter = 1
    while v >= counter:
        v -= counter
        counter += 1
        ans += 1
print(ans)


Measured memory_bytes: 68860
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int gcd(int a, int b){
  if(a % b == 0) return b;
  else return gcd(b, a%b);
}

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  d.push_back(x);
  sort(ALL(d));
  if (d.size() == 2) {
    cout << d[1] - d[0] << endl;
    return 0;
  }
  int a = gcd(d[1] - d[0], d[2] - d[1]);
  for (int i = 1; i < n; i++){
    a = gcd(a, d[i+1] - d[i]);
  }
  cout << a << endl;
}


Measured memory_bytes: 1024
a=input()
b=input()
c=input()
def s(x):
  if len(x)==1:
    return ''
  else:
    return x[1:]
def g(x):
  global a
  global b
  global c
  if x=='a':
    if len(a)==0:
      y='A'
    else:
      y=a[0]
      a=s(a)
  elif x=='b':
    if len(b)==0:
      y='B'
    else:
      y=b[0]
      b=s(b)
  else:
    if len(c)==0:
      y='C'
    else:
      y=c[0]
      c=s(c)
  return y
t=g(a[0])
while t!='A' and t!='B' and t!='C':
  t=g(t)
print(t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x) for(int i = 0;i < x;++i)
#define FOR(i,x,y) for(int i = x;i < y;++i)
#define ALL(a) a.begin(),a.end()
using ll = long long;

int m,n,k;
inline int hash_(char c)
{
    return ((c=='J')?0:((c=='O')?1:2));
}
int imos[3][1234][1234];

int main()
{
    cin >> m >> n;
    cin >> k;
    REP(i,m)
    {
        char str[1234];
        cin >> str;
        REP(j,n)
        {
            int id = hash_(str[j]);
            imos[id][i+1][j+1] = 1;
        }
    }
    REP(id,3)
    {
        REP(j,n+1)
        {
            REP(i,m+1)
            {
                imos[id][i + 1][j] += imos[id][i][j];
            }
        }
    }
    REP(id,3)
    {
        REP(j,n+1)
        {
            REP(i,m+1)
            {
                imos[id][i][j + 1] += imos[id][i][j];
            }
        }
    }
    REP(i,k)
    {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        --a;--b;
        REP(id,3)
        {
            int ans = imos[id][c][d] + imos[id][a][b] - imos[id][a][d] - imos[id][c][b];
            cout << ans << " \n"[id == 2];
        }
    }
    return 0;
}

Measured memory_bytes: 17340