akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)

using namespace std;

typedef vector<double> VD;
typedef vector<VD> matrix;

vector<double> gauss_jordan(const matrix& A,const VD& b){
  int n = A.size();
  matrix B(n,VD(n+1));
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) B[i][j] = A[i][j];

  for(int i=0;i<n;i++) B[i][n] = b[i];

  for(int i=0;i<n;i++) {
    int pivot = i;
    for(int j=i;j<n;j++) if( abs(B[j][i]) > abs(B[pivot][i]) ) pivot = j;
    swap(B[i],B[pivot]);
    if( abs(B[i][i]) < EPS ) return VD();
    
    for(int j=i+1;j<=n;j++) B[i][j] /= B[i][i];
    for(int j=0;j<n;j++) {
      if( i != j )  {
        for(int k=i+1;k<=n;k++) B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }
  VD x(n);
  for(int i=0;i<n;i++) x[i] = B[i][n];
  return x;
}



struct Edge {
  int src,dst;
  double weight;
};

const int MAX_V = 200;
const int IINF = INT_MAX;
int V,s,t,wf[MAX_V][MAX_V];
vector<Edge> G[MAX_V];
bool q[MAX_V];


void compute(){
  rep(i,V) rep(j,V) wf[i][j] = ((i==j)?0:IINF);
  rep(i,V) rep(j,(int)G[i].size()) wf[i][G[i][j].dst] = (int)G[i][j].weight;
  rep(k,V) rep(i,V) rep(j,V) if( wf[i][k] != IINF && wf[k][j] != IINF ) wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j]);

  if( wf[s][t] == IINF ) { puts("impossible"); return; }
  
  matrix A(V,VD(V,0));
  VD b(V,0);
  
  rep(i,V){
    if( i == t ) {
      A[i][i] = -1;
      b[i] = 0;
      continue;
    }
    double to_b = 0;
    double num_edge = 0;
    rep(j,(int)G[i].size()){
      if( wf[i][G[i][j].dst] == IINF ) continue;
      if( q[i] ){
        if( wf[i][G[i][j].dst] != IINF && wf[G[i][j].dst][t] != IINF && G[i][j].weight + wf[G[i][j].dst][t] == wf[i][t] ){
          to_b += G[i][j].weight;
          ++num_edge;
          A[i][G[i][j].dst] += 1;
        }
      } else {
        to_b += G[i][j].weight;
        ++num_edge;
        A[i][G[i][j].dst] += 1;
      }
    }
    A[i][i] += (-num_edge);
    b[i] = -to_b;
  }

  /*
  rep(i,V) {
    rep(j,V) {
      cout << A[i][j] << " ";
    }
    cout << endl;
  } cout << endl;
  cout << "-----------" << endl;
  rep(i,V) cout << b[i] << endl;
  */

  VD answer = gauss_jordan(A,b);

  printf("%.10f\n",answer[s]);
  //rep(i,(int)answer.size()) cout << "!" << answer[i] << endl;
}

