akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int res = n;
	for (int i = 0; i <= n; ++i) {
		int a = 0;
		int t = i;
		while (t > 0)a += t % 6, t /= 6;
		t = n - i;
		while (t > 0)a += t % 9, t /= 9;
		if (res > a) res = a;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    string s,t;
    cin >> s >> t;
    unordered_map<char,int> mp[2];
    bool ans = true;
    for(int i = 0; i < s.size(); i++){
        mp[0][s[i]] = mp[0][s[i]]*10+i;
        mp[1][t[i]] = mp[1][t[i]]*10+i;
    }    
    for(int i = 0; i < s.size(); i++){
        if(mp[0][s[i]] != mp[1][t[i]]) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define se second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<pair<ld,ld>> xy(N);
    rep(i,N) {
        cin >> xy.at(i).fi >> xy.at(i).se;
    }
    ld sum = 0;
    ld count = 0;
    vector<int> perm;
    rep(i,N) {
        perm.push_back(i);
    }
    do {
        rep(i,N-1) {
            sum += hypot(xy.at(perm.at(i)).first-xy.at(perm.at(i+1)).first,xy.at(perm.at(i)).second-xy.at(perm.at(i+1)).second);
        }
        count++;
    }while (next_permutation(perm.begin(),perm.end()));
    cout << setprecision(15) << sum/count << endl;
}

Measured memory_bytes: 512
n=input()

if int(n[-1])==2:
    print("hon")
elif int(n[-1])==4:
    print("hon")
elif int(n[-1])==5:
    print("hon")
elif int(n[-1])==7:
    print("hon")
elif int(n[-1])==9:
    print("hon")
elif int(n[-1])==0:
    print("pon")
elif int(n[-1])==1:
    print("pon")
elif int(n[-1])==6:
    print("pon")
elif int(n[-1])==8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

//ll bit[200010];
//ll kai[3010];
//ll Cnt[10010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}


/*map<ll, ll> pres;
ll ct;

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			if (pres[j] == 0) {
				ct++;
				pres[j] = ct;
			}
			Cnt[pres[j]] += cnt;
		}
	}
	if (X != 1) {
		if (pres[X] == 0) {
			ct++;
			pres[X] = ct;
		}
		Cnt[pres[X]] += 1;
	}
}*/

string N;
ll K;
ll ans;
ll ct;
ll num;

ll com(ll x, ll y) {
	if (x < y) return 0;
	ll res = 1;
	rep(i, y) {
		res *= x - i;
	}
	rep(i, y) {
		res /= i + 1;
	}
	return res;
}

void solve() {
	cin >> N >> K;
	ll k = K;
	ll len = N.length();
	rep(i, N.length()) if (N[i] != '0') num++;
	rep(i, N.length()) {
		if (N[i] == '0') continue;
		if (K >= 0) {
			ans += com(len - i - 1, K) * pow(9, K);
		}
		if (K - 1 >= 0) {
			ans += com(len - i - 1, K - 1) * pow(9, K - 1) * (N[i] - '1');
			//cout << co[len - i - 1][K - 1] * pow(9, K - 1) * (N[i] - '1') << endl;
		}
		K -= 1;
		//cout << ans << endl;
		if (K < 0) break;
	}
	if (num == k) {
		ans++;
	}
	if (N.length() < k) {
		cout << 0 << endl;
		return;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

int main(){
	int a[10010];
	int i = 0, i2, i3 = 0;
	while (i < 10010){
		cin >> a[i];
		if (a[i] == 0){
			i2 = i;
			break;
		}
		i++;
	}
	while (a[i3] != 0){
		cout << "Case " << i3 + 1 << ": " << a[i3] << endl;
		i3++;
	}
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int a,b;cin>>a>>b;cout<<a*b;}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)
		cout << "Yes" << "\n";
	else if (abs(a - b) <= d && abs(b - c) <= d)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
}

Measured memory_bytes: 3644
n = int(input().strip())
s = input().strip()
ansarray = []
for i in range(len(s)):
    if s[i] == 'A':
        snum = 1
    if s[i] == 'B':
        snum = 2
    if s[i] == 'C':
        snum = 3
    if s[i] == 'D':
        snum = 4
    if s[i] == 'E':
        snum = 5
    if s[i] == 'F':
        snum = 6
    if s[i] == 'G':
        snum = 7
    if s[i] == 'H':
        snum = 8
    if s[i] == 'I':
        snum = 9
    if s[i] == 'J':
        snum = 10
    if s[i] == 'K':
        snum = 11
    if s[i] == 'L':
        snum = 12
    if s[i] == 'M':
        snum = 13
    if s[i] == 'N':
        snum = 14
    if s[i] == 'O':
        snum = 15
    if s[i] == 'P':
        snum = 16
    if s[i] == 'Q':
        snum = 17
    if s[i] == 'R':
        snum = 18
    if s[i] == 'S':
        snum = 19
    if s[i] == 'T':
        snum = 20
    if s[i] == 'U':
        snum = 21
    if s[i] == 'V':
        snum = 22
    if s[i] == 'W':
        snum = 23
    if s[i] == 'X':
        snum = 24
    if s[i] == 'Y':
        snum = 25
    if s[i] == 'Z':
        snum = 26
    if snum + n <= 26:
        ansnum = snum + n
    else:
        ansnum = (snum + n) - 26
    if ansnum == 1:
        ansarray.append('A')
    if ansnum == 2:
        ansarray.append('B')
    if ansnum == 3:
        ansarray.append('C')
    if ansnum == 4:
        ansarray.append('D')
    if ansnum == 5:
        ansarray.append('E')
    if ansnum == 6:
        ansarray.append('F')
    if ansnum == 7:
        ansarray.append('G')
    if ansnum == 8:
        ansarray.append('H')
    if ansnum == 9:
        ansarray.append('I')
    if ansnum == 10:
        ansarray.append('J')
    if ansnum == 11:
        ansarray.append('K')
    if ansnum == 12:
        ansarray.append('L')
    if ansnum == 13:
        ansarray.append('M')
    if ansnum == 14:
        ansarray.append('N')
    if ansnum == 15:
        ansarray.append('O')
    if ansnum == 16:
        ansarray.append('P')
    if ansnum == 17:
        ansarray.append('Q')
    if ansnum == 18:
        ansarray.append('R')
    if ansnum == 19:
        ansarray.append('S')
    if ansnum == 20:
        ansarray.append('T')
    if ansnum == 21:
        ansarray.append('U')
    if ansnum == 22:
        ansarray.append('V')
    if ansnum == 23:
        ansarray.append('W')
    if ansnum == 24:
        ansarray.append('X')
    if ansnum == 25:
        ansarray.append('Y')
    if ansnum == 26:
        ansarray.append('Z')
ans = ''
for j in range(len(s)):
    ans = ans + ansarray[j]
print(ans)


Measured memory_bytes: 58712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
int a[100+10], memo[100000+10];
int go(int rem) {
    if (rem==0) return 0;
    if (memo[rem] != -1) return memo[rem];
    for (int i = 0; i < n; i++) {
        if (rem < a[i]) continue;
        int nxt = go(rem-a[i]);
        if (nxt % 2 == 0 && a[i] <= rem) { 
            return memo[rem] = nxt+1; // nxt is ev but the one step to get there makes it even
        }
    }
    return memo[rem] = 12;  // any even num
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    memset(memo, -1, sizeof memo);
    if (go(k)%2 == 1) cout << "First";
    else cout << "Second";

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int h, w, n;
  cin >> h >> w >> n;
  vector<vector<int>> a(h, vector<int>(w));
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int p = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      while (b[p] == 0) p++;
      b[p]--;
      a[i][j] = p + 1;
    }
  }
  for (int i = 1; i < h; i += 2) {
    reverse(a[i].begin(), a[i].end());
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
	bool flg = true;
	int a, b;
	char s[19];
	cin >> a >> b >> s;
	for (int i = 0; i < a; i++) {
		if (s[i] == '-') {
			flg = false;
		}
	}
		if (s[a] != '-') {
			flg = false;
		}
	for (int i = a+1; i < a+b+1; i++) {
			if (s[i] == '-') {
				flg = false;
			}
	}
	if (flg == true) {
		cout << "Yes";
	}
	else {
		cout << "No";

	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int w,h,n,x1=0,x2,y1=0,y2,x,y,a,i;
  scanf("%d%d%d",&w,&h,&n);
  x2=w;
  y2=h;
  for (i=0;i<n;i++){
    scanf("%d%d%d",&x,&y,&a);
    if (a==1){
      if (x>=x2){
        printf("0\n");
        return 0;
      }
      if (x>x1) x1=x;
    }else if (a==2){
      if (x<=x1){
        printf("0\n");
        return 0;
      }
      if (x<x2) x2=x;
    }else if (a==3){
      if (y>=y2){
        printf("0\n");
        return 0;
      }
      if (y>y1) y1=y;
    }else{
      if (y<=y1){
        printf("0\n");
        return 0;
      }
      if (y<y2) y2=y;
    }
  }
  printf("%d\n",(x2-x1)*(y2-y1));
  return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') s[i] = '9';
    else if (s[i] == '9') s[i] = '1';
  }

  // 解答
  cout << s << endl;
  return 0;
}

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

