akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

ll a[100005],b[100005];

int main()
{ios_base::sync_with_stdio(false);
int n;
gl(n);
ll c=0;
rep(i,1,n)cin>>a[i]>>b[i];

ren(i,n,1)
{
	ll x=a[i]+c;
	ll y=x/b[i];
	if(x%b[i]!=0)y++;
	ll cnt=y*b[i]-a[i]-c;
	c+=cnt;
}
ol(c);
return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int h,w;
char a[105][105];
int t[105],y[105];
int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#'){
        y[i]=1;
      }
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if(a[i][j]=='#'){
        t[j]=1;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(y[i]==1){
      for(int j=0;j<w;j++){
        if(t[j]==1){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
using vint = vector<int>;
using vvint = vector<vint>;
using vchar = vector<int>;
using vvchar = vector<vchar>;
constexpr double pi = 3.1415926535897932384626433832795028L;

int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int sigma_2(int n) {
  if (n == 0) {
    return 0;
  }
  return n + sigma_2(n - 1);
}
int sum_range(int a, int b) {
  if (a == b) {
    return a;
  }
  return sum_range(a, b - 1) + b;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}

int array_sum_from_i(vint &data, int i) {
  if (i == data.size()) {
    return 0;
  }
  int s = array_sum_from_i(data, i + 1);
  return data[i] + s;
}
int array_sum(vint &data) {
  return array_sum_from_i(data, 0);
}
bool has_divisor(int N, int i) {
  if (i == N) {
    return false;
  }
  if (N % i == 0) {
    return true;
  }
  return has_divisor(N, i + 1);
}

bool is_prime(int N) {
  if (N == 1) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else {
    return !has_divisor(N, 2);
  }
}
bool is_even(int);
bool is_odd(int);

bool is_even(int n) {
  if (n == 0) {
    return true;
  }
  return is_odd(n - 1);
}

bool is_odd(int n) {
  if (n == 0) {
    return false;
  }
  return is_even(n - 1);
}








signed main() {
    int N,A,B;
    cin >> N >> A >> B;
    int c = N/(A+B);
    int d = N%(A+B);
    if(d > A){
        cout << c*A + A<< endl;
        return 0;
    }

    cout << c*A + d<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n, m;
    cin>>n>>m;
    set<int>s;
    map<int, set<int>>un;
    map<int, int>u;
    for(int i = 0; i < m; i++){
        int l, r;
        cin>>l>>r;
        un[l].in(r);
    }
    vi ans(n);
    for(int i = 0; i < 10; i++){
        if(!sz(un[i]))continue;
        if(sz(un[i])>1){
            cout<<"-1\n";
            return;
        }
        if(i==1&&*un[i].begin()==0&&n>1){
            cout<<"-1\n";
            return;
        }
        if(!u[i]){
            if(i>n){
                cout<<"-1\n";
                return;
            }
            ans[i-1]=*un[i].begin();
            u[i]++;
        }
    }
    if(ans[0]==0&&n>1)ans[0]=1;
    for(int i = 0; i < n; i++)cout<<ans[i];
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	string S, T;
	cin >> S;
	cin >> T;

	vector<string> v;

	for (int i = 0; i < S.length() - T.length() + 1; i++) {
		v.push_back(S.substr(i, T.length()));	
	}

	int cnt = 0;
	int ans = T.length();
	for (int i = 0; i < v.size(); i++) {
		cnt = 0;
		for (int j = 0; j < T.length(); j++) {
			if (v[i][j] != T[j]) {
				cnt += 1;
			}
		}
		if (cnt < ans) {
			ans = cnt;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
    _cin;
    // cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> m;
    vpll a(n);
    fo(i,n) cin >> a[i].first >> a[i].second;
    vll dp(m+1,MIN);
    dp[0]=0;
    fo(i,n){
        for(j=m;j>=a[i].first; j--){
            dp[j] = max(dp[j-a[i].first]+a[i].second, dp[j]);
        }
    }
    mx=0;
    fo(i,m+1) mx = max(mx,dp[i]);
    cout << mx;
}
 return 0;      
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll mod=1e9+7;
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    rep(i,tx-sx) cout<<"R";
    rep(i,ty-sy) cout<<"U";
    rep(i,tx-sx) cout<<"L";
    rep(i,ty-sy) cout<<"D";
    cout<<"D";
    rep(i,tx-sx+1) cout<<"R";
    rep(i,ty-sy+1) cout<<"U";
    cout<<"L";
    cout<<"U";
    rep(i,tx-sx+1) cout<<"L";
    rep(i,ty-sy+1) cout<<"D";
    cout<<"R";
    cout<<"\n";
}

Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, ele, ans = 0, k;
    cin >>n >>k;
    while(n--){
        cin >>ele;
        if(ele >= k)
            ans++;
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
//  ITP1_6_C
#include <iostream>
using namespace std;
int main() {
    int a, b, c, d, n;
    int room[4][3][10];
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                room[i][j][k]=0;
            }
        }
    }

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a >> b >> c >> d;
        room[a-1][b-1][c-1] += d;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout << " " << room[i][j][k];
            }
            cout << "\n";
        }
        if(i<3){
            cout << "####################\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int s[100] = {};
int main() {
	int n, m, x;
	ll sum0 = 0, sum1 = 0;
	cin >> n >> m >> x;
	REP(i, m) {
		int a;
		cin >> a;
		if (a < x)sum0++;
		else sum1++;
	}
	
	cout << min(sum0,sum1) << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int a, b, c;
  lint k;
  scanf("%d %d %d %lld", &a, &b, &c, &k);
  int result;
  if (k % 2 == 0) result = a - b;
  else result = b - a;
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

template <class T> std::ostream& print(std::ostream& out, T const& val) { return (out << val << " "); }
template <class T1, class T2> std::ostream& print(std::ostream& out, std::pair<T1, T2> const& val) {
    return (out << "{" << val.first << " " << val.second << "} ");
}
template <template <class, class...> class TT, class... Args>
std::ostream& operator<<(std::ostream& out, TT<Args...> const& cont) {
    for (auto&& elem : cont) print(out, elem);
    return out;
}

void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) {
    cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...);
}
#ifdef _MY_DEBUG
#define dump(...)                                                                                                    \
    cerr << "/* " << #__VA_ARGS__ << " [" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), \
        cerr << "*/\n\n";
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: CREATED_TIMESTAMP
 **/

signed main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    REP(i, n) cin >> a[i];
    Int all = accumulate(ALL(a), 0LL);
    Int ans = 1e18;
    Int acc = 0;
    REP(i, n - 1) {
        acc += a[i];
        chmin(ans, abs(acc - (all - acc)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxn=2e5+10;
ll inv[maxn];
ll fac[maxn];
ll power(ll base,ll n)
{
    ll r=1;
    while(n)
    {
        if(n&1) r=r*base%mod;
        base=base*base%mod;
        n/=2;
    }
    return r;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<=2e5;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    inv[200000]=power(fac[200000],mod-2);
    for(int i=2e5;i>=1;i--)
    {
        inv[i-1]=inv[i]*i%mod;
    }
}
ll C(ll m,ll n)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    init();


    ll red=n-k;
    for(ll i=1;i<=k;i++)
    {
        if(i>red+1)
        {
            cout<<0<<'\n';
            continue;
        }
        ll ans=(C(i,red+1)*C(i-1,k-1))%mod;
        cout<<ans<<'\n';
    }


}


Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN=2005;

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

int n,A[MAXN];
bool vis[MAXN];
vector<int> adj[MAXN],adj2[MAXN];
int deg[MAXN],ans[MAXN];
priority_queue<int> Q;

void dfs(int u)
{
	vis[u]=true;
	for(int i=0;i<(int)adj[u].size();i++)
	{
		int v=adj[u][i];
		if(vis[v])
			continue;
		adj2[u].push_back(v);
		deg[v]++;
		dfs(v);
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j&&gcd(A[i],A[j])>1)
				adj[i].push_back(j);
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i);
	
	for(int i=1;i<=n;i++)
		if(deg[i]==0)
			Q.push(i);
	int it=0;
	while(!Q.empty())
	{
		int u=Q.top();
		ans[++it]=A[u];
		Q.pop();
		for(int i=0;i<(int)adj2[u].size();i++)
		{
			int v=adj2[u][i];
			deg[v]--;
			if(deg[v]==0)
				Q.push(v);
		}
	}
	
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	
	return 0;
}



Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int MOD = 1000000007;
struct SegTree {
    int N;
    vector<int> A;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N);
    }
    void addrange(int L, int R, int val) {
        L += N, R += N;
        while (L < R) {
            if (L & 1) {
                A[L] = (A[L] + val) % MOD;
                L++;
            }
            if (R & 1) {
                R--;
                A[R] = (A[R] + val) % MOD;
            }
            L /= 2, R /= 2;
        }
    }
    int get(int idx) {
        idx += N;
        int ans = 0;
        while (idx > 0) {
            ans = (ans + A[idx]) % MOD;
            idx /= 2;
        }
        return ans;
    }
    void set(int idx, int val) {
        int orig = get(idx);
        addrange(idx, idx + 1, (val - orig + MOD) % MOD);
    }
    void add(int idx, int val) {
        addrange(idx, idx + 1, val);
    }
};
int main() {
    int N; cin >> N;
    SegTree st(2 * N + 1);
    st.set(0, 1);
    for (int i = 0; i < N; i++) {
        int val = st.get(i);
        st.add(i + 1, val);
        st.addrange(i + 1 + 2, i + 1 + N + 1, val);
    }
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans = (ans + (Int)st.get(i) * (N - 1) % MOD * (N - 1)) % MOD;
    }
    for (int i = N; i < 2 * N + 1; i++) {
        ans = (ans + st.get(i)) % MOD;
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string t = s;
  t.at(k - 1) = tolower(s.at(k - 1));
  cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    typedef long long int ll;
    typedef long double ld;
     
    //****************************************************
    #define lp(var,start,end) for (ll var = start; var <end ; ++var)
    #define rlp(var,start,end) for(ll var = start; var>=end ; var--)
    #define pb push_back
    #define mp make_pair
    #define pf push_front
    #define ff first
    #define ss second
    #define vll vector<ll>
    #define pll pair<ll,ll> 
    #define vpll vector<pll>
    #define all(X) X.begin(),X.end()
    #define endl "\n" //comment it for interactive questions
    #define trace1(a) cerr << #a << ": " << a << endl;
    #define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
    #define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
    #define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
     
    #define MOD (ll)1e9+7; //change it for other mods
     
    #define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    //*******************************************************
     
    //Some Functions
     
    ll powmod(ll a,ll b)
    {
    	ll res = 1;
    	while(b > 0) {
    		if(b & 1) res = (res * a) % MOD;
    		a = (a*a)%MOD;
    		b = b >> 1; 
    	}
    	return res % MOD;
    }
     
    ll cnt(ll n){
    	ll res = 0;
    	while(n > 0){
    		res++;
    		n = n/10;
    	}
    	return res;
    }
     
    int main()
    {
     	ll n;
     	cin >> n;
     	ll ans = 0;
     	for(ll i=1;i<=n;i++){
     		if(cnt(i) % 2 == 1) ans++;
     	}
     	cout << ans << "\n";
     }

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

using namespace std;
#define sync   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define ll long long
#define INF 10e9+5
vector<int> edge[100000+4];
bool visited[100000+4];int indegree[100000+4],dist[100000+5];
void dfs(int i){
	assert(!visited[i]);
	visited[i]=true;
	for(int el:edge[i]){
		dist[el]=max(dist[i]+1,dist[el]);
		--indegree[el];
		if(indegree[el]==0)dfs(el);
	}
}
int main(){
	// sync;
	int n,m;

	cin>>n>>m;
	vector<int>len(n+1,0);
	
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		edge[u].push_back(v);
		++indegree[v];
	}
	for(int i=1;i<=n;i++){
		if(!visited[i] && indegree[i]==0)dfs(i);
	}
	int ans=0;
	for(int i=1;i<=n;++i){
		ans=max(ans,dist[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 14660
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                    # ll = deepcopy(l)
from heapq import *                    # heappush(hp,x)
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                # minn = -maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                # pre = [0] + list(accumulate(l))
from decimal import Decimal         # a = Decimal(a)    # use this for math questions
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(n):
    l = []
    i = 1
    while(26**i < 1000000000000001):
        l.append(26**i)
        i += 1
    # print(l,len(l))
    ans = ''
    i = len(l) - 1
    while(n and i >= 0):
        q = n // 26
        r = n % 26
        if(r):
            ans += chr(96+r)
            n //= 26
        else:
            ans += 'z'
            n //= 26
            n -= 1
    return ans[::-1]

    

N = int(stdin.readline())
ans = solve(N)
print(ans)



Measured memory_bytes: 10952
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
const ll mod = 998244353;
const ll maxn = 200005;
const ll mm = 1e+18;
bool isp(string s){
    int n=s.len;
    rep0(i,n/2){
        if(s[i]!=s[n-i-1]) return false;
    }
    return true;
}
void solve()
{
    string s;
    cin>>s;
    int n=s.len;
    string s1=s.substr(0,n/2);
    string s2=s.substr((n/2)+1,n/2);
    if(isp(s)&&isp(s1)&&isp(s2))  cout<<"Yes";
    else cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int cx, cy, x[100], y[100],h[100],N;
	int H;
bool judge(int H, int Cx, int Cy){
	for (int i = 0; i < N; i++){
		if (h[i] != max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0)){
			return false;
		}
	}
	return true;
}

int main(){
	
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> x[i] >> y[i] >> h[i];
	}

	for (int i = 0; i <=100; i++){
		for (int j = 0; j <= 100; j++){
			int Cx = i, Cy = j;
			for (int k = 0; k < N; k++){
				int Hk = h[k] + abs(x[k] - Cx) + abs(y[k] - Cy);
				if (judge(Hk,Cx,Cy)){
					cx = Cx;
					cy = Cy;
					H = Hk;
					i = 101;
					j = 101;
					break;
				}
			}
		}
	}
	cout << cx << " " << cy << " " << H;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, sum=0, A;
    scanf("%d", &N);
    scanf("%d", &A);
    for(;;){
        if(sum>N){
            sum -= 500;
            break;
        }else if(sum==N){
            break;
        }
        sum+=500;
    }
    if(N-sum<=A){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.09.07 16:09:28
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */
int n, a[200010];
int b[200010];

int main() {
    scanf("%d", &n);
    rep1(i, n) scanf("%d", &a[i]);
    rep1(i, n) b[i] = 0;

    int rcnt = 0;
    rrep1(i, n) {
        int j = i;
        int cnt = 0;
        while (j <= n) {
            cnt += b[j];
            j += i;
        }
        if (cnt % 2 == 1) {
            if (a[i]) {
                b[i] = 0;
            } else {
                b[i] = 1;
                rcnt++;
            }
        } else {
            if (a[i]) {
                b[i] = 1;
                rcnt++;
            } else {
                b[i] = 0;
            }
        }
    }

    printf("%d\n", rcnt);
    int bo = false;
    rep1(i, n) {
        if (b[i]) {
            if (bo) {
                printf(" ");
            }
            printf("%d", i);
            bo = true;
        }
    }
    if (rcnt > 0) {
        printf("\n");
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>
#define MAX 1000

typedef struct{
  char str1[MAX+1];
  char str2[MAX+1];
} info;


int a[10099][10099];




int long_sub(info p)
{
  int m,n,i,j;
  m = strlen(p.str1); //count the number of letters
  n = strlen(p.str2);
  
  for(i=1;i<=m;i++)a[i][0]=0;
  for(j=1;j<=n;j++)a[0][j]=0;
  
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(p.str1[i-1]==p.str2[j-1]) a[i][j]=a[i-1][j-1]+1;
      else if(a[i-1][j]>=a[i][j-1]) a[i][j]=a[i-1][j];
      else a[i][j]=a[i][j-1];
    }
  }
  
    
  return a[m][n];
}


int main()
{
  int q,i;
  info p;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s%s",p.str1,p.str2);
    printf("%d\n",long_sub(p));
      }
  return 0;
}



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

using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int n,z,x,y,dp[100001][3],ans,a[100001][3];

int calc(int i,int j)
{

    if(dp[i][j]!=0)return dp[i][j];
    if(i+1<n)
    { if(j==0)
        dp[i][j]=max(calc(i+1,1)+a[i+1][1],calc(i+1,2)+a[i+1][2]);
      if(j==1)
        dp[i][j]=max(calc(i+1,0)+a[i+1][0],calc(i+1,2)+a[i+1][2]);
      if(j==2)
        dp[i][j]=max(calc(i+1,0)+a[i+1][0],calc(i+1,1)+a[i+1][1]);
    }
    return dp[i][j];

}

int main()
{
    cin>>n;
    memset(dp,0,sizeof dp);

    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }

    x=calc(0,0)+a[0][0];
    y=calc(0,1)+a[0][1];
    z=calc(0,2)+a[0][2];
    ans=max(z,x);
    ans=max(ans,y);
    cout<<ans;

}



Measured memory_bytes: 7296
class Point
  include Comparable
  attr_accessor :x, :y
  def initialize(x=0.0, y=0.0)
    @x, @y = x.to_f, y.to_f
  end
  def <=>(p)
    @y!=p.y ? @y<=>p.y : @x<=>p.x
  end
  def -(p)
    Point.new(@x-p.x, @y-p.y)
  end

  def abs
    Math::hypot(@x, @y)
  end
  def angle
    Math::atan2(@y, @x)
  end
end

while (n=gets.to_i) != 0 do
  flag = Array.new
  n.times do
    flag.push(Point.new(*gets.split.reverse))
  end

  pre = Point.new
  now = flag.sort!.shift
  length = (now-pre).abs
  while !flag.empty? do
    min = 2.0 * Math::PI
    nextPoint = nil
    flag.each do |nex|
      angle = (nex-now).angle - (now-pre).angle
      angle += 2.0 * Math::PI if angle < 0.0
      next if min < angle
      next if min==angle && (nextPoint-now).abs<(nex-now).abs
      nextPoint = nex
      min = angle
    end
    pre, now = now, nextPoint
    flag.delete(nextPoint)
    length += (now-pre).abs
  end
  printf "%.1f\n", length
end

Measured memory_bytes: 6248
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 2019
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


ll x10[200100];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s;
    map<int, ll> xmap;
    xmap[0] = 1;
    ll now(0);
    x10[0] = 1;
    for (int i = 1; i < 200050; i++) {
        x10[i] = x10[i-1] * 10 % mod;
    }
    ll ans(0);
    int c(0);
    for (int i = s.length() -1; i >= 0;i--) {
        now = (now + (s[i]-'0') * x10[c]) % mod;
        ans += xmap[now];
        xmap[now]++;
        c++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5296
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long a[N];
	long long ans, s,k,x;
	long long n;
	scanf("%lld %lld", &n,&x);
	s = 0;
	f(i, n) {
		scanf("%lld", &a[i]);
		s += a[i];
	}
	ans = s;
	f(i, n) {
		s = x*(i+1);
		k = a[n - 1];
		f(j, n - 1) {
			a[n - j - 1] = min(a[n - j - 1], a[n - j - 2]);
			s += a[n - j - 1];
		}
		a[0] = min(a[0], k);
		s += a[0];
		ans = min(ans, s);
}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
a, b, c, x, y = list(map(int, input().split()))
nokori_x, nokori_y = x, y
cost = 0
count_a, count_b, count_c = 0, 0, 0

# まず、AとBのセットを最安の方法で買う
# AとBのセットは何個あるか？
ab_set_n = min(x, y)
if ab_set_n:
    if c * 2 < (a + b):
        # Cを買ったほうがお得
        cost += c * 2 * ab_set_n
    else:
        cost += (a + b) * ab_set_n

# セットにできるものはしたので、
# どちらもゼロ、あるいはAかBの片方だけが残っているはず
nokori_n = max(x, y) - ab_set_n
if nokori_n:
    price = a if max(x, y) == x else b
    if c * 2 < price:
        cost += c * 2 * nokori_n
    else:
        cost += price * nokori_n

print(cost)


Measured memory_bytes: 3064
import math

A, B, H, M = (int(i) for i in input().split())

rad = math.pi * 2 * (H / 12 + (M / 60) / 12 - M / 60)

rsq = A**2 + B**2 - 2 * A * B * math.cos(rad)

print(math.sqrt(rsq))


Measured memory_bytes: 9440
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> A(N);
    int cntOdd = 0, cntOver4 = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        if(A[i]%2 == 1) cntOdd++;
        else{
            int x = A[i]/2;
            if(x%2 == 0) cntOver4++;
        }
    }
    
    if(N%2 == 1 && cntOdd == cntOver4 + 1 || cntOdd <= cntOver4) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
   cin>>n;
   vector<pair<int,int>>v;
    for(int i=1;i<=n;i++)
      { int x,p;
        cin>>x>>p;
        v.push_back({x,p});
      }
      for(int i=0;i<n-2;i++)
        // cout<<v[i].first<<" "<<v[i].second<<endl;
        {
         if(v[i].first==v[i].second and v[i+1].first==v[i+1].second and v[i+2].first==v[i+2].second)
         {
           cout<<"Yes"<<endl;return 0;
         }


        }
        cout<<"No"<<endl;



return 0;}


Measured memory_bytes: 3644
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  ll o_cnt = 0;
  ll f_cnt = 0;
  ll t_cnt = 0;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    if (tmp % 2 != 0)
      o_cnt++;
    else if (tmp % 4 != 0)
      t_cnt++;
    else
      f_cnt++;
  }

  // cout << t_cnt << endl;
  // cout << o_cnt << endl;
  // cout << f_cnt << endl;

  string ans = "No";
  if (t_cnt >= 1) {
    ans = (o_cnt <= f_cnt) ? "Yes" : "No";
  } else {
    ans = (o_cnt <= f_cnt + 1) ? "Yes" : "No";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from math import radians
from math import cos

A, B, H, M = map(int, input().split())

h = H * (360 // 12) + M * (360/12/60)
m = M * (360 / 60)

theta = max(h, m) - min(h, m)
if theta > 180:
  theta = 360 - theta

ans = (A**2 + B**2 - 2*A*B*cos(radians(theta)))**0.5
print(ans)

Measured memory_bytes: 9508
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) int {
	ans := l[0]
	for _, n := range l {
		if n > ans {
			ans = n
		}
	}
	return ans
}

func min(l []int) int {
	ans := l[0]
	for _, n := range l {
		if n < ans {
			ans = n
		}
	}
	return ans
}

func run(s string, p string, c int) int {
	for i := 1; i < len(s); i++ {
		if p != s[0:i] {
			c++
			return run(s[i:], s[0:i], c)
		}
	}
	if p != s {
		c++
	}
	return c
}

func reverse(s string) string {
	t := make([]rune, len(s))
	for i, c := range s {
		t[len(s)-1-i] = c
	}
	return string(t)
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	s := next()
	ans := run(s, "", 0)
	t := reverse(s)
	revAns := run(t, "", 0)
	fmt.Println(max([]int{ans, revAns}))
}


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

using namespace std;

int main() {
    int n = 0;
    int p = 0;
    cin >> n;
    struct resturant
    {
        int id;
        string city;
        int point;
    };
    std::vector<resturant> lists;

    for(int i = 0; i < n; ++i)
    {
        string c;
        int p;
        cin >> c >> p; 
        lists.push_back(resturant {i+1, c, p});
    }
    sort(lists.begin(), lists.end(), [&](const auto& lhs, const auto rhs){
        if(lhs.city < rhs.city)
        {
            return true;
        } 
        else if (lhs.city == rhs.city)
        {
            return lhs.point > rhs.point;
        }
        else
        {
            return false;
        }
    });

    for(auto& r : lists)
    {
        cout << r.id << endl;
    }

    return 0;
}

Measured memory_bytes: 888
n = int(input())

hs = [int(x) for x in input().split()]

dp = [0, abs(hs[1] - hs[0])]

for i in range(2, n):
	dp.append(min(dp[i-1] + abs(hs[i] - hs[i-1]), dp[i-2] + abs(hs[i] - hs[i-2])))

print(dp[n-1])

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

int main()
{
        int n,p,d1,d2,sum=0,num;
        while(true){
        cin >> n;
        if(n == 0){
                break;
        }
        for(int i=0;i<n;i++){
                cin >> p >> d1 >> d2;

                if(i==0){
                        sum = d1 + d2;
                        num = p;
                }
                else if(sum < (d1+d2)){
                        sum = d1 + d2;
                        num = p;
                }
        }
        cout << num << ' ' << sum << endl;
        }

        return 0;
}

Measured memory_bytes: 868
#include<stdio.h>
int main(void){
    int N,j,k,l,i,c,d;
    scanf("%d",&N);
    int A[N],B[N],E[N];
    for(i=0;i<=N-1;i++){
        scanf("%d",&A[i]);
      d = A[i];
      E[d-1] = i+1;
    }
    
    for(l=0;l<=N-1;l++){
        printf("%d ",E[l]);
    }
    return 0;
}

Measured memory_bytes: 1536
N, M = [int(i) for i in input().split()]
from collections import deque

graph = [deque([]) for _ in range(N + 1)]
for _ in range(M):
    u, v = [int(x) for x in input().split()]
    graph[u].append(v)
    graph[v].append(u)  # 無向グラフ


sirube = [-1] * (N + 1)


def bfs(root):
    if root is None:
        return
    sirube[1] = 1
    q = deque()
    q.append(root)
    while q:
        r = q.popleft()
        qq = graph[r]
        while qq:
            n = qq.popleft()
            if sirube[n] == -1:
                sirube[n] = r
                q.append(n)

bfs(1)  # スタート

if -1 in sirube[1:]:
    print("No")
else:
    print("Yes")
    for i in range(2, N + 1):
        print(sirube[i])


Measured memory_bytes: 151052
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
long long ans;
int main()
{
	scanf("%d %d",&n,&m);
	ans+=(n-1)*n/2;
	ans+=(m-1)*m/2;
	printf("%lld\n",ans);
	return 0;
}

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

#define PI 3.14159265359
#define MODULO 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int result = 0;

	for(int i =0; i<5;i++){
		int x;
		cin >> x;
		result += (x^ (i+1));
	}
	cout << result;
}

Measured memory_bytes: 3580
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) { 
	    final int h = stdin.nextInt();
	    final int w = stdin.nextInt();
	    stdin.nextLine();

	    if ( h == 0 && w == 0 ){
		break;
	    }

	    final boolean[][] visited = new boolean[h][w];
	    char[][] map = new char[h][];
	    for ( int c = 0; c < map.length; c++ ) {
		map[c] = stdin.nextLine().toCharArray();
	    }

	    int c = 0;
	    int r = 0;

	    while ( !visited[c][r] ) {
		visited[c][r] = true;
		if ( map[c][r] == '.' ) {
		    break;
		} else if ( map[c][r] == '<' ) {
		    r--;
		} else if ( map[c][r] == '^' ) {
		    c--;
		} else if ( map[c][r] == '>' ) {
		    r++;
		} else if ( map[c][r] == 'v' ) {
		    c++;
		}
	    }
	    if ( map[c][r] == '.' ) {
		System.out.println(r + " " + c);
	    } else {
		System.out.println( "LOOP" );
	    }
	}	
    }

    static void printArray( char[][] map ) {
	for ( char[] row : map ){
	    for ( char ch : row ) {
		System.out.print(ch);
	    }
	    System.out.println();
	}
    }    
}

