akhauriyash/Code-Regression huggingface dataset:
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const i64 INF = (i64) 1e18 + 42;

const int MOD = 998244353; 
inline int add(int a, int b, int mod = MOD) {
  a += b; return a >= mod ? a - mod : a;
}
inline int sub(int a, int b, int mod = MOD) {
  a -= b; return a < 0 ? a + mod : a;
}
inline int mul(int a, int b, int mod = MOD) {
  return int((long long) a * b % mod);
}
inline int mpow(int base, long long ex, int mod = MOD) {
  int res = 1;
  for (; ex > 0; ex >>= 1) {
    if (ex & 1) res = mul(res, base, mod);
    base = mul(base, base, mod);
  }
  return res;
}
inline int inv(int a, int mod = MOD) {
  return mpow(a, mod - 2, mod);
}
inline int mdiv(int a, int b, int mod = MOD) {
  return mul(a, mpow(b, mod - 2,  mod));
}
inline void adds(int &a, int b, int mod = MOD) {
  a += b; if (a >= mod) a -= mod;
}
inline void subs(int &a, int b, int mod = MOD) {
  a -= b; if (a < 0) a += mod;
}
inline void muls(int &a, int b, int mod = MOD) {
  a = int((long long) a * b % mod);
}
inline void mdivs(int &a, int b, int mod = MOD) {
  a = mdiv(a, b, mod);
}

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, s; cin >> n >> s;
  const int i2 = (MOD + 1) >> 1;
  vector<int> dp(s + 1, 0);
  dp[0] = mpow(2, n);
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    auto dq = dp;
    for (int j = x; j <= s; ++j) {
      adds(dp[j], mul(dq[j - x], i2));
    }
  }
  kek(dp.back());
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,c,k;
int t[125252];

