akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n,m;
	cin>>n>>m;
	vector<pl> a(n),b(m);
	rep(i,n)cin>>a[i].fi>>a[i].se;
	rep(i,m)cin>>b[i].fi>>b[i].se;

	rep(i,n){
		ll dist=INF;
		ll ans=-1;
		rep(j,m){
			if(dist>(abs(a[i].fi-b[j].fi)+abs(a[i].se-b[j].se))){
				dist=abs(a[i].fi-b[j].fi)+abs(a[i].se-b[j].se);
				ans=j+1;
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
// #include <random>
#include <iomanip>
#include <bitset>
#include <cassert>
 
using namespace std;

#define int long long
#define y1 y11
#define double long double
#define less less228
#define left left228
#define right right228
#define list list228
#define all(v) v.begin(), v.end()
 
 
 
template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}
template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}

const int N = 105;
const int INF = 1e9 + 228;

int n, m;
int a[N][N], dp[N][N];
bitset<N> used[N];

void dfs(int x, int y, int i, int j) {
	if (x < 1 || x > n || y < 1 || y > m || a[x][y] != a[i][j] || used[x][y])return;
	used[x][y] = 1;
	uin(dp[i][j], min(dp[x - 1][y], dp[x][y - 1]) + 1);
	dfs(x - 1, y, i, j);
	dfs(x, y - 1, i, j);
}

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

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
    	for (int j = 1; j <= m; ++j) {
    		char c;
    		cin >> c;
    		if (c == '.') a[i][j]=0;
    		else a[i][j] = 1;
    	}
    }
    for (int i = 0; i <= n; ++i) {
    	for (int j = 0; j <= m; ++j) {
    		dp[i][j] = INF;
    	}
    }
    dp[0][1] = dp[1][0] = 0;
    for (int i = 1; i <= n; ++i) {
    	for (int j = 1; j <= m; ++j) {
    		if (a[i][j] == 0) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
    		else {
    			for (int x = 1; x <= n; ++x) {
    				used[x] = 0;
    			}
    			dfs(i, j, i, j);
    		}
    	}
    }
    cout << dp[n][m] << '\n';
    return 0;
}
// RU_023
 
/*
4 2
2 1 3 3
1 2 4 3
6 1 7 4
5 3 7 5

3 3
1 1 1 1
1 2 1 2
1 3 1 3

*/

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

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n);
	for (int i = 0; i < n; i++)cin >> a.at(i) >> b.at(i);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll x = n % 2;
	if (x == 0) cout << b.at(n / 2 - 1) + b.at(n / 2) - a.at(n / 2 - 1) - a.at(n / 2) + 1 << endl;
	else cout << b.at(n / 2) - a.at(n / 2) + 1 << endl;
}

Measured memory_bytes: 6420
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
vi vi;int n;cin>>n;
for(int i=0;i<n;i++){
    int a;cin>>a;
    vi.PB(a);
}
int m=*min_element(vi.begin(),vi.end());
int t=*max_element(vi.begin(),vi.end());
cout<<t-m<<endl;




over
}


Measured memory_bytes: 18612
#include <stdio.h>

int main()
{
    long long A,B,C,K;
    scanf("%lld %lld %lld %lld",&A,&B,&C,&K);
    long long sum = 0;
    if(A >= K)
    {
        sum = K;
        printf("%lld",sum);
        return 0;
    }
    if(A < K)
    {
        sum = A;
        K-=A;
        if(B >= K)
        {
            printf("%lld",sum);
            return 0;
        }
        else
        {
            K-=B;
            if(C >= K)
            {
                sum -= K;
            }else
            {
                sum -= C;
            }
        }
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int n,x,y;
int dis[1010][1010];
int d(int u,int v) {
	return abs(u-v);
}
int js(int u,int v) {
	int ans=d(u,v);
	ans=min(ans,d(u,x)+d(y,v)+1);
	ans=min(ans,d(u,y)+d(x,v)+1);
	return ans;
}
int gs[N];
int main()
{
	//cwk;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			gs[js(i,j)]++;	
		}
	}
	for(int i=1;i<n;i++) {
		printf("%d\n",gs[i]);
	}
	return 0;
}

