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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

int main()
{
	/*int n,q,l,r,ac=0;
	string str;
	cin>>n>>q>>str;
	int pre[n+5];
	mem(pre,0);
	for(int i=0;i<n;){
		if(str[i]=='A'&&str[i+1]=='C'){
			ac++;
			pre[i+2]=ac;
			pre[i+1]=ac-1;
			i+=2;
		}
		else{
			pre[i+1]=ac;
			i++;
		}
	}*/
	/*for(int i=1;i<=n;i++)cout<<pre[i]<<" ";
	cout<<endl;*/
	/*while(q--){
		cin>>l>>r;
		cout<<pre[r]-pre[l]<<endl;
	}*/
	/*char ch;
	cin>>ch;
	if(ch=='A')cout<<"T\n";
	if(ch=='T')cout<<"A\n";
	if(ch=='G')cout<<"C\n";
	if(ch=='C')cout<<"G\n";*/
	string str;
	cin>>str;
	if(count(str.begin(),str.end(),'7')>0)cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3604
// AOJ 0550: Dividing Snacks
// 2017.11.18 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define INF 0x33333333
int dp[2][2][5001];
int ti[10001];
char buf[20], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
    int n, n1, n2, i, j, jj, k1, k2;
#if TM
	clock_t start, finish;
	start = clock();
#endif
	fgets(p=buf, 20, stdin), n = getint(), n1 = n - 1, n2 = n >> 1;
	for (i = 0; i < n1; i++) {
		fgets(p=buf, 20, stdin); 
		ti[i] = getint();
	}

	memset(dp, INF, sizeof(dp));
    dp[0][0][0] = 0;
    for (k1 = 0, k2 = 1, i = 0; i < n; i++, k1 = k2, k2 = !k2) {
		dp[k2][0][0] = INF;
		jj = i; if (jj > n2) jj = n2;
		for (j = 0; j <= jj; j++) {
			dp[k2][0][j+1] = dp[k1][1][j] + ti[i];
			if (dp[k2][0][j+1] > dp[k1][0][j]) dp[k2][0][j+1] = dp[k1][0][j];

			dp[k2][1][j]   = dp[k1][0][j] + ti[i];
			if (dp[k2][1][j]   > dp[k1][1][j]) dp[k2][1][j]   = dp[k1][1][j];
		}
    }
	printf("%d\n", dp[k1][0][n2]);
#if TM
	finish = clock();
	printf("time %lf\n", (double)(finish-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1968
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	constexpr sieve() : s(), v() {
		s[2] = true;
		for (int i = 3; i < N; i += 2)
			s[i] = true;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	constexpr sieve<10001> s;
	for (int n; scan(n);) {
		int c = 0;
		if (n & 1) {
			for (auto i = s.v; *i <= n / 2; i++)
				if (s.s[n - *i + 1])
					c++;
			c = c * 2 + s.s[n / 2 + 1];
		} else
			c = s.s[n - 1] * 2;
		outl(c);
	}
}


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

int dp[100004], N, ar[100004];

int rec(int pos){
  if(pos == N-1) 
    return 0;
  if(pos == N-2){
  	return abs(ar[N-1] - ar[N-2]);
  }
  if(dp[pos]!=-1)
    return dp[pos];
  dp[pos] = min(abs(ar[pos+1]-ar[pos]) + rec(pos+1), abs(ar[pos+2] - ar[pos]) + rec(pos+2));
  return dp[pos];
}

int main() {
  scanf("%d",&N);
  for(int i=0;i<N;++i){
  	scanf("%d",&ar[i]);
  }
  memset(dp, -1, sizeof(dp));
  printf("%d",rec(0));
  return 0;
}

Measured memory_bytes: 2560
n=3
k=int(input())
INF=10**9+7
l=[0]*k
ans=0
for i in range(k-1,-1,-1):
    x=i+1
    temp=pow(k//x,n,INF)
    for j in range(2,k//x+1):
        temp=(temp-l[j*x-1])%INF
    l[i]=temp
    ans=(ans+x*temp)%INF
print(ans)



Measured memory_bytes: 61812
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  8/26 20:03:18 2017
 *Ended  Time*  : 六  8/26 20:07:38 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
LL Q, H, S, D, n;

int main()
{
    while(~scanf("%lld %lld %lld %lld %lld", &Q, &H, &S, &D, &n)){
        H = min(Q * 2, H);
        S = min(H * 2, S);
        D = min(S * 2, D);
        LL ans = n / 2 * D;
        if(n % 2) ans += S;
        printf("%lld\n", ans);
    }
    
    return 0;
}


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

const int N=105;
int ans[N<<1];
char s[10];

int query(const vector<int>& vec){
    printf("?");
    for(auto i:vec) printf(" %d",i);
    printf("\n");
    cout.flush();
    scanf("%s",s);
    if(s[0]=='R') return 0;
    else if(s[0]=='B') return 1;
    else{
        assert(0);
    }
    return -1;
}

void getAns(vector<int> vec,const vector<int>& pos,int n){
    assert((int)vec.size()==n-1);
    vec.push_back(0);
    for(auto i:pos){
        vec[n-1]=i;
        ans[i]=query(vec);
    }
}

int run(int i,int n){
    vector<int>vec(n);
    iota(vec.begin(),vec.end(),i);
    return query(vec);
}

void solve(){
    int n;
    scanf("%d",&n);
    // 0->red, 1->blue
    
    int lv=run(1,n);
    int l=1,r=n+1;
    while(l+1<r){
        int mid=(l+r)/2;
        if(run(mid,n)==lv) l=mid;
        else r=mid;
    }

    ans[l]=lv,ans[l+n]=1-lv;
    vector<int>v1,v2;
    for(int i=1;i<=2*n;i++){
        if(i==l || i==l+n) continue;
        if(i>l && i<l+n) v1.push_back(i);
        else v2.push_back(i);
    }
    getAns(v1,v2,n);
    getAns(v2,v1,n);

    printf("! ");
    for(int i=1;i<=2*n;i++){
        printf("%c",ans[i]==0?'R':'B');
    }
    printf("\n");
    cout.flush();
}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vvi node(N);
    vi a(N - 1), b(N - 1);
    rep(i, N-1)
    {
        cin >> a.at(i) >> b.at(i);
        node.at(a.at(i)-1).push_back(b.at(i)-1);
        node.at(b.at(i)-1).push_back(a.at(i)-1);
    }
    int deepest = 0;
    int diameter = 0;
    queue<vi> q;
    q.push({0, 0, 0}); // depth, self, parent
    while (!q.empty())
    {
        vi qf = q.front();
        q.pop();
        deepest = qf.at(1);
        for (auto &e : node.at(qf.at(1)))
        {
            if (e != qf.at(2))
            {
                q.push({qf.at(0) + 1, e, qf.at(1)});
            }
        }
    }
    q.push({0, deepest, deepest}); // depth, self, parent
    while (!q.empty())
    {
        vi qf = q.front();
        q.pop();
        diameter = qf.at(0);
        for (auto &e : node.at(qf.at(1)))
        {
            if (e != qf.at(2))
            {
                q.push({qf.at(0) + 1, e, qf.at(1)});
            }
        }
    }
    diameter++;
    if (diameter % 3 == 2)
    {
        cout << "Second" << endl;
    }
    else
    {
        cout << "First" << endl;
    }
    
}

Measured memory_bytes: 24692
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<string> G(3);
  for(int i=0; i<3; i++) cin >> G[i],reverse(G[i].begin(),G[i].end());
  int turn = 0;
  string ABC = "ABC";
  string abc = "abc";
  while(1){
    if(G[turn].size() == 0){
      cout << ABC[turn] << "\n";
      return 0;
    }
    for(int i=0; i<3; i++){
      if(G[turn].back() == abc[i]){
        G[turn].pop_back();
        turn = i;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,K,Q;
  cin>>N>>K>>Q;
  int A[N];
  FOR(i, 0, N)cin>>A[i];
  int ans = 1e9;
  // A[i]未満は取らない
  FOR(i, 0, N){
    vector<int> v;
    priority_queue<int, vector<int>, greater<int> > que;
    FOR(j, 0, N){
      if(A[j] >= A[i]) que.push(A[j]);
      if(A[j] < A[i] || j == N - 1){
        int k = 0;
        int M = que.size();
        while(!que.empty()){
          int q = que.top();
          que.pop();
          if(k < M - K + 1) {
            v.push_back(q);
          }
          k++;
        }
      }
    }
    if(v.size() < Q) continue;
    sort(v.begin(), v.end());
    ans = min(ans, v[Q-1] - v[0]);
  }
  cout<<ans<<endl;
}

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

const int maxn = 1e4+10;
bitset<maxn> cookie[10];

int main(){
	int R,C;
	while(cin>>R>>C && (R||C)){
		int i,j;
		for(int i=0; i<R; i++)
			for(int j=0; j<C; j++){
				int upward;
				cin >> upward;
				cookie[i][j] = upward;
			}

		int r = 1<<R;
		int res = 0;
		for(int i=0; i<r; i++){
			for(int j=0; j<R; j++){
				if(i & (1<<j)) 
					cookie[j].flip();
			}

			int ans = 0;
			for(int j=0; j<C; j++){
				int up = 0;
				for(int k=0; k<R; k++){
					if(cookie[k][j])
						up++;
				}
				ans += max(up,R-up);
			}

			res = max(ans,res);

			for(int j=0; j<R; j++){
				if(i & (1<<j)) 
					cookie[j].flip();
			}
		}
		printf("%d\n",res);
	}

}

Measured memory_bytes: 3132
#include<stdio.h>
int main()
{
    int n,r,j,i;
    scanf("%d %d", &n, &r);
    if(n<10)
    {
        i=100*(10-n);
        j=r+i;
        
    }
    else
    {
        j=r;
    }
    printf("%d",j);
}

Measured memory_bytes: 128
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;

#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--)
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;
const ll N = 100009;

vector<vector<ll> > mul(vector<vector<ll> > mat1, vector<vector<ll> > mat2, int row)
    {
        vector< vector<ll> > result(row, vector<ll>(5, 0));
        for(ll i = 0; i < row; i++)
            for(ll j = 0; j < 5; j++) {
                for(ll k = 0; k < 5; k++) {
                    result[i][j] = ((result[i][j]%MOD) + (mat1[i][k]%MOD) * (mat2[k][j]%MOD)) % MOD;
                }
            }
        return result;
    }
int main()
{
  fast();

  ll t=1;
  //cin >> t;
  while(t--)
  {
    string s1, s2;
    ll a, b;
    cin >> s1 >> s2;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s1)
      cout << a-1 <<  " " << b;
    else
      cout << a << " " << b -1;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

int main() {
    int N, L[202];
	cin >> N;
	rep(i,0,2*N) {
		cin >> L[i];
	}
	sort(L, L+2*N);
	ll ans = 0;
	rep(i,0,N) {
		ans += L[2 * i];
	}
	cout << ans << endl;
}


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

int main(){
	ll x,a;
	cin >> x >> a;
	if(x >= a)cout << 10 <<endl;
	else cout << 0 <<endl;
}

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

bool mycmp(pair<int,int> a,pair<int,int> b){
    if(a.first<b.first)return true;
    else if(a.first==b.first){
        if(a.second<b.second) return true;
        return false;
    }
    return false;
}

int main() {
	int num,w; cin>>num>>w;
	vector<pair<int,int>> w_v;
	
	for(int i=0;i<num;i++){
	    int a,b; cin>>a>>b;
	    w_v.push_back(make_pair(a,b));
	}
	sort(w_v.begin(),w_v.end());
	long sol=0;
	vector<vector<long>> dp(w_v.size(),vector<long>(w+1,0));
	for(int i=0;i<w_v.size();i++){
	    for(int j=0;j<dp[i].size();j++){
	        if(i==0){
	            while(j<dp[i].size()&&j<w_v[i].first){
	                j++;
	            }
	            dp[i][j] = w_v[i].second;
	        }else{
	            while(j<dp[i].size()&&j<w_v[i].first){
	                dp[i][j] = dp[i-1][j];
	                j++;
	            }
	            dp[i][j] = max(dp[i-1][j],w_v[i].second+dp[i-1][j-(w_v[i].first)]);
	        }
	        sol = max(sol,dp[i][j]);
	    }
	}
	
    cout<<sol<<endl;
}

Measured memory_bytes: 79488
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <set>
using namespace std;
#define maxn 10000+5
typedef long long int ll;
const double INF = 1e20;
const double pi = acos (-1.0);
int main () {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",(b/a)>c?c:(b/a));
    //while(1)getchar();
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> x(N);
    REP(i, N){
        cin >> x[i];
    }

    vector<ll> M;
    vector<ll> P;

    REP(i, N){
        if(x[i]<0) M.push_back(-x[i]);
        else P.push_back(x[i]);
    }

    ll MS = M.size();
    ll PS = P.size();

    sort(M.begin(), M.end());
    
    vector<ll> TM(MS+1);
    vector<ll> TP(PS+1);

    REP(i, MS+1){
        if(i==0) TM[i] = 0;
        else{
            TM[i] = M[i-1];
        }
        // cout << TM[i] << endl;
    }
    // cout << endl;

    REP(i, PS+1){
        if(i==0) TP[i] = 0;
        else{
            TP[i] = P[i-1];
        }
        // cout << TP[i] << endl;
    }

    ll ans = INF;
    for(ll i=0; i<=K; i++){
        ll left = i;
        ll right = K-i;
        if(i > MS) continue;
        if(K-i > PS) continue;

        ans = min(ans, TM[left] + TP[right]*2);
        ans = min(ans, TM[left]*2 + TP[right]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2804
def ss(A,n):
    cnt=0
    for k in range(n):
        minj=k
        for i in range(k,n):
            if A[i] < A[minj]:
                minj=i
        if minj !=k:
            tmp=A[k]
            A[k]=A[minj]
            A[minj]=tmp
            cnt=cnt+1
    return A,cnt

n=int(input())
A=list(map(int,input().split()))
A,cnt=ss(A,n)
As=[str(i)for i in A]
As = ' '.join(As)
print(As)
print(cnt)



Measured memory_bytes: 5604
/*  ex6_2 i18n
    pandacodeb  */

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

#define SIZE 101

int main(void){
    int length;
    char text[SIZE];

    //input text
    fgets(text, SIZE, stdin);

    //find text's length (include \n)
    length = strlen(text);

    //change \n into null (\0) at the end of the text
    if (length >= 3 && text[length-1] == '\n'){
        text[--length] = '\0';
    }

    //print out corresponding characters
    //print: first char, length - 2, last char
    putchar(text[0]);
    printf("%d", length - 2);
    putchar(text[length-1]);
    putchar('\n');
    return 0;
}

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

int main(){
    char str[256];
    char ans[256] = {'\0'};
    int i = 0;
    int index = 0;

    cin >> str;

    while(str[i] != '\0'){
        if(str[i] == '0'){
            ans[index] = '0';
            index++;
        }
        else if(str[i] == '1'){
            ans[index] = '1';
            index++;
        }
        else{
            if(index != 0){
                ans[index - 1] = '\0';
                index--;
            }
        }
        i++;
    }

    cout << ans << '\n';

    return 0;
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

signed main() {
    int N;
    cin>>N;
    cout<<N*N*N<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n = int(input())
b = list(map(int, input().split()))
a = [int(0) for i in range(n)]
a[0] = b[0]
a[n-1] = b[n-2]
b.append(b[n-2])
for i in range(1,n-1):
    a[i] = min(b[i-1], b[i])
print(sum(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
Int dp[666][666];
signed main(){
  Int n,d1,d2;
  cin>>n>>d1>>d2;

  memset(dp,0,sizeof(dp));

  auto in=
    [&](Int y,Int x){
      return 0<=y&&y<n*2&&0<=x&&x<n*2;
    };
  auto calc=
    [&](Int d,Int x){
      Int k=1;
      while(d%4==0) d/=4,k*=2;
      for(Int a=0;a<n*2;a+=k)
	for(Int b=((d&1)&((a/k)&1))*k;b<n*2;b+=k*2)
	  for(Int i=0;i<k;i++)
	    for(Int j=0;j<k;j++)
	      if(in(a+i,b+j)) dp[a+i][b+j]|=x;
    };
  
  calc(d1,1);
  calc(d2,2);
  if(0){
    for(Int i=0;i<n*2;i++){
      for(Int j=0;j<n*2;j++)
	cout<<dp[i][j]<<" ";
      cout<<endl;
    }
  }

  Int cnt[4]={};
  for(Int i=0;i<n*2;i++)
    for(Int j=0;j<n*2;j++)
      cnt[dp[i][j]]++;

  for(Int k=0;k<4;k++){
    if(cnt[k]>=n*n){
      Int res=0;
      for(Int i=0;i<n*2;i++){
	for(Int j=0;j<n*2;j++){
	  if(dp[i][j]!=k) continue;
	  cout<<i<<" "<<j<<endl;
	  if(++res==n*n) return 0;
	}
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 4352
N = int(input())
d = list(map(int,input().split()))
d.sort()
d_len = len(d)
if d_len == 2:
  print(d[d_len//2] - d[d_len//2-1])
else:
  if d[d_len//2] - d[d_len//2-1] > 0:
    print(d[d_len//2] - d[d_len//2-1])
  else:
    print(0)

Measured memory_bytes: 14396
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

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

 int maxv = -2000000000;
 int minv = R[0];
 
for(int i = 1 ; i < n; i++){
 maxv =max(maxv,R[i]-minv);
 minv = min(minv,R[i]);
}

cout << maxv << endl;

return 0;
}


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

int main()
{
    char s, ans;
    string a = "abcdefghijklmnopqrstuvwxyz";
    cin >> s;
    for(int i = 0; i < 26; ++i){
        if(a.at(i) == s) ans = a.at(i + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
using System;
using System.Linq;

namespace AtCoder.BC081
{
    public class B
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var nums = new int[n];
            var count = 0;
            nums = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToArray();

            while (nums.All(n => n % 2 == 0))
            {
                count++;
                for (int i = 0; i < nums.Length; i++)
                {
                    nums[i] = nums[i] / 2;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 28160
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define flush fflush(stdout)
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define ln '\n'
#define MAX 1000000009
#define MOD 1000000007
#define N 500005
using namespace std;
typedef long long ll;
typedef pair<int ,int > pii;
int n, m, a, b, dp[N];
vector <int> edge[N]; 
int DP(int now){
    if(dp[now] != -1){
        return dp[now];
    }
    dp[now] = 0;    
    for(auto a : edge[now]){
        dp[now] = max(dp[now], DP(a) + 1);
    }
    return dp[now];
}
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL); 
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    vector <int> v; 
    while(m--){
        cin >> a >> b;
        edge[a].pb(b);
    }
    int ans = -1;
    for(int i = 1; i <= n; i++){
        ans = max(ans, DP(i));
    }
    cout << ans;
}

Measured memory_bytes: 18432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		if (s.length()>=4&&"YAKI".equals(s.substring(0, 4))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 23124
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100005;

struct edge {
    int from, to, w;
};

bool cmp(edge a, edge b) {
    return a.w < b.w;
}

int n, m;
vector <edge> e;
int st[MAXN];
long long ans;

int getSet(int x) {
    if (st[x] == x)
        return x;
    st[x] = getSet(st[x]);
    return st[x];
}

void unite(int a, int b) {
    a = getSet(a); b = getSet(b);
    if (rand() & 1)
        swap(a, b);
    st[a] = b;
}

int getDist(pair <int, int> p1, pair <int, int> p2) {
    return min(abs(p1.first - p2.first), abs(p1.second - p2.second));
}

int main() {
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));

    scanf("%d", &n);
    vector <pair <pair <int, int>, int> > v1(n);
    vector <pair <pair <int, int>, int> > v2(n);
    
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &v1[i].first.first, &v1[i].first.second);
        v1[i].second = i + 1;
        v2[i] = v1[i];
        swap(v2[i].first.first, v2[i].first.second);
        //cout << v1[i].first.first << " " << v1[i].first.second << " " << v1[i].second << endl;
        //cout << v2[i].first.first << " " << v2[i].first.second << " " << v2[i].second << endl;
    }

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    for(int i = 0; i < n; i++) {
        for(int j = max(i - 8, 0); j < min(i + 8, n); j++) {
            if(i != j) {
                edge add;
                add.from = v1[i].second;
                add.to = v1[j].second;
                add.w = getDist(v1[i].first, v1[j].first);
                e.push_back(add);

                add.from = v2[i].second;
                add.to = v2[j].second;
                add.w = getDist(v2[i].first, v2[j].first);
                e.push_back(add);
            }
        }
    }


    for (int i = 1; i <= n; i++)
        st[i] = i;

    sort(e.begin(), e.end(), cmp);




    for (int i = 0; i < (int) e.size(); i++) {
        int from = getSet(e[i].from), to = getSet(e[i].to);
        if (from != to) {
            ans += (long long)e[i].w;
            unite(from, to);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 53860
N,M=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(M)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf=UnionFind(N)
for a,b in ab:
    uf.union(a-1,b-1)
print(uf.group_count()-1)

Measured memory_bytes: 29396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll x,y;
    cin>>x>>y;
    rep(0,i,x+1){
        ll j=x-i;
        if(y==2*i+4*j){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}


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

const int N = 100005;

int head[N], nxt[N], f[N], ans, n, k;
void link(int x, int y) { nxt[y] = head[x], head[x] = y; }

int dfs(int x) {
	int max = 1;
	for (int i = head[x]; i; i = nxt[i])
		max = std::max(max, dfs(i) + 1);
	if (max == k) ++ans, max = 0;
	return max;
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> k;
	for (int i = 1; i <= n; ++i) std::cin >> f[i];
	ans = f[1] != 1;
	for (int i = 2; i <= n; ++i) link(f[i], i);
	for (int i = head[1]; i; i = nxt[i]) for (int j = head[i]; j; j = nxt[j]) dfs(j);
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4608
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[0])
ans=float('inf')
for i in range(n-k+1):
    for j in range(i+k-1,n):
        x=l[j][0]-l[i][0]
        tl=sorted(l[i:j+1],key=lambda x:x[1])
        y=float('inf')
        for a in range(j-i+2-k):
            y=min(y,tl[a+k-1][1]-tl[a][1])
        ans=min(ans,x*y)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  int i=0;
  if(x == y && y != z)  i=1;
  if(y == z && z != x)  i=1;
  if(z == x && x != y)  i=1;
  if(i == 1)
    cout << "Yes" << endl;
  else
  	cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

int main(){
	using namespace std;
	int n,i,tmp;
	int ma = 0;
	cin >> n;
	int a[n], b[n], c[n-1];

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

	for (i = 0; i < n; i++) {
		cin >> b[i];
	}

	for (i = 0; i < n-1; i++) {
		cin >> c[i];
	}

	for (i = 0; i < n; i++) {
	ma = ma + b[i];

	if (a[i] == a[i-1] + 1) {
		tmp = a[i-1];
		ma += c[tmp-1];
	}

	}

	cout << ma << endl;
	return 0;
}

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

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

    long long tmp = n;
    int fn = 0;
    for(int karen = 0; karen < 10; karen++){
        if(tmp != 0){
            fn += (tmp % 10);
            tmp /= 10;
        }
    }
    // cout << fn << endl;
    if(n % fn == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

double abs(double x) {
  return x < 0 ? -x : x;
}

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  double mnAbs = 114514;
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    int h;
    cin >> h;
    double bbs = abs(t - 0.006 * h - a);
    if (bbs < mnAbs) {
      mnAbs = bbs;
      res = i;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
line = gets.split(' ').map(&:to_i)

t = line[0..1]
a = line[2..3]

winner = 0
while true do
  if winner == 0 || winner % 2 == 0
    break if (a[0] - t[1] <= 0)
    a[0] -= t[1]
  else
    break if (t[0] - a[1] <= 0)
    t[0] -= a[1]
  end
  winner += 1
end

if winner == 0 || winner % 2 == 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14428
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)
//string 変数　　変数.size()で数字化


int main(void)
{
	long long l, h, n;
	cin >> l >> h >> n;
	
	if (l%n == 0) {
		cout << h / n - l / n + 1 << endl;
	}
	else {
		cout << h / n - l / n << endl;
	}
	
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str
n=ni()
s=ns()
r=s.count("R")
b=s.count("B")
if r>b:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

   string s;
   cin >> s;
   for(char c = 'a';c <= 'z';c++){
   	bool exist = false;
   	for(unsigned i = 0;i < s.size();i++){
   		if(c == s[i]){
   			exist = true;
   			break;
   		}
   	}
   	if(exist == false){
   		cout << c << endl;
   		rtn 0;
   	}
   }
   cout << "None" << endl;
   
   rtn 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin >> n;
	int cr=1;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin >> x;
		if(x==cr)
		{
			cr+=1;
		}
	}
	if(cr==1)
	{
		cout << "-1\n";
	}
	else
	{
		ll ans=n-cr+1;
		cout << ans << "\n";
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin

def calc_ab_price_without_pricedown(a_list, b_list):
    ab_price = [[a_list[j]+b_list[i] for i in range(len(b_list))] for j in range(len(a_list))]

    return ab_price


def calc_pricedown(ab_price, pricedown_list):
    """値段表から値引きする"""
    for i, j, price in pricedown_list:
        for k, l, price2 in pricedown_list:
            if (i, j) == (k, l) and price >= price2:
                continue
            elif (i, j) == (k, l) and price < price2:
                price = 0

        ab_price[i-1][j-1] -= price

    return ab_price

def generate_table(a_list, b_list,  pricedown_list):
    min_a = min(a_list)
    min_b = min(b_list)
    min_price = min_a + min_b

    for i, j, price in pricedown_list:
        min_price = min(min_price, a_list[i-1]+b_list[j-1]-price)

    return min_price


def calc_min_price(a_list, b_list, ab_price):
    min_price = float('inf')
    for i in range(len(a_list)):
        for j in range(len(b_list)):
            min_price = min(ab_price[i][j], min_price)
    return min_price

a, b, m = map(int, input().split())

a_list = [int(x) for x in stdin.readline().rstrip().split()]
b_list = [int(x) for x in stdin.readline().rstrip().split()]

pricedown_list = []
for i in range(m):
    pricedown_list.append([int(x) for x in stdin.readline().rstrip().split()])
    # pricedown_list.append((list(map(int, input().split()))))


# 割引せずに購入する場合の合計金額のうち、最低金額を算出
# ab_price = calc_ab_price_without_pricedown(a_list, b_list)

# 最低金額を算出
# min_price = calc_min_price(a_list, b_list, ab_price)

# 割引の値段を含めて考える
# pricedowned_ab = calc_pricedown( ab_price, pricedown_list)

min_price = generate_table(a_list, b_list,  pricedown_list)

# 値引き後の最低金額を算出
# min_price = calc_min_price(a_list, b_list, price_table)

print(min_price)




Measured memory_bytes: 76220
a, b, c = map(int, input().split())
res = 0
if a == b and a == c and a % 2 == 0:
    print(-1)
else:
    while 10 > 0:
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            break
        a1 = a//2
        b1 = b//2
        c1 = c//2
        a = b1+c1
        b = a1+c1
        c = a1+b1
        res += 1
    print(res)


Measured memory_bytes: 9128
s = input()
a = ("No")
if s[0] == s[1] and s[2] == s[3] and s[0] != s[3]:
    a = ("Yes")
if s[0] == s[2] and s[1] == s[3] and s[0] != s[3]:
    a = ("Yes")
if s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    a = ("Yes")
print(a)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, m, q;

	cin>>n>>m>>q;

	vll l(m), r(m);

	vvll d(n, vll(n, 0)), sum(n+1, vll(n+1, 0));

	rep(i, m){
		cin>>l[i]>>r[i];
		l[i]--; r[i]--;
		d[l[i]][r[i]]++;
	}

	rep(i, n){
		rep(j, n){
			sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+d[i][j];
		}
	}

	rep(i, q){
		ll p1, p2, max=-1;
		cin>>p1>>p2;
		p1--;
		cout<<sum[p2][p2]-sum[p1][p2]-sum[p2][p1]+sum[p1][p1]<<endl;
	}
}


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

typedef long long ll;

bool solve(ll a, ll b, ll c, ll d) {
	if (a < b || d < b)
		return false;
	if (c >= b)
		return true;
	
	d = __gcd(d, b);
	a %= b;
	
	if (a > c)
		return false;
	
	if (a + d * ((c - a) / d + 1) < b)
		return false;

	return true;
}

int main() {
	int tc;
	scanf("%d", &tc);
	while (tc--) {
		ll a, b, c, d;
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		puts(solve(a, b, c, d) ? "Yes" : "No");
	}
	return 0;
}

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

using namespace std;

bool isPalindrome(string &S) {
    bool palindrome = true;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != S[S.length()-1-i]) {
            palindrome = false;
            break;
        }
    }

    return palindrome;
}

int h, w;
vector<string> G;
vector<int> mix(12);

bool tryGrid() {
    vector<string> T(h, "");
    vector<bool> used(h, false);
    int remaining = h;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            T[i] += G[i][mix[j]];
        }
        //cout << T[i] << endl;
    }
    //cout << endl;

    int remains = -1;
    for (int i = 0; i < h; i++) {
        if (used[i]) continue;
        for (int j = i+1; j < h; j++) {
            if (used[j]) continue;
            bool match = true;
            for (int k = 0; k < w; k++) {
                if (T[i][k] != T[j][w-1-k]) {
                    match = false;
                    break;
                }
            }
            if (match) {
                used[i] = true;
                used[j] = true;
                remaining -= 2;
                break;
            }
        }
        if (!used[i]) {
            remains = i;
        }
    }

    if (h%2 == 0) {
        if (remaining > 0) {
            return false;
        } else {
            return true;
        }
    } else {
        if (remaining == 1 && isPalindrome(T[remains])) {
            return true;
        } else {
            return false;
        }
    }
}

vector<bool> U(12, false);
bool works = false;
void mixColumns(int i) {
    if (works) return;
    if (i == w/2) {
        if (tryGrid()) {
            works = true;
            return;
        }
    }

    int c;
    for (c = i; c < w; c++) {
        if (!U[c]) break;
    }

    mix[i] = c;
    U[c] = true;
    for (int j = c+1; j < w; j++) {
        if (!U[j]) {
            mix[w-1-i] = j;
            U[j] = true;
            mixColumns(i+1);
            U[j] = false;
        }
    }
    U[c] = false;
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string T;
        cin >> T;
        G.push_back(T);
    }

    if (w%2 == 1) {
        for (int m = 0; m < w; m++) {
            U[m] = true;
            mix[w/2] = m;
            mixColumns(0);
            U[m] = false;
        }
    }
    mixColumns(0);

    if (works) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int r;
    cin >> r;
    cout << r * r<< endl;

    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>

int main()
{
	int n, i, j, k, l;

	while(scanf("%d", &n) != EOF){
		int num[100000] = {'\0'};
		num[0] = 2;
		l = 1;

		for(i = 3; i <= n; i++) {
			k = 0;

			j = 0;
			while(num[j] != '\0'){
				if(i % num[j] == 0) {k = 1; break;}
				else if(num[j] > sqrt(i)+1) break;

				j++;
			}

			if(k != 1) {num[l] = i; l++;}
		}

		if(n == 1) l = 0;

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

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i =0; i < n-2; i++) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    ll n, a, x[55], dp[55][55][2505] = {};

    cin >> n >> a;
    REP(i, n){
        cin >> x[i];
    }

    dp[0][0][0] = 1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; k <= 2500; k++){
                if(i >= 1 && x[i - 1] > k){
                    dp[i][j][k] = dp[i - 1][j][k];
                }
                else if(i >= 1 && j >= 1 && x[i - 1] <= k){
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
                }
            }
        }
    }

    ll ans = 0;
    REP(i, n){
        ans += dp[n][i + 1][(i + 1) * a];
    }

    cout << ans << endl;
}

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

int main(void)
{
  int a, b;
  cin >> a >> b;
  if(a > b)
    {
      cout << "a > b" << endl;
    }
  else if(a < b)
    {
      cout << "a < b" << endl;
    }
  else if(a == b)
    {
      cout << "a == b" << endl;
    }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
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> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3528
from itertools import product

h, w, k = map(int, input().split())
c = [input() for _ in range(h)]


def n_black(fillh, fillw):
    n = 0
    for ih, iw in product(range(h), range(w)):
        if (not fillh[ih]) and (not fillw[iw]) and c[ih][iw] == "#":
            n += 1
    return n


answer = 0
for fillh, fillw in product(
    product([True, False], repeat=h), product([True, False], repeat=w)
):
    if n_black(fillh, fillw) == k:
        answer += 1
print(answer)


Measured memory_bytes: 9084
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll sol[100005];

int main(){
	boost;
    for(ll i=1;i<=100;i++){
    	for(ll j=1;j<=100;j++){
    		for(ll k=1;k<=100;k++){
    			if(i*i+j*j+k*k+i*j+i*k+j*k<=10000){
    				sol[i*i+j*j+k*k+i*j+j*k+i*k]++;
				}
			}
		}
	}
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cout<<sol[i]<<endl;
	}
}
			
			


Measured memory_bytes: 3712