using namespace std;

int n;
int x[10];
int y[10];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d %d",&x[i],&y[i]);
    int permu[10];
    for(int i=0;i<n;i++) permu[i]=i;
    double ans=0;
    int i=0;
    do
    {
        for(int j=0;j<n-1;j++)
        {
            ans+=sqrt((x[permu[j]]-x[permu[j+1]])*(x[permu[j]]-x[permu[j+1]])
            +(y[permu[j]]-y[permu[j+1]])*(y[permu[j]]-y[permu[j+1]]));
        }
        i++;
    } while (next_permutation(permu,permu+n));
    printf("%0.20lf\n",ans/(double)i);
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> E(N + 1), W(N + 1);
  for (int i = 1; i < N + 1; i++) {
    E.at(i) = E.at(i - 1) + (S.at(i - 1) == 'E');
    W.at(i) = W.at(i - 1) + (S.at(i - 1) == 'W');
  }
  int ans = 2e9;
  for (int i = 0; i < N + 1; i++) {
    ans = min(ans, E.at(N) - E.at(i) + W.at(i));
  }
  cout << ans << "\n";
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	for (int i = 0; i < n; i++) {
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s + n);
	long ans = 0;
	int count = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i-1]) {
			count += 1;
		} else {
			ans += count * (count-1) / 2;
			count = 1;
		}
	}
	ans += (count * (long)(count-1)) / 2;

	cout << ans << endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define MAX_V 100000