int main(){
  while( cin >> V >> s >> t, V|s|t ){
    --s, --t;
    rep(i,V) { cin >> q[i]; G[i].clear(); }
    rep(i,V) rep(j,V){
      int a;
      cin >> a;
      if( a ) G[i].push_back((Edge){i,j,a});
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 1688
import java.util.*;
import java.util.ArrayList;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		String[] aa = a.split("");
		String[] bb = b.split("");
		String[] cc = c.split("");
		String message = "NO"; 
			if ( (aa[aa.length-1].equals( bb[0] )) && ( (bb[bb.length-1].equals(cc[0]))) ){
				message = "YES";
			}
				System.out.println(message);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  int n,count=0;
  string s,t;
  cin >> n >> s >> t;
  string a;
  rep(i,n){
    if(s[i] != t[count] && count != 0){
      count = 0;
    }
    if(s[i] == t[count]){
      count++;
    }
  }
  a = s + t.substr(count,n-count);
  cout << a.size() << endl;
}

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

using namespace std;

vector<bool> p;

bool get(int i)
{
    if(i<0)return true;
    return p[i];
}

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

    int n,k;
    cin >> n >> k;
    int c[n];
    for(int i=0;i<n;i++)
        cin >> c[i];

    p.assign(k+1,false);

    for(int i=1;i<=k;i++)
    {
        bool win=false;
        for(int j=0;j<n;j++)
            win|=!get(i-c[j]);

        p[i]=win;
    }

    cout << (p[k]?"First":"Second") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1, T2> &p) {
  os << p.first << ":" << p.second << " ";
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n, w, d; cin >> n >> w >> d;
    if(n == 0 && w == 0 && w == 0) break;
    vector<P> v = {{w, d}};
    vector<bool> del = {false};
    for(int i=0;i<n;++i) {
      int p, s; cin >> p >> s;
      p--;
      int id = 0;
      for(int j=0;j<(int)(del.size());++j) {
        if(del[id]) {
          id++;
          continue;
        }
        if(p > 0) id++, p--;
        else break;
      }
      P now = v[id];
      int w = now.first, d = now.second;
      s %= 2 * w + 2 * d;
      if(s < w) {
        P nxt1 = {s, d}, nxt2 = {w-s, d};
        if(s < w-s) {
          v.push_back(nxt1);
          v.push_back(nxt2);
        } else {
          v.push_back(nxt2);
          v.push_back(nxt1);
        }
      } else if(s < w + d) {
        P nxt1 = {w, s-w}, nxt2 = {w, w+d-s};
        if(s-w < w+d-s) {
          v.push_back(nxt1);
          v.push_back(nxt2);
        } else {
          v.push_back(nxt2);
          v.push_back(nxt1);
        }
      } else if(s < 2 * w + d) {
        P nxt1 = {s - w - d, d}, nxt2 = {2 * w + d - s, d};
        if(s - w - d < 2 * w + d - s) {
          v.push_back(nxt1);
          v.push_back(nxt2);
        } else {
          v.push_back(nxt2);
          v.push_back(nxt1);
        }
      } else {
        P nxt1 = {w, s - 2 * w - d}, nxt2 = {w, 2 * w + 2 * d - s};
        if(s - 2 * w - d < 2 * w + 2 * d - s) {
          v.push_back(nxt1);
          v.push_back(nxt2);
        } else {
          v.push_back(nxt2);
          v.push_back(nxt1);
        }
      }
      del[id] = true;
      del.push_back(false);
      del.push_back(false);
    }
    vi ans;
    for(int i=0;i<(int)(del.size());++i) {
      if(!del[i]) {
        ans.push_back(v[i].first * v[i].second);
      }
    }
    sort(ans.begin(), ans.end());
    printv(ans);
  }
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  if(n>m) swap(n,m);
  if(m-n>1){
    cout<<0<<endl;
    return 0;
  }
  ll ans=1;
  reps(i,n) (ans*=i)%=MOD;
  reps(i,m) (ans*=i)%=MOD;
  if(n==m) (ans*=2)%=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  if(r < 1200) {
      cout << "ABC" << endl;
  } else if(1200 <= r && 2800 > r) {
      cout << "ARC" << endl;
  } else {
      cout <<"AGC"<<endl;
  }
}

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

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

  int ans = 1;
  int cnt_max = 0;
  for (int i = 1; i <= n; i++) {
    int x = i;
    int cnt = 0;
    while(x % 2 == 0) {
      x/=2;
      cnt++;
    }
    if(cnt > cnt_max) {
      ans = i;
      cnt_max = cnt;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DXorSum2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n + 1];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }

            int qh = 0, qt = 0, countBit[] = new int[21];
            long ans = 0;

            while (qt < n) {
                for (int i = 0; i <= 20; ++i) {
                    if ((a[qt] >> i & 1) == 1) ++countBit[i];
                }
                ++qt;
                while (true) {
                    boolean ok = true;
                    for (int i = 0; i <= 20 && ok; ++i) {
                        if (countBit[i] > 1) ok = false;
                    }
                    if (ok) {
                        ans += qt - qh;
                        break;
                    }
                    for (int i = 0; i <= 20; ++i) {
                        if ((a[qh] >> i & 1) == 1) --countBit[i];
                    }
                    ++qh;
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

void dice_roll( int *dice, char i){
	if( i == 'W'){
		int tmp = dice[0];
		dice[0] = dice[1];
		dice[1] = dice[5];
		dice[5] = dice[4];
		dice[4] = tmp;
	}
	if( i == 'S'){
		int tmp = dice[0];
		dice[0] = dice[4];
		dice[4] = dice[5];
		dice[5] = dice[1];
		dice[1] = tmp;
	}
	if( i == 'D'){
		int tmp = dice[0];
		dice[0] = dice[3];
		dice[3] = dice[5];
		dice[5] = dice[2];
		dice[2] = tmp;
	}
	if( i == 'A'){
		int tmp = dice[0];
		dice[0] = dice[2];
		dice[2] = dice[5];
		dice[5] = dice[3];
		dice[3] = tmp;
	}
	if( i == 'd'){
		int tmp = dice[1];
		dice[1] = dice[2];
		dice[2] = dice[4];
		dice[4] = dice[3];
		dice[3] = tmp;
	}
}
int checkdice(int *d1, int *d2){
	int b = 0;
	for(int i = 0; i < 4; i++){
		dice_roll(d1, 'W');
		for(int j = 0; j < 4; j++){
			dice_roll(d1, 'D');
			for(int k = 0; k < 4; k++){
				dice_roll(d1, 'd');
				if(d1[0]==d2[0]&&d1[1]==d2[1]&&d1[2]==d2[2]&&d1[3]==d2[3]&&d1[4]==d2[4]&&d1[5]==d2[5]){
					return 1;
					i=4;j=4;k=4;
					b= 1;
				}
			}
		}
	}
	if(b!=1)return 0;
}
int main(){
	/*
		0
	3	1	2	4
		5
	*/
	int n;
	cin >> n;
	int d[n][6];
	string s = "Yes";
	for(int i = 0; i < n; i++){
		for(int j = 0; j< 6; j++) cin >> d[i][j];
	}
	for(int h = 0; h < n; h++){
		for(int i = 0; i < n; i++){
			int t1[] = { d[h][0],d[h][1],d[h][2],d[h][3],d[h][4],d[h][5] };
			int t2[] = { d[i][0],d[i][1],d[i][2],d[i][3],d[i][4],d[i][5] };
			if(h!=i){
			int t = checkdice(t1,t2);
				if(t==1){
					s = "No";
				}
			}
		}
	}
	cout << s <<endl;
	return 0;
}



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

int main()
{
	string str;
	while (cin >> str)
	{
		int gg = 0, pp = 0, ans = 0;
		for (int i = 0; i < (int)str.length(); i++)
		{
			if (str[i] == 'g')
			{
				if (pp < gg)
				{
					ans++;
					pp++;
				}
				else
					gg++;
			}
			else
			{
				if (pp < gg)
					pp++;
				else
				{
					gg++;
					ans--;
				}
			}
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007

ll binpow(ll a,ll b,ll mod) 
{
   ll res=1;
   for(ll i=1;i<=b;i++)
   {
       res=(((res+mod)*a)+mod)%mod;
   }
 
    return res;
}


int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll x;
    cin>>x;
    if(x==1)
    {
        cout<<0<<endl;
    }
    else if(x==2)
    {
        cout<<2<<endl;
    }
    else
    {
    ll ans;
    ll p=binpow(10,x,m);
    ll q=binpow(9,x,m);
    q=(((q+m)*2)+m)%m;
    ll r=binpow(8,x,m);
    ans=(p+r+m)%m;
    ans=(ans-q+m)%m;
    cout<<(ans+m)%m<<endl;
    }
	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int a,b;cin >> a >> b;
	char s;
	if(a+b==15) s='+';
	else if(a*b==15) s='*';
	else s='x';
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
    vector<int>prime;
    for(int i=3;i<=1e5;i+=2){
        bool f1=1,f2=1;
        for(int j=3;j*j<=i;j+=2)if(i%j==0){
            f1=0;break;
        }
        int t=(i+1)/2;
        for(int j=2;j*j<=t;j++)if(t%j==0){
            f2=0;break;
        }
        if(f1&&f2)prime.PB(i);
    }
    int Q;cin>>Q;
    vector<int>res;
    REP(i,Q){
        int l,r;
        cin>>l>>r;
        int p=upper_bound(prime.begin(),prime.end(),r)-lower_bound(prime.begin(),prime.end(),l);
        res.PB(p);
    }
    REP(i,Q)cout<<res[i]<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<ll,ll> a; 
ll dfs(ll x){
	if(a[x]) return a[x];
	a[x]=(dfs(x/2)+dfs((x-1)/2)+dfs((x-2)/2))%mod;
	return a[x];
}
int main(){
	a[0]=1;
	a[1]=2;
	ll n;
	scanf("%lld",&n);
	ll ans=dfs(n);
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 1e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 1e9 + 7;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 0)), pr(n + 1, vector<ll>(k + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i <= k; i++) pr[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			int ind = j - a[i - 1] - 1;
			if (ind < 0) dp[i][j] = pr[i - 1][j];
			else {
				dp[i][j] = (pr[i - 1][j] - pr[i - 1][ind] + mod) % mod;
			}
		}
		pr[i][0] = dp[i][0];
		for (int j = 1; j <= k; j++) {
			pr[i][j] = (pr[i][j - 1] + dp[i][j]) % mod;
		}
	}
	cout << dp[n][k];
	return 0;
}


Measured memory_bytes: 159088
use std::io::*;
use std::str::FromStr;
use std::iter::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

macro_rules! rotate {
    ($a: expr, $b: expr, $c: expr, $d: expr) => {{
        let t = $a;
        $a = $b;
        $b = $c;
        $c = $d;
        $d = t;
    }}
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut u: u32 = sc.read();
    let mut s: u32 = sc.read();
    let mut e: u32 = sc.read();
    let mut w: u32 = sc.read();
    let mut n: u32 = sc.read();
    let mut d: u32 = sc.read();

    let mut bs = [0; 6];
    for e in bs.iter_mut() {
        *e = sc.read();
    }

    let mut found = false;
    'outer: for k in 0..6 {
        for _ in 0..4 {
            if bs == [u, s, e, w, n, d] {
                found = true;
                break 'outer;
            }
            rotate!(n, e, s, w);
        }
        if k % 2 == 0 {
            rotate!(u, n, d, s);
        } else {
            rotate!(u, w, d, e);
        }
    }
    println!("{}", if found { "Yes" } else { "No" });
}



Measured memory_bytes: 5024
#include <stdio.h>
#define N 500000
#define INFTY 2000000000

int S[N];
int L[N/2+2],R[N/2+2];
int count=0;

int merge(int S[],int n, int left, int mid, int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;

  j=0;
  k=0;

  for(i=0; i<n1; i++) L[i] = S[left+i];
  for(i=0; i<n2; i++) R[i] = S[mid+i];

  L[n1] = R[n2] = INFTY;

  for(i=left; i<right; i++){
    count++;
    if(L[j]<=R[k]) S[i] = L[j++];
    else {
      S[i] = R[k++];
    }

  }
 //printf("%d\n",count);
}

int mergeSort(int S[],int n, int left, int right){
  if(left+1 < right){
    int mid = (left + right) /2;
    mergeSort(S,n,left,mid);
    mergeSort(S,n,mid,right);
    merge(S,n,left,mid,right);
  }
}

int main(){
  int S[N],i,n;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,n,0,n);

  for(i=0; i<n; i++){
    if(i) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");

  printf("%d\n",count);

  return 0;

}



Measured memory_bytes: 5612
import sys

stdin = sys.stdin

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

n, m = na()
g = [[False] * n for _ in range(n)]
gs = [[] for _ in range(n)]
for i in range(m):
    s, t = na()
    gs[s-1].append(t-1)
    g[s-1][t-1] = True

ans = 999999
best = None
for i in range(n):
    ds = [9999999] * n
    prevs = [-1] * n
    ds[i] = 0
    q = [i]
    qp = 0
    while qp < len(q):
        cur = q[qp]
        qp += 1
        for e in gs[cur]:
            if ds[e] > ds[cur] + 1:
                ds[e] = ds[cur] + 1
                prevs[e] = cur
                q.append(e)
    for j in range(n):
        if g[j][i]:
            if ds[j] + 1 < ans:
                ans = ds[j] + 1
                best = [0] * (ds[j]+1)
                best[0] = i
                cur = j
                r = -1
                while cur != i:
                    best[r] = cur
                    r -= 1
                    cur = prevs[cur]

if not best:
    print(-1)
else:
    print(ans)
    for x in best:
        print(x+1)


Measured memory_bytes: 13304
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[500005];
vector <P> table[20];

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

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(ll i=0;i<60;i++){
        ll cnt = 0;
        for(int j=0;j<n;j++){
            if((x[j] >> i) & 1){
                cnt ++;
            }
        }
        ll tmp = cnt * (n - cnt);
        tmp %= mod;
        ans += (tmp * rui(2, i)) % mod;
        ans %= mod;
    }
    p(ans);
    return 0;
}
 

Measured memory_bytes: 28928
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(){
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);

    bool flg = false;
    if (abs(a-c) <= d) flg = true;
    if (abs(a-b) <= d && abs(b-c) <= d) flg = true;

    if (flg == true) printf("Yes");
    else printf("No");

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);

    string ans="Yes";

    cin >> h[0];
    h[0] = h[0] -1;

    for (int i=1; i<n; ++i){
        cin>>h[i];
        if (h[i]-h[i-1]>=1){
            h[i]=h[i]-1;
        }
        else if (h[i]-h[i-1]<0){
            ans = "No";
            break;
        }

    }
    cout << ans << endl;

    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 lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