int main(){
  scanf("%d%d%d",&n,&c,&k);
  REP(i,n)scanf("%d",t+i);
  sort(t,t+n);
  int it = 0;
  int ans = 0;
  while(it < n){
    int beg = t[it];
    int yo = it;
    while(it<n-1 && it+1<yo+c && t[it+1]<=beg+k)it++;
    // DEBUG(it-yo+1);
    ans++;
    it++;
  }
  printf("%d\n",ans);
  return 0;
}


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

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

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

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<lpair> D;

  cin >> N;
  D.resize(N);
  for (auto &in: D) {
    cin >> in.first >> in.second;
  }

  string ans = "No";
  for (int i = 0; i < N - 2; i++) {
    if (D[i].first == D[i].second &&
        D[i + 1].first == D[i + 1].second &&
        D[i + 2].first == D[i + 2].second) {
      ans = "Yes";
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  int size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, M; cin >> N >> M;
  UnionFind uf(N);
  rep(i,M) {
    ll A, B; cin >> A >> B; A--; B--;
    uf.unite(A,B);
  }
  set<ll> s; rep(i,N) s.insert(uf.root(i));
  ll result = s.size() - 1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7852
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <math.h>
using namespace std;

int main(void) {
  
  int A;
  int B;
  
  cin >> A;
  cin >> B;
  
  if ( A <= 9 && B <= 9 ) {
    
    cout << A * B << endl;
  }
  
  else {
    
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3592
n = int(input())
a = list(map(int,input().split()))
dic = {}
over = 0
color = 8
for i in range(n):
    if a[i]<400:
        dic.setdefault(400,0)
        dic[400] += 1
    elif a[i]<800:
        dic.setdefault(800,0)
        dic[800] += 1
    elif a[i]<1200:
        dic.setdefault(1200,0)
        dic[1200] += 1
    elif a[i]<1600:
        dic.setdefault(1600,0)
        dic[1600] += 1
    elif a[i]<2000:
        dic.setdefault(2000,0)
        dic[2000] += 1
    elif a[i]<2400:
        dic.setdefault(2400,0)
        dic[2400] += 1
    elif a[i]<2800:
        dic.setdefault(2800,0)
        dic[2800] += 1
    elif a[i]<3200:
        dic.setdefault(3200,0)
        dic[3200] += 1
    else:
        over += 1

if over > 0:
    if len(dic)==0:
        print(1,over)
    else:
        print(len(dic),len(dic)+over)
else:
    print(len(dic),len(dic))

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        A--, B--;
        uf.unite(A, B);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int n, k, p;

    while(cin >> n){
        rep(i,n){
            cin >> k >> p;
            if(k % p == 0){
                cout << p << endl;
            }else{
                cout << k % p << endl;
            }
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

ll Lucas(ll a) {
    if(a == 0) return 2;
    else if(a == 1) return 1;
    else return Lucas(a-1) + Lucas(a-2);
}
int main() {
    int n; cin >> n;
    vector<ll> ans(n+1);
    ans[0] = 2;
    ans[1] = 1;
    Rep(i, 2, n+1) ans[i] = ans[i-1] + ans[i-2];
    cout << ans[n] << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;
    bool check = 1;

    for(int i = 0; i < A + B + 1; i++) {
        if(i != A) {
            if(S.at(i) < '0' || S.at(i) > '9') {
                check = 0;
                //cout << i << endl;
                break;
            }
            //cout << i << endl;
            
        } else {
            if(S.at(A) != '-') {
                check = 0;
                break;
            }
        }
    }

    if(check) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3544
#include <stdio.h>
int main (){
  int i,n,k[100],p[100];
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d %d",&k[i],&p[i]);
    if (k[i]%p[i]==0){
      printf("%d\n",p[i]);
    }
    else {
       printf("%d\n",k[i]%p[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int main(){
	int k=0,s=0;
	int ans=0;
	scanf("%d %d",&k,&s);
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			if(s - x - y<=k && s - x - y>=0)ans++;
		}
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 128
X = int(input())
def prime(N):
    Num = [int(x) for x in range(2,N+1)]
    Prime = []
    limit = int(N**0.5)+1
    while  True:
        p = Num[0]
        if limit <= p:
            return Prime + Num
        Prime.append(p)
        Num = [x for x in Num if x%p != 0]
Pbox = prime(100003)
for i in Pbox:
    if i>= X:
        print(i)
        break

Measured memory_bytes: 7448
#define _CRT_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define ll long long
#define mod 1000000007
#define ld long double
#define infinity (ll)1e18+1
#define PI 3.14159265358979

#define pdd pair<double,double>
#define pll pair<ll, ll>
#define pii pair<ll,ll>

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<ll>//ll
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define vch vector<char>
#define vb vector<bool>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()
#define X first
#define Y second
#define MAXN 100001

ll md(ll a, ll b, ll c)
{
	ll m = abs(a - c);
	m = max(m, abs(a - b));
	m = max(m, abs(c - b));

	return m;
}

int main()
{
	ios_base::sync_with_stdio(false);

	ll h;
	ll w;
	cin >> h >> w;

	if (((h*w) % 3) == 0)
		cout << 0;
	else
	{
		ll best = infinity;

		if (h*w % 2 == 0)
		{
			if (h % 2 == 0 && w%2 == 1)
			{
				best = min(best, h / 2);
				best = min(best, w);
				ll k = w / 2;
				FOR(l, 0, h + 1)
					best = min(best, md(k*l + l, l*k, w*(h - l)));
			}
			else
			{
				if (w % 2 == 0 && h % 2 == 1)
				{
					best = min(best, h);
					best = min(best, w / 2);
					ll k = h / 2;
					FOR(l, 0, w + 1)
						best = min(best, md(k*l + l, l*k, h*(w - l)));
				}
				else
				{
					best = min(h, w) / 2;
				}
			}
			
		}
		else
		{
			best = min(h, w);


			ll k = w / 2;
			FOR(l, 0, h + 1)
			{
				best = min(best, md(k*l + l, k*l, w*(h - l)));
			}

			k = h / 2;
			FOR(l, 0, w + 1)
			{
				best = min(best, md(k*l + l, k*l, h*(w - l)));
			}
		}

		cout << best;
	}

	return 0;
}
/*
ll h;
ll w;
char field[100][100];

pii s;
pii t;


ll main()
{
cin >> h >> w;
FOR(i, 0, h)
FOR(j, 0, w)
cin >> field[i][j];

FOR(i, 0, h)
FOR(j, 0, w)
if (field[i][j] == 'S')
s = MP(i, j);
else
if (field[i][j] == 'T')
t = MP(i, j);


if (t.first == s.first || t.second == s.second)
{
cout << -1;
return 0;
}

*/

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-19 20:38:40
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  char a, b; cin >> a >> b;
  char mx = min(a, b);

  int cnt = max(a, b) - '0';
  debug(cnt);

  string ans = "";

  for (int i = 0; i < cnt; ++i) {
    ans += mx;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define MAX 2000000000

int main() {
    int n;
    cin >> n;
    int ans=(-MAX), buytime=MAX;
    rep(i,n) {
        int c;
        cin >> c;
        ans = max(ans, c-buytime);
        buytime = min(buytime, c);
    }
    ct(ans);
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s=="SUN") printf("7\n");
	if(s=="MON") printf("6\n");
	if(s=="TUE") printf("5\n");
	if(s=="WED") printf("4\n");
	if(s=="THU") printf("3\n");
	if(s=="FRI") printf("2\n");
	if(s=="SAT") printf("1\n");
	return 0;
}

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

#define int long long int

int dp[400][400], p[400];

int rsq(int l, int r) {
	if(!l) return p[r];
  	return p[r] - p[l - 1];
}

int recurse(int i, int j) {
	auto& state = dp[i][j];
  	if(state != -1) return state;
  	if(i == j) return state = 0;
  	int cost = rsq(i, j);
  	state = numeric_limits<int>::max();
  	for(int k = i; k < j; ++k) {
    	state = min(
          state,
          recurse(i, k) + recurse(k + 1, j) + cost
        );
    }
}

signed main() {
	int n; cin >> n;
  	int s[n];
  	for(int i = 0; i < n; ++i) cin >> s[i];
  	memset(dp, -1, sizeof dp);
  	p[0] = s[0];
  	for(int i = 1; i < n; ++i) p[i] = p[i - 1] + s[i];
  	cout << recurse(0, n - 1);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};



int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int cnt;
    if(a == b && b == c) cnt = 1;
    else if(a == b || b == c || c == a) cnt = 2;
    else cnt = 3;
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
	int i,n;
	while(scanf("%d",&n)!=EOF)
	{
		int a=0,b=0,t;
		for(i=0;i<n;i++)
		{
			scanf("%d",&t);
			if(t%2==0)
				a++;
			if(t%4==0)
				b++;
		//	printf("%d %d %d\n",a,b,n);
		}
		a=a-b;
		if((n-a)<=2*b&&a!=0)
			printf("Yes\n");
		else if((n-a-1)<=2*b&&a==0)
			printf("Yes\n");
		else
			printf("No\n");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c, a*d, b*c, b*d})<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    char a[4],b[4];
    for(int i=0;i < 3;i++)cin >> a[i];
    for(int i=0;i < 3;i++)cin >> b[i];

    if(a[1] == b[1] && a[0] == b[2] && a[2] == b[0])cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<int>& a, vector<int>& b) {
	return a[0] < b[0];
}

int ycomp(vector<int>& a, vector<int>& b) {
	return a[1] < b[1];
}

int zcomp(vector<int>& a, vector<int>& b) {
	return a[2] < b[2];
}
#define XSORT(c) sort((c).begin(),(c).end(),xcomp)
#define YSORT(c) sort((c).begin(),(c).end(),ycomp)
#define ZSORT(c) sort((c).begin(),(c).end(),zcomp)

#define ALL(x) (x).begin(),(x).end()
vector<LL> prime = { 2};
	LL mod = 1000000007;
int main() {
	FOR(i, 3, 1000) {

		REP(j, prime.size()) {
			if (i%prime[j] == 0) {
				goto KASU;
			}
		}
		prime.push_back(i);
	KASU:
		;
	}

		LL N;
		cin >> N;
		vector <LL> hoge(prime.size(), 0);
		FOR(i, 1, N + 1) {
			int x = i;
			REP(j, prime.size()) {
				while (x%prime[j] == 0) {
					x = x / prime[j];
					hoge[j]++;
				}
			}
		}
		LL ans = 1;
		REP(i, prime.size()) {
			ans = (ans*(hoge[i] + 1)) % mod;
		}
		cout << ans << endl;
	
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc164/tasks/abc164_c

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

    int main(void)
    {
        int i,l,flg = 0;
        char n[4];
        scanf("%s",&n);

        l = strlen(n);
        for(i=0;i<l;i++){
            if(n[i]=='7'){
                flg =  1;
                break;
            }
        }

        if(flg == 0){printf("No\n");}
        else{printf("Yes\n");}
        
        return 0;
    }

Measured memory_bytes: 1588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d[i];
  int sum = 0;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(i==j) continue;
      sum += d[i]*d[j];
    }
  }
  cout << sum/2 << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
for i in range(1000):
    i = str(i).zfill(3)

    one, two, three = False, False, False
    for j in range(n):
        if one:
            if two:
                if three:
                    break
                else:
                    if s[j] == i[2]:
                        three = True
            else:
                if s[j] == i[1]:
                    two = True
        else:
            if s[j] == i[0]:
                one = True
    if three:
        ans += 1
print(ans)


Measured memory_bytes: 42204
x,n = map(int, input().split())
if n==0:
  print(x)
else:
  p = list(map(int, input().split()))
  
  for i in range(101):
    if not x-i in p:
      print(x-i)
      break
    elif not x+i in p:
      print(x+i)
      break


Measured memory_bytes: 9112
#include <iostream>

#define ll long long

using namespace std;

ll powi(int x, int y){
    ll res = 1;
    for (int i = 0; i < y; i++){
        res *= (ll) x;
    }
    return res;
}

int main(){
    int n, k;
    cin >> n >> k;
    ll res;
    if (k % 2 == 0){
        int kk = k / 2;
        int knum, kknum;
        knum = n / k;
        kknum = n / kk - knum;
        res = powi(knum, 3) + powi(kknum, 3);
    } else {
        int knum = n / k;
        res = powi(knum, 3);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int max1,max2,max3,height;
  max1 = max2 = max3 = 0;
  int i;
  for ( i = 0;i < 10; i++)
    {
      scanf("%d",&height);
      if(max1 < height){max3 = max2;max2 = max1; max1 = height;}
      else if (max2 < height){max3 = max2; max2 = height;}
      else if (max3 < height) max3 = height;
    }
  printf("%d\n",max1);
  printf("%d\n",max2);
  printf("%d\n",max3);

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         int N=gi();
         int[] L=new int[N];


         long ans=0;
         for  (int i=0; i<N; i++) {
        	 L[i]=gi();
         }
         
         for  (int i=0; i<N; i++) {
        	 for  (int j=i+1; j<N; j++) {
        		 for  (int k=j+1; k<N; k++) {
                	 if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]) {
                		 if(Math.max(L[i], Math.max(L[j], L[k]))==L[i] && L[i]<L[j]+L[k]) {
                			 ans++;
                		 } else if(Math.max(L[i], Math.max(L[j], L[k]))==L[j] && L[j]<L[i]+L[k]) {
                			 ans++;
                		 } else if(Math.max(L[i], Math.max(L[j], L[k]))==L[k] && L[k]<L[j]+L[i]) {
                			 ans++;
                		 }
                		 
                	 }
                 }
             }
         }

         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35716
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(int a, int b, int c) {
    return min(a, b) < c && c < max(a, b);
}

void main() {
    auto abc = readints;
    int a = abc[0];
    int b = abc[1];
    int c = abc[2];
    writeln(calc(a, b, c) ? "Yes" : "No");
}


Measured memory_bytes: 256
import sys

n, a, b, c, d = tuple(map(int, input().split()))

n -= 1;

u_lim = a + n * d;
l_lim = a + n * c;

for i in range(n):
	if b >= l_lim and b <= u_lim:
		print("YES")
		sys.exit(0)
	u_lim = u_lim - c - d;
	l_lim = l_lim - c - d;
print("NO")

Measured memory_bytes: 3188
(d,), cc, *sstt = [list(map(int, s.split())) for s in open(0)]

ss = sstt[:d]

tt = list(map(lambda x: x-1, sum(sstt[d:], [])))

comp = [0]*len(cc)

ans = 0

for i in range(d):
    comp = [sum(x) for x in zip(comp, cc)]
    t = tt[i]
    ans += ss[i][t]
    comp[t] = 0
    ans -= sum(comp)
    print(ans)

Measured memory_bytes: 9252
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int K = 50;
int32_t main(){
    int n;
    cin >> n;
    vector<int> v;
    for (int i=0; i < K; i++){
        v.push_back(K-1);
    }
    int d = n / 50;
    for (int i=0; i < K; i++){
        v[i] += d;
    }
    int ost = n % 50;
    for (int i=0; i < K-ost; i++){
        v[i] -= ost;
    }
    for (int i=K-ost;i<K;i++){
        v[i] += (K + 1 - ost);
    }
    cout << K << endl;
    for (int i=0; i < K; i++){
        cout << v[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

struct Elem {
    int x, y, mode;
    bool operator<(const Elem &e) const {
        return x < e.x;
    }
};

signed main() {
    int N, ans = 0; scanf("%lld", &N);

    vector<Elem> es;
    for(int i=0; i<2*N; i++) {
        int a, b; scanf("%lld%lld", &a, &b);
        es.push_back(Elem{a, b, i < N});
    }

    sort(es.begin(), es.end());
    set<int> S;
    for(int i=0; i<2*N; i++) {
        Elem e = es[i];
        if(e.mode == 1) {
            S.insert(es[i].y);
        }
        else {
            auto it = S.lower_bound(es[i].y);
            if(it == S.begin()) continue;
            it--; ans++;
            S.erase(*it);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	double a,b,c,d,e,f;
	double x,y;
	
	while( scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF )
	{
		y = ( c*d - f*a ) / ( b*d - a*e );
		x = ( c - b*y ) / a;
		printf("%.3f %.3f\n",x ,y );
	}
	
	return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
int main(void) {
  int n;
  int a[100000];
  cin>>n;
  for(int i=0; i<n; i++) {
    cin>>a[i];
  }
  int i=0;
  int x=1;
  while(n-i!=0) {
    if(x==2) {
      cout<<i<<endl;
      return 0;
    }
    x=a[x-1];
    i++;
  }

  cout<<-1<<endl;
  
  return 0;
}


Measured memory_bytes: 640
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 3e5+123;
int h,w,m,u,v,row[mx],col[mx],mxcol,mxrow;
map<pair<int,int>,int>mp;
vector<int>rowv,colv;

void _case_()
{
   cin >> h >> w >> m;
   while (m--)
   {
       cin >> u >> v;
       row[u]++;
       col[v]++;
       mp[{u,v}]++;
   }
   for(int i=1;i<=h;i++) mxrow=max(row[i],mxrow);
   for(int i=1;i<=h;i++)
       if(row[i]==mxrow) rowv.push_back(i);
   for(int i=1;i<=w;i++) mxcol=max(col[i],mxcol);
   for(int i=1;i<=w;i++)
        if(col[i]==mxcol) colv.push_back(i);
   for(auto i:rowv)
       for(auto j:colv)
       {
           if(!mp[{i,j}])
           {
               cout << mxrow+mxcol el;
               return;
           }
       }
   cout << mxrow+mxcol-1 el;
}

int main()
{

    optimize();
    //_test_
      _case_();
    return 0;

}

///////////*  N A Y E M  *///////////

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

int n, t;
vector<int> w;
vector<int> v;
struct Item {
  int w, v;
  Item() {}
  Item(int w, int v) : w(w), v(v) {}
};

vector<Item> items;

int dp[3001][3001];
int solve() {
  sort(items.begin(), items.end(), [](const Item& lhs, const Item& rhs){
    if (lhs.w == rhs.w) return lhs.v < rhs.v;
    return lhs.w > rhs.w;
  });
  // for (auto item: items) {
  //   cerr << item.w << " " << item.v << endl;
  // }
  int ret = 0;
  for (int i = n-1; i >= 0; --i) { 
    for (int j = 0; j <= t; ++j) { 
      // if (j == 0) { 
      //   dp[i][j] = dp[i+1][j];
      // }
      // else if (j < w[i]) {
      //   // dp[i][j] = dp[i+1][j];
      //   dp[i][j] = max(dp[i+1][j], dp[i+1][0]+v[i]);
      // }
      if (j < items[i].w) {
        dp[i][j] = dp[i+1][j];
        ret = max(ret, dp[i+1][t-1]+items[i].v);
      }
      else { 
        dp[i][j] = max(dp[i+1][j], dp[i+1][j-items[i].w]+items[i].v);
      }
    }
    // cerr << i  << " " << dp[i][t] << endl;
  }
  return max(ret, dp[0][t]);
}

int main() {
  cin >> n >> t;
  for (int i = 0; i < n; ++i) { 
    int a, b;
    cin >> a >> b;
    w.push_back(a);
    v.push_back(b);
    items.emplace_back(a, b);
  }
  cout << solve() << endl;
}


Measured memory_bytes: 35456
int main(void){
    int i,j,k,a,b,dice[2][7],
        side[5] = {2,3,5,4,2},
        n = 0;
      
    for(i=0;i<2;i++)
      for(j=1;j<7;j++)
        scanf("%d", &dice[i][j]);
     
    for(i=0;i<6;i++){
      if(dice[0][1]==dice[1][1])
        for(j=0;j<4;j++){
 
  //一致判定
          for(k=1;k<7;k++)
            if(dice[0][k]!=dice[1][k]) break;
  
          if(k==7){
            printf("Yes\n");
            return 0;
          }
 
  //スピン
          dice[1][0] = dice[1][2];
          dice[1][2] = dice[1][3];
          dice[1][3] = dice[1][5];
          dice[1][5] = dice[1][4]; 
          dice[1][4] = dice[1][0]; 
 
       
      }
          
       //回転  
      
      dice[1][0] = dice[1][1];
          
      switch(i){
                  
          case 2:
              dice[1][1] = dice[1][3];
              dice[1][3] = dice[1][6];
              dice[1][6] = dice[1][4];
              dice[1][4] = dice[1][0]; 
              break;
              
          default:
              dice[1][1] = dice[1][2];
              dice[1][2] = dice[1][6];
              dice[1][6] = dice[1][5];
              dice[1][5] = dice[1][0]; 
              break;
         
          }
    }
 
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2116
N=int(input())
s=input()
mod = 10**9+7
d=""
cnt=N
while cnt:
    if  cnt > 1 and s[N-cnt] ==s[N-cnt+1]:
        d += "W"
        cnt -=2
    else:
        d += "H"
        cnt -=1
if d[0] == "W":
    ans = 6
else:
    ans = 3
for i in range(1,len(d)):
    if d[i-1] =="H":
        ans *= 2
    elif d[i] =="W":
        ans *= 3
    ans %= mod
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<string.h>
#include<math.h>
#include<stack>
#include<assert.h>
using namespace std;
typedef long long ll;

const int max_n = 1e5 + 5;
 
 
int N;
ll C,ans,x[max_n],v[max_n],a[max_n],b[max_n];
ll aa[max_n], bb[max_n];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> N >>C;
	for (int i = 1; i <= N; i++)
		cin >> x[i] >> v[i];

	for (int i = 1; i <= N; i++)
	{
		a[i] = a[i - 1] + v[i];
		ans = max(ans, a[i]-x[i]);
		aa[i] = max(aa[i - 1], a[i] - 2 * x[i]);
	}
	for (int i = N; i > 0; i--)
	{
		b[i] = b[i + 1] + v[i];
		ans = max(ans, b[i]-(C-x[i]));
		bb[i] = max(bb[i + 1], b[i] - 2 * (C-x[i]));
	}

	for (int i = 1; i <= N; i++)
	{
		ans = max(ans, a[i] - x[i] + bb[i+1]);
		ans = max(ans, b[i] - (C - x[i]) + aa[i-1]);
	}
	cout << ans;
} 

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

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

int N, Ma, Mb;
int dp[2][401][401];
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> Ma >> Mb;
    
    REP(k,2)REP(i,401)REP(j,401) dp[k][i][j]=INF;
    dp[0][0][0]=0;
    dp[1][0][0]=0;
    REP(k,N) {
        int a, b, c;
        cin >> a >> b >> c;
        
        REP(i,401) REP(j,401){
            dp[k%2][i][j] = min(dp[k%2][i][j], dp[1-k%2][i][j]);
            if(i+a<401&&j+b<401) {
                dp[k%2][i+a][j+b] = min(dp[k%2][i+a][j+b],dp[1-k%2][i][j]+c);
            }
        }
    }
    
    int ans = INF;
    for(int i = 1; i*Ma<=400 && i*Mb<=400; i++) ans=min(ans, dp[1-N%2][Ma*i][Mb*i]);
    
    if(ans < INF) cout << ans << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 1536
L = int(input())
S = bin(L)[2:]
N = len(S)
ans = []
m = 2**(N-2)
for i in range(1,N):
  ans.append((i,i+1,m))
  ans.append((i,i+1,0))
  m >>= 1
s = '1'
for i,c in enumerate(S[1:],1):
  if c=='1':
    ans.append((1,i+1,int(s,2)<<(N-i)))
  s += c
print(N,len(ans))
for a in ans:
  print(*a)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int count = A + B + C;
  if (count >= 22) {
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
import sys
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
co = []
for i in range(n):
    t = na()
    if t[0] == 0 and t[1] == 0:
        continue
    co.append(t)

n = len(co)
if n == 0:
    print(0)
    sys.exit(0)

co.sort(key=lambda x: math.atan2(x[1], x[0]))

ans = 0
co = co + co
for i in range(n):
    vx, vy = 0, 0
    for j in range(i, i+n):
        vx += co[j][0]
        vy += co[j][1]
        ans = max(ans, vx*vx+vy*vy)
print("{:.14f}".format(math.sqrt(ans)))


Measured memory_bytes: 38896
#define NDEBUG
#include <bits/stdc++.h>
#define clean(x,y) memset(x,y,sizeof(x))
#define inc(i,s,t) for(int i=s;i<=t;++i)
#define dec(i,s,t) for(int i=s;i>=t;--i)
#define debug(x) std::cerr<<(x)<<" "
typedef long long ll;
const int inf = 0x7f7f7f7f;

inline void gettime() {
	debug("Time: ");
	debug(clock()) << " ms\n";
}
inline int read() {
	static char c;
	static int x;
	while (c = getchar(), !isdigit(c));
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = (x << 1) + (x << 3) + c - '0';
	return x;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}

int n, ns[200];

int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif
	n = read();
	inc(i, 1, n) ns[i] = read();
	ns[++n] = 0;

	int cnt = 0, ans = 0;
	inc(i, 1, n) {
		if (ns[i] != ns[i - 1]) ans += cnt / 2, cnt = 1;
		else ++cnt;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  long long N;
  long long A;
  long long B;
  long long res = 0;
  rd(N);
  rd(A);
  rd(B);
  res += A * (N / (A+B));
  N %= A+B;
  res +=min_L(N, A);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200303-1 [beta]

// --- original code ---
// {
//   ll N, A, B, res = 0;
//   rd(N,A,B);
//   res += A * (N / (A+B));
//   N %= A+B;
//   res += min(N,A);
//   wt(res);
// }


Measured memory_bytes: 256
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ull unsigned long long
#define ll long long
#define pb push_back
#define f first
#define se second
#define mp make_pair
#define Speedforce boost();

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const int inf = 1e9 + 7;

ll n, x, ans;

ll rec(ll a, ll b){
    if(b % a == 0){
        return 2 * b - a;
    }
    return rec(b % a, a) + b / a * a * 2;
}

int main() {
    Speedforce
    cin >> n >> x;
    cout << n + rec(min(x, n - x), max(x, n - x));
}

Measured memory_bytes: 256
// 2020-09-14 20:57:26
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  int d = 0;
  rep(ai, n) {
    auto itr = lower_bound(ALL(b), a[ai]);
    if (itr != b.end() && a[ai] == *itr) {
      chmax(d, ai - int(itr - b.begin() - 1));
    }
  }
  bool ok = true;
  debug(d);
  rep(i, n) ok &= (a[i] != b[(n + i - d) % n]);
  if (ok) {
    cout << "Yes" << '\n';
    rep(i, n) {
      if (i) cout << ' ';
      cout << b[(n + i - d) % n];
    }
    cout << '\n';
  } else {
    cout << "No" << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4752
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{ 
  int i;
  long long int n,a,b,c,d,MOD;
  MOD=1000000000+7;
  a=1;b=1;c=1;
  cin>>n;
  
  for(i=0;i<n;i++)
  {
    a*=10;
    a=a%MOD;
  }
 
  for(i=0;i<n;i++)
  { 
    b=b*9;
    b=b%MOD;
  }
  for(i=0;i<n;i++)
  {
  c*=8;
    c=c%MOD;
  }
  b=b*2;
  b=b%MOD;
  d=a+c;
  d=d%MOD;
  d=d-b;
  if(d<0)d+=MOD;
  
  
 
  
 
 
  
  cout<<d<<endl;
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) {
        ll num; cin >> num;
        a[i] = num - (i + 1);
    }
    sort(ALL(a));
    if (a.size()) {
        ll middle = a[a.size()/2];
        ll total = 0;
        REP(i, n) {
            total += abs(a[i] - middle);
        }
        cout << total << endl;
        return 0;
    } else {
        ll total1 = 0, total2 = 0;
        REP(i, n) {
            total1 += abs(a[i] - a[a.size()/2]);
            total2 += abs(a[i] - a[a.size()/2-1]);
        }
        cout << min(total1, total2) << endl;
        return 0;
    }
    return 0;
}

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

int main(){

    string s;
    cin >> s;
    vector<int> l(s.size(),0),r(s.size(),0);
    int n=s.size();
    int t=0;

    for(int i=n-1;i>=0;i--){
        t++;
        if(s[i]=='L'){
            t=0;
        }else{
            l[i]=t;
        }
    }
    t=0;
    for(int i=0;i<n;i++){
        t++;
        if(s[i]=='R'){
            t=0;
        }else{
            r[i]=t;
        }
    }
    vector<int> ans(n,0);
    for(int i=0;i<n;i++){
        if(l[i]){
            if(l[i]%2==0){
                ans[i+l[i]]++;
            }else{
                ans[i+l[i]-1]++;
            }
        }else if(r[i]){
            if(r[i]%2==0){
                ans[i-r[i]]++;
            }else{
                ans[i-r[i]+1]++;
            }
        }
    }

    rep(i,n){
        cout << ans[i] << " ";
    }cout << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int n;
    string s,d;
    cin>>n>>s>>d;
    string t;
    for(int i=0;i<=n-1;i++){
        t = t+s[i]+""+d[i]+"";
    }
    cout<<t;
    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

	ll n, x;
	cin >> n >> x;


	ll ans = n;
	n -= x;
	if (x > n)
		swap(x, n);

	while (true) {



		ll k = n / x;
		n -= x * k;
		ans += x * 2 * k;
		if (x > n)
			swap(x, n);

		if (n == x || x == 0) {
			cout << ans - n << endl;
			return 0;
		}

	}


}




Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll r,ans;
  cin>>r;
  ans=3*pow(r,2);
  cout<<ans<<endl;

  return 0;
}



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> a(n);
	for (int i = 2; i < n; i++)
	{
		if (!a[i].empty())
			continue;
		for (int j = i; j < n; j += i)
		{
			int count = 0;
			int temp = j;
			while (temp % i == 0)
			{
				temp /= i;
				count++;
			}
			a[j].push_back({ i, count });
		}
	}
	int res = 1;
	for (int i = 2; i < n; i++)
	{
		int temp = 1;
		for (const pair<int, int>& p : a[i])
			temp *= p.second + 1;
		res += temp;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 73140
#include <iostream>
#include <algorithm>

#define SIZE 200000

using namespace std;

int main() {
    long long int i,j,K,N,M,Q,X;
    string S;
  //  long long int A[100][100];

 cin >> K >> S;

 if (S.length() <= K)
  cout << S << endl;
  else {
    S.resize(K);
    cout << S << "..." << endl;
  }


  return 0;

}


Measured memory_bytes: 3624