struct edge { int to, cost; };
typedef pair<int, int> P; //firstは距離、secondは頂点の番号

int V; //頂点数
vector<edge> G[MAX_V]; //添字がfrom
int d[MAX_V]; //最短コスト

int prim() {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	int res = 0;
	que.push(P(0, 0));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] != INF)continue;
		res += p.first;
		d[v] = p.first;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] == INF)que.push(P(e.cost, e.to));
		}
	}
	return res;
}

signed main() {
	int E;
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		int s, t, c;
		edge e;
		cin >> s >> t >> c;
		e.to = t;
		e.cost = c;
		G[s].push_back(e);
		e.to = s;
		G[t].push_back(e);
	}
	cout << prim() << endl;
	return 0;
}


Measured memory_bytes: 12484
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LL long long



int main(){
  int N, K;
  cin>>N>>K;
  int D;
  bool d[10]; //きらいならtrue;
  REP(i, 10) d[i]=false;
  REP(i, K){
    cin>>D;
    d[D]=true;
  }

  int work;
  bool dame;
  for(int i=N; i<100000; ++i){
    work=i;
    dame=false;
    while(work>0){
      if(d[work%10]) dame=true;
      work /= 10;
    }
    if(!dame){
      cout<<i<<endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//#include<bits/stdc++.h>
using namespace std;
#define Base1   101LL
#define Base2   10000079LL
#define Base3   10000103LL
#define MOD1    1000000007LL
#define MOD2    1000000009LL
#define MOD3    1000000021LL
#define mx 100000//Number of charter of main string
#define mx1 25000// Number off character of total charcater
#define mx2 500// Number of pattern and number of ch of each pattern
 
 int dx[]= {1,-1,0,0};
 int dy[] = {0,0,1,-1};
 
int main(){

  int n,m;
  cin>>n>>m;
  map<int,int>mp, wa1;
  int ac =0,wa =0;
  for(int i=1;i<=m;i++){
      int x,y;
      cin>>x;
      string s;
      cin>>s;
      if(mp[x] == 0){
          if(s=="WA")wa1[x]++;
          else {
              ac++;
              wa+=wa1[x];
              mp[x] = 1;
          }
          
      }

  }
  cout<<ac<<" "<<wa<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <bits/stdc++.h>

#define rep(i,z) for(int i = 0; i < (z); i++)

using namespace std;

typedef long long ll;

int main(){
    int n,m;
    cin >>n;
    cin >>m;
    priority_queue<int> q;
    rep(i, n){
        int a;
        cin >>a;
        q.push(a);
    }
    rep(i,m){
        int a = q.top()/2;
        q.pop();
        q.push(a);
    }

    ll ans = 0;
    rep(i,n){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

string p[9],m[9];
bool used[9];
int dfs(int cnt){
    int ret=0;
    if(cnt==9) return 1;
    rep(i,9){
        if(used[i]) continue;
        rep(j,4){
            if(cnt>0&&cnt%3==0){
                if(abs(m[cnt-3][2]-p[i][j])!=32) continue;
            }
            else if(cnt>2&&cnt%3!=0){
                if(abs(m[cnt-3][2]-p[i][j])!=32||abs(m[cnt-1][1]-p[i][(j+3)%4])!=32) continue;
            }
            else if(cnt<3&&cnt>0){
                if(abs(m[cnt-1][1]-p[i][(j+3)%4])!=32) continue;
            }
            used[i]=true;
            string rp=p[i];
            rotate_copy(p[i].begin(),p[i].begin()+j,p[i].end(),rp.begin());
            m[cnt]=rp;
            ret +=dfs(cnt+1);
            used[i]=false;
        }
    }
    return ret;
}
int main(){
    int n;
    cin>>n;
    while(n--){
        rep(i,9) cin>>p[i];
        cout<<dfs(0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3140
N, M, Q = map(int, input().split())
#N: 正整数列の長さ, M:正整数列の最大値, Q: 4つの整数の組みの数

Q_li = [list(map(int, input().split())) for _ in range(Q)]

def dfs(now, n, num): #nowはこれから生成するもの
    if n == 0:
        make_group.append(now)
    else:
        for i in range(num, M+1):
            dfs(now+[i], n-1, i)

make_group = []
dfs([], N, 1)
ans = 0
for group in make_group:
    tmp = 0
    for q in Q_li:
        a = q[0] - 1
        b = q[1] - 1
        if q[2] == (group[b] - group[a]):
            tmp += q[3]
    ans = max(ans, tmp)
print(ans)



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

int main() {
  int N, K;
  cin >> N >> K;
  long h[N];
  for(int i=0; i<N; i++) {
    cin >> h[i];
  }
  sort(h, h+N);
  long D=10000000000;
  for(int i=0; i<N-K+1; i++) {
    if(D>=h[i+K-1]-h[i]) {
      D=h[i+K-1]-h[i];
    }
  }
  cout << D << endl;
}

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

void Main() {
  long long N;
  cin >> N;

  map<long long, int> soinsu;
  for (long long i = 2; i * i <= N; i++) {
    while (N % i == 0) {
      soinsu[i]++;
      N /= i;
    }
  }
  if (N != 1) soinsu[N]++;

  long long ans = 0;
  for (auto s: soinsu) {
    int sum = 0;
    for (int i = 1; sum + i <= s.second; i++) {
      sum += i;
      ans++;
    }
  }
  cout << ans << endl;
}

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



Measured memory_bytes: 3656
n = gets.to_i
ans = ''
loop {
    tmp = '9' + ans
    if tmp.to_i > n
        break
    end
    ans = tmp
    }
9.downto(1) do |i|
    tmp = i.to_s + ans
    if tmp.to_i <= n
        ans = tmp
        break
    end
end
x = 0
ans.chars do |c|
    x += c.to_i
end
p x

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MAX=100500;
const ll MOD=1e9+7;
ll fact[MAX],n,m;
int main(){
    scanf("%lld%lld",&n,&m);
    fact[0]=1;
    for(ll i=1;i<=max(n,m);i++) fact[i]=i*fact[i-1]%MOD;
    if(n==m){
        printf("%lld\n",fact[n]*fact[m]*2%MOD);
    }
    else if(abs(n-m)==1){
        printf("%lld\n",fact[n]*fact[m]%MOD);
    }
    else{
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    private static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        int balls = input.nextInt();
        int people = input.nextInt();

        if (people == 1) {
            System.out.println(0);
        } else {
            System.out.println(balls - people);
        }
    }
}


Measured memory_bytes: 22996
#include <cstdio>
using namespace std;

#define N 2100
#define M 1000000007
#define Q 200100
#define ll long long
int f[N * 2][N * 2];
int a[Q], b[Q], fact[N * 4], fact_inv[N * 4];

int power(int x, int y)
{
	int ans = 1;
	for (; y; y >>= 1, x = (ll)x * x % M)
		if (y & 1)
			ans = (ll)ans * x % M;
	return ans;
}

inline int C(int n, int m)
{
	//printf("%d %d %d\n", n, m, (ll)fact[n] * fact_inv[m] % M * fact_inv[n - m] % M);
	return (ll)fact[n] * fact_inv[m] % M * fact_inv[n - m] % M;
}

int main()
{
	fact[0] = 1;
	for (int i = 1; i < N * 4; i++)
		fact[i] = (ll)fact[i - 1] * i % M;
	fact_inv[N * 4 - 1] = power(fact[N * 4 - 1], M - 2);
	for (int i = N * 4 - 1; i >= 1; i--)
		fact_inv[i - 1] = (ll)fact_inv[i] * i % M;
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d", a + i, b + i);
		f[N - a[i]][N - b[i]]++;
	}
	for (int i = 1; i < N * 2; i++)
		for (int j = 1; j < N * 2; j++)
			f[i][j] = ((ll)f[i][j] + f[i - 1][j] + f[i][j - 1]) % M;

	ll ans = 0;
	for (int i = 1; i <= n; i++)
		ans += f[a[i] + N][b[i] + N];
	for (int i = 1; i <= n; i++)
		ans -= C((a[i] + b[i]) * 2, a[i] * 2);
	ans %= M;
	if (ans < 0)
		ans += M;
	printf("%lld\n", ans * power(2, M - 2) % M);
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int p[maxn];
vector<int>graph[maxn];
int c[maxn];
void dfs(int u , int pp , int comp)
{
	c[u] = comp;
	for(int i = 0 ; i < graph[u].size(); i++)
	{
		int v = graph[u][i];
		if(v == pp)
			continue;
		if(c[v] == 0)
			dfs(v,u,comp);
	}
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int ans1 = 0;
	for(int i = 1 ; i <= n ; i++)
	{
		scanf("%d",&p[i]);
		if(p[i] == i)
			ans1++;
	}
	while(m--)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	for(int i = 1 ; i <= n ; i++)
	{
		if(c[i] == 0)
			dfs(i,-1,i);
	}
	int ans = 0;
	for(int i = 1; i <= n ; i++)
	{
		if(c[i] != c[p[i]])
		{
			ans++;
		}
	}
	ans = max(ans1,n-ans);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 13184
#include<iostream>
using namespace std;
int main()
{
    int a, b, k, i;
    cin>>k>>a>>b;
    for(i=a; i<=b; i++)
    {
        if(i%k==0)
        {
             cout<<"OK";
           return 0;
        }
    }
     cout<< "NG"<<endl;
     return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>

int main(void){
    long long int a,b,c,d,e,f;
    scanf("%lld",&a);
   b=a*(a+1)/2;
   c=(a/3)*((a/3)+1)*3/2;
   d=(a/5)*((a/5)+1)*5/2;
   e=(a/15)*((a/15)+1)*15/2;
   f=b-c-d+e;
   printf("%lld",f);
}

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

moji_num = {1: 26}
for i in range(2, 100):
    moji_num[i] = moji_num[i-1] * 26
#print(moji_num)

ac = {0: 0, 1: 26}
for i in range(1, 100):
    if ac[i-1] >= n:
        break
    ac[i] = ac[i-1] + moji_num[i]
#print(ac)
mojisuu = i-1
nanmojime = n - ac[i-2] - 1
#print(mojisuu, nanmojime)

arr = []
for keta in range(mojisuu):
    sisuu = mojisuu - keta - 1
    #print(sisuu)
    arr.append(nanmojime // 26**sisuu)
    nanmojime %= 26 ** sisuu
#print(arr)

mojiretu = []
for num in arr:
    mojiretu.append(chr(97 + num))
#print(mojiretu)
print(*mojiretu, sep="")

Measured memory_bytes: 61780
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
ST = []
D = {}
for i in range(N):
    s, t = input().split()
    t = int(t)
    ST.append((s, t))
    D[s] = i

X = input()
idx = D[X]
ans = 0
for i in range(idx+1, N):
    ans += ST[i][1]
print(ans)


Measured memory_bytes: 3444
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int INF = 1 << 28;
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] dp = new int[h + 1][w + 1];
		for (int i = 0; i <= h; i++) {
			Arrays.fill(dp[i], INF);
		}
		for (int i = 1; i <= h; i++) {
			char[] tmp = sc.next().toCharArray();
			for (int j = 0; j < tmp.length; j++) {
				dp[i][j + 1] = tmp[j] - '0';
			}
		}
		dp[0][1] = dp[1][0] = 0;

		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				dp[i][j] += Math.min(dp[i - 1][j], dp[i][j - 1]);
			}
		}
		System.out.println(dp[h][w]);
	}
}

Measured memory_bytes: 12000
import math

n,m = map(int,input().split())
a = max(n,m)
b = min(n,m)
if a>b+1:
    print(0)
    exit()
if a>b:
    print((math.factorial(a)*math.factorial(b)%(10**9 + 7)))
else:
    print((math.factorial(a)*math.factorial(b)*2%(10**9 + 7)))

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

int main(){
  int n, x;
  while (true) {
    cin >> n >> x;
    if (n==0 && x==0) break;

    int cnt = 0;
    int sum = -1;
    rep(i, n) {
      rep(j, n) {
        rep(k, n) {
          if(i>=j || j>=k || i>=k) continue;
          sum = i+1+j+1+k+1;
          if (sum==x) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



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

#define SIZE 100

int main(void){
  int n;
  int i;
  int dif;
  int change = 0;
  char a[SIZE], b[SIZE], c[SIZE];
  scanf("%d %s %s %s", &n, a, b, c);
  for ( i = 0; i < n; i++ ) {
    dif = 0;
    if ( a[i] != b[i] ) dif += 1;
    if ( a[i] != c[i] ) dif += 1;
    if ( b[i] != c[i] ) dif += 1;
    switch(dif){
      case 3: change += 1;
      case 2: change += 1; break;
    }
  }
  printf("%d", change);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
//文字列str入力→逆順20文字以内半角

int main(){
	int i,len;
	char s[20],tmp;
	scanf("%s",s);
	len = strlen(s);
	for(i=0;i<len/2;i++){
		tmp = s[i];
		s[i] = s[len-i-1];
		s[len-i-1] = tmp;
	}
	printf("%s\n",s);
	return 0;
}

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

#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                      \
  cout << #v << ":";                                      \
  for (int i = 0; i < v.size(); i++) cout << " " << v[i]; \
  cout << endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >
#define vll vector<vector<ll> >
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
const int inf = 1000000001;
const ll INF = 1e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int n, x, y, z;

ll mod_pow(ll x, ll p, ll M) {
  ll a = 1;
  while (p) {
    if (p % 2) {
      a = a*x%MOD;
    }
    x = x*x%MOD;
    p /= 2;
  }
  return a;
}

bool safe(int a, int b) {
  a <<= 1;
  a += 1;
  a <<= (b - 1);
  bool flag = true;
  int c = 1;
  c <<= (z - 1);
  if (!(c & a)) {
    flag = false;
  }
  c <<= y;
  if (!(c & a)) {
    flag = false;
  }
  c <<= x;
  if (!(c & a)) {
    flag = false;
  }
  return !flag;
}
  

int main() {
  int i, j, k;
  cin >> n >> x >> y >> z;
  ll m = 1 << (x + y + z);
  vll dp(n + 1, vl(m));
  dp[0][0] = 1;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      for (k = 1; k <= 10; k++) {
	if (safe(j, k)) {
	  int jn = j;
	  jn <<= 1;
	  jn += 1;
	  jn <<= (k - 1);
	  jn %= (1 << (x + y + z));
	  dp[i+1][jn] = (dp[i+1][jn] + dp[i][j]) % MOD;
	}
      }
    }
  }
  /*
  for (i = 0; i <= n; i++) {
    for (j = 0; j < m; j++) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  ll ans = 0;
  
  for (j = 0; j < m; j++) {
    ans = (ans + dp[n][j]) % MOD;
  }
  ans = (mod_pow(10, n, MOD) - ans) % MOD;
  while (ans < 0) {
    ans += MOD;
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 43392
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long
  
using namespace std;
  
const int N = 1e5 + 7;
const int INF = 1e18;
const int mod = 1e9 + 7; 
  
int32_t main() {
    speed;
	int x, y, a, b, c, cntR = 0, cntG = 0, ans = 0;
	cin >> x >> y >> a >> b >> c;

	vector < int > p(a), q(b), r(c);
	vector < pair < int, int > > vc;

	for ( auto &i: p ) {
		cin >> i;

		vc.push_back( { i, 'R' } );
	}
	for ( auto &i: q ) {
		cin >> i;

		vc.push_back( { i, 'G' } );
	}
	for ( auto &i: r ) {
		cin >> i;

		vc.push_back( { i, 'B' } );
	}
	sort( vc.rbegin(), vc.rend() );

	int total = x + y;

	for ( int i = 0; i < vc.size(); i++ ) {

		if ( total <= 0 ) {
			break;
		}

		if ( vc[i].second == 'R' ) {

			if ( cntR < x ) {
				cntR++;
				ans += vc[i].first;
				total--;
			}
		}
		else if ( vc[i].second == 'G' ) {

			if ( cntG < y ) {
				cntG++;
				ans += vc[i].first;
				total--;
			}
		}
		else {
			total--;
			ans += vc[i].first;			
		}
	}	
	cout << ans;
}

Measured memory_bytes: 12780
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    int n, i, j, t;

    vector<int> c(501);

    vector<int> s(501);

    vector<int> f(501);

         
    cin >> n;


    for( i = 0 ; i < n - 1 ; i = i + 1 ){

         cin >> c.at(i) >> s.at(i) >> f.at(i);

         }


    for( i = 0 ; i < n ; i = i + 1 ){

         t = 0;

         for( j = i ; j < n - 1 ; j = j + 1 ){

              if( t < s.at(j) ) t = s.at(j);

              else if( s.at(j) < t && t % f.at(j) == 0 ) t = t;

              else  t = ( t + f.at(j) - ( t % f.at(j) ) );

              t += c.at(j);

              }

         cout << t << endl;

         }


    return 0;
                                                          
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int g = 0 , p = 0;
    for(int i = 0 ; i < s.length() ; i++ ) {
        if( s[i] == 'g' ) g++;
        else p++;
    }
    cout << ( g - p ) / 2;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin>>S;
    if(S=="SUN")
    cout<<"7";
    else if(S=="SAT")
    cout<<"1";
	else if(S=="FRI")
    cout<<"2";
    else if(S=="THU")
    cout<<"3";
    else if(S=="WED")
    cout<<"4";
	else if(S=="TUE")
    cout<<"5";
    else
    cout<<"6";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool adj_mtrix[8][8];
int dfs(int v, int n, bool achieved[8]){
  bool all_achieved = true;
  for(int i=0; i<n; ++i){
    if(!achieved[i]) all_achieved = false;
  }
  if( all_achieved) return 1;
  int ret = 0;
  for(int i=0; i<n; ++i){
    if( !adj_mtrix[v][i] ) continue;
    if( achieved[i] ) continue;
    achieved[i] =true;
    ret += dfs(i, n, achieved); 
    achieved[i] =false;
  }
  return ret;
}
int main(){
  int n,m; cin>>n>>m;
  bool achieved[n];
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      adj_mtrix[i][j] = false;
    }
    achieved[i] = false;
  }
  for(int i=0; i<m; ++i){
    int a,b;
    cin>>a>>b;
    adj_mtrix[a-1][b-1] = adj_mtrix[b-1][a-1] = true;
  }
  achieved[0] =true;
  cout << dfs(0, n, achieved)<<endl;
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let s:Vec<char> = s.trim().chars().collect();
    
    let mut t = String::new();
    io::stdin().read_line(&mut t).expect("");
    let t:Vec<char> = t.trim().chars().collect();
    let mut cnt = t.len() as u64;
    
    for i in 0..(s.len()-t.len() + 1 as usize) {
        let mut k = 0 as u64;
        for j in 0..t.len() {
            if s[i+j] != t[j] {
                k += 1;
            }
        }
        if k < cnt {
            cnt = k;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 2108
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;

long long int N,M,K,sum=0,res=0,A[200200],D[200][3];
string S;
int main(){
    cout << fixed << setprecision(18);
    cin>>N;
    N--;
    for(long long int A = 1; A <= N; A++){
        res+=N/A;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

XOR=0
for a in A:
    XOR^=a

for i in range(N):
    A[i] &=~XOR
    
USED=[0]*N

for bi in range(60,-1,-1):
    for i in range(N):
        if USED[i]==0 and A[i] & (1<<bi)!=0:
            USED[i]=1
            useind=i
            break
    else:
        continue

    for i in range(N):
        if i==useind:
            continue
        if A[i] & (1<<bi)!=0:
            A[i]^=A[useind]
            
ANS=0
for a in A:
    ANS^=a

print(2*ANS+XOR)


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

int main()
{
	int N;
	cin >> N;
	vector<long long> A( N * 3 );
	for( int i = 0; i < N * 3; i++ ) {
		cin >> A[i];
	}

	sort( A.begin(), A.end() );
	long  long ans = 0;
	for( int i = N; i < N * 3; i += 2 ) {
		ans += A[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=1000010;
const ll mod=1e9+7;

void rec(int d, ll val, vector<ll> &a){
  // 格納
  a.push_back(val);

  // 10 桁だったらそれ以上やらずに打ち切り
  if (d == 10) return;

  // 次の桁へ進む処理
  REP(i,-1,2){
    int nxt = (val%10)+i;
    if(0<=nxt && nxt<=9) rec(d+1, val*10+nxt, a);
  }
} 
int main(){
  int k;
  cin >> k;
  vector<ll> a;
  REP(i,1,10) rec(1,i,a);
  sort(a.begin(),a.end());
  ll ans = a[k-1];
  cout << ans << endl;  
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if(S[S.length() - 1] == 's') {
        cout << S + "es" << endl;
    }else{
        cout << S + "s" << endl;
    }
    return 0;
}

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

int main(int argc, char *argv[]) {
    int cnt[26] = {0};
    char s[100000];

    scanf("%s", s);

    for (int i = 0; i < strlen(s); i++) {
        cnt[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (cnt[i] == 0) {
            printf("%c\n", i + 'a');
            return 0;
        }
    }

    printf("None\n");

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i = a;i <= b;i++){
            if(c % i == 0){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main() {
  
  int N,ac=0,wa=0,tle=0,re=0;
  string jg;
  
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> jg;
    if(jg=="AC"){
      ac++;
    }else if(jg=="WA"){
      wa++;
    }else if(jg=="TLE"){
      tle++;
    }else if(jg=="RE"){
      re++;
    }
  }
  cout << "AC x " << ac <<endl;
  cout << "WA x " << wa <<endl;
  cout << "TLE x " << tle <<endl; 
  cout << "RE x " << re <<endl; 
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

struct dice{
	int d[6];
	void rotation(int& w,int& x,int& y,int& z){
		int tmp=w; w=x; x=y; y=z; z=tmp;
	}
	void n(){rotation(d[4],d[0],d[1],d[5]);}
	void e(){rotation(d[2],d[0],d[3],d[5]);}
	void w(){rotation(d[3],d[0],d[2],d[5]);}
	void s(){rotation(d[1],d[0],d[4],d[5]);}
};

dice dic;
string s;

int main(){
	cin.sync_with_stdio(false);
	rep(i,6){
		cin>>dic.d[i];
	}
	cin>>s;
	rep(i,s.length()){
		if(s[i]=='N')dic.n();
		if(s[i]=='E')dic.e();
		if(s[i]=='W')dic.w();
		if(s[i]=='S')dic.s();
	}
	cout<<dic.d[0]<<endl;
	return 0;
}

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

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

    int SE[N+1];
    SE[0] = 0; 
    for (int i=0; i<N; ++i) {
        if (S[i] == 'E') SE[i+1] = SE[i] + 1;
        else SE[i+1] = SE[i];
    }
    int ans = 1000000;
    int cand;
    for (int i=0; i<N; ++i) {
        cand = (i - SE[i]) + (SE[N]-SE[i+1]);
        if (cand < ans) ans = cand;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1916
// https://atcoder.jp/contests/abc120/tasks/abc120_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int A, B, K;
  vector<int> m;
  cin >> A >> B >> K;
  FOR(i, 1, min(A, B) + 1)
  {
    if (A % i == 0 && B % i == 0)
      m.push_back(i);
  }
  reverse(ALL(m));

  cout << m[K - 1] << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int INF = (int)1e8;
int main(){
	int a, b, c, d, e, na, nb, nc;

	while (1){
		cin >> a >> b >> c >> d >> e;
		if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0)return 0;
		cin >> na >> nb >> nc;
		int res = na*a+nb*b+nc*c;
		if (nc >= d){
			res=min(res, nc*e + na*a + nb*b);
		}

		for (int i = 0; i <= na + nb + nc;i++){
			int C = max(nc - i, 0);
			int B = max(nb - (i - (nc - C)), 0);
			int A = na - (i - (nc - C) - (nb - B));
			if ((nc - C)*c + (nb - B)*b + (na-A)*a>d*e)
			res = min(res, max(d,i)*e + C*c + B*b + A*a);
		}
		cout << res << endl;
	}

	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  string s;
  
  for(int i=0; i < w+2; i++)
    cout << '#';
  cout << endl;
  for(int i=0; i < h; i++){
  	cin >> s;
	cout << '#' << s << '#' << endl;
  }
      
  for(int i=0; i < w+2; i++)
    cout << '#';
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); //cinの高速化
  
  ll N;
  IN(N);
  vector<ll> H(N);
  REP(i,N) IN(H[i]);
  
  string ans = "Yes";
  for(int i=1; i<N; ++i){
    if(H[i]-H[i-1] > 0) --H[i];
    else if(H[i]-H[i-1] < 0){
      ans="No";
      goto for_break;
    }
  }
  for_break:
  
  OUT(ans);
}

Measured memory_bytes: 1024
S = list(input())
count = 0
valueA = 0
for i in range(len(S)):
  if S[i] == 'B':
    count += 1
    valueA += i

valueB = 0
for i in range(count):
  valueB += (len(S) - 1 - i)
  
print(valueB - valueA)

Measured memory_bytes: 10464
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
ans = INF
for a in aa:
	tmp = 0
	while a%2 == 0:
		a //= 2
		tmp += 1
	ans  = min(tmp,ans)
print(ans)


Measured memory_bytes: 4212