signed main(){
    int k;
    cin >> k;
    if (k % 7 == 0){
        k /= 7;
    }
    set<int> s;
    int a = 1;
    int A = 1;
    int cnt = 1;
    while (true) {
        //cout << A << endl;
        if (s.find(A) != s.end()){
            cout << -1 << endl;
            return 0;
        }
        else{
            s.insert(A);
        }
        if (A % k == 0){
            cout << cnt << endl;
            return 0;
        }
        a *= 10;
        a %= k;
        A += a;
        A %= k;
        cnt += 1;
    }
}

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

int main() {
	//cout<<"GfG!";
	int l,r,n,i,c=0;
	cin>>l>>r>>n;
	for(i=l;i<=r;i++)
	{
	    if(i%n==0)
	    c++;
	}
	cout<<c;
//	return 0;
}

Measured memory_bytes: 3160
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};

fn main() {
    input! {
        a: isize,
        b: isize,
        c: isize,
        k: isize,
    }
    let ans = if a + b >= k {min(a, k)} else {a - (k - a - b)};
    println!("{}", ans);
}


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

void solve(){
	
	string s1 ;
	string s2 ;

	cin>>s1>>s2 ;

	int m=s1.length() ;
	int n=s2.length() ;

	int dp[m+1][n+1] ;
	memset(dp,0,sizeof(dp)) ;

	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){

			if(i==0||j==0)

				dp[i][j]=0 ;
			else{
				if(s1[i-1]==s2[j-1])
					dp[i][j]=dp[i-1][j-1]+1 ;
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]) ;

			}

		}
	}

	vector<char> pos ;

	int i=m ,j=n ;

	while(i>0 && j>0){

		if(s1[i-1] == s2[j-1]){
			pos.push_back(s1[i-1]) ;
			i-- ;
			j-- ;

		}
		else if(dp[i][j-1]>dp[i-1][j]){
			j-- ;
		}
		
		else{
			i-- ;
		}


	}

	reverse(pos.begin(),pos.end()) ;

	for(int i=0;i<pos.size();i++){
		cout<<pos[i] ;
	}
	/*
	cout<<"\n" ;
	


	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			cout<<dp[i][j]<<" " ;
		}
		cout<<"\n" ; 
	}
	
	*/
}	

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 38792
#include<stdio.h>
#include<string.h>

