akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

ll func(vector<vector<ll>> &v, int left, int right, vector<vector<ll>> &cache) {

    if (left > right) return 0;

    if (cache[left][right] != -1)
        return cache[left][right];

    int idx = left + (v.size() - 1 - right);

    ll ret = std::max(v[idx][0] * (v[idx][1] - left) + func(v, left + 1, right, cache),
                      v[idx][0] * (right - v[idx][1]) + func(v, left, right - 1, cache));

    return cache[left][right] = ret;
}


ll solve()
{
    int N;

    std::cin >> N;

    vector<vector<ll>> v;
    for (int i = 0; i < N; ++i) {
        vector<ll> curr(2);
        cin >> curr[0];
        curr[1] = i;

        v.push_back(curr);
    }

    std:sort(v.begin(), v.end(), std::greater<vector<ll>>());

    vector<vector<ll>> cache(N, vector<ll>(N, -1));

    ll ans = func(v, 0, N - 1, cache);

    return ans;
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 34948
#include <stdio.h>

int main(void) {
  int N, X;
  int L[100];
  int i, cnt, sum;
  cnt = 0;
  sum = 0;

  scanf("%d %d", &N, &X);
  for(i = 0; i < N; i++) {
    scanf("%d", &L[i]);
  }
  
  for(i = 0; sum <= X; i++) {
    cnt++;
    sum = sum + L[i];
  }
 
  printf("%d", cnt);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, std::string S) {
  int ans = 0;
  for (auto c : S)
    if (c == '.') ans++;
  int tmp = ans;
  for (int i = 0; i < N; i++) {
    if (S[i] == '.')
      tmp--;
    else
      tmp++;
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

int main() {
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 772
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a,b;
	cin>>a>>b;
	if((a+b)%2==0){
		cout<<(a+b)/2;
	}
	else
		cout<<"IMPOSSIBLE";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
vector<ll> dp(200010,-1),c(200010,-1),nc;
vector<vector<ll>> nex(200010);
ll n;
ll get(ll k){
    if (dp[k] != -1) return dp[k];
    if (k >= n) return dp[k] = 1;
    int l = *upper_bound(all(nex[nc[k]]),k);
    if (l == 1000000) return dp[k] = get(k+1)%MOD;
    else return dp[k] = (get(k+1)+get(l))%MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n) cin >> c[i];
    rep(i,n) c[i]--;
    rep(i,n){
        if (c[i] != c[i+1]) nc.push_back(c[i]);
    }
    n = nc.size();
    rep(i,n){
        nex[nc[i]].push_back(i);
    }
    rep(i,200010){
        nex[i].push_back(1000000);
    }
    PRINT(get(0));
}


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

using namespace std;
using ll = long long;
const int NMAX = 100010;

int used[NMAX];
pair<int, int> dt[NMAX];
ll f[NMAX];

int main(){
    ios::sync_with_stdio(false);
    int N, K;
    scanf("%d %d", &N, &K);
    // vector<pair<int, int>> dt(N);
    // vector<int> used(N+1, 0);
    fill(used, used+N+1, 0);
    // vector<ll> f(N+1, -1LL);
    fill(f, f+N+1, -1);
    for(int i = 0; i < N; i++)scanf("%d %d", &(dt[i].second), &(dt[i].first));  // first = d, second = t;

    sort(dt, dt + N, greater<pair<int, int>>());

    ll goodness = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    int used_cnt = 0;
    for(int i = 0; i < K; i++){
        que.push(dt[i]);
        goodness += dt[i].first;
        if(used[dt[i].second] == false){
            used_cnt++;
        }
        used[dt[i].second]++;
    }

    f[used_cnt] = goodness;

    for(int i = K; i < N; i++){
        if(used[dt[i].second] > 0) continue;
        while(!que.empty() && used[que.top().second] == 1){
            que.pop();
        }
        if(que.empty()){
            break;
        }
        pair<int, int> q = que.top();
        que.pop();
        goodness -= q.first;
        goodness += dt[i].first;
        used[dt[i].second]++;
        used_cnt++;
        f[used_cnt] = goodness;
    }

    ll ans = 0;
    for(int i = 1; i <= N; i++){
        if(f[i] == -1) continue;
        ans = max(ans, f[i] + (ll)i*(ll)i);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define N 300005
using namespace std;
int X,n,m,q,op,ans[N];
struct node{
	int t,a,num;
	node(int _t=0,int _a=0,int _num=0){ t=_t,a=_a,num=_num;}
}a[N];
bool cmp(const node &p,const node &q){ return p.t<q.t||(p.t==q.t&&p.num<q.num);}
int main()
{
	int i,x,y,p,l,r,v;
	scanf("%d",&X);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&x),a[++m]=node(x,0,0);
	scanf("%d",&q);
	for(i=1;i<=q;i++)
		scanf("%d %d",&x,&y),a[++m]=node(x,y,i);
	sort(a+1,a+m+1,cmp);
	op=-1,p=l=v=0,r=X;
	for(i=1;i<=m;i++){
		y=(a[i].t-p)*op;
		if(a[i].num!=0){
			x=a[i].a+v;
			x=min(x,r);
			x=max(x,l);
			x+=y;
			x=min(x,X);
			x=max(x,0);
			ans[a[i].num]=x;
		  }
		else{
			r+=y,l+=y,v+=y;
			r=min(r,X),r=max(r,0);
			l=min(l,X),l=max(l,0);
			p=a[i].t,op=-op;
		  }
	  }
	for(i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;

signed main(){
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100001];
int solve(int i,int a[],int n)
{
    if(i<=0)
    return dp[0]=0;
    if(dp[i]!=-1)
    return dp[i];
    if(i==1)
    return dp[1]=abs(a[1]-a[0]);
    return dp[i]=min(abs(a[i]-a[i-1])+solve(i-1,a,n),abs(a[i]-a[i-2])+solve(i-2,a,n));
}
int main()
{
    for(int i=0;i<100001;i++)
    dp[i]=-1;
    int n,i;
    cin>>n;
    int c[n];
    for(i=0;i<n;i++)
    cin>>c[i];
    solve(n-1,c,n);
    cout<<dp[n-1];
}

Measured memory_bytes: 4864
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(){
  int x,t;
  cin >> x >> t;
  cout << ((x>t)?x-t:0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main(void)
{
    uint32_t N, K;
    uint32_t ans;
    scanf("%u %u", &N, &K);
    ans = K * pow(K-1, N-1);
    printf("%u\n", ans);
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,r,p,c;
  while(cin>>n>>r&&n){
    vector<int> A(n);
    for(int i=0;i<n;i++) A[i]=n-i;
    for(int i=0;i<r;i++){
      cin>>p>>c;
      rotate(A.begin(),A.begin()+p-1,A.begin()+p+c-1);
    }
    cout<<A[0]<<endl;
  }
}


Measured memory_bytes: 3008
#include<stdio.h>
int main()
{
    int k;
    scanf("%d",&k);
    if(k>=1 && k<=32)
    {


    if(k==8 || k==12 || k==18 && k==20 || k==27)
        printf("5\n");
     else if(k==4 || k==6 || k==9 && k==10 || k==14 || k==21 || k== 22 || k==25 || k==26)
        printf("2\n");
    else if(k==28 || k==30 )
        printf("4\n");
        else if(k==16)
            printf("14\n");
        else if(k==24)
            printf("15\n");
        else if(k==32)
            printf("51\n");
        else
            printf("1\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int i;
	char s[4];
	scanf("%s",s);
	for(i=0;i<3;i++){
		if(s[i]=='1')
			printf("9");
		if(s[i]=='9')
			printf("1");
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
(n,m) = [int(i) for i in input().split()]

matrix = []
vector = []
product = [0 for d in range(n)]

for nc in range(n):
    matrix.append([int(i) for i in input().split()])

for mc in range(m):
    vector.append(int(input()))

for nc in range(n):
    for mc in range(m):
        product[nc] += matrix[nc][mc] * vector[mc]

[print(product[nc]) for nc in range(n)]

Measured memory_bytes: 7016
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main() {
  string str;
  while(cin >> str) {
    if(str == "0000") break;
    int const size = str.size();
    
    bool ok = true;
    for(int i=0; i<size-1; i++) {
      ok = ok && str[i] == str[i+1];
    }
    if(ok) { cout << "NA" << endl; continue; }
    
    int cnt = 0;
    while(1) {
      if(str == "6174") {
        break;
      }
      string L = str, S = str;
      sort(S.begin(), S.end());
      sort(L.begin(), L.end(), greater<char>());
      const char *pL = L.c_str();
      const char *pS = S.c_str();
      char *e;
      int l = strtol(pL, &e, 10);
      int s = strtol(pS, &e, 10);
      int n = l - s;
      for(int i=0; i<size; i++) {
        str[size-i-1] = char(n%10 + '0');
        n/=10;
      }
      cnt ++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
typedef pair<P,int> T;
vector<T> comb; 
vi num;
vi ans;
void cal(T k)
{
	num[k.fi.fi]--;
	num[k.fi.sec]--;
	num[k.sec]--;
	return ;
}
bool pos(T k)
{
	if(k.fi.fi==k.fi.sec)
	{
		if(num[k.fi.fi]>=3)return true;
		else return false;
	}
	if(num[k.fi.fi]>=1&&num[k.fi.sec]>=1&&num[k.sec]>=1)
	{
		return true;
	}
	return false;
}
/*void output(int a)
{
	cout <<comb[a].fi.fi<<' '<<comb[a].fi.sec<<' '<<comb[a].sec<<endl;
	return ;
}*/
bool check(int x)
{
	if(num[x]==4)return false;
	num[x]++;
	for(int a=1;a<10;a++)
	{
		if(num[a]>=2)
		{
			comb.clear();
			num[a]-=2;
			for(int b=1;b<10;b++)
			{
				if(num[b]>=3)
				{
					comb.pb(T(P(b,b),b));
				}
				if(b<=7&&num[b]&&num[b+1]&&num[b+2])
				{
					comb.pb(T(P(b,b+1),b+2));
				}
			}
			bool flag=false;
			vi p,q,r,s;
			for(int i=0;i<sz(comb);i++)
			{
				if(i==0)
				{
					p.clear();
					p=num;
				}
				else num=p;
				if(!(pos(comb[i])))continue;
				else cal(comb[i]);
				for(int j=0;j<sz(comb);j++)
				{
					if(j==0)
					{
						q.clear();
						q=num;
					}
					else num=q;
					if(!(pos(comb[j])))continue;
					else cal(comb[j]);
					for(int k=0;k<sz(comb);k++)
					{
						if(k==0)
						{
							r.clear();
							r=num;
						}
						else num=r;
						if(!(pos(comb[k])))continue;
						else cal(comb[k]);
						for(int l=0;l<sz(comb);l++)
						{
							if(l==0)
							{
								s.clear();
								s=num;
							}
							else num=s;
							if(!(pos(comb[l])))continue;
							else cal(comb[l]);
							flag=true;
							num=p;
							num[a]+=2;
							num[x]--;
							//output(i);output(j);output(k);output(l);
							return flag;
						}
					}
				}
			}
			num=p;
			num[a]+=2;
		}
	}
	num[x]--;
	return false;
}

int main()
{
	string s;
	while(cin >> s)
	{
		ans.clear();
		num.clear();
		for(int i=0;i<10;i++)
		{
			num.pb(0);
		}
		for(int i=0;i<13;i++)
		{
			int p=s[i]-'0';
			num[p]++;
		}
		for(int i=1;i<10;i++)
		{
			if(check(i))
			{
				ans.pb(i);
			}
		}
		if(sz(ans)==0)
		{
			cout << 0 << endl;
		}
		else
		{
			for(int i=0;i<sz(ans);i++)
			{
				if(i==sz(ans)-1)
				{
					cout << ans[i] << endl;
				}
				else
				{
					cout << ans[i] << ' ';
				}
			}
		}
		s.clear();
	}
	return 0;
}

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

signed main(){
	int n;
	map<int,int >m;
	cin>>n;
	while(n){
		m[n%10]++;
		n/=10;
	}
	cout<<m[2]<<endl;
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
	freopen (".in", "r", stdin);
	freopen (".out", "w", stdout);
}

int deg[5];

int main () {

	For (i, 1, 3)
		++ deg[read()], ++ deg[read()];

	For (i, 1, 4)
		if (deg[i] > 2) return puts("NO"), 0;
	puts("YES");

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

int n;
int H;
vector <ii> seq;
int res;

int main()
{
	scanf("%d %d", &n, &H);
	for (int i = 0; i < n; i++) {
		int a, b; scanf("%d %d", &a, &b);
		seq.push_back(ii(a, -1)); seq.push_back(ii(b, 1));
	}
	sort(seq.begin(), seq.end());
	for (int i = int(seq.size()) - 1; i >= 0; i--) {
		res++; H -= seq[i].first;
		if (H <= 0) break;
		if (seq[i].second == -1) {
			res += (H - 1) / seq[i].first + 1;
			break;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
int main(void){
  
  int h,n,a,s=0,i;
  
  scanf("%d%d",&h,&n);
  for(i=0; i<n; i++){
    scanf("%d",&a);
    s+=a;
  }
  
  if(s>=h) printf("Yes");
  else     printf("No");
  
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: String,
        b: String
    };
    if a == b {
        println!("EQUAL");
        return;
    }
    let alen = a.len();
    let blen = b.len();
    if alen > blen {
        println!("GREATER");
    } else if alen < blen {
        println!("LESS");
    } else {
        for (ac, bc) in a.chars().zip(b.chars()) {
            let acu8 = ac as u8;
            let bcu8 = bc as u8;
            if acu8 > bcu8 {
                println!("GREATER");
                return;
            } else if acu8 < bcu8 {
                println!("LESS");
                return;
            }
        }
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,res=1;
    cin >> n;

    string s;
    cin >> s;

    char c;
    c=s.at(0);

    for(int i=1; i<n;i++){
        if(s.at(i) != c)
        res++;
        c = s.at(i);
    }

    cout << res << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    if(n<=599)
    cout<<8;
    else if(n<=799)
    cout<<7;
    else if(n<=999)
    cout<<6;
    else if(n<=1199)
    cout<<5;
    else if(n<=1399)
    cout<<4;
    else if(n<=1599)
    cout<<3;
    else if(n<=1799)
    cout<<2;
    else
    cout<<1;}
   
   
   
   

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int p[n + 1];
  REP(i, 1, n + 1) { cin >> p[i]; }
  int cnt = 0;
  int sum = 0;
  REP(i, 1, n + 1) {
    if (i == p[i]) {
      cnt++;
    } else {
      sum += cnt / 2;
      if (cnt % 2 != 0) {
        sum++;
      }
      cnt = 0;
    }
    if (i == n) {
      sum += cnt / 2;
      if (cnt % 2 != 0) {
        sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	//double  r = scanner.nextInt();
	  	double r = scanner.nextDouble();
	  	double  n = 0.f;
        double  p = 3.141592653589793;
        
        
		n = r * r * p;
        System.out.printf("%.6f ",n);
        
		n = 2 * r * p;
        System.out.printf("%.6f",n);
        
        scanner.close();
  }
}


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

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

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

void Main(){
    int n; cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a; cin >> a; mp[a]++;
    }
    int m = mp.size();
    if(mp[0] == n){
        puts("Yes");
        return;
    } 
    if(n%3 == 0){
        if(m == 2 && mp[0] == n/3){
            puts("Yes");
            return;
        }else if(m == 3){
            int tmp = 0;
            for(auto [k, v] : mp){
                if(v == 0) continue;
                if(v != n/3){
                    puts("No");
                    return;
                }
                tmp ^= k;
                // cout << tmp << endl;
            }
            if(tmp == 0){
                puts("Yes");
                return;
            }
        }
    }    
    puts("No");
    return;
}

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

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

int a[100][100],memo[100][100];

int solve(int n,int m){

  if(memo[n][m] != 0) return memo[n][m];

  if(n == 1 && m == 1) return 1;
  if(n == 0 || m == 0) return 0;
  if(a[n][m] == -1) return 0;

  return memo[n][m] = solve(n-1,m) + solve(n,m-1);
}

int main(){

  int n,m,w,x,y;

  while(true){
    cin >> n >> m;
    if(!n && !m) break;

    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	a[i][j] = 0;
	memo[i][j] = 0;
      }
    }

    cin >> w;

    for(int i=0;i<w;i++){
      cin >> y >> x;
      a[y][x] = -1;
    }

    cout << solve(n,m) << endl;
  }
}

Measured memory_bytes: 1236
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    int ct=0;
    rep(i,s.size()) if(s[i]=='x') ct ++;
    cout<<(ct>7?"NO":"YES");
}

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

using namespace std;

string s, t;

int main() {
	int n;
	cin >> n;
	while (n--) {
		//dp[i][j] := s???i??????????????§???t???j??????????????§?????£?????¨??????LCS
		vector<vector<int>> dp(2000, vector<int>(2000));
		cin >> s >> t;
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < t.size(); j++) {
				if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
		cout << dp[s.size()][t.size()] << endl;
	}
}

Measured memory_bytes: 18724
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m;
int x,y;
int a[102],b[102];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&x,&y);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&b[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	bool f=0;
	for(int i=x+1;i<=y;i++)
		if(a[n]<i&&b[1]>=i)
		{
			f=1;
			break;
		}
	if(f)printf("No War");
	else printf("War");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] buttons = new int[n+1];
        int[] selected = new int[n+1];
        
        for (int i = 1; i <= n ;i++) {
            buttons[i] = Integer.parseInt(br.readLine());
            selected[i] = 0;
        }
        
        int ans = 0;
        boolean possible = false;
        int index = 1;
        
        
        
        while (selected[index] == 0) {
            ans++;
            if (buttons[index] == 2) {
                possible = true;
                break;
            }
            selected[index] = 1;
            index = buttons[index];
        }
        System.out.println(possible?ans:-1);
    }
}


Measured memory_bytes: 32468
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <deque>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;




int main(void){
    string s;
    string front;
    string back;
    int q;
    bool rev=false;

    cin >> s;
    cin >>q;

    int t,f;
    char c;

    fr(i,0,q){
        cin >> t;
        if(t==1){
            rev=!rev;
        }else{
            cin >> f >> c;
            if(f==1){
                if(rev==false){
                    front.push_back(c);
                }else{
                    back.push_back(c);
                }
            }else{
                if(rev==false){
                    back.push_back(c);
                }else{
                    front.push_back(c);
                }
            }
        }
    }

    if(rev==false){
        reverse(all(front));
        cout << front+s+back << endl;
    }else{
        reverse(all(back));
        reverse(all(s));
        cout << back+s+front << endl;
    }
}


Measured memory_bytes: 1348
#include<stdio.h>
#define X 1
#define Y 1000000000

int main()
{
  int x,y,num,div=0;

  while(1)
    {
      scanf("%d %d",&x,&y);
      /*if((x >= X && x <= Y) && (y >= X && y <= Y))*/ break;
    }

  if(x<y)
    {
      num = x;
      x = y;
      y = num;
    }
 
  while(1)
    {
      div = x % y;
      if(div == 0) break;
      x = y;
      y = div;
     }

  printf("%d\n",y);
  
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<vector<int>> G(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> path;
  bool reached = false;
  auto dfs = [&](auto dfs, int cur, int par) -> void {
    if(cur == n-1) {
      path.push_back(n-1);
      reached = true;
      return;
    }
    if(reached) return;
    path.push_back(cur);
    for(int ne: G[cur]) {
      if(ne != par) dfs(dfs, ne, cur);
      if(reached) return;
    }
    path.pop_back();
  };
  dfs(dfs, 0, -1);
  int l = 0, r = path.size()-1;
  vector<int> col(n, -1);
  while(l <= r) {
    col[path[l]] = 0;
    l++;
    if(l > r) break;
    col[path[r]] = 1;
    r--;
  }
  auto dfs2 = [&](auto dfs2, int cur, int par) -> void {
    if(par != -1 && col[cur] == -1) col[cur] = col[par];
    for(int ne: G[cur]) {
      if(ne != par) dfs2(dfs2, ne, cur);
    }
  };
  dfs2(dfs2, path[l], -1);
  int score = accumulate(all(col), 0);
  cout << (score >= n-score ? "Snuke" : "Fennec") << "\n";
  return 0;
}


Measured memory_bytes: 20588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    char ch[15],hc[15];
    char s[15];
    cin>>ch;
    cin>>hc;
    cin>>a>>b;
    cin>>s;
    if(strcmp(s,ch)=='\0')
    {
        cout<<a-1<<" "<<b<<endl;
    }
    else{
        cout<<a<<" "<<b-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
f = gets.to_i
k = Array.new(4){ Array.new(3){ Array.new(10, 0) } }
for i in 0..f-1 do
	l, m, n, o = gets.split.map(&:to_i)
	k[l-1][m-1][n-1] += o
end
for i in 0..3 do
	for j in 0..2 do
		puts " #{k[i][j].join(" ")}"
	end
	puts "####################" unless i == 3
end

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

template <class Monoid> class SegmentTree {
    using F = std::function<Monoid(Monoid, Monoid)>;

    private:
      int sz;
      std::vector<Monoid> seg;

      const F f;
      const Monoid M1;

    public:
      SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz *= 2;
        seg.assign(2 * sz, M1);
      }

      void update(int k, const Monoid &x) {
        k += sz - 1;
        seg[k] = x;
        while(k > 0) {
          k = (k - 1) / 2;
          seg[k] = f(seg[2 * k + 1], seg[2 * k + 2]);
        }
      }

      Monoid query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if(r == -1) r = sz;

        if(b <= l || r <= a) return M1;
        if(a <= l && r <= b) return seg[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
      }
  };

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

  int n, q;
  cin >> n >> q;
  SegmentTree<int> seg(n, [](int a, int b){ return min(a, b); }, INT_MAX);
  rep(i, 0, q) {
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 0) seg.update(x, y);
    else cout << seg.query(x, y + 1) << endl;
  }
}


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

int main()
{
    string s;
    cin >> s;

    if (s == "SUN")
        cout << '7' << endl;
    if (s == "MON")
        cout << '6' << endl;
    if (s == "TUE")
        cout << "5" << endl;
    if (s == "WED")
        cout << "4" << endl;
    if (s == "THU")
        cout << "3" << endl;
    if (s == "FRI")
        cout << "2" << endl;
    if (s == "SAT")
        cout << "1" << endl;

    return 0;
}

Measured memory_bytes: 256
//In the name of 'Allah'//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n , x ,i ;
    cin >> n >> x ;
    vector<int> v(n) ;
    for( int i = 0; i < n; i++ )
    {
        cin>> v[i] ;
    }
     ll ans = 0;
     for( int i = 0; i < n-1 ;i++ )
     {
         if(v[i]+v[i+1] > x)
         {
             ans += v[i] + v[i+1] - x;
             v[i+1] -= min(v[i]+v[i+1]-x, v[i+1]);
         }
     }
     cout << ans <<endl;
     return 0;
}


Measured memory_bytes: 3756
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W,M=map(int,input().split())
s={tuple(map(lambda x: int(x)-1, input().split())) for i in range(M)}
lh=[0]*H
lw=[0]*W
for i in s:
    lh[i[0]]+=1
    lw[i[1]]+=1
mh=max(lh)
mw=max(lw)
sh=[]
sw=[]
for i in range(H):
    if lh[i]==mh:
        sh.append(i)
for i in range(W):
    if lw[i]==mw:
        sw.append(i)
if len(sh)*len(sw)>M:
    print(mh+mw)
else:
    for i in sh:
        for j in sw:
            if (i,j) not in s:
                print(mh+mw)
                break
        else:
            continue
        break
    else:
        print(mh+mw-1)

Measured memory_bytes: 190572
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 1000000
#define INFTY 2000000000
typedef long long ll;


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



Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if (a == b){
        cout << "a == b" << endl;
    }
    else if (a > b){
        cout << "a > b" << endl;;
    }
    else if (a < b){
        cout << "a < b" << endl;
    }
}



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

int main() {
  priority_queue<int, vector<int>, greater<int> > que;
  int N, K; cin >> N >> K;
  rep(i,N){
    int p;
    cin >> p;
    que.push(p);
  }
  int res = 0;
  rep(i,K){
    res += que.top();
    que.pop();
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
n, k, q = input().split()
N = int(n)
K = int(k)
Q = int(q)
Q_list = [0] * N
for i in range(Q):
    num = int(input())
    Q_list[num - 1] += 1

for i in range(N):
    p = K - (Q - Q_list[i])
    if p <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 4680
use POSIX qw(ceil);
my ($N,$K) =split(/ /,<>);
my $s = <>; chomp $s;
my @dat = split(/ /,$s);

my $ok =10**9;
my $ng =0; 
my $okc;
my $ngc;

while(){
    if(($ok-$ng)<=1){last;}
    my $md =int(($ok+$ng)/2);
    my $sum=0;
    for(my $i=0;$i<=$#dat;$i++){
        #print "$dat[$i]\n";
        #$sum = $sum + (int(($cut-0.1+$dat[$i])/$cut)-1);
        $sum = $sum + (ceil($dat[$i]/$md)-1);
        #print "$dat[$i] $cut $sum\n";
    }
    if($sum <= $K){
        $ok = $md;
    }else{
        $ng = $md;
    }
    #print "cut $md $ok $ng  sum$sum\n";
    #last;
}

print "$ok\n";

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll h, n;
    cin >> h >> n;
    vll nums(n);
    FOR(i, n) cin >> nums[i];
    FOR(i, n)
    {
        h -= nums[i];
    }
    cout << (h <= 0 ? "Yes" : "No") << '\n';
}



Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int gcd (int x, int y) {

    int r, z;

    if (x < y) {

        z = x;
        x = y;
        y = z;

    }

    while (y > 0) {

        r = x % y;
        x = y;
        y = r;

    }

    return x;

}

int main () {

    int x, y;

    cin >> x >> y;

    cout << gcd (x, y) << endl;

    return 0;

}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//スキャナークラスを宣言
		Scanner scan = new Scanner(System.in);

		//int型の宣言と入力された数値を代入
		int intNum1 = scan.nextInt();
		int intNum2 = scan.nextInt();
		int intNum3 = scan.nextInt();

		//約数の個数
		int intCount = 0;

		for(;intNum1 <= intNum2 ;intNum1++){
			//Num3をNum1で割った余り
			int intRemainder = intNum3 % intNum1;

			//Num3をNum1+nで割り、余りがない場合,Num1+nはNum3の約数
			if(intRemainder == 0){
				intCount++;
			}
		}
		System.out.println(intCount);
		scan.close();
	}
}


Measured memory_bytes: 26148
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
using namespace std;
#define N 1000000

int main(){
    long n, k, q;
    cin>>n>>k>>q;
    long point[n+1];
    for (int i=1; i<=n; i++){
        point[i]=k-q;
    }
    for (int i=0; i<q; i++){
        int a;
        cin>>a;
        point[a]+=1;
    } 
    for (int i=1; i<=n; i++){
        if (point[i]>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>

using namespace std;

int a[100000], b[100000], n, h;

int main(void) {
	scanf("%d %d", &n, &h);
	for(int i= 0; i < n; i++) scanf("%d %d", a + i, b + i);
	sort(a, a + n);
	sort(b, b + n);
	
	int largest = a[n - 1];
	int ans = 0;
	for(int i = n - 1; i >= 0; i--) {
		if(b[i] <= largest) break;
		h -= b[i];
		ans++;
		if(h <= 0) break;
	}
	
	if(h > 0) ans += (h + largest - 1) / largest;
	printf("%d\n", ans);
	return 0;
}

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

    divisors.sort()
    return divisors

N = int(input())

maxStep = N-1

divs = make_divisors(N)
#print(divs)

for i in range(1,len(divs)+1):
	A=divs[i-1]
	B=divs[-i]
	#print(A,B,A-1 + B-1)
	if  A-1 + B-1 < maxStep:
		maxStep = A-1 + B-1

print(maxStep)



Measured memory_bytes: 3280
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;


int main(){
    ll A, B;
    cin >> A >> B;

    cout << A * B;

    return 0;
}

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

using namespace std;

typedef long long ll;
#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair

const int maxn = 4e5+10;
const int mod = 998244353;
//const ll inf = 1e9+10;

int n;
int pw(int a, int b)
{
    if(b == 0) return 1;
    int x = pw(a,b/2); x = (x * 1ll * x) % mod;
    if(b & 1) x = (x * 1ll * a) % mod;
    return x;
}

int pw2[maxn];
string M;
vector<int> D[maxn];
int f[maxn], dp[maxn];
int ps[maxn];

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

    cin>> n >> M;
    pw2[0] = 1;
    for(int i = 1; i <= 2*n; i++)
    {
        for(int j = i; j <= 2*n; j += i)
            D[j].push_back(i);
        pw2[i] = (pw2[i-1] * 2) % mod;
    }

    for(auto y : D[n])
        if((n/y) & 1)
        {
            /// block 1 < M
            string res;
            for(int i = 0; i < y; i++)
            {
                if(M[i] == '1')
                    (f[y] += pw2[y-i-1]) %= mod;
                res.push_back(M[i]);
            }
            /// block 1 = M
            bool sw = 1;
            for(int i = y; i < n; i++)
                if(res[i-y] == '1') res.push_back('0');
                else res.push_back('1');

            for(int i = 0; i < n; i++)
                if(M[i] != res[i])
                {
                    if(M[i] == '0' && res[i] == '1') sw = 0;
                    break;
                }
            (f[y] += sw) %= mod;
        }

    int ans = 0;
    for(auto x : D[2*n])
        if(n%x)
        {
            int y = x/2;
            dp[x] = f[y];
            for(auto w : D[x])
                if(w < x)
                    (dp[x] -= dp[w]) %= mod;
            (ans += (dp[x] * x) % mod) %= mod;
        }
    cout<< (ans + mod) % mod;
}




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

int n,ans;
string a,b,c;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b >> c;
	for (int i=0;i<n;i++){
		set<char> s;
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		ans += (int)s.size()-1;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int x,y;
cin>>x>>y;

for(int i=0;i<=x;i++)
{
	int ans = 2*i + 4*(x-i);
	//cout<<ans;
	if(ans==y)
	{
		cout<<"Yes";
		return 0;
	}
}
cout<<"No";
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

const int MAX_N = 202020;

vector<int> graph[MAX_N];
ll counter[MAX_N];
bool is_visited[MAX_N];

void dfs(int node, ll prev_cost) {
    counter[node] += prev_cost;
    is_visited[node] = true;
    for (int i = 0; i < graph[node].size(); ++i) {
        if (is_visited[graph[node][i]]) continue;
        dfs(graph[node][i], counter[node]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    int a, b;
    for (int i = 0; i < N - 1; ++i) {
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
    }
    int p;
    ll x;
    for (int i = 0; i < Q; ++i) {
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    dfs(0, 0);
    for (int i = 0; i < N; ++i) {
        cout << counter[i] << " \n"[i == N - 1];
    }
    return 0;
}

Measured memory_bytes: 24576
min = 10 ** 9 + 1
max = 0
benefit = 0
prev = 2 * 10 ** 9
lost = - 10 ** 9
gets.to_i.times do
  r = gets.to_i
  if r < min
    min = r
    max = 0
  elsif r >= max
    max = r
    if max - min > benefit
      benefit = max - min
    end
  end
  if lost < r - prev
    lost = r - prev
  end
  prev = r
end
if lost > 0
  puts benefit
else
  puts lost
end

Measured memory_bytes: 6104