Measured memory_bytes: 384
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	vector<string> c(3);

	for(int i = 0; i < 3; i++){
		cin >> c[i];
	}

	cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int a,b,c,d;
int main(){
  scan(a);scan(b);scan(c);scan(d);
  if(a+b>c+d)prin("Left");
  else if(a+b==c+d)prin("Balanced");
  else prin("Right");
  return 0;
}


Measured memory_bytes: 256
def for_factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val %= (10 ** 9 + 7)
    return val
N, M = map(int, input().split())
if N == M:
    print(for_factorial(N) * for_factorial(M) * 2 % (10 ** 9 + 7))
elif abs(N-M) == 1:
    print(for_factorial(N) * for_factorial(M) % (10 ** 9 + 7))
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main()
{
    int niz[3];
    cin>>niz[0]>>niz[1]>>niz[2];
    sort(niz, niz+3);
    if ( niz[0] == niz[1] && niz[2] == 7 && niz[0] == 5 ){
            cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int K,ans=0;
  cin>>K;
  
  int DP[K]; // DP[i]=Kで割った余りがiとなる整数のうちの各桁の和の最小値
  REP(i,K) DP[i]=MOD;
  
  priority_queue<pair<int,int>> Q;
  RREP(i,9){
    chmin(DP[i%K],i);
    Q.push(MP(-DP[i%K],i%K));
  }
  
  while(!Q.empty()){
    int f=-Q.top().first;
    int s=Q.top().second;
    Q.pop();
    if(f!=DP[s]) continue;
    REP(i,10){
      ll nf=f+i;
      ll ns=(s*10+i)%K;
      if(nf<DP[ns]){
        DP[ns]=nf;
        Q.push(MP(-nf,ns));
      }
    }
  }
  
  cout<<DP[0]<<endl;
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    double ans = 0.0, A;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        ans += 1.0 / A;
    }
    ans = 1.0 / ans;
    cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

int N;
void solve(string tmp, char max, int n);
int main(void) {

    cin >> N;
    solve("a", 'a', 2);
    return 0;
}

void solve(string tmp, char mx, int n) {
    if(n > N) {
        cout << tmp << endl;
        return;
    }
    rep(i, n) {
        string c = "a";
        c[0] += i;

        if(c[0] - mx > 1) break;

        char nmx = max(mx, c[0]);

        solve(tmp+c, nmx, n+1);
    }
}


Measured memory_bytes: 1536
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int INF = 1000000000;

int n, m;
string recipe[1000];
map<string, int> dp;
vector<string> keys;

int intrecipe[1000];
int intdp[5000000];

string nand(string s1, string s2) {
  string output = s1;
  REP(i, m) {
    output[i] = '0' + (s1[i]-'0' + s2[i]-'0') % 2;
  }
  return output;
}

int str2int(string s) {
  int output = 0;
  REP(i, m) {
    if (s[i] == '1') {
      int shift = m-1-i;
      output += 1<<shift;
    }
  }
  return output;
}

int main(){
  while(1) {
    cin >> n >> m;
    if (n==0) break;

    REP(i, n) {
      cin >> recipe[i];
      intrecipe[i] = str2int(recipe[i]);
    }

    if (m <= 22) {
      int maxnum = pow(2, m);
      REP(i, maxnum) {
        intdp[i] = -1;
      }
      intdp[0] = 0;
      
      REP(i, n) {
        int cur_dp[5000000];
        REP(i, maxnum) {
          cur_dp[i] = -1;
        }

        REP(key, maxnum) {
          cur_dp[key] = max(cur_dp[key], intdp[key]);
          if (intdp[key] < 0) continue;

          int new_key = key^intrecipe[i];
          cur_dp[new_key] = max(intdp[new_key], intdp[key]+1);
        }

        REP(i, maxnum) {
          intdp[i] = cur_dp[i];
        }
      }
      cout << intdp[0] << endl;
    
    } else {
      dp = map<string, int>();
      keys = vector<string>();

      string init = string(m, '0');
      dp[init] = 0;
      keys.push_back(init);

      REP(i, n) {
        int keysize = keys.size();
        map<string, int> cur_dp;
        REP(j, keysize) {
          string key = keys[j];
          cur_dp[key] = max(cur_dp[key], dp[key]);
          string new_key = nand(key, recipe[i]);
          
          if (dp.find(new_key) != dp.end()) {
            cur_dp[new_key] = max(dp[new_key], dp[key] + 1);
          } else {
            cur_dp[new_key] = dp[key] + 1;
            keys.push_back(new_key);
          }
        }
        dp = cur_dp;
      }

      cout << dp[init] << endl;
    }
  }
}



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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (n * a > b) {
        cout << b << endl;
    } else if (n * a < b) {
        cout << n * a << endl;
    } else {
        cout << b << endl;
    }
    return 0;
}

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