int main(){
    char s[3];
    char* str = "No";
    for(int i = 0; i < 3; i++){
        scanf("%c", &s[i]);
        if(s[i] == '7'){
            str = "Yes";
        }
    }
    printf("%s", str);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MAX_N = 40 + 10;
const int MAX_W = MAX_N * 10;
const int INF = 100100100100;

int dp[MAX_N][MAX_W][MAX_W];

int main() {
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    rep(i, MAX_N) rep(j, MAX_W) rep(k, MAX_W) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        rep(j, MAX_W) {
            rep(k, MAX_W) {
                dp[i + 1][j][k] = dp[i][j][k];
                if (j - a >= 0 && k - b >= 0) {
                    chmin(dp[i + 1][j][k], dp[i][j - a][k - b] + c);
                }
            }
        }
    }

    int ans = INF;
    rep(j, MAX_W) {
        rep(k, MAX_W) {
            if (j == 0 && k == 0) continue;
            if (j * Mb != k * Ma) continue;
            chmin(ans, dp[N][j][k]);
        }
    }

    if (ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 49024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int cnt=0;
  for(int i=min(a,b);i>0;i--){
    if(a%i==0&&b%i==0)
      cnt++;
    if(cnt==c){
      cout<<i<<endl;
      break;
    }
  }
}
  


Measured memory_bytes: 256
N, A, B, C, D = [int(x) for x in input().split()]
# N < 200_000
S = " " + input()

# A sunuke -> C
# B funuke -> D
# .
# # 

def solve(N, A, B, C, D, S):
    if S[A:C].find("##") != -1:
        return "No"
    if S[B:D].find("##") != -1:
        return "No"

    # A C B D
    if A < C < B < D:
        return "Yes"

    # A B C D
    if A < B < C < D:
        return "Yes"

    # A B D C
    if A < B < D < C:
        if S[B-1:D+2].find("...") != -1:
            return "Yes"
    return "No"

print(solve(N, A, B, C, D, S))




Measured memory_bytes: 3636
n, k = map(int, input().split())
x = list(map(lambda x: int(x), input().split()))

ans = float('inf')
for i in range(n-k+1):
    r = x[i+k-1]
    l = x[i]
    ans = min(ans, abs(r - l) + min(abs(l), abs(r)))

print(ans)

Measured memory_bytes: 14252
n = int(input())
v_ls = [int(i) for i in input().split()]
_1st = v_ls[1::2]
_2nd = v_ls[::2]
_1st_dict = dict()
_2nd_dict = dict()
for i in _1st:
    if _1st_dict.get(i) is None:
        _1st_dict[i] = 1
    else:
        _1st_dict[i] += 1
for i in _2nd:
    if _2nd_dict.get(i) is None:
        _2nd_dict[i] = 1
    else:
        _2nd_dict[i] += 1
if len(_1st_dict) <= 1 and len(_2nd_dict) <= 1:
    if _1st[0] == _2nd[0]:
        print(len(_2nd))
    else:
        print(0)
else:
    _1st_dict = sorted(_1st_dict.items(), key= lambda x:x[1], reverse=True)
    _2nd_dict = sorted(_2nd_dict.items(), key= lambda x:x[1], reverse=True)
    while _1st_dict[0][0] == _2nd_dict[0][0]:
        if _1st_dict[0][1] > _2nd_dict[0][1]:
            _2nd_dict.pop(0)
        elif _1st_dict[0][1] < _2nd_dict[0][1]:
            _1st_dict.pop(0)
        elif _1st_dict[1][1] > _2nd_dict[1][1]:
             _1st_dict.pop(0)
        else:
            _2nd_dict.pop(0)
    _1st_dict = dict(_1st_dict)
    _2nd_dict = dict(_2nd_dict)
    dupli = max(_1st_dict.values()) + max(_2nd_dict.values())
    print(len(v_ls) - dupli)

Measured memory_bytes: 23128
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int A = one.get(1);
        int B = one.get(2);
		myout(Math.min(N * A, B));
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32968
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int x = sc.nextInt();
		int a = sc.nextInt();
		if(x < a) System.out.println(0);
		else System.out.println(10);
	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 22736
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#define mod 1000000007
using namespace std; 

int main(){
    int a; cin >> a;
	if (a%2==0) cout << a/2 << "\n";
	else cout << a/2+1 << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0)
	{
		c -= b;
		if (!(a > 0 && c > 0))
			break ;
		a -= d;
	}
	if (a <= 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}



Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    L, R, D = Scanner.map_int()
    ans = 0
    for i in range(L, R+1):
        if i % D == 0:
            ans += 1
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10676
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> X(N);
	vector<int> Y(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}


	map<pair<int, int>, int> mp;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i != j) {
				mp[make_pair(X[i] - X[j], Y[i] - Y[j])]++;
				res = max(res, mp[make_pair(X[i] - X[j], Y[i] - Y[j])]);
			}
		}
	}

	cout << N  - res << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N;
	cin >> N;
	vll A(N);
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}


	for (ll i = 1; i < N; i++) {
		A[i] += A[i - 1];
	}

	sort(A.begin(), A.end());

	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		if (A[i] == 0) {
			ans++;
		}
	}
	for (ll i = 0; i < N - 1; i++) {

		for (ll j = 1; i + j < N; j++) {
			if (A[i] != A[i + j]) {
				ans += ((j - 1) * j) / 2;
				i += j - 1;
				break;
			}
			else if (i + j == N - 1) {
				ans += (j * (j + 1)) / 2;
				i = N;
				break;
			}
		}


	}

	cout << ans;


}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    int kazu;
     
    public void solve(){
        Scanner sc = new Scanner(System.in);
        kazu = sc.nextInt();
        System.out.println(kazu*kazu*kazu);
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17168
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;  

void test_case()
{
    ll x,y,i,j;
    cin >> x >> y;
    if(y&1 || 2*x > y || 4*x < y)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }

}
 
