akhauriyash/Code-Regression huggingface dataset:
using System.Linq;
using System;

public class Hello
{
    public const long INF = 99999999999999999;
    public static void Main()
    {
        var ret = new long[4];
        for (int i = 0; i < 4; i++) ret[i] = INF;
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = long.Parse(line[0]);
        var y = long.Parse(line[1]);
        ret[0] = getAns(x, y);
        ret[1] = getAns(x, -y) + 1;
        ret[2] = getAns(-x, y) + 1;
        ret[3] = getAns(-x, -y) + 2;
        Console.WriteLine(ret.Min());
    }
    public static long getAns(long a, long b)
    {
        return a <= b ? b - a : INF;
    }
}


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

int yakusuu(int n){
  int count = 0;
  for(int i=1;i<=n;i++){
    if(n%i == 0){
      count++;
    }
  }
  return count;
}
int main() {
  int N;
  cin >> N;
  int count = 0;
  for(int i=1;i<=N;i++){
    if(yakusuu(i) == 8 && i%2 == 1){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll A;
  string B;
  cin >> A >> B;
  ll B1, B2, B3;
  B1 = (B.at(0) - '0') * 100;
  B2 = (B.at(2) - '0') * 10;
  B3 = B.at(3) - '0';
  ll C = B1 + B2 + B3;
  ll D = A * C;
  ll E = D / 100;
  cout << E << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
int N,x,cunt[MAX+1],X[MAX+1],max_p;
int a[3]={-1,0,1};
int main(){
    cin>>N;
    vector<int>V[N];
    
    for(int i=1;i<=N;i++){
        cin>>x;
        for(int j=0;j<3;j++)
            mp[x+a[j]]++;
    }
    
    for(auto p:mp){
        max_p=max(max_p,p.second);
    }

    cout<<max_p<<"\n";

    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

void solve() {
    ll n; cin >> n;
    ll nn = n;

    ll m;
    for (m = 1; n > 0; ++m) {
        n -= pow(26, m);
    }
    --m;

    string s;

    for (int i = 0; i < m; ++i) {
        --nn;
        s += (char) ('a' + nn % 26);
        nn /= 26;
    }

    reverse(s.begin(), s.end());
    cout << s << endl;
}

int main(void) {
    int t; t = 1;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<list>
#include<vector>
#include <cstdio>
#include<string>
static const int	RootParentID = -1;
static const int	NIL = -2;
class node {
private:
	int Parent;
	int LeftChild;
	int RightBro;
public:
	node() {
		Parent = RootParentID;
		LeftChild = RightBro = NIL;
	}

	int CheckDepth(const std::vector<node> & nodes) {
		int CheckNodeParent = Parent;
		int cnt = 0;
		while (CheckNodeParent != RootParentID) {
			++cnt;
			CheckNodeParent = nodes[CheckNodeParent].Parent;
		}
		return cnt;
	}
	void AddParent(int id) {
		Parent = id;
		return;
	}
	void AddRightBro(int id) {
		RightBro = id;
		return;
	}
	void AddLeftChild(int id) {
		LeftChild = id;
		return;
	}
	int GetParent() {
		return Parent;
	}
	int GetLeftChild() {
		return LeftChild;
	}
	int GetRightBro() {
		return RightBro;
	}
};
int main(void) {
	//	std::ios_base::sync_with_stdio(false);
	int n;
	std::cin >> n;
	int id, k;
	int child;
	//	node * nodes = new node[ n];
	std::vector<node> nodes(n);
	for (int i = 0; i < n; i++) {
		std::cin >> id >> k;
		std::vector<int> v(k + 1);
		for (int j = 0; j < k; ++j) {
			std::cin >> child;
			v[j] = child;
		}
		v[k] = NIL;
		for (int j = 0; j < k; ++j) {
			nodes[v[j]].AddParent(id);
			nodes[v[j]].AddRightBro(v[j + 1]);
		}
		nodes[id].AddLeftChild(v[0]);
	}
	for (int i = 0; i < n; ++i) {
		printf("node %d: parent = %d, depth = %d, %s, [", i, nodes[i].GetParent(), nodes[i].CheckDepth(nodes),(nodes[i].GetParent() == RootParentID ? "root" : (nodes[i].GetLeftChild() == NIL ? "leaf" : "internal node")) );
		if (nodes[i].GetLeftChild() == NIL) printf("]\n");
		for (int k = nodes[i].GetLeftChild(); k != NIL; k = nodes[k].GetRightBro()) {
			printf("%d%s", k, (nodes[k].GetRightBro() == NIL ? "]\n" : ", "));
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  for(int i = 0; i < 12; i++){
    cout << S.at(i);
    if(i == 3) cout << ' ';
  }
  cout << endl;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

vi normalize(vi a)
{
	vi res=a;
	rep(i,3){
		rotate(all(a)-1,end(a));
		res=min(res,a);
	}
	return res;
}

ll count(const vvi& faces)
{
	ll res=1;
	for(vi face:faces)
		if(face[0]==face[2]&&face[1]==face[3]){
			res*=2;
			if(face[0]==face[1])
				res*=2;
		}
	return res;
}

ll npr(int n,int p)
{
	ll res=1;
	rep(i,p) res*=n-i;
	return res;
}

ll calc(const vvi& cs,map<vi,ll>& f,int ti,int bi)
{
	vvi faces={
		normalize(vi{cs[ti][1],cs[ti][0],cs[bi][1],cs[bi][0]}),
		normalize(vi{cs[ti][2],cs[ti][1],cs[bi][0],cs[bi][3]}),
		normalize(vi{cs[ti][3],cs[ti][2],cs[bi][3],cs[bi][2]}),
		normalize(vi{cs[ti][0],cs[ti][3],cs[bi][2],cs[bi][1]}),
	};
	map<vi,int> g;
	for(auto face:faces) g[face]++;
	ll res=count(faces);
	for(auto p:g){
		vi face=p.first;
		int n=f[face]-(face==cs[ti])-(face==normalize(cs[bi]));
		res*=npr(n,p.second);
	}
	return res;
}

int main()
{
	for(int n;cin>>n&&n;){
		vvi cs(n,vi(4));
		rep(i,n){
			rep(j,4) cin>>cs[i][j];
			cs[i]=normalize(cs[i]);
		}

		map<vi,ll> f;
		rep(i,n) f[cs[i]]++;

		ll res=0;
		rep(i,n) repi(j,i+1,n) rep(k,4){
			res+=calc(cs,f,i,j);
			rotate(all(cs[j])-1,end(cs[j]));
		}
		cout<<res/3<<endl;
	}
}


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

int main() {
    int N; cin >> N;
    vector<ll> h(N+1);
    h[0] = 0;

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

    vector<ll> dp(N+1);
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= N; i++)
        dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
    cout << dp[N] << endl;
}


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

void main_()
{
    double a, b, x;
    cin >> a >> b >> x;

    double volume = a * a * b;

    double ans;
    if (x * 2 < volume) {
        auto theta = atan(2.0 * x / (a * b * b));
        ans = (M_PI / 2 - theta) * 180.0 / M_PI;
    } else {
        auto theta = atan(2.0 * ((a * b - (x / a)) / (a * a)));
        ans = theta * 180.0 / M_PI;
    }

    cout << setprecision(15) << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 512
import itertools as it

N,K = map(int, input().split())
mod = 10**9 + 7
left = it.islice(it.accumulate(reversed(range(N+1))), K-1, N+1)
right = it.islice(it.accumulate(range(N+1)), K-1, N+1)
ans = sum(map(lambda x,y: x-y+1, left, right))
print(ans%mod)

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

ll lcm(ll a,ll b){
    ll big,small;
    if(a > b){
        big = a;
        small = b;
    }else{
        big = b;
        small = a;
    }
    ll tmp_small;
    while(true){
     tmp_small = small;
        small = big % small;
        if(small == 0) break;
        big = tmp_small;
    }

    return a * b / tmp_small;
}

ll number(ll s,ll g,ll r){
    ll first,last;
    if(s % r == 0){
        first = s / r;
    }else{
        first = s / r + 1;
    }

    last = g / r;
    return last - first + 1;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll all = b - a + 1;
    ll l = lcm(c,d);
    ll num = all - number(a,b,c) - number(a,b,d) + number(a,b,l);
    cout << num << endl;
}

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

signed main(){
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(abs(a-b)>1000000000000000000){
    cout<<"Unfair";
  }
  else if(k%2==0){
    cout<<a-b;
  }
  else if(k%2==1){
    cout<<b-a;
  }
}

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

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

c = []
for n in range(1, N+1):
    _n = n
    i = 0
    while True:
        a = _n % 2
        _n = _n // 2
        if a:
            c += [i]
            break
        i += 1

print(c.index(max(c))+1)


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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'

using namespace std;

const int MOD = 1e9 + 7;
const int N = 510;
int num, x;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	char ch[n];
	for (int i = 0; i < n; ++i) {
		cin >> ch[i];
		if ( ch[i] == 'R')
			++num;
	}
	for (int i = 0; i < n; ++i) {
		if (i < num and ch[i] == 'R')
			++x;
	}
	cout << num - x << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main()
{	
	ULL n;
	string x;
	cin >> n >> x;

	ULL one0 = 0;
	for (ULL i = 0; i < n; i++) {
		if (x[i] == '1') one0++;
	}
	bool cnt0 = false;
	ULL one1 = one0 + 1, one_1 = 1;
	if (one0 > 1) one_1 = one0 - 1;
	else cnt0 = true;

	VV<ULL> mods(2, V<ULL>(n, 0));
	ULL t1 = 1, t_1 = 1;
	for (ULL i = 0; i < n; i++) {
		mods[0][i] = t_1 % one_1;
		mods[1][i] = t1 % one1;
		t_1 = t_1 * 2 % one_1;
		t1 = t1 * 2 % one1;
	}

	ULL mod_1 = 0, mod1 = 0;
	for (ULL i = 0; i < n; i++) {
		if (x[i] == '1') {
			mod_1 = mod_1 + mods[0][n - 1 - i];
			mod1 = mod1 + mods[1][n - 1 - i];
		}
	}

	for (ULL i = 0; i < n; i++) {
		if (x[i] == '1') {
			if (cnt0) {
				col(0);
				continue;
			}

			ULL mod0 = (mod_1 - mods[0][n - 1 - i]) % one_1;
			ULL cnt = 1;
			while (mod0 > 0) {
				bitset<32> b(mod0);
				mod0 = mod0 % b.count();
				cnt++;
			}

			col(cnt);
		}
		else {
			ULL mod0 = (mod1 + mods[1][n - 1 - i]) % one1;
			ULL cnt = 1;
			while (mod0 > 0) {
				bitset<32> b(mod0);
				mod0 = mod0 % b.count();
				cnt++;
			}

			col(cnt);
		}
	}

	return 0;
}


Measured memory_bytes: 8332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
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 long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}
 
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int s = 0;
    s = a*b/2;
    cout << s << "\n";
}


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

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

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int sx,sy,gx,gy,n,lx,ly;
    set<pair<int,int>> ng;
    cin >> sx >> sy >> gx >> gy >> n;
    rep(i,0,n){
        int x,y;
        cin >> x >> y;
        ng.insert(make_pair(x,y));
    }
    cin >> lx >> ly;

    const int dx[]={0,1,1,0,-1,-1,0};
    const int dy[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};
    map<tuple<int,int,int>,int> dp;
    priority_queue<pair<int,tuple<int,int,int>>,vector<pair<int,tuple<int,int,int>>>,greater<pair<int,tuple<int,int,int>>>> updates;
    dp.insert(make_pair(make_tuple(sx,sy,0),0));
    updates.push(make_pair(0,make_tuple(sx,sy,0)));
    while(!updates.empty()){
        auto p=updates.top(); updates.pop();
        const int x=get<0>(p.second),y=get<1>(p.second);
        const int t=get<2>(p.second),c=p.first;
        {
            auto it=dp.find(make_tuple(x,y,t));
            if(it!=dp.end() and c>it->second) continue;
        }
        if(x==gx and y==gy){
            cout << c << endl;
            return;
        }
        const int dir=abs(x*y*t)%6;
        rep(i,0,7){
            const int nx=x+dx[i],ny=y+dy[(x+256)%2][i]; if(abs(nx)>lx or abs(ny)>ly) continue;
            const auto next_key=make_tuple(nx,ny,(t+1)%6);
            if(ng.find(make_pair(nx,ny))!=ng.end()) continue;
            if(dp.find(next_key)==dp.end()) dp.insert(make_pair(next_key,inf));
            auto it=dp.find(next_key);
            int tmp1=c+(i!=dir),&tmp2=it->second;
            if(tmp1>=tmp2) continue;
            tmp2=tmp1;
            updates.push(make_pair(tmp2,next_key));
        }
    }
    cout << -1 << endl;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 17832
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  ll a,b,x;
  cin >> a >> b >> x;
  if(a%x==0){
    cout << (b/x+1) - (a/x+1)  +1 << endl;
  }
  else cout << (b/x+1) - (a/x+1) << endl;
}


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

long long cal;
long long mn[30],all;

main()
{
    long long d;
    scanf("%lld",&d);
    for(int i=0;i<26;i++)
    {
        scanf("%lld",&mn[i]);
        all+=mn[i];
    }
    long long sum=0;
    for(int i=0;i<d;i++)
    {
        int idx;
        long long mx=-1e18;
        for(int j=0;j<26;j++)
        {
            long long a;
            scanf("%lld",&a);
            // printf("%lld\n",a+mn[i]-all);
            if(mx<a+mn[j]-all)
            {
                mx=a+mn[j]-all;
                idx=j+1;
            }
        }
        printf("%d\n",idx);
    }
}


Measured memory_bytes: 3776
#include <iostream>
using namespace std;
int main()
{
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < 4; i++){
        if(s[i]=='+'){
        	ans ++;
		} else{
			ans --;
		}
    }
     cout << ans; 
}

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


 int main(){
 int a,b,c,d,e,k;
 cin >> a >> b >> c >> d >> e >> k;
 if(e - a > k){
     cout << ":(\n";
 }else{
     cout << "Yay!\n";
 }
 }

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

int mizuyari(int h[], int n) {
	int minval = 99999999;
	for (int i = 0; i < n; i++)minval = min(minval, h[i]);
	for (int i = 0; i < n; i++)h[i] -= minval;
	return minval;
}

int solve(int h[], int n) {
	int times = 0;
	int head = 0, tail = n;
	for (head = 0; head < n; head++) {
		while (h[head] > 0) {
			for (tail = head; tail < n && h[tail] > 0; tail++);
			times += mizuyari(h + head, tail - head);
		}
	}
	return times;
}

int main() {
	int h[100], n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> h[i];

	cout << solve(h, n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long


int main()
{
    io
	int t=1;
//	cin >> t;
	while (t--)
	{
        int n;
        cin >> n;
        set<string> s;
        for(int i = 0; i < n; i++)
        {
            string str;
            cin >> str;
            s.insert(str);
        }
        cout << s.size() << "\n";
	}
	return 0;
}

Measured memory_bytes: 19232
#include<bits/stdc++.h>
#define ll long long
#define add insert
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int answer=0;
    int f=1;
    while(b>f&&a>0)
    {
        f*=2;
        a--;
    }
    while(a-->0) f+=b;
    cout<<f;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int have = sc.nextInt();
        int[] array = new int[num];
        int min = 1001;
        int minIndex = -1;
        int count = -1;

        for(int i=0; i<num; i++){
            int a = sc.nextInt();
            array[i] = a;
            if(a < min){
                min = a;
                minIndex = i;
            }
            have -= a;
            count++;
        }

        while(have >= 0){
            have -= array[minIndex];
            count++;
        }

        System.out.println(count);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

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

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{

   int a,b,c,i;
    cin>>a>>b>>c;
    for( i=1;i<=100;i++){
      if(a*i%b==c){cout<<"YES\n";
            break;}
     }
      if(i==101){cout<<"NO\n";}
    
    

  }

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

int main(){
    int A[3];
    for(int i = 0; i < 3; i++)  cin >> A[i];
    sort(A, A+3);

    if(A[0] == 5 && A[1] == 5 && A[2] == 7) cout << "YES" << endl;
    else                                    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var h = sc.NextLong();
        var w = sc.NextLong();

        if (h == 1 || w == 1)
        {
            Console.WriteLine(1);
            return;
        }
        
        var l = h * w;

        Console.WriteLine((l + 1) / 2);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BAlgae {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long r = s.nextInt();
            long d = s.nextInt();
            long prev = s.nextInt();
            int i = 0;
            while (i < 10) {
                long ans = r * prev - d;
                out.println(ans);
                prev = ans;
                i++;
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

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

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

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll s;cin>>s;
  map<ll,ll> mp;
  ll now=s;
  mp[s]++;
  for(ll i=2;;i++){
    if(now%2==0)now/=2;
    else now=3*now+1;
    if(mp[now]==1){
      cout<<i<<endl;
      return 0;
    }
    mp[now]++;
  }
}
  


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,i,s=0,d=0;
    scanf("%lld",&a);
    for(i=1;i<=a;i++)
    {
        if(i%3==0||i%5==0||i%15==0)
        {
           s=s+i;
        }
        d=d+i;
    }
    printf("%lld",d-s);
}


Measured memory_bytes: 1732
#include <iostream> 
#include <vector>

static const long long MOD = 1000000007;

using namespace std;

long long fact[100002];
long long inv[100002];

void pre_computation() {
	fact[0] = 1;
	for (int i = 1; i <= 100001; i++) fact[i] = (i * fact[i - 1]) % MOD;
	// x^(p-1) mod p = 1 mod p --> x^(p-2) mod p = x^(-1) mod p
	inv[0] = 1;
	for (int i = 1; i <= 100001; i++) {
		int pow = MOD - 2;
		long long x = fact[i];
		inv[i] = 1;
		while (pow > 0) {
			if (pow % 2 == 0) {
				x = (x * x) % MOD;
				pow /= 2;
			} else {
				inv[i] = (inv[i] * x) % MOD;
				pow --;
			}
		}
	}
}

long long C(long long n, long long k) {
	if (n < k) return 0;
	return (((fact[n] * inv[n-k]) % MOD) * inv[k]) % MOD;
}

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	vector<int> a(N+1);
	int l = 0, r = 0;
	for (int i = 1; i <= N + 1; i++) {
		int ai;
		cin >> ai;
		if (a[ai] != 0) { r = i; l = a[ai]; }
		a[ai] = i;
	}

	pre_computation();

	for (int k = 1; k <= N + 1; k++) {
		cout << ((C(N+1, k) - C(l+N-r,k-1) + MOD) % MOD) << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int ar[n],ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }

    for(int i=1;i<n;i++)
    {
        if(ar[i]<ar[i-1])
        {
            ans=ans+ar[i-1]-ar[i];
            ar[i]=ar[i-1];
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 5116
#include <cstdio>
#include <memory.h>

using namespace std;

int main() {
    char num[4][3][10];
    memset(num, '0', sizeof(num));

    size_t n;
    scanf("%zu", &n);

    for (size_t i=0; i<n; ++i) {
        size_t b, f, r;
        int v;
        scanf("%zu %zu %zu %d", &b, &f, &r, &v);
        --b, --f, --r;

        num[b][f][r] += v;
    }

    for (size_t b=0; b<4; ++b) {
        for (size_t f=0; f<3; ++f) {
            for (size_t r=0; r<10; ++r) {
                printf(" %c", num[b][f][r]);
            }
            printf("\n");
        }
        if (b < 3)
            printf("####################\n");
    }

    return 0;
}

Measured memory_bytes: 2684
import sys
input = sys.stdin.buffer.readline
n,q=map(int,input().split())
a=list(map(int,input().split()))
queries=[[]for _ in[0]*n]
for i in range(q):
  l,r=map(int,input().split())
  l-=1
  r-=1
  queries[r].append((l,i))
lastAppeared=[0]*n
bit=[0]*(n+1)
ans=[0]*q
for i in range(n):
  x=lastAppeared[a[i]-1]+1
  while x<=n+1:
    bit[x-1]-=1
    x+=x&-x
  x=i+2
  while x<=n+1:
    bit[x-1]+=1
    x+=x&-x
  lastAppeared[a[i]-1]=i+1
  for l,ind in queries[i]:
    x=i+2
    while x:
      ans[ind]+=bit[x-1]
      x-=x&-x
    x=l+1
    while x:
      ans[ind]-=bit[x-1]
      x-=x&-x
print(*ans)


Measured memory_bytes: 194572
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define rnd(d) (ll)((double)d + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)x ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define ceildiv(a, b) ((ll)a / (ll)b + ((ll)a % (ll)b == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

struct sushi {
	ll x;
	ll v;
};

int main() {
	int n; cin >> n;
	ll c; cin >> c;
	vector<vector<sushi>> a(2, vector<sushi>(n));
	Loop(i, n) {
		cin >> a[0][i].x >> a[0][i].v;
	}
	Loopr(i, n) {
		a[1][n - 1 - i].x = c - a[0][i].x;
		a[1][n - 1 - i].v = a[0][i].v;
	}
	vvll dat(2, vll(n + 1, 0));
	Loop(k, 2) {
		Loop(i, n) {
			ll pre_x = i > 0 ? a[k][i - 1].x : 0;
			dat[k][i + 1] = dat[k][i] + a[k][i].v - (a[k][i].x - pre_x);
		}
	}
	vvll max_dat(2, vll(n + 1, 0));
	Loop(k, 2) {
		Loop(i, n) {
			max_dat[k][i + 1] = max(max_dat[k][i], dat[k][i + 1]);
		}
	}
	ll ans = 0;
	Loop(k, 2) {
		Loop(i, n) {
			ll buf1 = dat[k][i + 1];
			ll buf2 = dat[k][i + 1] - a[k][i].x + max_dat[(k + 1) % 2][n - 1 - i];
			ans = max(ans, max(buf1, buf2));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7268
#include<bits/stdc++.h>
#pragma GCC optimize("inline,Ofast",3)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
#define gc getchar()
#define lowbit(x) (x&(-x))
//register
//inline
//i=-~i
inline int read(){
	int sum=0,f=1;
	char ch=gc;
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch)){
		sum=(sum<<1)+(sum<<3)+(ch^48);
		ch=gc;
	}
	return f*sum;
}
int n,ans;
char ch[110];
int main(){
	n=read();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++){
		if(ch[i]=='A'&&ch[i+1]=='B'&&ch[i+2]=='C'){
			ans++;
			i+=2;
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    long n, a, b;
    scan(n, a, b);
    auto t = n / (a + b);
    auto r = n - t * (a + b);
    writeln(a * t + min(a, r));
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using ll = long long;
using ld = long double;
using Pa = std::pair<ll, ll>;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow(((x * x)%mod), n / 2,mod));
	else
		return ((x%mod) * pow(x, n - 1,mod));
}
vector<ll>primess(ll n) {
	vector<ll>a;
	while (n % 2 == 0)n /= 2, a.push_back(2);
	ll sosuu = 3;
	while (n != 1) {
		if (n % sosuu == 0)n /= sosuu, a.push_back(sosuu);
		else if (sosuu > sqrt(n) + 2) {
			a.push_back(n);
			break;
		}
		else sosuu += 2;
	}
	return a;
}
bool prime(int n) {
	int i = 2;
	if (n == 2)return true;
	else if(n <= 1)return false;
	if (n % i == 0)return false;
	i = 3;
	while (i <= sqrt(n)) {
		if (n % i == 0)return false;
		i += 2;
	}
	return true;
}
int main() {
	string s; cin >> s;
	int conut = 0;
	rip(i, 3)if (s[i] == 'R')conut++;
	if (s[1] == 'S')cout << min(conut, 1);
	else cout << conut << endl;
}

Measured memory_bytes: 3720
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

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

ll lcm(ll a,ll b){
    ll g =gcd(a,b);
    return a/g*b;
}

int main(){
    ll a , b , c , d;
    cin >> a >> b >> c >> d;
    ll l=lcm(c,d);
    ll C=b/c-(a-1)/c;
    ll D=b/d-(a-1)/d;
    ll L=b/l-(a-1)/l;
    cout<<b-a+1-(C+D-L)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int PrimeNumberCount(int*, int);

const unsigned int MAX_NATURAL_NUMBER = 1000000;

int main(){
	int BoolPrimeNumber[MAX_NATURAL_NUMBER] = { 1, 1 };
	int NaturalNumber;
	for (int i = 2; i * i < MAX_NATURAL_NUMBER; ++i){
		if (!BoolPrimeNumber[i]){
			for (int j = i * 2; j < MAX_NATURAL_NUMBER; j += i){
				BoolPrimeNumber[j] = 1;
			}
		}
	}
	while (std::cin >> NaturalNumber){
		std::cout << PrimeNumberCount(BoolPrimeNumber, NaturalNumber) << std::endl;
	}
}

int PrimeNumberCount(int* BoolPrimeNumber, int NaturalNumber){
	int count = 0;
	for (int i = 2; i < NaturalNumber + 1; ++i){
		if (BoolPrimeNumber[i] == 0){
			++count;
		}
	}
	return count;
}


Measured memory_bytes: 7008
#include <iostream>
using namespace std;
int main(void){
    int n,a[100],b=0,m=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b+=a[i];
    }
    for(int i=1;i<n;i++){
        if(abs(a[i]*n-b)<abs(a[m]*n-b)){
            m=i;
        }
    }
    cout<<m<<endl;
}


Measured memory_bytes: 764
//This code is written by Shammi Anand
#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define Max(a,b,c)      max(a,max(b,c))
#define Min(a,b,c)      min(a,min(b,c))
#define pb              push_back
#define mp              make_pair
#define f               first
#define s               second
#define mod             1000000007
#define nl              "\n"
#define w(x)            int x; cin>>x; while(x--)

void shammi() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main() {
	shammi();
	int X; cin >> X;
	if (X >= 30) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
 

int main()
{
    int A1,A2,A3,bust, win,x;
    scanf("%d %d %d",&A1,&A2,&A3);
    1<=A1,A2,A3<=13 ;
    x = 22 ;
    
    if(A1+A2+A3 >= x)
    {
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }
        
    return 0 ;
}
  

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;

map<int,ll> mp;

ll nck(ll n){
    if(n<=1)return 0;
    return n*(n-1)/2;
}
ll b[2000001]={0};
ll b2[2000001]={0};


int main(){
    ll N;
    cin>>N;
    ll A[200001];
    rep(i,N)cin>>A[i];
    rep(i,N){
        auto itr=mp.find(A[i]);
        if(itr != mp.end()){
            mp[A[i]]+=1;
        }
        else{
            mp[A[i]]=1;
        }
    }
   
    ll sum=0;
    for( auto i = mp.begin(); i != mp.end() ; ++i ) {
        ll j=i->first;
        ll j2=i->second;
        b[j]=nck(j2);b2[j]=nck(j2-1);
      
        sum+=b[j];
    }
    rep(i,N){
        int x;
        x=A[i];
        cout<<sum-b[x]+b2[x]<<endl;
    }
    return 0;
}

Measured memory_bytes: 16768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

void p(int a,char op1,int b,char op2,int c, char op3,int d){
    cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    int a = S[0] - '0',b = S[1] - '0',c = S[2] - '0',d = S[3] - '0';
    if(a + b + c + d == 7){
        p(a,'+',b,'+',c,'+',d);
    }else if(a + b + c - d == 7){
        p(a,'+',b,'+',c,'-',d);
    }else if(a + b - c + d == 7){
        p(a,'+',b,'-',c,'+',d);
    }else if(a - b + c + d == 7){
        p(a,'-',b,'+',c,'+',d);
    }else if(a - b + c - d == 7){
        p(a,'-',b,'+',c,'-',d);
    }else if(a + b - c - d == 7){
        p(a,'+',b,'-',c,'-',d);
    }else if(a - b - c + d == 7){
        p(a,'-',b,'-',c,'+',d);
    }else if(a-b-c-d == 7){
        p(a,'-',b,'-',c,'-',d);
    }
    return 0;
}


Measured memory_bytes: 256
class Dice
  attr_reader :current
  def initialize(current = 1, north = 5, east = 3)
    @current = current
    @north = north
    @east = east
  end

  def rotate(direction)
    case direction
    when "N"
      @current, @north = 7 - @north, @current
    when "S"
      @current, @north = @north, 7 - @current
    when "E"
      @current, @east  = 7 - @east, @current
    when "W"
      @current, @east  = @east, 7 - @current
    end
    self
  end
end

dice = gets.split
puts dice[gets.chomp.chars.reduce(Dice.new) {|acc, x| acc.rotate(x) }.current - 1]

Measured memory_bytes: 8628
#include<bits/stdc++.h>
using namespace std;
int n,tmp,ans=0;
std::vector<int> data;



void solve(){
  for(int i=0;i<=n-2;i++){
    for(int j=i+1;j<=n-1;j++){
      ans+=data.at(i)*data.at(j);
    }
  }

  cout<<ans<<endl;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    data.push_back(tmp);
  }

  solve();
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
LL INF = 1e9;
double EPS=1.0e-9;


int main()
{
    LL h,w,n;
    cin>>h>>w>>n;
    map<PII,int> m;
    REP(i,n)
    {
        int a,b;
        cin>>a>>b;
        for(int j=0;j<3;j++)
        for(int k=0;k<3;k++)
        if(0<a-j&&a-j<=h-2&&0<b-k&&b-k<=w-2)
        m[PII(a-j,b-k)]++;
    }
    LL cnt[10];
    LL sum=0;
    REP(i,10)
        cnt[i]=0;
    for(auto e=m.begin();e!=m.end();++e)
    {
        //cout<<(*e).first.first<<" "<<(*e).first.second<<" "<<(*e).second<<endl;
        cnt[(*e).second]++;
    }
    REP(i,10)
        sum+=cnt[i];
    cnt[0]=(h-2)*(w-2)-sum;
    
    REP(i,10)
    cout<<cnt[i]<<endl;
}

Measured memory_bytes: 56448
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
  public static void main(String[] args){
    FastScanner sc = new FastScanner();

    int A = sc.nextInt();
    int B = sc.nextInt();

    if((1 <= A && A <= 9) && (1<= B && B <= 9)){
      System.out.println(A * B);
    }else{
      System.out.println(-1);
    }
  }

  public static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(String s) {
      try {
        br = new BufferedReader(new FileReader(s));
      } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    public FastScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(nextToken());
    }

    long nextLong() {
      return Long.parseLong(nextToken());
    }

    double nextDouble() {
      return Double.parseDouble(nextToken());
    }
  }
}


Measured memory_bytes: 23252
#include <cstdio>

int main(){
    int min,max_s=-1000000001,n,r;
    
    scanf("%d",&n);
    scanf("%d",&min);
    for(int i=0;i<n-1;i++){
        scanf("%d",&r);
        if(r-min>max_s) max_s=r-min;
        if(min>r)min =r;
    }
    
    printf("%d\n",max_s);
    
    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

typedef struct { char suit, value; } Card;

void b(Card A[], int N)
{
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void s(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  b(C1,N);
  s(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2088