#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi (3.14159265358979323846264338327950288419716939937510)
#define fo(i, n) for(int i = 0; i < n; ++i)
#define ro(i, n) for(int i = n - 1; i >= 0; --i)
#define fill(x, y) memset(x, y, sizeof(x))


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef double D;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

int main() {
    int n;
    cin >> n;
    int l = 0, r = n - 1;
    string str;
    cout << 0 << endl;
    cin >> str;
    bool check = (str[0] == 'F');
    while (str[0] != 'V') {
        int c = (l + r) >> 1;
        cout << c << endl;
        cin >> str;
        bool b = (str[0] == 'F');
        if (1 & c) b = !b;
        if (b == check) l = c + 1;
        else r = c - 1;
    }
}


Measured memory_bytes: 852
<?php
fscanf(STDIN, '%d', $N);
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

// 偶数の数字のみ取得して配列にする。要素がない(全て奇数)の時は'APPROVED'を出力する
$array_even = array_filter( $A, "filterEven" );
if(!count($array_even)) {
    echo 'APPROVED';
    return;
}

// 配列の要素に対して、3または5で割り切れるか確認する。あったら'DENIED'を出力する
foreach ($array_even as $num) {
    if(!canDevidedByThreeOrFive($num)) {
        echo 'DENIED';
        return;
    }
}

// 'APPROVED'を出力する
echo 'APPROVED';


// 関数の定義
function filterEven( $num ) {
    return( !( $num & 1 ) );
}
function canDevidedByThreeOrFive ( $num ) {
    if ($num % 3 === 0 || $num % 5 === 0 ) return true;
    return false;
}

?>


Measured memory_bytes: 4856
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>

class TVertex
{
    int FIndex;
    int FCommuniyId;
    std::list<TVertex*> FList;

public:
    TVertex(int Index)
     : FIndex(Index), FCommuniyId(0)
    {}
    void AddPath(TVertex* Vertex)
    {
        FList.push_back(Vertex);
    }
    void SetCommunity(int CommunityId)
    {
        if(FCommuniyId) return;
        FCommuniyId = CommunityId;
        for(std::list<TVertex*>::iterator It = FList.begin(); It != FList.end(); ++It){
            TVertex* V = *It;
            V->SetCommunity(CommunityId);
        }
    }
    int CommunityId()const
    {
        return FCommuniyId;
    }
};
class TGraph
{
    std::vector<TVertex*> FTable;
    void Init(int n)
    {
        assert(n > 0);
        FTable.resize(n);
        for(int i = 0; i < n; ++i){
            FTable[i] = new TVertex(i);
        }
    }
public:
    TGraph(int n)
    {
        Init(n);
    }
    void MakeFriend(int s, int t)
    {
        assert(s < FTable.size());
        assert(t < FTable.size());
        FTable[s]->AddPath(FTable[t]);
        FTable[t]->AddPath(FTable[s]);
    }
    void SetCommunity()
    {
        for(std::size_t i = 0; i < FTable.size(); ++i){
            FTable[i]->SetCommunity(i+1);
        }
    }
    bool IsSameCommunity(int s, int t)const
    {
        assert(s < FTable.size());
        assert(t < FTable.size());
        return FTable[s]->CommunityId() == FTable[t]->CommunityId();
    }
};