int32_t main()
{
    IOS(); 
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      int a[3];
      cin >> a[0] >> a[1] >> a[2];
      sort(a,a+3);
      int ans=0;
      if((a[1]-a[0])%2==1){
       a[0]++;
        a[2]++;
        ans++;
      }
      while(a[1]-a[0]>=2){
        ans++;
        a[0]+=2;
      }
       ans+=a[2]-a[1]; 
      cout << ans << endl;
      return 0;}

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

using namespace std;

#define REP(I,N) for (int I = 0; I < (N); I++)
#define ALLOF(C) C.begin(), C.end()
#define FOREACH(...) for (auto && __VA_ARGS__)

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

	// tuple<string,int,int> を要素とした可変長配列
	vector<tuple<string, int, int>> v;

	// i を N 回すマクロ
	REP(i, N)
	{
		// 入力
		string cityname; cin >> cityname;
		int score; cin >> score;

		// 可変長配列に要素を追加
		v.emplace_back(cityname, -score, i + 1);
	}

	// tuple のソートは各要素を順にみての昇順ソート。
	// あらかじめscoreをマイナスにしてある。マイナスにしたものの昇順ソートは、元の値の降順ソート
	sort(ALLOF(v));

	// コンテナの中身全部回す range-based for のマクロ
	FOREACH(e : v)
	{
		// tuple e から [2]の要素を取り出す。
		// tupple から要素を取り出すには std::get<>
		cout << get<2>(e) << endl;
	}

	// 3要素くらいなら、pair をネストしてもいい。
	// struct pair<T1, T2>
	// {
	//   T1 first;
	//   T2 second;
	// };
	// で 比較演算子もついてくるので、同じことができる。 
	//    first 同士を比較して、違えばその結果、同じなら second 同士を比較してその結果。
	//
	// typedef pair< pair<string, int>, int> entry_t とすれば、
	//   e.first.first = cityname
	//   e.first.second = -score
	//   e.second =  i + 1
	// となる。

	return 0;
}


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

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

    string str;
    while(n > 0) {
        n--;
        str += n % 26 + 'a';
        n /= 26;
    }

    reverse(str.begin(), str.end());

    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vec[0] %= M;
  int COUNT = 0;
  for (int i = 0; i < N-1; i++)
  {
    vec[i+1] += vec[i];
    vec[i+1] %= M;
  }
  map<int,int> mp;
  mp[0] = 1;

  for (int i = 0; i < N; i++)
  {
    int X = vec[i];
    auto itr = mp.find(X);
    if(itr == mp.end())
    {
      mp[X] = 1;
    }
    else
    {
      itr->second++;
    }
  }
  int ANS = 0;
  for (int i = 0; i < mp.size(); i++)
  {
    static auto itr = mp.begin();
    int X = itr->second;
    ANS += X*(X-1)/2;
    itr++;
  }
  
  cout<<ANS<<endl;
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
from collections import deque