Measured memory_bytes: 24336
import java.util.*;

public class Main{
  //O()
  //テ・ツ可催・ツ?ヲテァツ青?」ツ?ォテヲツ卍づゥツ鳴禿」ツ?古」ツ?凝」ツ?凝」ツつ凝」ツ?古」ツ??ァツエツ?ヲツ閉ーティツ。ツィテ」ツつ津、ツスツソテ」ツ??・ツ崢榲」ツ?崚」ツつ凝・ツ按?」ツ?（sPrimeテ」ツつ暗」ツつ甘ゥツ?淌」ツ??
  static boolean[] erato(int n){
    boolean[] prime = new boolean[n + 1];
    Arrays.fill(prime, true);
    prime[0] = prime[1] = false;

    for(int i = 2; i * i <= n; i++){
      if(!prime[i]) continue;
      for(int j = i + i; j <= n; j += i){
        prime[j] = false;
      }
    }

    return prime;
  }

  //O( sqrt(n) )
  //テ」ツつィテ」ツδゥテ」ツδ暗」ツつケテ」ツδ?」ツδ催」ツつケテ」ツ?ァテァツエツ?ヲツ閉ーティツ。ツィテ」ツつ津、ツスツ愿」ツつ凝ヲツ鳴ケテ」ツ?古ゥツォツ佚ゥツ??
  //  -> テァツオツ静ヲツ楪弋LE
  static boolean isPrime(int n){
    if(n <= 1) return false;

    for(int i = 2; i * i <= n; i++){
      if(n % i == 0){
        return false;
      }
    }
    return true;
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    boolean[] prime = erato(10000000);

    while(true){
      int n = sc.nextInt();
      if(n == 0) break;

      while(true){
        if(prime[n] && prime[n - 2] && prime[n - 6] && prime[n - 8]){
          break;
        }
        n--;
      }

      System.out.println(n);
    }
  }
}