int main()
{
    int n, m;
    std::cin >> n >> m;
    TGraph Graph(n);
    for(int i = 0; i < m; ++i){
        int s, t;
        std::cin >> s >> t;
        Graph.MakeFriend(s, t);
    }
    int q;
    std::cin >> q;
    Graph.SetCommunity();
    for(int i = 0; i < q; ++i){
        int s, t;
        std::cin >> s >> t;
        std::cout << (Graph.IsSameCommunity(s, t) ? "yes" : "no") << std::endl;
    }
    return 0;
    
}

Measured memory_bytes: 15148
#include<stdio.h>
#include<math.h>
int main() {
  int a, b, c, d, l, n, x, z;
  scanf("%d %d %d %d %d", &l, &a, &b, &c, &d);
  n = ceil((double)a / (double)c);
  x = ceil((double)b / (double)d);
  if(n >= x) {
    z = l - n;
  }else{
    z = l - x;
  }
  printf("%d\n", z);
  return 0;
}

Measured memory_bytes: 1028
# coding: utf-8
from collections import deque


def solve(*args: str) -> str:
    h, w = map(int, args[0].split())
    walls = [[c == '#' for c in s] for s in args[1:]]

    count = 0
    Q = deque()

    for sy in range(h):
        for sx in range(w):
            if walls[sy][sx]:
                continue

            passed = [[False]*w for _ in range(h)]
            Q.append((sx, sy, 0))
            while Q:
                x, y, c = Q.popleft()
                if walls[y][x] or passed[y][x]:
                    continue

                passed[y][x] = True
                count = max(c, count)

                if 0 < x:
                    Q.append((x-1, y, c+1))
                if x+1 < w:
                    Q.append((x+1, y, c+1))
                if 0 < y:
                    Q.append((x, y-1, c+1))
                if y+1 < h:
                    Q.append((x, y+1, c+1))

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
 