def main():
  h, w, k = map(int, input().split())
  A = [input().rstrip() for _ in range(h)]
  for i, a in enumerate(A):
    if "S" in a:
      sy = i
      sx = a.index("S")
      break

  que = deque()
  D = ((-1, 0), (0, -1), (1, 0), (0, 1))

  def bfs(y, x):
    seen = [0]*h
    seen[y] |= 1 << x
    F = deque()
    F.append((y, x, 0))
    while F:
      ny, nx, cnt = F.popleft()
      que.append((ny, nx, k))
      if cnt == k:
        continue
      for dy, dx in D:
        yy, xx = ny+dy, nx+dx
        if 0 <= yy < h and 0 <= xx < w:
          if A[yy][xx] == "#":
            continue
          if seen[yy] >> xx & 1:
            continue
          seen[yy] |= 1 << xx
          F.append((yy, xx, cnt+1))

  bfs(sy, sx)

  seen = [0]*h
  while que:
    y, x, cnt = que.popleft()
    if y == 0 or y == h-1 or x == 0 or x == w-1:
      ans = -(-cnt // k)
      break
    for dy, dx in D:
      ny, nx = y+dy, x+dx
      if 0 <= ny < h and 0 <= nx < w:
        if seen[ny] >> nx & 1:
          continue
        seen[ny] |= 1 << nx
        que.append((ny, nx, cnt+1))

  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 83140