Measured memory_bytes: 34300
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
int main(){
    int N,A,B;
    string S;
    cin >> N >> A >> B >> S;
    int kokunai = A + B;
    int sanka = 0;
    int kaigai = 0;
    for(int i = 0; i < N; i++){
        if (S[i] == 'a' && sanka < A+B){
            kokunai--;
            sanka++;
            cout << "Yes" << endl;
        }else if (S[i] == 'b' && kaigai < B && sanka < A+B){
            sanka++;
            kaigai++;
            cout << "Yes" << endl;
        }else if (S[i] == 'c'){
            cout << "No" << endl;
        }else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main(){
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0&&w==0) break;
        
        for(int i=0;i<h; i++){
            
            for(int j=0; j<w; j++){
                cout<<'#';
            }
            cout<<'\n';
        }
        cout<<endl;
    
   }
}



Measured memory_bytes: 3076
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int K = scanInt(),A = scanInt(), B = scanInt();
        for (int i = A; i <= B; i++) {
            if (i % K == 0) {
                out.print("OK");
                return;
            }
        }
        out.print("NG");
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 32624
#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
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  string s;
  cin>>s;
  if(s=="ARC")
    cout<<"ABC"<<endl;
  else
    cout<<"ARC"<<endl;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys


def solve(N: int, X: int):
    total = [0] * (N + 1)
    p = [0] * (N + 1)
    total[0] = 1
    p[0] = 1
    for i in range(1, N + 1):
        total[i] = total[i - 1] * 2 + 3
        p[i] = p[i - 1] * 2 + 1
    def rec(idx, x):
        if x <= 0:
            return 0
        if x >= total[idx] - idx:
            return p[idx]
        elif x <= total[idx] // 2:
            return rec(idx - 1, x - 1)
        else:
            rest = x - (total[idx] // 2 + 1)
            ret = p[idx - 1] + 1 + rec(idx - 1, rest)
        return ret
    ret = rec(N, X)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(' ').map { it.toInt() }

    val freq = IntArray(100000)
    for (x in A) {
        freq[x]++
    }

    var res = 0
    for (i in 0..freq.size-3) {
        res = Math.max(res, freq[i]+freq[i+1]+freq[i+2])
    }

    println(res)
}

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

int n;
int fact[10];
vector<int> v;
vector<int> num = {1,2,3,4,5,6,7,8,9};

int main(){
	cin >> n;
	int used[10] = {0};
	for(int i=0;i<=n;i++){
		if(i==0) fact[i] = 1;
		else fact[i] = fact[i-1]*i;
	}
	for(int i=0;i<fact[n];i++){
		int c = n,t = i;
		for(int j=0;j<n;j++){
//			t /= fact[c];
/*			if(i==0){
				v.push_back(j+1);
			}else{*/
			if(c>0){
				v.push_back(num[t/fact[c-1]]);
				num.erase(num.begin()+t/fact[c-1]);
				t -= (t/fact[c-1])*fact[c-1];
				c--;
			}else{
				v.push_back(num[0]);
			}//}
		}
		num.clear();
		for(int j=0;j<n;j++){
			if(j!=n-1) cout << v[j] << " ";
			else cout << v[j] << endl;
			used[j] = 0;
			num.push_back(j+1);
		}
		v.clear();
	}
}


Measured memory_bytes: 3152