using namespace std;
int main(void){
 
    int dice[6];
    cin >> dice[0] >> dice[1] >> dice[2] >> dice[3] >> dice[4] >> dice[5];
     
    int q;
    cin >> q;
 
    for(int i=0;i<q;i++){
        int f_u,f_f;
        cin >> f_u >> f_f;
        
        for(int j=0;j<6;j++) if(dice[j]==f_u) f_u=j+1;
        for(int j=0;j<6;j++) if(dice[j]==f_f) f_f=j+1;
         
        if(f_u==1 and f_f==2){
            cout << dice[3-1] << endl;
        }else if(f_u==1 and f_f==3){
            cout << dice[5-1] << endl;
        }else if(f_u==1 and f_f==4){
            cout << dice[2-1] << endl;            
        }else if(f_u==1 and f_f==5){
            cout << dice[4-1] << endl;
        }else if(f_u==2 and f_f==1){
            cout << dice[4-1] << endl;
        }else if(f_u==2 and f_f==3){
            cout << dice[1-1] << endl;
        }else if(f_u==2 and f_f==4){
            cout << dice[6-1] << endl;
        }else if(f_u==2 and f_f==6){
            cout << dice[3-1] << endl;
        }else if(f_u==3 and f_f==1){
            cout << dice[2-1] << endl;
        }else if(f_u==3 and f_f==2){
            cout << dice[6-1] << endl;
        }else if(f_u==3 and f_f==5){
            cout << dice[1-1] << endl;
        }else if(f_u==3 and f_f==6){
            cout << dice[5-1] << endl;
        }else if(f_u==4 and f_f==1){
            cout << dice[5-1] << endl;
        }else if(f_u==4 and f_f==2){
            cout << dice[1-1] << endl;
        }else if(f_u==4 and f_f==5){
            cout << dice[6-1] << endl;
        }else if(f_u==4 and f_f==6){
            cout << dice[2-1] << endl;
        }else if(f_u==5 and f_f==1){
            cout << dice[3-1] << endl;
        }else if(f_u==5 and f_f==3){
            cout << dice[6-1] << endl;
        }else if(f_u==5 and f_f==4){
            cout << dice[1-1] << endl;
        }else if(f_u==5 and f_f==6){
            cout << dice[4-1] << endl;
        }else if(f_u==6 and f_f==2){
            cout << dice[4-1] << endl;
        }else if(f_u==6 and f_f==3){
            cout << dice[2-1] << endl;
        }else if(f_u==6 and f_f==4){
            cout << dice[5-1] << endl;
        }else if(f_u==6 and f_f==5){
            cout << dice[3-1] << endl;
        }
 
    }
 
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int ans[2][105];
long long num[105];
long long now[105];
int divv[2][105];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&num[i]);
	}
	int divn=0,f=1;
	divv[0][0]=0;
	for(int i=1;i<n;i++)
	{
		if(f==1&&num[i]<num[i-1])
		{
			divv[1][divn]=i-1;
			divn++;
			f=-1;
		}
		else if(f==-1&&num[i]>num[i-1])
		{
			divv[0][divn]=i-1;
			f=1;
		}
	}
	if(f==1)divv[1][divn++]=n-1;
	else if(f==-1)
	{
		divv[0][divn]=n-1;
		divv[1][divn]=n-1;
		divn++;
	}
	int cnt;
	for(int i=0;i<divn;i++)
	{
		for(int j=0;j<n;j++)
		{
			now[j]=num[j];
		}
		int st=divv[0][i],ed=divv[1][i];
		cnt=0;
			if((i>0&&now[st]>0)||(i<divn-1&&now[ed]<0))continue;
			int p=st;
			while(cnt<=2*n&&p>0)
			{
				while(cnt<=2*n&&now[p-1]>now[p])
				{
					now[p-1]+=now[p];
					ans[0][cnt]=p;
					ans[1][cnt]=p-1;
					cnt++;
				}
				p--;
			}
			p=ed;
			while(cnt<=2*n&&p<n-1)
			{
				while(cnt<=2*n&&now[p+1]<now[p])
				{
					now[p+1]+=now[p];
					ans[0][cnt]=p;
					ans[1][cnt]=p+1;
					cnt++;
				}
				p++;
			}
		if(cnt<=2*n)break;
	}
	printf("%d\n",cnt);
	for(int i=0;i<cnt;i++)
	{
		printf("%d %d\n",ans[0][i]+1,ans[1][i]+1);
	}
	return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    string ans = "No";
    
    for(int j =1 ;j < 10;j++){
        for(int i =1 ;i < 10;i++){
            if(j*i == n){
                ans = "Yes";
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class AOJ
{
    public static void Main()
    {
        var line = Console.ReadLine().Trim().Split(' ').Select(s => int.Parse(s)).ToArray();
        int a = line[0];
        int b = line[1];
        int c = a*b;
        int d = 2*a + 2*b;
        Console.WriteLine(c+" "+d);
    }
}


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

int main()
{
    int data;
    int a[101] = {};

    while( cin >> data )
        a[data]++;
        
    int max = 0;
    for( int i = 1; i < 101; i++ )
        if( max < a[i] )
            max = a[i];

    for( int i = 1; i < 101; i++ )
        if( max == a[i] )
            cout << i << endl;
    return 0;
}


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

int main(){
    
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;

    int ans=2*n;
    bool a=true;
    for(int i=n; i>0; i--){
        a=true;
        for(int j=0; j<i; j++){
            if(s.at(n-i+j)!=t.at(j)){

                a=false;
                break;
            }
        }
        if(a){
            ans-=i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(void){
	int a,b;
	cin >> a >> b;
	printf("%.6lf\n",(double)4 / 3 * M_PI * b * b * b * max((double)1, (double)a / (double)b));
	
	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int k;
	cin >> k;
	cout << k / 2 * ((k + 1) / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,ans;
bool ch1[17];
vector<pair<ll,ll>>ch[17];

void cal(){
	bool t=true;
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(ch1[i]){
			cnt++;
			for(ll j=0;j<ch[i].size();j++){
				pair<ll,ll>now=ch[i][j];
				if(now.second!=ch1[now.first]){
					t=false;
				}
			}
		}
	}
	if(t){
		ans=max(ans,cnt);
	}
}
void dep(ll now){
	if(now==n){
		cal();
		return ;
	}
	ch1[now]=1;dep(now+1);
	ch1[now]=0;dep(now+1);
}
int main() {
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		for(ll j=0;j<x;j++){
			ll y,z;
			cin>>y>>z;
			y--;
			ch[i].push_back(make_pair(y,z));
		}
	}
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#枚数の入力
input500=int(input())
input100=int(input())
input50=int(input())
inputSum=int(input())

#通りの変数
sumWay=0
tempSum=0

if inputSum >= 500:
    #500円の計算
    for i in range(input500 + 1):
        tempSum=0
        tempSum+=(500 * i)
        
        #ここで全体を抜ける処理
        if inputSum == tempSum:
            sumWay+=1
            break
        
        elif tempSum < inputSum :
            #100円の計算
            for m in range(input100 + 1):
                tempSum100=tempSum
                tempSum100=tempSum + (100 * m)
                if inputSum < tempSum100:
                    break
                elif tempSum100 == inputSum:
                    sumWay+=1
                    continue
                else:
                    #50円の計算
                    for n in range(input50 + 1):
                        tempSum50=tempSum100
                        tempSum50= tempSum100 + (50 * n)
                        #ピッタリ
                        if inputSum == tempSum50:
                            sumWay+=1
                            continue
                        elif inputSum < tempSum50:
                            break
elif inputSum < 500 and inputSum >= 100:
#100円の計算
    for m in range(input100 + 1):
        tempSum100= 100 * m
        if inputSum < tempSum100:
            break
        elif tempSum100 == inputSum:
            sumWay+=1
            continue
        else:
            #50円の計算
            for n in range(input50 + 1):
                tempSum50=tempSum100
                tempSum50= tempSum100 + (50 * n)
                #ピッタリ
                if inputSum == tempSum50:
                    sumWay+=1
                    continue
                elif inputSum < tempSum50:
                    break
elif inputSum < 100:
#50円の計算
    for n in range(input50 + 1):
        tempSum50= 50 * n
        #ピッタリ
        if inputSum == tempSum50:
            sumWay+=1
            continue
        elif inputSum < tempSum50:
            break

print(sumWay)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define w(t) int t;cin>>t; while(t--)
using namespace std;

int main(){
    ll n, m;
    cin>>n>>m;
    ll h[n];
    for(ll i=0; i<n; i++) cin>>h[i];
    bool check[n+1];
    memset(check, true, sizeof(check));
    for(ll i=0; i<m; i++){
        ll u, v;
        cin>>u>>v;
        ll x, y;
        x = h[u-1];
        y = h[v-1];
        if(x>y){
            check[v] = false;
        }
        else if(y>x){
            check[u] = false;
        }
        else {
            check[u]= false;
            check[v] = false;
        }
    }
    ll ans = 0;
    for(ll i=1; i<=n; i++){
        if(check[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4488
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int kaijo(int x)
{
    int ans = 1;
    rep(i, 1, x + 1) ans *= i;
    return ans;
}

string n_shin(int x, int n)
{
    string s;
    while (x > 0)
    {
        s += to_string(x % n + 1);
        x /= n;
    }
    while (s.size() < n)
    {
        s += '0';
    }
    s.reserve();
    //cout << s << endl;
    return s;
}

int main()
{
    int n;
    cin >> n;
    set<int> s;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    Print(s.size() == n);
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
map<char,int>mp;
int main(){
    string s;
    cin>>s;
    for (int i = 0; i < s.size(); i++)
    {
        mp[s[i]]++;
    }
    int cnt=0;
    for (char mozi = 'a'; mozi <='c'; mozi++)
    {
        if(mp[mozi]) cnt++;
    }
    if(cnt==1){
        if(s.size()!=1)
        cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    else if(cnt==2){
        if(s.size()==2){
            cout<<"YES"<<endl;
        }
        else cout<<"NO"<<endl;
             
        }
    else if(cnt==3){
        if(s.size()%3==0){
            int ans=0;
              for (char mozi = 'a'; mozi <='c'; mozi++)
            {
            if(mp[mozi]==s.size()/3) ans++;
            }
            if(ans==3) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            }
        

        else if(s.size()%3==1){
             int ans=0;
              for (char mozi = 'a'; mozi <='c'; mozi++)
            {
            if(mp[mozi]==s.size()/3 ) ans++;
            if(mp[mozi]==s.size()/3+1) ans++;
            }
            if(ans==3) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            }

        
        else if(s.size()%3==2){
             int ans1=0,ans2=0,ans3=0;;
              for (char mozi = 'a'; mozi <='c'; mozi++)
            {
            if(mp[mozi]==s.size()/3 ) ans1++;
            if(mp[mozi]==s.size()/3+1) ans2++;
              if(mp[mozi]==s.size()/3-1) ans3++;
            }
            
            if(ans1+ans2+ans3 ==3) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            }
}
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include<cmath>

using namespace std;

int main(void) {
	int n,k;
	cin >> n >> k;

	if (n == 0) {
		cout << '1';
		return 0;
	}


	int ans = 1, omomi = k;
	while (true) {
		if (n-omomi<0) {
			cout << ans << endl;
			return 0;
		}
		else {
			ans++;
			omomi *= k;
		}
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

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

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

char a[101];
char b[101];

int main(){
	scanf("%s", a);
	scanf("%s", b);
	
	int len_a = strlen(a);
	int len_b = strlen(b);
	
	if (len_a > len_b) cout << "GREATER" << endl;
	else if (len_a < len_b) cout << "LESS" << endl;
	else {
		REP(i,len_a){
			if (a[i] - b[i] > 0){
				cout << "GREATER" << endl;
				break;
			}
			else if (a[i] - b[i] < 0){
				cout << "LESS" << endl;
				break;
			}
			
			if (i == len_a-1){
				cout << "EQUAL" << endl;
				break;
			}
		}
	}
	
	return 0;
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ll long long
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef vector<ll> vi;
typedef vector<char> vc;
     
#define mp make_pair
#define ff first
#define ss second
     
const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;  
const int inf = 1e9 + 5;
ll lcm(ll a,ll b)
{
        return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
int max(int a,int b)
{
        if(a<b)
        return b;
        return a;
}

int main()
{
  fast_io;
  int T=1;
 //  cin>>T;
  while(T--)
  { 
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      ll a1=max((ll)(a*c),(ll)(b*d));
      ll a2=max((ll)(a*d),(ll)(b*c));
      cout<<max(a1,a2)<<'\n';

  }
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};
const char d[4]={'R','L','D','U'};
const int N=1005;
typedef long long ll;
const ll inf=1e18;
vector<int> vec;
int n,x[N],y[N],s0,s1;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d%d",&x[i],&y[i]);
		if ((x[i]+y[i])&1) s1++;else s0++;
	}
	if (s0&&s1) return puts("-1"),0;
	if (s0) puts("32");else puts("31");
	for (int i=30;i>=0;i--)
	  vec.push_back(1<<i),printf("%d ",1<<i);
	if (s0) vec.push_back(1),printf("%d",1);
	puts("");
	for (int i=1;i<=n;i++)
	{
		ll nx=0,ny=0;
		for (int j=0;j<vec.size();j++)
		{ 
		   ll Min=inf,pos;
		   for (int k=0;k<4;k++)
		   {
		   	  ll xx=nx+vec[j]*dx[k],yy=ny+vec[j]*dy[k];
		   	  if ((ll)abs(x[i]-xx)+abs(y[i]-yy)<Min)
		   	  {
		   	  	  Min=(ll)abs(x[i]-xx)+abs(y[i]-yy);
		   	  	  pos=k;
			  }
		   }
		   printf("%c",d[pos]);
		   nx+=vec[j]*dx[pos];ny+=vec[j]*dy[pos];
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[100],b[100],c[100],n;
int main(){
     cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<n;i++){
        cin>>c[i];
    }
    ll ans=0,last=0;
    for(int i=1;i<=n;i++){
        int x=a[i];
        ans+=b[x];
        if(last+1==x){
            ans+=c[last];
        }
        //cout<<last<<" "<<ans<<endl;
        last=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# N個のimosなので二次元でやる 0.5がうざいので*2する( (2*10^5) * C )

# なぜか2WAが取れない

# これ嘘解法ぽい気がする

N, C = map(int, input().split())
x = 2 * (10**5)
# x = 30  # test
imos = [[0 for _ in range(x)] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    s, t, c = s * 2 - 1, t * 2 - 1, c - 1
    imos[c][s - 1] += 1
    imos[c][t] -= 1
    # imos[c][s - 1] = min(1, imos[c][s - 1])  # test

for i in range(C):
    for j in range(1, x):
        imos[i][j] += imos[i][j - 1]
        # imos[i][j] = min(1, imos[i][j])  # test

ans = 0
for j in range(x):
    tmp = 0
    for i in range(C):
        tmp += min(1, imos[i][j])
    ans = max(ans, tmp)
# print("-----------")
# for x in imos:
#     print(x)
print(ans)

# 1 3
# 3 4 2


Measured memory_bytes: 133932
let n = stdin.ReadLine() |> int
let values = stdin.ReadLine().Split() 

// 出現回数マックスの文字と出現回数
let maxAppearNum seq = seq |> Seq.countBy (fun x -> x) |> Seq.maxBy (fun (str,count) -> count) 

let nextMaxAppearNum seq maxStr =
    seq |> Seq.filter (fun x -> x <> maxStr) |> Seq.toList 
    |> function
    |[] -> ("#",0)
    |x -> maxAppearNum x


let evenValues, oddValues =
    values |> Seq.mapi (fun i x -> i,x) |> Seq.filter (fun (i,_) -> i%2 = 0) |> Seq.map snd
    ,values |> Seq.mapi (fun i x -> i,x) |> Seq.filter (fun (i,_) -> i%2 = 1) |> Seq.map snd

(
    maxAppearNum evenValues,
    maxAppearNum oddValues
)
||> fun (str1,count1) (str2,count2) -> 
    if str1 = str2 then
        min
            (
                let (str2,count2) = nextMaxAppearNum oddValues str2 
                n - count1 - count2
            )
            (
                let (str1,count1) = nextMaxAppearNum evenValues str1
                n - count1 - count2
            )

    else
        n - count1 - count2
|> stdout.WriteLine

Measured memory_bytes: 36616
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    string A = "AAA";
    string B = "BBB";
    if (s != A && s != B) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main(void){
    //substr
    int K; string S;
    cin >> K >> S;
    if(S.size() <= K) cout << S << endl;
    if(S.size() > K) {
        // substr(const string&, int, int) -> string
        string ss = S.substr(0, K);
        cout << ss << "..." << endl;
        
        
    }
}


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

int main(){
	int N;
	int K;
	cin >> N >> K;
	
	int h[100010];
	int ans=0;
	for(int i=0; i<N; i++){
		cin >> h[i];
		if(h[i]>=K){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
n = int(input())
def f(a,b):
    a = list(str(a))
    b = list(str(b))
    return max(len(a),len(b))

m = float('inf')
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        m = min(m,f(i,n//i))
print(m)


Measured memory_bytes: 9312
// https://atcoder.jp/contests/abc163/tasks/abc163_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "unordered_map"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    [[nodiscard]]
#elif defined(__GNUC__) && \
    (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
    __attribute__((warn_unused_result))
#endif
    FixPoint : private F {
 public:
  explicit constexpr FixPoint(F && f) noexcept : F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
      noexcept(noexcept(
          F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) makeFixPoint(F&& f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

void solve() {
  ll N;
  cin >> N;

  struct Val {
    ll i, a;
  };

  V<Val> as(N);
  rep(i, N) {
    ll a;
    cin >> a;

    as[i] = {i, a};
  }

  sort(all(as), [](Val a, Val b) { return a.a > b.a; });

  VVL memo(N + 1, VL(N + 1));

  auto dfs = makeFixPoint([&](auto f, ll i, ll next_left) -> ll {
    if (i == N) return 0;
    ll next_right = N - 1 - i + next_left;

    if (memo[i][next_left]) {
      return memo[i][next_left];
    }

    Val val = as[i];

    ll left_dis = abs(val.i - next_left);
    ll right_dis = abs(val.i - next_right);

    ll res = 0;

    chmax(res, val.a * right_dis + f(i + 1, next_left));
    chmax(res, val.a * left_dis + f(i + 1, next_left + 1));

    memo[i][next_left] = res;

    return res;
  });

  ll res = dfs(0, 0);

  cout << res << "\n";
}


Measured memory_bytes: 34896